Skip to content

Commit

Permalink
Clinical ETL: add encounter reference to ICD-10 condition entries
Browse files Browse the repository at this point in the history
FHIR ETL requires encounter reference to be present in order
to process condition entries
  • Loading branch information
sallybg committed Apr 19, 2024
1 parent d899c73 commit d0febf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/seattleflu/id3c/cli/command/etl/clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def generate_fhir_bundle(db: DatabaseSession, record: dict, site_id: str) -> Opt

if record["site"].upper() == 'KP2023':
# KP2023 includes some types of metadata that PHSKC does not
icd10_condition_entries = create_icd10_conditions_kp2023(record, patient_reference)
icd10_condition_entries = create_icd10_conditions_kp2023(record, patient_reference, encounter_reference)
symptom_condition_entries = create_symptom_conditions(record, patient_reference, encounter_reference)
immunization_entries = create_immunization_kp2023(record, patient_reference)
resource_entries.extend(icd10_condition_entries + symptom_condition_entries + immunization_entries)
Expand Down Expand Up @@ -513,7 +513,7 @@ def create_symptom_conditions(record: dict, patient_reference: dict, encounter_r
return condition_entries


def create_icd10_conditions_kp2023(record:dict, patient_reference: dict) -> list:
def create_icd10_conditions_kp2023(record:dict, patient_reference: dict, encounter_reference: dict) -> list:
"""
Create a condition resource for each ICD-10 code, following the FHIR format
(http://www.hl7.org/implement/standards/fhir/condition.html)
Expand Down Expand Up @@ -1051,7 +1051,8 @@ def create_icd10_conditions_kp2023(record:dict, patient_reference: dict) -> list
create_codeable_concept(
system = icd10_codes[icd10_code]["system"],
code = icd10_codes[icd10_code]["code"],
display = icd10_codes[icd10_code]["display"])
display = icd10_codes[icd10_code]["display"]),
encounter_reference
)

condition_entries.append(create_resource_entry(
Expand Down

0 comments on commit d0febf4

Please sign in to comment.