Search in sources :

Example 46 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ServiceRequestFHIRConversionTest method test_ppr_pc1_service_request.

@Test
void test_ppr_pc1_service_request() throws IOException {
    // Currently only tests limited items, TODO add tests for other field
    String hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS|||||||SUR||||||||S||||||||||||||||||||||||||\n" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\n" + "OBX|1|NM|111^TotalProtein||7.5|gm/dl|5.9-8.4||||W\n" + "ORC|NW|1000^OE|9999999^RX||SC|E|^Q6H^D10^^^R\n" + "OBR|1|TESTID|TESTID|||202101010000|202101010000||||||||||||||||||F||||||WEAKNESS||||||||||||\n" + "OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\n" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\n";
    String json = ftv.convert(hl7message, OPTIONS);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    // OBX under PRB (the PROBLEM.PROBLEM_OBSERVATION.OBSERVATION) creates an Observation resource
    // Verifying this OBX to assure ServiceRequest is using correct OBX information
    List<Resource> obsResource = e.stream().filter(v -> ResourceType.Observation == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    Observation o = (Observation) obsResource.get(0);
    assertEquals("111", o.getCode().getCodingFirstRep().getCode());
    assertEquals("TotalProtein", o.getCode().getText());
    // From OBX.11 'W'
    assertEquals("Entered in Error", o.getStatus().getDisplay());
    List<Resource> serviceRequestResource = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    ServiceRequest sr = (ServiceRequest) serviceRequestResource.get(0);
    assertEquals(1, serviceRequestResource.size());
    // From ORC.5 'SC'
    assertEquals("Active", sr.getStatus().getDisplay());
    // Ensure the intent is set to "order" for all messages
    assertEquals("order", sr.getIntentElement().getValueAsString());
    // status defaults to "unknown"
    hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS|||||||SUR||||||||S||||||||||||||||||||||||||\n" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\n" + "ORC|NW|1000^OE|9999999^RX|||E|^Q6H^D10^^^R\n";
    json = ftv.convert(hl7message, OPTIONS);
    assertThat(json).isNotBlank();
    bundleResource = context.getParser().parseResource(json);
    b = (Bundle) bundleResource;
    e = b.getEntry();
    serviceRequestResource = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    sr = (ServiceRequest) serviceRequestResource.get(0);
    // Default since no OBX in message
    assertEquals("Unknown", sr.getStatus().getDisplay());
}
Also used : Logger(org.slf4j.Logger) ConverterOptions(io.github.linuxforhealth.hl7.ConverterOptions) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) Resource(org.hl7.fhir.r4.model.Resource) IOException(java.io.IOException) Builder(io.github.linuxforhealth.hl7.ConverterOptions.Builder) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) ResourceType(org.hl7.fhir.r4.model.ResourceType) List(java.util.List) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FHIRContext(io.github.linuxforhealth.fhir.FHIRContext) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) Observation(org.hl7.fhir.r4.model.Observation) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Observation(org.hl7.fhir.r4.model.Observation) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.jupiter.api.Test)

Example 47 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7TelecomFHIRConversionTest method patient_telcom_test.

// Suppress warnings about too many assertions in a test.  Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void patient_telcom_test() {
    String patientPhone = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + // Home has 2 phones and an email, work has one phone and two emails
    "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^||20060504|M|||||^PRN^PH^^22^555^1111313^^^^^^^^^^^3~^PRN^CP^^22^555^2221313^^^^^^^^^^^1~^NET^X.400^email.test@gmail.com^^^^^^^^^^^^^^2|^PRN^PH^^^555^1111414^889~^^^professional@buisness.com~^^^moose.mickey@buisness.com^^^^^^^^^^^^^^4||||||||||||||||\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientPhone);
    assertThat(patient.hasTelecom()).isTrue();
    List<ContactPoint> contacts = patient.getTelecom();
    assertThat(contacts.size()).isEqualTo(6);
    // First home contact
    ContactPoint contact = contacts.get(0);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("+22 555 111 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("3");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second home contact is mobile
    contact = contacts.get(1);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.MOBILE);
    assertThat(contact.getValue()).hasToString("+22 555 222 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("1");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Third home contact is an email
    contact = contacts.get(2);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("email.test@gmail.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("2");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // First work contact is work phone
    contact = contacts.get(3);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("(555) 111 1414 ext. 889");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second work contact is external work email
    contact = contacts.get(4);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("professional@buisness.com");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // Third work contact is internal work email and is ranked for contact
    contact = contacts.get(5);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("moose.mickey@buisness.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("4");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test)

Example 48 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7NoteFHIRConverterTest method testNoteCreationMutiplePPR.

// Test that multiple problems (PRB) each with multiple notes (NTE) are associated with the correct NTE / PRB
// and that there is no "bleed"
@Test
void testNoteCreationMutiplePPR() throws IOException {
    // TODO: Add PC2 and PC3 tests in future
    String message = "PPR^PC1";
    String hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|" + message + "|1|P^I|2.6||||||ASCII||\n" + "PID|||555444222111^^^MPI&GenHosp&L^MR||james^anderson|||M||||||||||||||\n" + "PV1||I|||||||||||||||||1400|||||||||||||||||||||||||199501102300\n" + "PRB|AD|200603150625|aortic stenosis|53692||2||200603150625\n" + "NTE|1|O|TEST PRBa NOTE AA line 1|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "NTE|3|O|TEST NOTE AA line 3|\n" + "OBX|1|NM|17985^GLYCOHEMOGLOBIN HGB A1C^LRR^^^^^^GLYCOHEMOGLOBIN HGB A1C||5.6|%|<6.0||||F||||||||||||||\n" + "NTE|1|L|TEST OBXb NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2|\n" + "NTE|3|L|TEST NOTE BB line 3|\n" + "OBX|2|NM|17853^MEAN BLOOD GLUCOSE^LRR^^^^^^MEAN BLOOD GLUCOSE||114.02|mg/dL|||||F||||||||||||||\n" + "NTE|1|L|TEST OBXc NOTE CC line 1|\n" + "NTE|2|L|TEST NOTE CC line 2|\n" + "NTE|3|L|TEST NOTE CC line 3|\n" + "PRB|AD|200603150625|I47.2^Ventricular tachycardia^ICD-10-CM|53692||2||200603150625\n" + "NTE|1|O|TEST PRBd NOTE DD line 1|\n" + "NTE|2|O|TEST NOTE DD line 2|\n" + "NTE|3|O|TEST NOTE DD line 3|\n" + "OBX|1|NM|8595^BP Mean|1|88|MM HG|||||F|||20180520230000|||\n" + "NTE|1|L|TEST OBXe NOTE EE line 1|\n" + "NTE|2|L|TEST NOTE EE line 2|\n" + "NTE|3|L|TEST NOTE EE line 3|\n" + "OBX|2|NM|7302^Resp Rate|1|19||||||F|||20180520230000|||\n" + // Single NTE to ensure it is created correctly
    "NTE|1|L|TEST OBXf NOTE FF line 1|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patients).hasSize(1);
    // Two Conditions from two PRBs. One has "... stenosis" and notes AA, One has "... Tachycardia" and notes DD
    List<Resource> conditions = ResourceUtils.getResourceList(e, ResourceType.Condition);
    assertThat(conditions).hasSize(2);
    Condition condStenosis = ResourceUtils.getResourceCondition(conditions.get(0), ResourceUtils.context);
    Condition condTachy = ResourceUtils.getResourceCondition(conditions.get(1), ResourceUtils.context);
    // Figure out which is first and reassign if needed for testing
    if (!condStenosis.getCode().getCodingFirstRep().getCode().contains("aortic stenosis")) {
        Condition temp = condStenosis;
        condStenosis = condTachy;
        condTachy = temp;
    }
    // Test the conditions have the correct NTE's associated and have correct content.
    // NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
    // Must use getTextElement().getValueAsString() to see untrimmed contents.
    assertThat(condStenosis.hasNote()).isTrue();
    assertThat(condStenosis.getNote()).hasSize(1);
    assertThat(condStenosis.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST PRBa NOTE AA line 1  \nTEST NOTE AA line 2  \nTEST NOTE AA line 3");
    assertThat(condTachy.hasNote()).isTrue();
    assertThat(condTachy.getNote()).hasSize(1);
    assertThat(condTachy.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST PRBd NOTE DD line 1  \nTEST NOTE DD line 2  \nTEST NOTE DD line 3");
    // Four observations.  Two associated with the first problem and two with the second
    // This map tells us what Annotation text is associated with an Observation code
    Map<String, String> matchObsCodeToNotes = new HashMap<>();
    matchObsCodeToNotes.put("17985", "TEST OBXb NOTE BB line 1  \nTEST NOTE BB line 2  \nTEST NOTE BB line 3");
    matchObsCodeToNotes.put("17853", "TEST OBXc NOTE CC line 1  \nTEST NOTE CC line 2  \nTEST NOTE CC line 3");
    matchObsCodeToNotes.put("8595", "TEST OBXe NOTE EE line 1  \nTEST NOTE EE line 2  \nTEST NOTE EE line 3");
    matchObsCodeToNotes.put("7302", "TEST OBXf NOTE FF line 1");
    // This map tells us what Parent should be associated with an Observation code
    Map<String, String> matchObsCodeToParent = new HashMap<>();
    matchObsCodeToParent.put("17985", "aortic stenosis");
    matchObsCodeToParent.put("17853", "aortic stenosis");
    matchObsCodeToParent.put("8595", "I47.2");
    matchObsCodeToParent.put("7302", "I47.2");
    List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(observations).hasSize(4);
    int observationsVerified = 0;
    // For the list of Conditions
    for (int condIndex = 0; condIndex < conditions.size(); condIndex++) {
        // condIndex is index for condition
        // Get the list of Observation references
        Condition cond = ResourceUtils.getResourceCondition(conditions.get(condIndex), ResourceUtils.context);
        List<ConditionEvidenceComponent> evidences = cond.getEvidence();
        for (int evidenceIndex = 0; evidenceIndex < evidences.size(); evidenceIndex++) {
            // Get the evidence Observation reference
            String obsReferenceId = evidences.get(evidenceIndex).getDetailFirstRep().getReference();
            // Find the referenced observation
            for (int obsIndex = 0; obsIndex < observations.size(); obsIndex++) {
                // If the Id's match
                if (obsReferenceId.contains(observations.get(obsIndex).getId())) {
                    // Check the contents and the parent
                    Observation obs = ResourceUtils.getResourceObservation(observations.get(obsIndex), ResourceUtils.context);
                    String code = obs.getCode().getCodingFirstRep().getCode().toString();
                    // The Annotation text should match the mapped text for this key
                    assertThat(obs.getNoteFirstRep().getText()).hasToString(matchObsCodeToNotes.get(code));
                    // The parent Condition code.coding.code should match the expected mapped code for this key
                    assertThat(cond.getCode().getCodingFirstRep().getCode()).hasToString(matchObsCodeToParent.get(code));
                    observationsVerified++;
                    break;
                }
            }
        }
    }
    // This confirms ALL of the observations were checked.
    assertThat(observationsVerified).isEqualTo(4);
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ConditionEvidenceComponent(org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent) HashMap(java.util.HashMap) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 49 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7NoteFHIRConverterTest method testNoteCreationServiceRequestMutipleOBX.

// Suppress warnings about too many assertions in a test.  Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@ParameterizedTest
@MethodSource("provideParmsForNoteCreationServiceRequestMutipleOBX")
void testNoteCreationServiceRequestMutipleOBX(String message, int numExpectedDiagnosticReports) {
    String hl7ORU = "MSH|^~\\&|||||20180924152907||" + message + "|213|T|2.3.1|||||||||||\n" + "PID|||Pract1ID^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // "NTE|1|O|TEST NOTE DD line 1|\n" + "NTE|2|O|TEST NOTE DD line 2 |\n" + "NTE|3|O|TEST NOTE D line 3|\n"
    "PV1|1|I||||||||||||||||||||||||||||||||||||||||||20180924152707|\n" + "ORC|RE|248648498^|248648498^|ML18267-C00001^Beaker|||||||||||||||||||||||||||\n" + "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C||||||||||||||||||||||||||||||||||||\n" + // ServiceRequest NTE has a practitioner reference in NTE.5
    "NTE|1|O|TEST ORC/OBR NOTE AA line 1||Pract1ID^Pract1Last^Pract1First|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "NTE|3|O|TEST NOTE AA line 3|\n" + "OBX|1|NM|17985^GLYCOHEMOGLOBIN HGB A1C^LRR^^^^^^GLYCOHEMOGLOBIN HGB A1C||5.6|%|<6.0||||F||||||||||||||\n" + // GLYCOHEMOGLOBIN Observation NTE has a practitioner reference in NTE.5.  Note in second NTE. The first valied NTE.5 is used.
    "NTE|1|L|TEST OBXa NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2||Pract2ID^Pract2Last^Pract2First|\n" + "NTE|3|L|TEST NOTE BB line 3|\n" + "OBX|2|NM|17853^MEAN BLOOD GLUCOSE^LRR^^^^^^MEAN BLOOD GLUCOSE||114.02|mg/dL|||||F||||||||||||||\n" + // Glucose Observation NTE has no practitioner reference in NTE.5
    "NTE|1|L|TEST OBXb NOTE CC line 1|\n" + "NTE|2|L|TEST NOTE CC line 2|\n" + // Test that blank lines are preserved.
    "NTE|3|L| |\n" + "NTE|4|L|TEST NOTE CC line 4|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7ORU);
    List<Resource> diagnosticReports = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    // DiagnosticReport expected for ORU, but not for ORM
    // From the OBR in the ORU test case
    assertThat(diagnosticReports).hasSize(numExpectedDiagnosticReports);
    // One ServiceRequest contains NTE for ORC/OBR
    List<Resource> serviceRequests = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    assertThat(serviceRequests).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequests.get(0), ResourceUtils.context);
    assertThat(serviceRequest.hasNote()).isTrue();
    assertThat(serviceRequest.getNote()).hasSize(1);
    // Processing adds "  \n" two spaces and a line feed between each line.
    // NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
    // Must use getTextElement().getValueAsString() to see untrimmed contents.
    assertThat(serviceRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST ORC/OBR NOTE AA line 1  \nTEST NOTE AA line 2  \nTEST NOTE AA line 3");
    assertThat(serviceRequest.getNote().get(0).hasAuthorReference()).isTrue();
    String practitionerServReqRefId = serviceRequest.getNote().get(0).getAuthorReference().getReference();
    // Two observations.  One has GLYCOHEMOGLOBIN and notes BB, One has GLUCOSE and notes CC
    List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
    // Should be 2 for ORU and ORM
    assertThat(observations).hasSize(2);
    Observation obsGlucose = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
    Observation obsHemoglobin = ResourceUtils.getResourceObservation(observations.get(1), ResourceUtils.context);
    // Figure out which is first and reassign if needed for testing
    if (obsGlucose.getCode().getText() != "MEAN BLOOD GLUCOSE") {
        Observation temp = obsGlucose;
        obsGlucose = obsHemoglobin;
        obsHemoglobin = temp;
    }
    // Validate the note contents and references
    assertThat(obsHemoglobin.hasNote()).isTrue();
    assertThat(obsHemoglobin.getNote()).hasSize(1);
    assertThat(obsHemoglobin.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBXa NOTE BB line 1  \nTEST NOTE BB line 2  \nTEST NOTE BB line 3");
    assertThat(obsHemoglobin.getNote().get(0).hasAuthorReference()).isTrue();
    String practitionerObsHemoglobinRefId = obsHemoglobin.getNote().get(0).getAuthorReference().getReference();
    assertThat(obsGlucose.hasNote()).isTrue();
    assertThat(obsGlucose.getNote()).hasSize(1);
    assertThat(obsGlucose.getNote().get(0).getTextElement().getValueAsString()).isEqualTo(// Test that blank lines are preserved.
    "TEST OBXb NOTE CC line 1  \nTEST NOTE CC line 2  \n   \nTEST NOTE CC line 4");
    assertThat(obsGlucose.getNote().get(0).hasAuthorReference()).isFalse();
    // Two Practitioners, one for the serviceRequest, one for the GLYCOHEMOGLOBIN Observation
    List<Resource> practitioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    assertThat(practitioners).hasSize(2);
    Practitioner practitionerServReq = ResourceUtils.getResourcePractitioner(practitioners.get(0), ResourceUtils.context);
    Practitioner practitionerObsHemoglobin = ResourceUtils.getResourcePractitioner(practitioners.get(1), ResourceUtils.context);
    // Adjust to correct practitioner if needed
    if (!practitionerServReq.getIdentifierFirstRep().getValue().contentEquals("Pract1ID")) {
        Practitioner temp = practitionerObsHemoglobin;
        practitionerObsHemoglobin = practitionerServReq;
        practitionerServReq = temp;
    }
    // Check the values for the Practitioners and validate match to references.
    assertThat(practitionerServReq.getIdentifier()).hasSize(1);
    assertThat(practitionerServReq.getIdentifierFirstRep().getValue()).isEqualTo("Pract1ID");
    assertThat(practitionerServReq.getName()).hasSize(1);
    assertThat(practitionerServReq.getNameFirstRep().getText()).isEqualTo("Pract1First Pract1Last");
    // Check the cross-reference
    assertThat(practitionerServReq.getId()).isEqualTo(practitionerServReqRefId);
    // Sanity check to confirm data corruption in meta content has not returned.
    CodeableConcept ccSourceEventTrigger = (CodeableConcept) practitionerServReq.getMeta().getExtensionByUrl("http://ibm.com/fhir/cdm/StructureDefinition/source-event-trigger").getValue();
    assertThat(ccSourceEventTrigger.hasText()).isFalse();
    assertThat(practitionerObsHemoglobin.getIdentifier()).hasSize(1);
    assertThat(practitionerObsHemoglobin.getIdentifierFirstRep().getValue()).isEqualTo("Pract2ID");
    assertThat(practitionerObsHemoglobin.getName()).hasSize(1);
    assertThat(practitionerObsHemoglobin.getNameFirstRep().getText()).isEqualTo("Pract2First Pract2Last");
    // Check the cross-reference
    assertThat(practitionerObsHemoglobin.getId()).isEqualTo(practitionerObsHemoglobinRefId);
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 50 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateQuantityRXE.

@Test
void dosageInstructionTestRateQuantityRXE() {
    // Test dosageInstruction.rateQuantity where RXE.23 exists and RXE.22 does not exist -> use RXE segment, no range
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|||||E|||||||||||||||||||||||I\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|||||||||||||||||||" + // RXE.24.3 purposely empty to check that default system is used
    "||7|PC^^http://unitsofmeasure.org||||||||||||||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    // Confirm that one medicationRequest was created.
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    Quantity rateQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateQuantity();
    // dosageInstruction.doseAndRate.rateQuantity RXE.23
    // RXO.23
    assertThat(rateQuantity.getValue()).hasToString("7.0");
    // RXO.24.1
    assertThat(rateQuantity.getUnit()).isEqualTo("PC");
    // RXO.24.3
    assertThat(rateQuantity.getSystem()).isEqualTo("http://unitsofmeasure.org");
    // Verify no extraneous resources
    // Expect MedicationRequest, and Patient
    assertThat(e).hasSize(2);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)126 Resource (org.hl7.fhir.r4.model.Resource)86 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)58 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)40 Patient (org.hl7.fhir.r4.model.Patient)36 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)35 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.r4.model.Bundle)29 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)22 Immunization (org.hl7.fhir.r4.model.Immunization)19 Encounter (org.hl7.fhir.r4.model.Encounter)18 Coding (org.hl7.fhir.r4.model.Coding)16 Observation (org.hl7.fhir.r4.model.Observation)15 Organization (org.hl7.fhir.r4.model.Organization)15 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)15 ValueSource (org.junit.jupiter.params.provider.ValueSource)14 ResourceModel (io.github.linuxforhealth.api.ResourceModel)13 Reference (org.hl7.fhir.r4.model.Reference)13 Extension (org.hl7.fhir.r4.model.Extension)11