Search in sources :

Example 56 with MR

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

the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestCategoryRequesterAndDispenseRequest.

@Test
void testMedicationRequestCategoryRequesterAndDispenseRequest() {
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.29 to category
    "ORC|NW|||||||||||3122^PROVIDER^ORDERING^^^DR|||20190606193536||||||||||||||I\n" + // RXE.13 empty so ORC.12 takes priority
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|47||||||||||||||||||||||||||||||||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    // requester comes from ORC.12 which is the back up value for RXE.13
    String requesterRef = medicationRequest.getRequester().getReference();
    Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
    Identifier practitionerIdentifier = practBundle.getIdentifierFirstRep();
    HumanName practName = practBundle.getNameFirstRep();
    // ORC.12.1
    assertThat(practitionerIdentifier.getValue()).isEqualTo("3122");
    // ORC.12.9
    assertThat(practitionerIdentifier.getSystem()).isNull();
    // ORC.12.2
    assertThat(practName.getFamily()).isEqualTo("PROVIDER");
    // ORC.12.3
    assertThat(practName.getGivenAsSingleString()).isEqualTo("ORDERING");
    // ORC.12.6
    assertThat(practName.getPrefixAsSingleString()).isEqualTo("DR");
    // ORC.12.5
    assertThat(practName.getSuffix()).isEmpty();
    // ORC.12
    assertThat(practName.getText()).isEqualTo("DR ORDERING PROVIDER");
    // category comes from  ORC.29
    assertThat(medicationRequest.getCategory()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(medicationRequest.getCategory().get(0), "inpatient", "Inpatient", "http://terminology.hl7.org/CodeSystem/medicationrequest-category", null);
    // DispenseRequest.start comes from ORC.15
    assertThat(medicationRequest.getDispenseRequest().hasValidityPeriod()).isTrue();
    assertThat(medicationRequest.getDispenseRequest().getValidityPeriod().getStartElement().toString()).containsPattern("2019-06-06");
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with MR

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateRatioRXE.

@Test
void dosageInstructionTestRateRatioRXE() {
    // Test dosageInstruction.RateRatio from RXE.22,23,24
    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 empty to cause default in dosageInstruction.doseAndRate.rateRatio.numerator.system
    "|PC|7|PC||||||||||||||||\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);
    Ratio rateRatio = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateRatio();
    // dosageInstruction.doseAndRate.rateRatio.numerator(RXE.23)
    // RXE.23
    assertThat(rateRatio.getNumerator().getValue()).hasToString("7.0");
    // RXE.24
    assertThat(rateRatio.getNumerator().getUnit()).isEqualTo("PC");
    // Defaulted
    assertThat(rateRatio.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // dosageInstruction.doseAndRate.rateRatio.denominator
    assertThat(rateRatio.getDenominator().getValue()).hasToString("1.0");
    // RXE.22
    assertThat(rateRatio.getDenominator().getUnit()).isEqualTo("PC");
    assertThat(rateRatio.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // 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) Ratio(org.hl7.fhir.r4.model.Ratio) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 58 with MR

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

the class Hl7MedicationRequestFHIRConversionTest method dispenseRequestTestRXE.

@Test
void dispenseRequestTestRXE() {
    // Get DispenseRequest from RXE segment (RXE.10, RXE.11.1 and RXE.11.3)
    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.39 to dispenseRequest.InitialFill.Quantity
    "|1|PC^^measureofunits|0|||||||||||||||||||||||||||7|\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);
    MedicationRequest.MedicationRequestDispenseRequestComponent disReq = medicationRequest.getDispenseRequest();
    // dispenseRequest.Quantity comes from RXE.10, RXE.11.1 and RXE.11.3
    assertThat(disReq.getQuantity().getValue()).hasToString("1.0");
    assertThat(disReq.getQuantity().getUnit()).isEqualTo("PC");
    assertThat(disReq.getQuantity().getSystem()).isEqualTo("urn:id:measureofunits");
    // dispenseRequest.NumberOfRepeatsAllowed RXE.12
    assertThat(disReq.getNumberOfRepeatsAllowed()).hasToString("0");
    // dispenseRequest.InitialFill.Quantity comes from RXE.39
    assertThat(disReq.getInitialFill().getQuantity().getValue()).hasToString("7.0");
    // 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)

Example 59 with MR

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

the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestReasonCode.

@Test
void testMedicationRequestReasonCode() {
    // Reason code from RXO.20, should ignore ORC.16
    String hl7message = "MSH|^~\\&||||||S1|PPR^PC1||T|2.6|||||||||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\r" + "PRB|AD|20141015103243|15777000^Prediabetes (disorder)^SNM|654321^^OtherSoftware.ProblemOID|||||\r" + // ORC.16 purposely present to be ignored because RXO.20 is present
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\r" + "OBR|1|||555|||20170825010500||||||||||||||||||F\r" + // RXO.2 through RXO.35 otherwise purposely empty
    "RXO|65862-063-01^METOPROLOL TARTRATE^NDC|||||||||||||||||||134006\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // RXO.20.1
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("134006");
    // No RXO.20.2
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isNull();
    // No RXO.20.3
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isNull();
    // Reason code from RXE.27. Ignores ORC.16.
    hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 purposely present to be ignored because RXE.27 is present
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 otherwise purposely empty
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL||||||||||||||||||||||Wheezing^Wheezing^PRN|||||||||||||\r";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("Wheezing");
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
    // Reason code from ORC.16 (when RXE.27 is not present)
    hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 to reason code
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 purposely empty
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|||||||||||||||||||||||||||||||||||\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // ORC.16.1
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("4338008");
    // ORC.16.2
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
    // ORC.16.3 (unknown system)
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
}
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)

Example 60 with MR

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

the class Hl7IdentifierFHIRConversionTest method conditionDg1IdentifierTest3.

@Test
void conditionDg1IdentifierTest3() {
    String withDG132 = "MSH|^~\\&|||||201610015080000||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||A|||||||||||||||||||SF|K||||20170215080000\n" + "DG1|1|ICD10|^Ovarian Cancer|Test|20210322154449|A|E123|R45|Y|J76|C|15|1458.98||1|123^DOE^JOHN^A^|C|Y|20210322154326||S1234|Parent Diagnosis|Value345|Group567|DiagnosisG45|Y\r";
    Condition condition = ResourceUtils.getCondition(ftv, withDG132);
    // Expect 2 identifiers
    assertThat(condition.hasIdentifier()).isTrue();
    assertThat(condition.getIdentifier()).hasSize(2);
    List<Identifier> identifiers = condition.getIdentifier();
    // Match the id's to position; we can't depend on an order.
    int posVN = getIdentifierPositionByValue("201610015080000", identifiers);
    assertThat(posVN).isNotSameAs(-1);
    int posExtId = getIdentifierPositionByValue("Ovarian Cancer", identifiers);
    assertThat(posExtId).isNotSameAs(-1);
    // Identifier 1: Visit number
    Identifier identifier = condition.getIdentifier().get(posVN);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH.7
    assertThat(value).isEqualTo("201610015080000");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 3: DG1.3.2
    identifier = condition.getIdentifier().get(posExtId);
    value = identifier.getValue();
    system = identifier.getSystem();
    // DG1.3.2
    assertThat(value).isEqualTo("Ovarian Cancer");
    assertThat(system).isEqualTo("urn:id:extID");
}
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)

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