Search in sources :

Example 36 with MR

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

the class Hl7IdentifierFHIRConversionTest method conditionDg1IdentifierTest2.

@Test
void conditionDg1IdentifierTest2() {
    // Test PV1-19 for visit number; extID with DG1-3.1.
    // Also test DG1-20 creates additional identifiers.
    String withDG120 = "MSH|^~\\&|||||||ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r" + "PID|||10290^^^WEST^MR||||20040530|M||||||||||||||||||||||N\n" + "PV1||I||||||||SUR||||||||S|8846511^^^ACME|A|||||||||||||||||||SF|K||||20170215080000\n" + "DG1|1|ICD10|B45678|Broken Arm|20210322154449|A|E123|R45|Y|J76|C|15|1458.98||1|123^DOE^JOHN^A^|C|Y|20210322154326|one^https://terminology.hl7.org/CodeSystem/two^three^https://terminology.hl7.org/CodeSystem/four|S1234|Parent Diagnosis|Value345|Group567|DiagnosisG45|Y\r";
    Condition condition = ResourceUtils.getCondition(ftv, withDG120);
    // Expect 4 identifiers
    assertThat(condition.hasIdentifier()).isTrue();
    assertThat(condition.getIdentifier()).hasSize(4);
    List<Identifier> identifiers = condition.getIdentifier();
    // Match the id's to position; we can't depend on an order.
    int posVN = getIdentifierPositionByValue("8846511", identifiers);
    assertThat(posVN).isNotSameAs(-1);
    int posExtId = getIdentifierPositionByValue("B45678", identifiers);
    assertThat(posExtId).isNotSameAs(-1);
    int posExtDG20a = getIdentifierPositionByValue("one", identifiers);
    assertThat(posExtDG20a).isNotSameAs(-1);
    int posExtDG20b = getIdentifierPositionByValue("three", identifiers);
    assertThat(posExtDG20b).isNotSameAs(-1);
    // Identifier 1: Visit number
    Identifier identifier = condition.getIdentifier().get(posVN);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // PV1.19.1
    assertThat(value).isEqualTo("8846511");
    // PV1.19.4
    assertThat(system).isEqualTo("urn:id:ACME");
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 2: DG1.3.1
    identifier = condition.getIdentifier().get(posExtId);
    value = identifier.getValue();
    system = identifier.getSystem();
    // DG1.3.1
    assertThat(value).isEqualTo("B45678");
    assertThat(system).isEqualTo("urn:id:extID");
    // Identifier 3: DG1.20.1 and DG1.20.2
    identifier = condition.getIdentifier().get(posExtDG20a);
    value = identifier.getValue();
    system = identifier.getSystem();
    // DG1.20.1
    assertThat(value).isEqualTo("one");
    // DG1.20.2
    assertThat(system).isEqualTo("https://terminology.hl7.org/CodeSystem/two");
    // Identifier 4: DG1.20.3 and DG1.20.4
    identifier = condition.getIdentifier().get(posExtDG20b);
    value = identifier.getValue();
    system = identifier.getSystem();
    // DG1.20.3
    assertThat(value).isEqualTo("three");
    // DG1.20.4
    assertThat(system).isEqualTo("https://terminology.hl7.org/CodeSystem/four");
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 37 with MR

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

the class Hl7IdentifierFHIRConversionTest method observationIdentifierTest.

@Test
void observationIdentifierTest() {
    // identifier uses the logic from BUILD_IDENTIFIER_FROM_CWE (OBX.3) and joins FILL or PLAC values with it
    // Filler from OBR-3; OBX-3.1/OBX-3.3
    String joinFillPlaAndObx3 = "MSH|^~\\&|SOARF|E_AMC|||201512201012||ADT^A01|MSG$1|P|2.7||1|||||||\r" + "EVN|A01|201512201012||CI|wiestc|201512201007|1488\r" + "PID|||MRN12345678^^^ID-XYZ^MR~111223333^^^USA^SS~MN1234567^^^MNDOT^DL||||||||||||||\r" + "PV1|1|I|E2^E211^E211B^1488|Elective||||||||||V\r" + "OBR|1|ORD448811^NIST EHR|R-511^NIST Lab Filler|1000^Hepatitis A B C Panel^99USL|||20120628070100|||||||||\r" + "OBX|1|ST|DINnumber^^LSFUSERDATAE||N/A||||||R||||||\r";
    Observation observation = ResourceUtils.getObservation(ftv, joinFillPlaAndObx3);
    // Expect a single identifier
    assertThat(observation.hasIdentifier()).isTrue();
    assertThat(observation.getIdentifier()).hasSize(1);
    // Identifier 1: extID from OBR.3 plus OBX-3.1/OBX-3.3
    Identifier identifier = observation.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // OBR.3.1-OBX.3.1-OBX.3.3
    assertThat(value).isEqualTo("R-511-DINnumber-LSFUSERDATAE");
    assertThat(system).isEqualTo("urn:id:extID");
    // Placer from OBR-2; OBX-3.1
    String msg = "MSH|^~\\&|SOARF|E_AMC|||201512201012||ADT^A01|MSG$1|P|2.7||1|||||||\r" + "EVN|A01|201512201012||CI|wiestc|201512201007|1488\r" + "PID|||MRN12345678^^^ID-XYZ^MR~111223333^^^USA^SS~MN1234567^^^MNDOT^DL||||||||||||||\r" + "PV1|1|I|E2^E211^E211B^1488|Elective||||||||||V\r" + "OBR|1|ORD448811^NIST EHR|^NIST Lab Filler|1000^Hepatitis A B C Panel^99USL|||20120628070100|||||||||\r" + "OBX|1|ST|DINnumber^^||N/A||||||R||||||\r";
    observation = ResourceUtils.getObservation(ftv, msg);
    // Expect a single identifier
    assertThat(observation.hasIdentifier()).isTrue();
    assertThat(observation.getIdentifier()).hasSize(1);
    // Identifier 1: extID from OBR.2 and OBX-3.1
    identifier = observation.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    // OBR.2.1-OBX.3.1
    assertThat(value).isEqualTo("ORD448811-DINnumber");
    assertThat(system).isEqualTo("urn:id:extID");
    // Filler from ORC-3; OBX-3.2
    msg = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\r" + "PID|||555444222111^^^MPI&GenHosp&L^MR||james^anderson||19600614|M||C|||^^^^^626^5641111|^^^^^626^5647654||||||||N\r" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON^CARL|0148^ADDISON^JAMES||SUR|||||||0148^ANDERSON^CARL|S|1400|A|||||||||||||||||||SF|K||||199501102300\r" + "PRB|AD|200603150625|aortic stenosis|53692||2||200603150625\r" + "OBX|1|ST|DINnumber^^LSFUSERDATAE||ECHOCARDIOGRAPHIC REPORT||||||F|||20150930164100|||\r" + "ORC|NW|PON001|FON001|PGN001|SC|D|1||20170825010500|MS|MS||||20170825010500|";
    observation = ResourceUtils.getObservation(ftv, msg);
    // Expect a single identifier
    assertThat(observation.hasIdentifier()).isTrue();
    assertThat(observation.getIdentifier()).hasSize(1);
    // Identifier 1: extID from OBR.3 plus OBX-3.1/OBX-3.3
    identifier = observation.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    // ORC.3-OBX.3.1-OBX.3.3
    assertThat(value).isEqualTo("FON001-DINnumber-LSFUSERDATAE");
    assertThat(system).isEqualTo("urn:id:extID");
    // Placer from ORC-2; OBX-3.1
    msg = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\r" + "PID|||555444222111^^^MPI&GenHosp&L^MR||james^anderson||19600614|M||C|99 Oakland #106^^qwerty^OH^44889||||||||||N\r" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON^CARL|0148^ADDISON^JAMES||SUR|||||||0148^ANDERSON^CARL|S|1400|A||SF|K||||199501102300\r" + "PRB|AD|200603150625|aortic stenosis|53692||2||200603150625\r" + "OBX|1|ST|DINnumber||ECHOCARDIOGRAPHIC REPORT||||||F|||20150930164100|||\r" + "ORC|NW|PON001|||SC|D|1||20170825010500|MS|MS|||||";
    observation = ResourceUtils.getObservation(ftv, msg);
    // Expect a single identifier
    assertThat(observation.hasIdentifier()).isTrue();
    assertThat(observation.getIdentifier()).hasSize(1);
    // Identifier 1: extID from OBR.2 and OBX-3.1
    identifier = observation.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    // ORC.2-OBX.3.1
    assertThat(value).isEqualTo("PON001-DINnumber");
    assertThat(system).isEqualTo("urn:id:extID");
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test)

Example 38 with MR

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

the class Hl7IdentifierFHIRConversionTest method encounterIdentifierTest.

@Test
void encounterIdentifierTest() {
    // Test: Visit number from PV1-19
    String encounterMsg = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644||01\r" + "PID|||12345^^^^MR||smith^john|||||||||||||112233\r" + "PV1||I||||||||SUR||||||||S||A\r";
    Encounter encounter = ResourceUtils.getEncounter(ftv, encounterMsg);
    // Expect a single identifier
    assertThat(encounter.hasIdentifier()).isTrue();
    assertThat(encounter.getIdentifier()).hasSize(1);
    // Identifier 1: Visit number
    Identifier identifier = encounter.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // PID.18
    assertThat(value).isEqualTo("112233");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    Coding coding = type.getCoding().get(0);
    assertThat(type.getText()).isNull();
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
    assertThat(coding.getCode()).isEqualTo("VN");
    assertThat(coding.getDisplay()).isEqualTo("Visit number");
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) Encounter(org.hl7.fhir.r4.model.Encounter) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 39 with MR

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

the class Hl7IdentifierFHIRConversionTest method serviceRequestIdentifierTest5.

// NOTE: ORU_RO1 records do not create the ServiceRequest directly.  They create a DiagnosticReport and it creates the ServiceRequest.
// This test makes sure the specification for ORU_RO1.DiagnosticReport is specifying PID and PV1 correctly in AdditionalSegments.
@Test
void serviceRequestIdentifierTest5() {
    // Test 3:
    // - MSH.7 as the visit number
    // - filler from ORC
    // - placer from ORC
    String serviceRequest = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is empty so MSH.7 with be used as backup identifier visit number
    "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.19 is empty so MSH.7 with be used as backup identifier visit number
    "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // 1. ORC.3 is used as Filler because it has priority over OBR.3
    "ORC|RE|222298|222299|ML18267-C00001^Beaker||||||||||||||||||||||||||||\n" + // 11. OBR.3 ignored as Filler
    "OBR|1|||83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||||||||||||||||||||||||||||||||||||||||||\n";
    ServiceRequest serviceReq = ResourceUtils.getServiceRequest(ftv, serviceRequest);
    // Expect 3 identifiers
    assertThat(serviceReq.hasIdentifier()).isTrue();
    assertThat(serviceReq.getIdentifier()).hasSize(3);
    // Expect 3 identifiers
    assertThat(serviceReq.hasIdentifier()).isTrue();
    assertThat(serviceReq.getIdentifier()).hasSize(3);
    List<Identifier> identifiers = serviceReq.getIdentifier();
    // Match the three id's to position; we can't depend on an order.
    int posVN = getIdentifierPositionByValue("20180924152907", identifiers);
    assertThat(posVN).isNotSameAs(-1);
    int posFILLER = getIdentifierPositionByValue("222299", identifiers);
    assertThat(posFILLER).isNotSameAs(-1);
    int posPLACER = getIdentifierPositionByValue("222298", identifiers);
    assertThat(posPLACER).isNotSameAs(-1);
    // Identifier 1: visit number should be set by MSH.7
    Identifier identifier = serviceReq.getIdentifier().get(posVN);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH.7
    assertThat(value).isEqualTo("20180924152907");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 2: filler
    identifier = serviceReq.getIdentifier().get(posFILLER);
    value = identifier.getValue();
    system = identifier.getSystem();
    // ORC.3
    assertThat(value).isEqualTo("222299");
    assertThat(system).isNull();
    type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "FILL", "Filler Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 3: placer
    identifier = serviceReq.getIdentifier().get(posPLACER);
    value = identifier.getValue();
    system = identifier.getSystem();
    // ORC.2
    assertThat(value).isEqualTo("222298");
    assertThat(system).isNull();
    type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "PLAC", "Placer Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 40 with MR

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

the class Hl7OrderRequestFHIRConversionTest method testAdditionalOBRFieldsNoORCSegment.

@Test
void testAdditionalOBRFieldsNoORCSegment() {
    String hl7message = "MSH|^~\\&|Epic|ATRIUS|||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // ORC.15 is missing, so use OBR.7 as ServiceRequest.occurrenceDateTime
    "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||20170707120707|20180808120808|||||||||||||||||F|||||||||||||||||||||||||\n";
    String json = ftv.convert(hl7message, PatientUtils.OPTIONS);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle bundle = (Bundle) bundleResource;
    List<BundleEntryComponent> e = bundle.getEntry();
    List<Resource> diagnosticReportList = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    DiagnosticReport diagnosticReport = ResourceUtils.getResourceDiagnosticReport(diagnosticReportList.get(0), context);
    // OBR.7 and OBR.8 together map to DiagnosticReport.effectivePeriod
    assertThat(diagnosticReport.hasEffectivePeriod()).isTrue();
    assertThat(diagnosticReport.getEffectivePeriod().getStartElement().toString()).containsPattern("2017-07-07T12:07:07");
    assertThat(diagnosticReport.getEffectivePeriod().getEndElement().toString()).containsPattern("2018-08-08T12:08:08");
    List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // Important that we have exactly one service request (no duplication).  OBR creates it as a reference.
    assertThat(serviceRequestList).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
    assertThat(serviceRequest.hasStatus()).isTrue();
    // OBR.7 should create an ServiceRequest.occurrenceDateTime date
    assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
    assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2017-07-07T12:07:07");
    // ORC.5 is missing, so serviceRequest.status() should be unknown
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.getStatusElement().getCode()).isEqualTo("unknown");
}
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) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) 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