diff --git a/containers/fhir-converter/Templates/eCR/Entry/Result/_entry.liquid b/containers/fhir-converter/Templates/eCR/Entry/Result/_entry.liquid index 8e632307c5..443ef5e13f 100644 --- a/containers/fhir-converter/Templates/eCR/Entry/Result/_entry.liquid +++ b/containers/fhir-converter/Templates/eCR/Entry/Result/_entry.liquid @@ -38,18 +38,23 @@ {% endfor -%} {% endif -%} {% if comp.procedure.participant.participantRole.id -%} - {% if comp.procedure.participant.participantRole.playingEntity.code.translation -%} - {% assign translations = comp.procedure.participant.participantRole.playingEntity.code.translation | to_array -%} + {% assign playingEntity = comp.procedure.participant.participantRole.playingEntity -%} + {% if playingEntity.code.translation -%} + {% assign translations = playingEntity.code.translation | to_array -%} {% if translations.first.displayName -%} {% assign specValue = translations.first.displayName -%} {% endif -%} {% elsif comp.procedure.participant.participantRole.id.displayName -%} {% assign specValue = comp.procedure.participant.participantRole.id.displayName -%} - {% elsif entry.organizer.component.procedure.participant.participantRole.playingEntity.code.displayName -%} - {% assign specValue = comp.procedure.participant.participantRole.playingEntity.code.displayName -%} + {% elsif playingEntity.code.originalText._ %} + {% assign specValue = playingEntity.code.originalText._ -%} + {% elsif playingEntity.code.displayName -%} + {% assign specValue = playingEntity.code.displayName -%} {% else -%} {% assign specValue = "None" -%} {% endif -%} + {% else -%} + {% assign specValue = "None" -%} {% endif -%} {% endif -%} {% endfor-%} diff --git a/containers/fhir-converter/tests/integration/test_FHIR-Converter.py b/containers/fhir-converter/tests/integration/test_FHIR-Converter.py index 269e9aa008..a91313757b 100644 --- a/containers/fhir-converter/tests/integration/test_FHIR-Converter.py +++ b/containers/fhir-converter/tests/integration/test_FHIR-Converter.py @@ -212,3 +212,26 @@ def test_encounter_diagnosis(): assert len(diagnosis_references) == 1 assert "Condition/d282a8e7-21b0-49ff-d7b0-1ce84b5d9b07" in diagnosis_references + + +@pytest.mark.integration +def test_lab_specimen(): + input_data = open( + Path(__file__).parent.parent / "test_files/eICR_with_single_lab.xml" + ).read() + request = {"input_data": input_data, "input_type": "ecr", "root_template": "EICR"} + ecr_conversion_response = httpx.post(CONVERT_TO_FHIR, json=request) + assert ecr_conversion_response.status_code == 200 + + specimen_sources = [] + for entry in filter( + lambda entry: entry["resource"]["resourceType"] == "Observation", + ecr_conversion_response.json()["response"]["FhirResource"]["entry"], + ): + for ext in entry["resource"].get("extension", []): + if ext["url"] == "http://hl7.org/fhir/R4/specimen.html": + for sub_ext in ext.get("extension", []): + if sub_ext["url"] == "specimen source": + specimen_sources.append(sub_ext["valueString"]) + + assert len(specimen_sources) == 4 diff --git a/containers/fhir-converter/tests/test_files/eICR_with_single_lab.xml b/containers/fhir-converter/tests/test_files/eICR_with_single_lab.xml new file mode 100644 index 0000000000..51b6a10c07 --- /dev/null +++ b/containers/fhir-converter/tests/test_files/eICR_with_single_lab.xml @@ -0,0 +1 @@ +Initial Public Health Case Report123 Maltman AveLOS ANGELELos AngelesCA90026USLindseyCedarstestCedars Sinai - Health Systems TST8700 Beverly Blvd.Los Angeles, CA 90048LOS ANGELESCA90048USCedars Sinai - Health Systems TST8700 Beverly Blvd.Los Angeles, CA 90048LOS ANGELESCA90048USOffice VisitCedars Sinai - Health Systems TST8700 Beverly Blvd.Los Angeles, CA 90048LOS ANGELESCA90048USInternal MedicineCSMG Internal Medicine8767 Wilshire Blvd2nd FloorLOS ANGELEBEVERLY HILLSCA90211USWILSHIRE 87678767 Wilshire Blvd2nd FloorLOS ANGELEBEVERLY HILLSCA90211USCedars Sinai - Health Systems TST
Miscellaneous NotesNot on filedocumented in this encounter
ImmunizationsNot on filedocumented as of this encounter
Administered MedicationsNot on filedocumented in this encounter
Plan of TreatmentNot on filedocumented as of this encounter
Problems
PregnantComments
Yes

No additional problems on filedocumented as of this encounter (statuses as of 12/16/2022)
Reason for Visit
ReasonComments
Nausea
Nausea
Results(ABNORMAL) CORONAVIRUS (COVID-19), PCR (12/16/2022 12:00 AM PST)
ComponentValueRef RangeTest MethodAnalysis TimePerformed AtPathologist Signature
SARS-CoV-2, RNADetected (A)Not DetectedLABCORP
Comment:
Patients who have a positive COVID-19 test result may now have
treatment options. Treatment options are available for patients
with mild to moderate symptoms and for hospitalized patients.
Visit our website at https://www.labcorp.com/COVID19 for
resources and information.
This nucleic acid amplification test was developed and its performance
characteristics determined by LabCorp Laboratories. Nucleic acid
amplification tests include RT-PCR and TMA. This test has not been
FDA cleared or approved. This test has been authorized by FDA under
an Emergency Use Authorization (EUA). This test is only authorized
for the duration of time the declaration that circumstances exist
justifying the authorization of the emergency use of in vitro
diagnostic tests for detection of SARS-CoV-2 virus and/or diagnosis
of COVID-19 infection under section 564(b)(1) of the Act, 21 U.S.C.
360bbb-3(b) (1), unless the authorization is terminated or revoked
sooner.
When diagnostic testing is negative, the possibility of a false
negative result should be considered in the context of a patient's
recent exposures and the presence of clinical signs and symptoms
consistent with COVID-19. An individual without symptoms of COVID-19
and who is not shedding SARS-CoV-2 virus would expect to have a
negative (not detected) result in this assay.
Specimen (Source)Anatomical Location / LateralityCollection Method / VolumeCollection TimeReceived Time
Nasopharyngeal (NASOPHARYNGEAL)12/16/202212/16/2022
Narrative
LABCORP - 12/16/2022 12:00 AM PSTPerformed at: 01 - Integrated Genetics Sequenom
3595 John Hopkins Court, San Diego, CA 921211121
Lab Director: Phillip Cacheris MDPhD, Phone: 8778217266
Authorizing ProviderResult Type
Agnes Chiang Jee MDMICRO (NON-CULT) ORDERABLES
Performing OrganizationAddressCity/State/ZIP CodePhone Number
LABCORP13112 Evening Creek Dr, Ste 200San Diego, CA 92128858-668-3700
documented in this encounter
CORONAVIRUS (COVID-19), PCRCedars Sinai - Health Systems TSTPediatrics301 W HUNTINGTON DR SUITE 320LOS ANGELEPASADENACA91107USAgnesChiangJee MDNASOPHARYNGEALNasopharyngealSARS-CoV-2, RNADetectedAbnormalLABCORP13112 Evening Creek Dr, Ste 200San DiegoCA92128Kelli Hanson, M.D.Not DetectedNot DetectedLABCORP13112 Evening Creek Dr, Ste 200San DiegoCA92128Kelli Hanson, M.D.NarrativeLab InterpretationAbnormal
Social History
Tobacco UseTypesPacks/DayYears UsedDate
Smoking Tobacco: Never
Smokeless Tobacco: Never
Alcohol UseStandard Drinks/WeekComments
Not Currently0 (1 standard drink = 0.6 oz pure alcohol)
Sex Assigned at BirthDate Recorded
Not on file
documented as of this encounter
Encounter Details
DateTypeDepartmentCare TeamDescription
12/16/22Office VisitCSMG Internal Medicine8767 Wilshire Blvd2nd FloorBEVERLY HILLS, CA 90211310-385-6031So, NaomiCOVID-19 virus detected (Primary Dx)
NaomiSoInternal Medicine8767 Wilshire Blvd2nd FloorLOS ANGELEBEVERLY HILLSCA90211USCSMG Internal MedicineInternal MedicineCOVID-19 virus detectedCOVID-19 virus detected
\ No newline at end of file