Search in sources :

Example 86 with MR

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

the class HL7OMLMessageTest method testOMLO21WithPatientWithPatientVisitAndMinimumOrder.

@Test
public void testOMLO21WithPatientWithPatientVisitAndMinimumOrder() throws IOException {
    String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "PV1|1|O|||||||||||||||||2462201|||||||||||||||||||||||||20180520230000\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r";
    String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // from PID
    assertThat(patientResource).hasSize(1);
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // from PV1
    assertThat(encounterResource).hasSize(1);
    // TODO: When function is added to create ServiceRequest from ORC then also check for ServiceRequest
    // List<Resource> serviceResource = e.stream()
    // .filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType())
    // .map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // assertThat(serviceResource).hasSize(1);
    // Confirm that there are no extra resources
    // TODO: When ServiceRequest is added then this line should check for 3.
    assertThat(e.size()).isEqualTo(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) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 87 with MR

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

the class HL7OMLMessageTest method testOMLO21WithPatientAndOrderWithObservationRequestWithDG1.

@Test
public void testOMLO21WithPatientAndOrderWithObservationRequestWithDG1() throws IOException {
    String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r" + "OBR|1|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||58410-2^CBC panel - Blood by Automated count^LN||||||||||||\r" + "DG1|1||A013^Paratyphoid fever C^I10C|||A|||||||||1\r";
    String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // from PID
    assertThat(patientResource).hasSize(1);
    List<Resource> serviceResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // from ORC
    assertThat(serviceResource).hasSize(1);
    List<Resource> diagnosticresource = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    // from OBR
    assertThat(diagnosticresource).hasSize(1);
    List<Resource> conditionresource = ResourceUtils.getResourceList(e, ResourceType.Condition);
    // from DG1
    assertThat(conditionresource).hasSize(1);
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticresource.get(0), context);
    Reference patRef = diag.getSubject();
    assertThat(patRef.isEmpty()).isFalse();
    ServiceRequest request = ResourceUtils.getResourceServiceRequest(serviceResource.get(0), context);
    Reference patientRef = request.getSubject();
    assertThat(patientRef.isEmpty()).isFalse();
    // Confirm that there are no extra resources
    assertThat(e.size()).isEqualTo(4);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) 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)

Example 88 with MR

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

the class HL7OMLMessageTest method testOMLO21MultipleOrdersWithoutObservations.

@Test
@Disabled
public // Note that even though the HL7 message definition does not require PID, it is necessary so that the resulting FHIR ServiceRequests pass FHIR validation.
void testOMLO21MultipleOrdersWithoutObservations() throws IOException {
    String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r";
    String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    assertThat(b.getType()).isEqualTo(BundleType.COLLECTION);
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // from PID
    assertThat(patientResource).hasSize(1);
    List<Resource> serviceResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // from ORC
    assertThat(serviceResource).hasSize(2);
    // Confirm that there are no extra resources
    assertThat(e.size()).isEqualTo(3);
}
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) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 89 with MR

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

the class Hl7DFTMessageTest method testResourceCreationFromDFT.

@Test
void testResourceCreationFromDFT() throws IOException {
    // Tests structure of DFT_P03 message type and DFT messages in general
    // DFT_P03 message types and IN1 are tested in detail in Hl7FinancialInsuranceTest
    String hl7message = "MSH|^~\\&|||||20151008111200||DFT^P03^DFT_P03|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // Minimal ORC for ServiceRequest
    "ORC|NW|||||||||||||||\n" + // Minimal OBR for ServiceRequest
    "OBR|1||||||||||||||||||||||||||||||||\n" + "NTE|1|O|TEST ORC/OBR NOTE AA|||\n" + // OBX is type ST so an observation will be created
    "OBX|1|ST|100||This is content|||||||X\n" + "NTE|1|L|TEST OBXa NOTE|\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to Identifier 2
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (See test testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "|DoeFake^Judy^^^Rev.|PAR||||||||||||||||||" + // IN1.50 through IN1.53 NOT REFERENCED
    "|MEMBER36||||||||||Value46|||J494949||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(1);
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // From IN1.16 through IN1.19; IN1.43; INI.49
    assertThat(relatedPersons).hasSize(1);
    List<Resource> serviceRequests = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // From ORC / OBR
    assertThat(serviceRequests).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequests.get(0), ResourceUtils.context);
    assertThat(serviceRequest.getNote()).hasSize(1);
    assertThat(serviceRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST ORC/OBR NOTE AA");
    List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
    // From OBX
    assertThat(observations).hasSize(1);
    Observation observation = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
    assertThat(observation.getNote()).hasSize(1);
    assertThat(observation.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBXa NOTE");
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter, RelatedPerson, ServiceRequest, Observation
    assertThat(e).hasSize(7);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.jupiter.api.Test)

Example 90 with MR

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

the class InputTimeZoneIdTest method testEncounterLengthWithZoneIdContext.

@Test
void testEncounterLengthWithZoneIdContext() {
    // This is the same as the test for PV1.44 and PV1.45 in Hl7EncounterFHIRConversionTest.testEncounterLength, but
    // here we pass in ZoneIdText context to ensure that Hl7RelatedGeneralUtils.pv1DurationLength works correctly with an input ZoneId.
    // Both start PV1.44 and end PV1.45 must be present to use either value as part of length
    // When both are present, the calculation value is provided in "Minutes"
    String hl7message = "MSH|^~\\&|PROSOLV||||20151008111200||ADT^A01^ADT_A01|MSGID000001|T|2.6|||||||||\n" + "EVN|A04|20151008111200|||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.44 present; PV1.45 present
    "PV1|1|E||||||||||||||||||||||||||||||||||||||||||20161013154626|20161014154634|||||||\n";
    // Test with city based ZoneId passed through options
    ConverterOptions customOptionsWithTenant = new Builder().withValidateResource().withPrettyPrint().withZoneIdText("Europe/Paris").build();
    // "Europe/Paris" will become -01:00, but it we don't see because it is internal and relative to other date.
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message, customOptionsWithTenant);
    // Find the encounter from the FHIR bundle.
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounters).hasSize(1);
    Encounter encounter = (Encounter) encounters.get(0);
    assertThat(encounter.hasLength()).isTrue();
    Duration encounterLength = encounter.getLength();
    assertThat(encounterLength.getValue()).isEqualTo((BigDecimal.valueOf(1440)));
    assertThat(encounterLength.getUnit()).isEqualTo("minutes");
    assertThat(encounterLength.getCode()).isEqualTo("min");
    assertThat(encounterLength.getSystem()).isEqualTo("http://unitsofmeasure.org");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ConverterOptions(io.github.linuxforhealth.hl7.ConverterOptions) Builder(io.github.linuxforhealth.hl7.ConverterOptions.Builder) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) Duration(org.hl7.fhir.r4.model.Duration) 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