Search in sources :

Example 11 with MR

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

the class Hl7AllergyFHIRConversionTest method test_allergy_no_severity_no_coding_system.

@Test
void test_allergy_no_severity_no_coding_system() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\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" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION\r";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.hasCriticality()).isFalse();
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("OXYCODONE");
    List<Coding> codings = allergy.getCode().getCoding();
    Assertions.assertEquals(1, codings.size());
    Coding coding = codings.get(0);
    Assertions.assertEquals("00000741", coding.getCode());
    Assertions.assertEquals("OXYCODONE", coding.getDisplay());
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactly("HYPOTENSION");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 12 with MR

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

the class Hl7AllergyFHIRConversionTest method test_allergy_single.

@Test
void test_allergy_single() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\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" + "AL1|1|DA|^PENICILLIN|MI|PRODUCES HIVES~RASH|MI\r" + "AL1|2|AA|^CAT DANDER|SV";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.getCriticality().toCode()).isEqualTo("low");
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("PENICILLIN");
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactlyInAnyOrder("PRODUCES HIVES", "RASH");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.jupiter.api.Test)

Example 13 with MR

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

the class Hl7EncounterFHIRConversionTest method test_encounter_with_serviceProvider_from_PV1_3_4.

// Test for serviceProvider reference in messages with PV1 segment and no PV2 segment
// Use serviceProvider from PV1-3.4.1
@ParameterizedTest
@ValueSource(strings = { "ADT^A01", /* "ADT^A02", "ADT^A03", "ADT^A04", */
"ADT^A08", // MDM messages are not tested here because they do not have PV2 segments
"OMP^O09", "ORU^R01", "RDE^O11", "RDE^O25", "VXU^V04" })
void test_encounter_with_serviceProvider_from_PV1_3_4(String message) {
    String hl7message = "MSH|^~\\&|TestSystem||TestTransformationAgent||20150502090000||" + message + "|controlID|P|2.6\r" + "EVN|A01|20150502090000|\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + // PV1-3.4 used for serviceProvider reference; used for both id and name
    "PV1||I|INT^0001^02^Toronto East|||||||SUR||||||||S|VisitNumber^^^Toronto North|A|||||||||||||||||||Toronto West||||||\r";
    String json = ftv.convert(hl7message, OPTIONS);
    assertThat(json).isNotBlank();
    LOGGER.debug("FHIR json result:\n" + json);
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounterResource).hasSize(1);
    Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
    Reference serviceProvider = encounter.getServiceProvider();
    assertThat(serviceProvider).isNotNull();
    String providerString = serviceProvider.getReference();
    // Also verify underscore replacement for VALID_ID
    assertThat(providerString).isEqualTo("Organization/toronto-east");
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    assertThat(organizations).hasSize(1);
    Organization orgResource = ResourceUtils.getResourceOrganization(organizations.get(0), context);
    assertThat(orgResource.getId()).isEqualTo(providerString);
    // PV1.3.4.1
    assertThat(orgResource.getName()).isEqualTo("Toronto East");
    assertThat(orgResource.getIdentifier()).hasSize(1);
    // PV1.3.4.1
    assertThat(orgResource.getIdentifierFirstRep().getValue()).hasToString("Toronto East");
    // Because ID is name based
    assertThat(orgResource.getIdentifierFirstRep().getSystem()).hasToString("urn:id:extID");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with MR

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

the class HL7ConditionFHIRConversionTest method validateEncounterMultipleDiagnosesTestingMultipleDiagnosisAndReasonReferences.

// Tests that the Encounter has the full array of condition references in both
// diagnosis and reasonReference.
@Test
void validateEncounterMultipleDiagnosesTestingMultipleDiagnosisAndReasonReferences() {
    String hl7message = "MSH|^~\\&||||||S1|ADT^A01^ADT_A01||T|2.6|||||||||\r" + "EVN|A04||||||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||I|||||||||||||||||1492|||||||||||||||||||||||||\r" + "DG1|1|D1|V72.83^Other specified pre-operative examination^ICD-9^^^|Other specified pre-operative examination|20151008111200|F|||||||||8|\r" + "DG1|2|D2|R00.0^Tachycardia, unspecified^ICD-10^^^|Tachycardia, unspecified|20150725201300|F|||||||||8|\r" + "DG1|3|D3|R06.02^Shortness of breath^ICD-10^^^|Shortness of breath||F|||||||||8|\r" + "DG1|4|D4|Q99.9^Chromosomal abnormality, unspecified^ICD-10^^^|Chromosomal abnormality, unspecified||F|||||||||8|\r" + "DG1|5|D5|I34.8^Arteriosclerosis^ICD-10^^^|Arteriosclerosis||F|||||||||8|\r" + "DG1|6|D6|I34.0^Mitral valve regurgitation^ICD-10^^^|Mitral valve regurgitation||F|||||||||8|\r" + "DG1|6|D7|I05.9^Mitral valve disorder in childbirth^ICD-10^^^|Mitral valve disorder in childbirth||F|||||||||8|\r" + "DG1|7|D8|J45.909^Unspecified asthma, uncomplicated^ICD-10^^^|Unspecified asthma, uncomplicated||F|||||||||8|\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Find the conditions from the FHIR bundle.
    List<Resource> conditionResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
    // We should have 1 condition for each diagnosis therefore 8 for this message.
    assertThat(conditionResource).hasSize(8);
    // Find the encounter from the FHIR bundle.
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // Verify we only have 1 encounter
    assertThat(encounterResource).hasSize(1);
    Encounter encounter = (Encounter) encounterResource.get(0);
    // Verify reasonReference has a reference for each condition. Therefore there should be 8.
    assertThat(encounter.getReasonReference()).hasSize(8);
    // Check the references are referencing conditions
    for (int i = 0; i < 8; i++) {
        assertThat(encounter.getReasonReference().get(i).getReference().substring(0, 10)).isEqualTo("Condition/");
    }
    // Verify there is encounter.diagnosis for every diagnosis. Therefore there should be 8.
    assertThat(encounter.getDiagnosis()).hasSize(8);
    List<String> referencedConditions = encounter.getDiagnosis().stream().map(i -> i.getCondition().getReference()).collect(Collectors.toList());
    List<String> condIdentifiers = conditionResource.stream().map(r -> (Condition) r).map(c -> c.getId()).collect(Collectors.toList());
    assertThat(referencedConditions).containsExactlyInAnyOrderElementsOf(condIdentifiers);
    // Verify each diagnosis is set correctly.
    for (int i = 0; i < 8; i++) {
        // Diagnosis requires a reference to condition.
        assertThat(encounter.getDiagnosis().get(i).getCondition().getReference().substring(0, 10)).isEqualTo("Condition/");
        // Verify Use coding of each diagnosis
        DatatypeUtils.checkCommonCodeableConceptAssertions(encounter.getDiagnosis().get(i).getUse(), "F", "Final", "http://terminology.hl7.org/CodeSystem/v2-0052", null);
        // Verify encounter diagnosis rank is set correctly.
        // DG1.15
        assertThat(encounter.getDiagnosis().get(i).getRank()).isEqualTo(8);
    }
}
Also used : ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(org.hl7.fhir.r4.model.Resource) Condition(org.hl7.fhir.r4.model.Condition) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Encounter(org.hl7.fhir.r4.model.Encounter) ResourceType(org.hl7.fhir.r4.model.ResourceType) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DatatypeUtils(io.github.linuxforhealth.hl7.segments.util.DatatypeUtils) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with MR

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

the class HL7MergeFHIRConversionTest method validateHappyPathADT_A34WithMRG.

// Test ADT_A34 with one MRG segment (the most it supports).
@Test
void validateHappyPathADT_A34WithMRG() {
    String hl7message = "MSH|^~\\&|SENDING_APPLICATION|SENDING_FACILITY|RECEIVING_APPLICATION|RECEIVING_FACILITY|||ADT^A34||P|2.3||||\r" + "EVN|A40|20110613122406637||01\r" + // Identifier value 234 with no system and no identifier type
    "PID|1||123^^^^MR||||||||||||||||||||||||||||||||||||\r" + // Identifier value 456 with no system and no identifier type
    "MRG|456||||||\r";
    // Convert hl7 message
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Find the patient resources in the FHIR bundle.
    List<Resource> patientResources = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // There should be 2 - One for the PID segment and one for the MRG segment
    assertThat(patientResources).hasSize(2);
    // Get first patient and associated identifiers and id.
    Patient patientOne = PatientUtils.getPatientFromResource(patientResources.get(0));
    String patientOneId = patientOne.getId();
    List<Identifier> patientOneIdentifierList = patientOne.getIdentifier();
    // Get second patient and associated identifiers and id.
    Patient patientTwo = PatientUtils.getPatientFromResource(patientResources.get(1));
    String patientTwoId = patientTwo.getId();
    List<Identifier> patientTwoIdentifierList = patientTwo.getIdentifier();
    /*-----------Verify Patient One-----------*/
    // Verify patient one's identifier is set correctly (this is the patient build
    // from the PID segment)
    // 
    // "identifier":[
    // {
    // "type":{
    // "coding":[
    // {
    // "system":"http://terminology.hl7.org/CodeSystem/v2-0203",
    // "code":"MR",
    // "display":"Medical record number"
    // }
    // ]
    // },
    // "value":"123"
    // },
    // {
    // "use":"old",
    // "value":"456"
    // }
    // ]
    // Verify the patient has two identifiers
    assertThat(patientOneIdentifierList).hasSize(2);
    // Verify the identifier values are correct.
    assertThat(patientOneIdentifierList.get(0).getValue()).isEqualTo("123");
    assertThat(patientOneIdentifierList.get(1).getValue()).isEqualTo("456");
    // Verify the system values are not present
    assertThat(patientOneIdentifierList.get(0).getSystem()).isNull();
    assertThat(patientOneIdentifierList.get(1).getSystem()).isNull();
    // Verify the first identifier has no use field.
    assertThat(patientOneIdentifierList.get(0).getUse()).isNull();
    // Verify the second identifier is marked as old
    assertThat(patientOneIdentifierList.get(1).getUse()).isEqualTo(Identifier.IdentifierUse.OLD);
    // Verify identifier type is set correctly for the first identifier
    CodeableConcept patientOneIdentifierType = patientOneIdentifierList.get(0).getType();
    assertThat(patientOneIdentifierType.getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
    assertThat(patientOneIdentifierType.getCoding().get(0).getDisplay()).isEqualTo("Medical record number");
    assertThat(patientOneIdentifierType.getCoding().get(0).getCode()).isEqualTo("MR");
    // Verify the identifier type for the second identifier is not present.
    assertThat(patientOneIdentifierList.get(1).getType().getCoding()).isEmpty();
    // Verify first patient has these fields
    // 
    // "active":true,
    // "link":[
    // {
    // "other":{
    // "reference":"Patient/expiringID-MRG"
    // },
    // "type":"replaces"
    // }
    // ]
    // The first patient should be active.
    assertThat(patientOne.getActive()).isTrue();
    // Verify link.other.reference references the MRG (2nd) patient with of a type of 'replaces'
    PatientLinkComponent linkOne = patientOne.getLink().get(0);
    assertThat(linkOne.getType()).isEqualTo(Patient.LinkType.REPLACES);
    assertThat(linkOne.getOther().getReference()).isEqualTo(patientTwoId);
    /*-----------Verify Patient Two-----------*/
    // Verify patient two's identifier is set correctly (this is the patient build
    // from the MRG segment)
    // 
    // "identifier":[
    // {
    // "use":"old",
    // "value":"456"
    // }
    // ]
    // Verify has only 1 identifier
    assertThat(patientTwoIdentifierList).hasSize(1);
    // Verify the identifier value is correct.
    assertThat(patientTwoIdentifierList.get(0).getValue()).isEqualTo("456");
    // Verify the system is not present
    assertThat(patientTwoIdentifierList.get(0).getSystem()).isNull();
    // Verify the identifier is marked as old
    assertThat(patientTwoIdentifierList.get(0).getUse()).isEqualTo(Identifier.IdentifierUse.OLD);
    // Verify identifier type is not present
    assertThat(patientTwoIdentifierList.get(0).getType().getCoding()).isEmpty();
    // Verify second patient has these fields.
    // "active":false,
    // "link":[
    // {
    // "other":{
    // "reference":"Patient/survivingID"
    // },
    // "type":"replaced-by"
    // }
    // ]
    // The second patient should NOT be active.
    assertThat(patientTwo.getActive()).isFalse();
    // We should have link.other.reference to the PID (1st) patient with a type of 'replaced-by'
    PatientLinkComponent linkTwo = patientTwo.getLink().get(0);
    assertThat(linkTwo.getType()).isEqualTo(Patient.LinkType.REPLACEDBY);
    assertThat(linkTwo.getOther().getReference()).isEqualTo(patientOneId);
    ;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) PatientLinkComponent(org.hl7.fhir.r4.model.Patient.PatientLinkComponent) 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