Search in sources :

Example 91 with MR

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

the class Hl7OrderRequestFHIRConversionTest method testBroadORCPlusOBRFields.

// This test is a companion to testBroadORCFields.   ORC and OBR records often have repeated data; one taking priority over the other.
// Read comments carefully.  This sometimes tests the secondary value and may be the opposite to the tests in testBroadORCFields.
@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")
void testBroadORCPlusOBRFields() {
    String hl7message = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is used as backup identifier visit number because PV1.19 is empty
    "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||665544||||||||||||\n" + // PV1.19 is empty and not used as visit number identifier
    "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // 7. ORC.16 is set to a reason code (but it is ignored because it is secondary to OBR.31, which is present in this case and therefore overrides ORC.16)
    "ORC|RE|248648498^|248648498^|||||||||||||042^Human immunodeficiency virus [HIV] disease [42]^I9CDX^^^^29|||||||||||||||\n" + // 14. OBR.6 creates ServiceRequest.authoredOn
    "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C||20120606120606|20170707150707||||L|||||54321678^SCHMIDT^FRIEDA^^MD^^^^NPI^D^^^NPI||||||20180924152900|||F||||||HIV^HIV/Aids^L^^^^V1|323232&Mahoney&Paul&J||||||||||||||||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> serviceRequestList = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // 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();
    assertThat(serviceRequest.hasIdentifier()).isTrue();
    assertThat(serviceRequest.getIdentifier()).hasSize(3);
    // Identifier 1: visit number should be set by in this test by secondary PID.18
    // ORU_RO1 records do not create the ServiceRequest directly.  They create a DiagnosticReport and it creates the ServiceRequest.
    // This makes sure the specification for ORU_RO1.DiagnosticReport is specifying PID correctly in AdditionalSegments.
    // Extensive testing of identifiers is done in Hl7IdentifierFHIRConversionTest.java
    Identifier identifier = serviceRequest.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // PID.18
    assertThat(value).isEqualTo("665544");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // No requisition in the serviceRequest.
    assertThat(serviceRequest.hasRequisition()).isFalse();
    // OBR.6 should create authoredOn because ORC.9 is not filled in
    assertThat(serviceRequest.hasAuthoredOn()).isTrue();
    assertThat(serviceRequest.getAuthoredOnElement().toString()).containsPattern("2012-06-06T12:06:06");
    // OBR.7 is used to create an ServiceRequest.occurrenceDateTime date because ORC.15 is empty
    assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
    assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2017-07-07T15:07:07");
    // OBR.31 should create the ServiceRequest.reasonCode CWE
    assertThat(serviceRequest.hasReasonCode()).isTrue();
    assertThat(serviceRequest.getReasonCode()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptVersionedAssertions(serviceRequest.getReasonCodeFirstRep(), "HIV", "HIV/Aids", "urn:id:L", "HIV/Aids", "V1");
    // OBR.16 should create an ServiceRequest.requester reference & display
    assertThat(serviceRequest.hasRequester()).isTrue();
    assertThat(serviceRequest.getRequester().hasDisplay()).isTrue();
    assertThat(serviceRequest.getRequester().getDisplay()).isEqualTo("FRIEDA SCHMIDT MD");
    assertThat(serviceRequest.getRequester().hasReference()).isTrue();
    String requesterRef = serviceRequest.getRequester().getReference();
    Practitioner pract = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
    // Confirm that the matching practitioner by ID has the correct content (simple validation)
    // Should be OBR.16 because ORC.12 is empty.
    // Check the practitioner content in detail, validating subfields.
    assertThat(pract.getIdentifier()).hasSize(1);
    // OBR.16.1
    assertThat(pract.getIdentifierFirstRep().getValue()).isEqualTo("54321678");
    // OBR.16.9, tests known system logic
    assertThat(pract.getIdentifierFirstRep().getSystem()).isEqualTo("http://hl7.org/fhir/sid/us-npi");
    DatatypeUtils.checkCommonCodeableConceptAssertions(pract.getIdentifierFirstRep().getType(), "NPI", "National provider identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", // OBR.16.13
    null);
    assertThat(pract.getName()).hasSize(1);
    // Combined OBR.16.2 - OBR.16.7
    assertThat(pract.getNameFirstRep().getTextElement().toString()).hasToString("FRIEDA SCHMIDT MD");
    // OBR.16.10
    assertThat(pract.getNameFirstRep().getUseElement().getCode()).isEqualTo("usual");
    // OBR.4 maps to ServiceRequest.code.  Verify resulting CodeableConcept.
    assertThat(serviceRequest.hasCode()).isTrue();
    DatatypeUtils.checkCommonCodeableConceptAssertions(serviceRequest.getCode(), "83036E", "HEMOGLOBIN A1C", "urn:id:PACSEAP", "HEMOGLOBIN A1C");
    List<Resource> diagnosticReportList = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    assertThat(diagnosticReportList).hasSize(1);
    DiagnosticReport diagnosticReport = ResourceUtils.getResourceDiagnosticReport(diagnosticReportList.get(0), context);
    // OBR.4 ALSO maps to DiagnosticReport.code.  Verify resulting CodeableConcept.
    assertThat(diagnosticReport.hasCode()).isTrue();
    DatatypeUtils.checkCommonCodeableConceptAssertions(diagnosticReport.getCode(), "83036E", "HEMOGLOBIN A1C", "urn:id:PACSEAP", "HEMOGLOBIN A1C");
    assertThat(diagnosticReport.hasBasedOn()).isTrue();
    assertThat(diagnosticReport.getBasedOn()).hasSize(1);
    // OBR.7 maps to create an DiagnosticReport.effectiveDateTime
    assertThat(diagnosticReport.hasEffectiveDateTimeType()).isTrue();
    assertThat(diagnosticReport.getEffectiveDateTimeType().toString()).containsPattern("2017-07-07T15:07:07");
    // Check for DiagnosticReport.issued instant of OBR.22
    assertThat(diagnosticReport.hasIssued()).isTrue();
    // NOTE: The data is kept as an InstantType, and is extracted with .toInstant
    // thus results in a different format than other time stamps that are based on DateTimeType
    assertThat(diagnosticReport.getIssued().toInstant().toString()).contains("2018-09-24T07:29:00Z");
    // Get the diagnosticReport.resultsInterpreter, which should match the Practitioner data from OBR.32
    assertThat(diagnosticReport.hasResultsInterpreter()).isTrue();
    assertThat(diagnosticReport.getResultsInterpreter()).hasSize(1);
    String resultsInterpreterRef = diagnosticReport.getResultsInterpreter().get(0).getReference();
    pract = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, resultsInterpreterRef);
    // Confirm that the matching practitioner by ID has the correct content (simple validation)
    // Should be the value OBR.32
    assertThat(pract.getIdentifierFirstRep().getValue()).isEqualTo("323232");
    assertThat(pract.getName()).hasSize(1);
    assertThat(pract.getName().get(0).getTextElement()).hasToString("Paul J Mahoney");
    // Check for OBR.25 mapped to DiagnosticReport.status
    assertThat(diagnosticReport.hasStatus()).isTrue();
    assertThat(diagnosticReport.getStatusElement().getCode()).isEqualTo("final");
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 92 with MR

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

the class Hl7PatientFHIRConversionTest method test_patient_additional_demographics.

// Tests the PD1 segment with all supported message types.
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.6|\r", // "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A04|||2.6|\r",
"MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A08|||2.6|\r", // "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A31|||2.6|\r",
"MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A34|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A40|||2.6|\r", // MDM messages are not tested here because they do not contain PD1 segments
"MSH|^~\\&|hl7Integration|hl7Integration|||||OMP^O09|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||ORM^O01|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||ORU^R01|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||RDE^O11|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||RDE^O25|||2.6|\r", "MSH|^~\\&|hl7Integration|hl7Integration|||||VXU^V04|||2.6|\r" })
void test_patient_additional_demographics(String msh) {
    String hl7message = msh + "PID|1||1234^^^AssigningAuthority^MR||TEST^PATIENT|\r" + "PD1|||Sample Family Practice^^2222|1111^LastName^ClinicianFirstName^^^^Title||||||||||||A|\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patientResource).hasSize(1);
    Patient patient = getResourcePatient(patientResource.get(0));
    List<Reference> refs = patient.getGeneralPractitioner();
    assertThat(refs.size()).isPositive();
    List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    assertThat(practitionerResource).hasSize(1);
    Practitioner doc = getResourcePractitioner(practitionerResource.get(0));
    String lastName = doc.getName().get(0).getFamily();
    assertThat(lastName).isEqualTo("LastName");
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 93 with MR

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

the class Hl7PatientFHIRConversionTest method patient_use_name_conversion_test.

@Test
void patient_use_name_conversion_test() {
    String patientUseName = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + "PID|1||PA123456^^^MYEMR^MR||TestPatient^John^M^^^^B|MILLER^MARTHA^G^^^^M|20140227|M||2106-3^WHITE^CDCREC|1234 W FIRST ST^^BEVERLY HILLS^CA^90210^^H||^PRN^PH^^^555^5555555||ENG^English^HL70296|||||||2186-5^ not Hispanic or Latino^CDCREC||Y|2\r";
    Patient patientObjUsualName = PatientUtils.createPatientFromHl7Segment(ftv, patientUseName);
    java.util.List<org.hl7.fhir.r4.model.HumanName> name = patientObjUsualName.getName();
    HumanName.NameUse useName = name.get(0).getUse();
    assertThat(useName).isEqualTo(HumanName.NameUse.OFFICIAL);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 94 with MR

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

the class Hl7TelecomFHIRConversionTest method patient_no_telcom_test.

@Test
void patient_no_telcom_test() {
    String patientNoPhone = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^||20060504|M||||||||||||||||||||||\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientNoPhone);
    assertThat(patient.hasTelecom()).isFalse();
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test)

Example 95 with MR

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestPatientInstructionRXE.

@Test
void dosageInstructionTestPatientInstructionRXE() {
    // Test dosageInstruction.patietInstruction (RXE.7)
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW||||||||||||||||||||||||||||\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS||||" + // RXE.7 to dosageInstruction.patientInstruction
    "|333^Take 1 tablet by mouth every 6 (six) hours.|||||||||||||||||||||||||||||||||\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);
    String patInstruct = medicationRequest.getDosageInstructionFirstRep().getPatientInstruction();
    // dosageInstruction.patientInstruction (RXE.7.1 and 7.2 separated by a ':')
    assertThat(patInstruct).isEqualTo("333:Take 1 tablet by mouth every 6 (six) hours.");
    // Verify no extraneous resources
    // Expect MedicationRequest, 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) 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