Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkells committed May 12, 2024
1 parent 61d3a78 commit 28562b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
17 changes: 6 additions & 11 deletions healthchain/data_generator/encounter_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def generate():
class EncounterTypeGenerator(BaseGenerator):
@staticmethod
def generate():
encounter_type_mapping = {"ADMS": "admission", "EMER": "emergency"}
encounter_type = faker.random_element(elements=("ADMS", "EMER"))
encounter_type_mapping = {"11429006": "consultation", "50849002": "emergency"}
encounter_type = faker.random_element(elements=("11429006", "50849002"))
return CodeableConceptModel(
coding=[
CodingModel(
system="http://terminology.hl7.org/CodeSystem/v3-ActCode",
system="http://snomed.info/sct",
code=encounter_type,
display=encounter_type_mapping.get(encounter_type),
)
Expand All @@ -49,16 +49,12 @@ def generate():
class EncounterPriorityGenerator(BaseGenerator):
@staticmethod
def generate():
encounter_priority_mapping = {
"ALRT": "alert",
"CRIT": "critical",
"NRM": "normal",
}
encounter_priority = faker.random_element(elements=("ALRT", "CRIT", "NRM"))
encounter_priority_mapping = {"17621005": "normal", "24484000": "critical"}
encounter_priority = faker.random_element(elements=("17621005", "24484000"))
return CodeableConceptModel(
coding=[
CodingModel(
system="http://terminology.hl7.org/CodeSystem/v3-ActCode",
system="http://snomed.info/sct",
code=encounter_priority,
display=encounter_priority_mapping.get(encounter_priority),
)
Expand All @@ -79,7 +75,6 @@ def generate(patient_reference: Optional[str]):
"status": "generated",
"div": '<div xmlns="http://www.w3.org/1999/xhtml">Encounter with patient @example</div>',
},
# TODO: Move the elements to live with the resources
status=faker.random_element(
elements=(
"planned",
Expand Down
3 changes: 3 additions & 0 deletions tests/fhir_resources_unit_tests/test_fhir_resources_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def test_code_invalid():
codeTestModel(**data)


# TODO: Add tests for the remaining base resources


# Run the tests
if __name__ == "__main__":
pytest.main()
8 changes: 2 additions & 6 deletions tests/generators_tests/test_encounter_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def test_ClassGenerator():

def test_EncounterTypeGenerator():
encounter_type = EncounterTypeGenerator.generate()
assert (
encounter_type.coding_field[0].system_field
== "http://terminology.hl7.org/CodeSystem/v3-ActCode"
)
assert encounter_type.coding_field[0].code_field in ("ADMS", "EMER")
assert encounter_type.coding_field[0].display_field in ("admission", "emergency")
assert encounter_type.coding_field[0].system_field == "http://snomed.info/sct"
assert encounter_type.coding_field[0].display_field in ("consultation", "emergency")


def test_EncounterModel():
Expand Down

0 comments on commit 28562b5

Please sign in to comment.