Search in sources :

Example 16 with MR

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

the class Hl7MDMMessageTest method test_mdm_ORDER_with_OBXnotTX.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void test_mdm_ORDER_with_OBXnotTX(String message) throws IOException {
    // Also check NTE working for MDM messages.
    String hl7message = "MSH|^~\\&|HNAM|W|RAD_IMAGING_REPORT|W|20180118111520||" + message + "|<MESSAGEID>|P|2.6\r" + "EVN||20150502090000|\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||O||||||||||||||||||||||||||||||||||||||||||199501102300\r" + "ORC|NW|622470H432|||||^^^^^R||||||||||||||\r" + "OBR|1|622470H432|102397CE432|||20170725143849|20180102|||||||||||||||||RAD|O||^^^^^R||||REASON_ID_1^REASON_TEXT_1||||\r" + // 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" + "TXA|1|HP^History and physical examination|TX||||201801171442||||||||||||AV|||||\r" + "OBX|1|NM|Most Current Weight^Most current measured weight (actual)||90|kg\r" + // Observation NTE has a practitioner reference in second NTE.5. Annotation uses the first valid NTE.5
    "NTE|1|L|TEST OBX NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2||Pract2ID^Pract2Last^Pract2First|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Check for the expected resources
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // from EVN, PV1
    assertThat(encounterResource).hasSize(1);
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // from PID
    assertThat(patientResource).hasSize(1);
    List<Resource> serviceRequestResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // from ORC, OBR
    assertThat(serviceRequestResource).hasSize(1);
    // Light check that ServiceRequest contains NTE for ORC/OBR;  Deep check of NTE in Hl7NoteFHIRConverterTest.
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestResource.get(0), ResourceUtils.context);
    assertThat(serviceRequest.hasNote()).isTrue();
    assertThat(serviceRequest.getNote()).hasSize(1);
    // 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");
    assertThat(serviceRequest.getNote().get(0).hasAuthorReference()).isTrue();
    List<Resource> documentReferenceResource = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
    // from TXA
    assertThat(documentReferenceResource).hasSize(1);
    List<Resource> observationResources = ResourceUtils.getResourceList(e, ResourceType.Observation);
    // from OBX(not type TX)
    assertThat(observationResources).hasSize(1);
    // Light check that Observation contains NTE for OBX;  Deep check of NTE in Hl7NoteFHIRConverterTest.
    Observation observation = ResourceUtils.getResourceObservation(observationResources.get(0), ResourceUtils.context);
    // Validate the note contents and reference existance.
    assertThat(observation.hasNote()).isTrue();
    assertThat(observation.getNote()).hasSize(1);
    // NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
    // Must use getTextElement().getValueAsString() to see untrimmed contents.
    assertThat(observation.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBX NOTE BB line 1  \nTEST NOTE BB line 2");
    assertThat(observation.getNote().get(0).hasAuthorReference()).isTrue();
    // Two Practitioners, one for the serviceRequest, one for the Observation
    List<Resource> practitioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    // from NTE.4 references
    assertThat(practitioners).hasSize(2);
    // Confirm that no extra resources are created
    assertThat(e.size()).isEqualTo(7);
}
Also used : 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) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with MR

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

the class Hl7MessageTest method test_observation.

@Test
void test_observation() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/Observation");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Observation").withResourceModel(rsm).withSegment("OBX").withIsReferenced(true).withRepeats(false).build();
    HL7FHIRResourceTemplate observation = new HL7FHIRResourceTemplate(attributes);
    HL7MessageModel message = new HL7MessageModel("ADT", Lists.newArrayList(observation));
    String hl7message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^MR~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^Sr^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\r" + "OBX|1|NM|0135-4^TotalProtein||7.3|gm/dl|5.9-8.4||||F|||||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^|\r";
    String json = message.convert(hl7message, engine);
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    // We expect observation because not TX in OBX
    List<Resource> obsResource = e.stream().filter(v -> ResourceType.Observation == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(obsResource).hasSize(1);
    List<Resource> pracResource = e.stream().filter(v -> ResourceType.Practitioner == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(pracResource).hasSize(5);
}
Also used : 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) ResourceModel(io.github.linuxforhealth.api.ResourceModel) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 18 with MR

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

the class Hl7MessageTest method test_specimen_multiple.

@Test
void test_specimen_multiple() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/Specimen");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Specimen").withResourceModel(rsm).withSegment("SPM").withIsReferenced(true).withRepeats(true).build();
    HL7FHIRResourceTemplate specimen = new HL7FHIRResourceTemplate(attributes);
    HL7MessageModel message = new HL7MessageModel("ORU", Lists.newArrayList(specimen));
    String hl7message = "MSH|^~\\&|Amalga HIS|BUM|New Tester|MS|20111121103141||ORU^R01|2847970-201111211031|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^MR~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^Sr^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\r" + "OBX|1|TX|1234||First line: ECHOCARDIOGRAPHIC REPORT||||||F|||||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^|\r" + "SPM|1|SpecimenID||BLOOD^Blood^^87612001^BLOOD^SCT^^||||Cord Art^Blood, Cord Arterial^^^^^^^|||P||||||201110060535|201110060821||Y||||||1\r" + "SPM|2|SpecimenID||BLD|||||||P||||||201110060535|201110060821||Y||||||1";
    String json = message.convert(hl7message, engine);
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> spmResource = e.stream().filter(v -> ResourceType.Specimen == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(spmResource).hasSize(2);
}
Also used : 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) ResourceModel(io.github.linuxforhealth.api.ResourceModel) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 19 with MR

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

the class Hl7MessageTest method test_encounter_with_observation.

@Test
void test_encounter_with_observation() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/Patient");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Patient").withResourceModel(rsm).withSegment("PID").withIsReferenced(true).withRepeats(false).build();
    HL7FHIRResourceTemplate patient = new HL7FHIRResourceTemplate(attributes);
    ResourceModel encounter = ResourceReader.getInstance().generateResourceModel("resource/Encounter");
    HL7FHIRResourceTemplateAttributes attributesEncounter = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Encounter").withResourceModel(encounter).withSegment("PV1").withIsReferenced(true).withRepeats(false).withAdditionalSegments(Lists.newArrayList("PV2", "OBX")).build();
    HL7FHIRResourceTemplate encounterFH = new HL7FHIRResourceTemplate(attributesEncounter);
    ResourceModel obsModel = ResourceReader.getInstance().generateResourceModel("resource/Observation");
    HL7FHIRResourceTemplateAttributes attributesObs = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Observation").withResourceModel(obsModel).withSegment("OBX").withIsReferenced(true).withRepeats(true).build();
    HL7FHIRResourceTemplate obsTemplate = new HL7FHIRResourceTemplate(attributesObs);
    HL7MessageModel message = new HL7MessageModel("ADT", Lists.newArrayList(patient, encounterFH, obsTemplate));
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN||201209122222\r" + "PID|0010||PID1234^5^M11^A^MR^HOSP~1234568965^^^USA^SS||DOE^JOHN^A^||19800202|F||W|111 TEST_STREET_NAME^^TEST_CITY^NY^111-1111^USA||(905)111-1111|||S|ZZ|12^^^124|34-13-312||||TEST_BIRTH_PLACE\r" + "PV1|1|ff|yyy|EL|ABC||200^ATTEND_DOC_FAMILY_TEST^ATTEND_DOC_GIVEN_TEST|201^REFER_DOC_FAMILY_TEST^REFER_DOC_GIVEN_TEST|202^CONSULTING_DOC_FAMILY_TEST^CONSULTING_DOC_GIVEN_TEST|MED|||||B6|E|272^ADMITTING_DOC_FAMILY_TEST^ADMITTING_DOC_GIVEN_TEST||48390|||||||||||||||||||||||||201409122200|20150206031726\r" + "OBX|1|NM|0135-4^TotalProtein||7.3|gm/dl|5.9-8.4||||F|||||2740^TRDSE^Janetary~2913^MRTTE^Darren^F~3065^MGHOBT^Paul^J~4723^LOTHDEW^Robert^L|\r" + "AL1|1|DRUG|00000741^OXYCODONE||HYPOTENSION\r" + "AL1|2|DRUG|00001433^TRAMADOL||SEIZURES~VOMITING\r";
    String json = message.convert(hl7message, engine);
    LOGGER.debug(json);
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> obsResource = e.stream().filter(v -> ResourceType.Observation == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(obsResource).hasSize(1);
    List<Resource> pracResource = e.stream().filter(v -> ResourceType.Practitioner == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(pracResource).hasSize(8);
    List<Resource> encounterResource = e.stream().filter(v -> ResourceType.Encounter == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(encounterResource).hasSize(1);
    Encounter encounterRes = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
    Reference patRef = encounterRes.getSubject();
    assertThat(patRef.isEmpty()).isFalse();
    List<Reference> obsRef = encounterRes.getReasonReference();
    assertThat(obsRef).hasSize(1);
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ResourceModel(io.github.linuxforhealth.api.ResourceModel) Encounter(org.hl7.fhir.r4.model.Encounter) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 20 with MR

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

the class Hl7MessageTest method test_patient.

@Test
void test_patient() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/Patient");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Patient").withResourceModel(rsm).withSegment("PID").withIsReferenced(false).withRepeats(false).build();
    HL7FHIRResourceTemplate patient = new HL7FHIRResourceTemplate(attributes);
    HL7MessageModel message = new HL7MessageModel("ADT", Lists.newArrayList(patient));
    String hl7message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^MR~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^Sr^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||";
    String json = message.convert(hl7message, engine);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> patientResource = e.stream().filter(v -> ResourceType.Patient == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(patientResource).hasSize(1);
}
Also used : 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) ResourceModel(io.github.linuxforhealth.api.ResourceModel) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

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