Search in sources :

Example 16 with Location

use of org.hl7.fhir.r4.model.Location 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 17 with Location

use of org.hl7.fhir.r4.model.Location 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 18 with Location

use of org.hl7.fhir.r4.model.Location 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)

Example 19 with Location

use of org.hl7.fhir.r4.model.Location in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MessageTest method test_messageHeader_with_ORU.

@Test
void test_messageHeader_with_ORU() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/MessageHeader");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("MessageHeader").withResourceModel(rsm).withSegment("MSH").withAdditionalSegments(Lists.newArrayList("EVN")).withIsReferenced(false).withRepeats(false).build();
    HL7FHIRResourceTemplate messageHeaderTemplate = new HL7FHIRResourceTemplate(attributes);
    HL7MessageModel message = new HL7MessageModel("ORU", Lists.newArrayList(messageHeaderTemplate));
    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||01\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> messageHeader = e.stream().filter(v -> ResourceType.MessageHeader == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(messageHeader).hasSize(1);
    MessageHeader msgH = ResourceUtils.getResourceMessageHeader(messageHeader.get(0), context);
    assertThat(msgH.getId()).isNotNull();
    assertThat(msgH.getEventCoding()).isNotNull();
    assertThat(msgH.getEventCoding().getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0003");
    assertThat(msgH.getEventCoding().getCode()).isEqualTo("R01");
    assertThat(msgH.getEventCoding().getDisplay()).isEqualTo("ORU/ACK - Unsolicited transmission of an observation message");
    assertThat(msgH.getDestination()).hasSize(1);
    assertThat(msgH.getDestinationFirstRep().getName()).isEqualTo("New Tester");
    assertThat(msgH.getDestinationFirstRep().getEndpoint()).isEqualTo("MS");
    assertThat(msgH.getSource()).isNotNull();
    assertThat(msgH.getSource().getName()).isEqualTo("Amalga HIS");
    assertThat(msgH.getReason()).isNotNull();
    assertThat(msgH.getReason().getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0062");
    assertThat(msgH.getReason().getCoding().get(0).getCode()).isEqualTo("01");
    assertThat(msgH.getReason().getCoding().get(0).getDisplay()).isEqualTo("Patient request");
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) 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) MessageHeader(org.hl7.fhir.r4.model.MessageHeader) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 20 with Location

use of org.hl7.fhir.r4.model.Location in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MessageTest method test_specimen.

@Test
void test_specimen() throws IOException {
    ResourceModel rsm = ResourceReader.getInstance().generateResourceModel("resource/Specimen");
    HL7FHIRResourceTemplateAttributes attributes = new HL7FHIRResourceTemplateAttributes.Builder().withResourceName("Specimen").withResourceModel(rsm).withSegment("SPM").withIsReferenced(true).withRepeats(false).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";
    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(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.Test)215 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)94 Location (org.hl7.fhir.r4.model.Location)92 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)71 Location (org.hl7.fhir.dstu3.model.Location)66 InputStream (java.io.InputStream)46 Matchers.containsString (org.hamcrest.Matchers.containsString)38 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)38 Test (org.junit.jupiter.api.Test)37 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)35 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)29 ArrayList (java.util.ArrayList)28 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)26 Date (java.util.Date)24 Reference (org.hl7.fhir.r4.model.Reference)24 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)23 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)23 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)23 Bundle (org.hl7.fhir.r4.model.Bundle)23