Skip to content

Commit

Permalink
Release/0.0.7rc2 (#107)
Browse files Browse the repository at this point in the history
* update pytest and version number

* linting

* ensure dataframer unit tests pass

* fix test

* fix test to work with new output

* fix spacing

---------

Co-authored-by: matthewpeterkort <matthewpeterkort@gmail.com>
  • Loading branch information
quinnwai and matthewpeterkort committed Jan 17, 2025
1 parent 0a1cc17 commit ebc8dd4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gen3_tracker/git/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def push(
bundle.entry.append(bundle_entry)

headers = {"Authorization": f"{auth._access_token}"}
bundle_dict = bundle.model_dump()
bundle_dict = bundle.dict()
with Halo(
text="Sending to FHIR Server",
spinner="line",
Expand Down
1 change: 1 addition & 0 deletions gen3_tracker/meta/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def identifiers(self) -> dict:
else identifier.get("system").split("/")[-1]: identifier.get("value")
for identifier in identifiers
}

return base_identifier

@computed_field
Expand Down
35 changes: 23 additions & 12 deletions tests/unit/test_flatten_fhir_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ def flatten_scalars(self: DomainResource) -> dict:
"""Convert the DomainResource instance to a dictionary."""
_ = {
k: _isodate(v)
for k, v in self.model_dump().items()
for k, v in self.dict().items()
if not isinstance(v, (list, dict))
}
return _


def flatten_references(self: DomainResource) -> dict:
"""Convert the DomainResource instance to a dictionary."""
fields = [_ for _ in self.model_fields.keys() if not _.endswith("__ext")]

fields = [_ for _ in self.__fields__.keys() if not _.endswith("__ext")]
_ = {}
# if any top level field in this resource is a Reference, use the Reference.reference https://build.fhir.org/references-definitions.html#Reference.reference
for k in fields:
Expand Down Expand Up @@ -327,15 +328,17 @@ def patched_scalars_references_identifiers_observation() -> bool:
def test_patient_without_flatten(patient_dict: dict):
"""This patient object should NOT have a 'flatten' method."""
# without path dependency, just have a plain patient object with no flatten method
patient = Patient.model_validate(patient_dict)

patient = Patient.parse_obj(patient_dict)
assert not hasattr(
patient, "flatten"
), "Patient object should not have a 'flatten' method"


def test_patient_with_simple(patched_domain_resource_simple: bool, patient_dict: dict):
"""This patient object should have a 'flatten' method."""
patient = Patient.model_validate(patient_dict)

patient = Patient.parse_obj(patient_dict)
assert hasattr(
patient, "flatten"
), "Patient object does not have a 'flatten' method"
Expand All @@ -346,7 +349,8 @@ def test_patient_with_simple(patched_domain_resource_simple: bool, patient_dict:

def test_patient_with_scalars(patched_scalars: bool, patient_dict: dict):
"""This patient object should have a 'flatten' method that returns a dict of scalar values."""
patient = Patient.model_validate(patient_dict)

patient = Patient.parse_obj(patient_dict)
assert hasattr(
patient, "flatten"
), "Patient object does not have a 'flatten' method"
Expand All @@ -362,7 +366,8 @@ def test_patient_with_scalars_and_references(
patched_scalars_and_references: bool, patient_dict: dict
):
"""This patient object should have a 'flatten' method that returns a dict of scalar values and references."""
patient = Patient.model_validate(patient_dict)

patient = Patient.parse_obj(patient_dict)
assert hasattr(
patient, "flatten"
), "Patient object does not have a 'flatten' method"
Expand All @@ -379,7 +384,8 @@ def test_patient_with_scalars_references_identifiers(
patched_scalars_references_identifiers: bool, patient_dict: dict
):
"""This patient object should have a 'flatten' method that returns a dict of scalar values and references."""
patient = Patient.model_validate(patient_dict)

patient = Patient.parse_obj(patient_dict)
assert hasattr(
patient, "flatten"
), "Patient object does not have a 'flatten' method"
Expand All @@ -397,7 +403,8 @@ def test_specimen_with_scalars_references_identifiers(
patched_scalars_references_identifiers: bool, specimen_dict: dict
):
"""This patient object should have a 'flatten' method that returns a dict of scalar values and references."""
specimen = Specimen.model_validate(specimen_dict)

specimen = Specimen.parse_obj(specimen_dict)
assert hasattr(
specimen, "flatten"
), "Specimen object does not have a 'flatten' method"
Expand All @@ -416,15 +423,17 @@ def test_eye_color_observation(
observation_eye_color_dict: dict,
):
"""This patient object should have a 'flatten' method that returns a dict of scalar values and references."""
observation = Observation.model_validate(observation_eye_color_dict)

observation = Observation.parse_obj(observation_eye_color_dict)
assert hasattr(
observation, "flatten"
), "Observation object does not have a 'flatten' method"
assert observation.flatten() == {
"resourceType": "Observation",
"id": "eye-color",
"status": "final",
"effectiveDateTime": "2016-05-18T00:00:00",

"effectiveDateTime": "2016-05-18",
"value": "blue",
"subject": "Patient/example",
}
Expand All @@ -434,12 +443,14 @@ def test_bmi_observation(
patched_scalars_references_identifiers_observation: bool, observation_bmi_dict: dict
):
"""This patient object should have a 'flatten' method that returns a dict of scalar values and references."""
observation = Observation.model_validate(observation_bmi_dict)

observation = Observation.parse_obj(observation_bmi_dict)
assert hasattr(
observation, "flatten"
), "Observation object does not have a 'flatten' method"
assert observation.flatten() == {
"effectiveDateTime": "1999-07-02T00:00:00",

"effectiveDateTime": "1999-07-02",
"id": "bmi-using-related",
"resourceType": "Observation",
"status": "final",
Expand Down

0 comments on commit ebc8dd4

Please sign in to comment.