Skip to content

Commit

Permalink
KP2023 ETL: Map KP2023 to site KaiserPermanente in id3c
Browse files Browse the repository at this point in the history
  • Loading branch information
sallybg committed Nov 14, 2023
1 parent ced49e2 commit 740283f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/seattleflu/id3c/cli/command/etl/clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def etl_clinical(*, db: DatabaseSession):
# PHSKC and KP2023 will be handled differently than other clinical records, converted
# to FHIR format and inserted into receiving.fhir table to be processed
# by the FHIR ETL. When time allows, SCH and KP should follow suit.
if site.identifier in ('RetrospectivePHSKC', 'KaiserPermanente2023'):
# Since KP2023 and KP samples both have KaiserPermanente as their site in id3c,
# use the ndjson document's site to distinguish KP vs KP2023 samples
if site.identifier == 'RetrospectivePHSKC' or record.document["site"].upper() == 'KP2023':
fhir_bundle = generate_fhir_bundle(db, record.document, site.identifier)
insert_fhir_bundle(db, fhir_bundle)

Expand Down Expand Up @@ -248,7 +250,7 @@ def generate_fhir_bundle(db: DatabaseSession, record: dict, site_id: str) -> Opt
# ideally would not require site id for this, since it makes it more difficult to incorporate future projects
if site_id == 'RetrospectivePHSKC':
location_entries, location_references = create_resident_locations(record)
elif site_id == 'KaiserPermanente2023':
elif record["site"].upper() == 'KP2023':
location_entries, location_references = create_location_tract_only(record)
else:
LOG.warning(f'Function generate_fhir_bundle does not currently create location resource entries for site {site_id}')
Expand Down Expand Up @@ -298,7 +300,7 @@ def generate_fhir_bundle(db: DatabaseSession, record: dict, site_id: str) -> Opt
if diagnostic_report_resource_entry:
resource_entries.append(diagnostic_report_resource_entry)

if site_id == 'KaiserPermanente2023':
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)
symptom_condition_entries = create_symptom_conditions(record, patient_reference, encounter_reference)
Expand Down Expand Up @@ -1093,7 +1095,7 @@ def site_identifier(site_name: str) -> str:
"SCH": "RetrospectiveChildrensHospitalSeattle",
"KP": "KaiserPermanente",
"PHSKC": "RetrospectivePHSKC",
"KP2023": "KaiserPermanente2023"
"KP2023": "KaiserPermanente" # kp2023 samples should be mapped to kp site in id3c; they are marked as kp2023 in manifest document because they will be processed into fhir bundles, unlike earlier kp samples
}
if site_name not in site_map:
raise UnknownSiteError(f"Unknown site name «{site_name}»")
Expand Down

0 comments on commit 740283f

Please sign in to comment.