LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reference each condition resource type

jgrant22 opened this issue · comments

Describe the bug
The way this is currently designed. if I have multiple DG1 segments (which creates multiple condition resources)

diagnosis:
   expressionType: nested
   evaluateLater: true
   generateList: true
   specs: DG1
   expressionsMap:
     condition:
        valueOf: datatype/Reference
        expressionType: resource
        specs: $Condition
     use:
        valueOf: datatype/CodeableConcept
        expressionType: resource
        specs: DG1.6
        vars:
          coding: DIAGNOSIS_USE, DG1.6
     rank:
        type: STRING
        valueOf: DG1.15
        expressionType: HL7Spec

we reference Condition but in this case I am testing we have two conditions created. which created two references but they both reference the first condition.
I tried to do it this way as well

diagnosis:
   expressionType: nested
   evaluateLater: true
   generateList: true
   specs: DG1
   expressionsMap:
     condition:
        valueOf: resource/Condition
        generateList: true
        expressionType: reference
        specs: DG1
     use:
        valueOf: datatype/CodeableConcept
        expressionType: resource
        specs: DG1.6
        vars:
          coding: DIAGNOSIS_USE, DG1.6
     rank:
        type: STRING
        valueOf: DG1.15
        expressionType: HL7Spec

and this gives us two different references but neither of those references are from the two conditions originally created from DG1 (you can tell by looking at the reference id)

To Reproduce
run this test

    @Test
    void testAdtA03MultipleConditionsPresent() throws IOException {
        String hl7message =
                "MSH|^~\\&|PROSOLV|SENTARA|WHIA|IBM|20151008130307||ADT^A01^ADT_A01|MSGID000003|T|2.6\r" +
                        "EVN|A01|20151008130307|||\r"
                        + "PID|||1234^^^^MR\r"
                        + "PV1||I||||||||SUR||||||||S|VisitNumber^^^ACME|A||||||||||||||||||||||||20150502090000|\r"
                        + "DG1|1||B45678|||A|\r"
                        + "DG1|2||B45678|||A|\r";

        List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(hl7message);

        // Expecting 4 total resources
        assertThat(e.size()).isEqualTo(4);

        List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
        assertThat(patientResource).hasSize(1); // from PID and PD1

        List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
        assertThat(encounterResource).hasSize(1); // from EVN, PV1, and PV2

        List<Resource> conditionResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
        assertThat(conditionResource).hasSize(2); // from DG1

    }

Expected behavior
in the test case above we are expecting two conditions and one reference to each condition

In release 1.0.16