Search in sources :

Example 46 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ORUMessageTest method test_ORU_r01_without_status.

@Test
void test_ORU_r01_without_status() throws IOException {
    String ORU_r01 = "MSH|^~\\&|NIST Test Lab APP|NIST Lab Facility||NIST EHR Facility|20150926140551||ORU^R01|NIST-LOI_5.0_1.1-NG|T|2.5.1|||AL|AL|||||\r" + "PID|1||PATID5421^^^NISTMPI^MR||Wilson^Patrice^Natasha^^^^L||19820304|F||2106-3^White^HL70005|144 East 12th Street^^Los Angeles^CA^90012^^H||^PRN^PH^^^203^2290210|||||||||N^Not Hispanic or Latino^HL70189\r" + "ORC|NW|ORD448811^NIST EHR|R-511^NIST Lab Filler||||||20120628070100|||5742200012^Radon^Nicholas^^^^^^NPI^L^^^NPI\r" + "OBR|1|ORD448811^NIST EHR|R-511^NIST Lab Filler|1000^Hepatitis A B C Panel^99USL|||20120628070100|||||||||5742200012^Radon^Nicholas^^^^^^NPI^L^^^NPI\r" + "OBX|1|CWE|22314-9^Hepatitis A virus IgM Ab [Presence] in Serum^LN^HAVM^Hepatitis A IgM antibodies (IgM anti-HAV)^L^2.52||260385009^Negative (qualifier value)^SCT^NEG^NEGATIVE^L^201509USEd^^Negative (qualifier value)||Negative|N|||F|||20150925|||||201509261400\r" + "OBX|2|CWE|20575-7^Hepatitis A virus Ab [Presence] in Serum^LN^HAVAB^Hepatitis A antibodies (anti-HAV)^L^2.52||260385009^Negative (qualifier value)^SCT^NEG^NEGATIVE^L^201509USEd^^Negative (qualifier value)||Negative|N|||F|||20150925|||||201509261400\r" + "OBX|3|NM|22316-4^Hepatitis B virus core Ab [Units/volume] in Serum^LN^HBcAbQ^Hepatitis B core antibodies (anti-HBVc) Quant^L^2.52||0.70|[IU]/mL^international unit per milliliter^UCUM^IU/ml^^L^1.9|<0.50 IU/mL|H|||F|||20150925|||||201509261400";
    String json = ftv.convert(ORU_r01, OPTIONS);
    FHIRContext context = new FHIRContext();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    assertThat(diagnosticReport).hasSize(1);
    String s = context.getParser().encodeResourceToString(diagnosticReport.get(0));
    Class<? extends IBaseResource> klass = DiagnosticReport.class;
    DiagnosticReport expectStatusUnknown = (DiagnosticReport) context.getParser().parseResource(klass, s);
    DiagnosticReport.DiagnosticReportStatus status = expectStatusUnknown.getStatus();
    assertThat(expectStatusUnknown.hasStatus()).isTrue();
    assertThat(status).isEqualTo(DiagnosticReport.DiagnosticReportStatus.UNKNOWN);
}
Also used : FHIRContext(io.github.linuxforhealth.fhir.FHIRContext) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test)

Example 47 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7OMLMessageTest method testOMLO21WithAllergy.

@Test
public void testOMLO21WithAllergy() 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" + "AL1|1|DRUG|00000741^OXYCODONE||HYPOTENSION\r" + "AL1|2|DRUG|00001433^TRAMADOL||SEIZURES~VOMITING\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" + "AL1|1|DA|1605^acetaminophen^L|MO|Muscle Pain~hair loss\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> allergyResource = ResourceUtils.getResourceList(e, ResourceType.AllergyIntolerance);
    // from AL1
    assertThat(allergyResource).hasSize(3);
    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);
    // Confirm that there are no extra resources
    assertThat(e.size()).isEqualTo(6);
}
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 48 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7OMLMessageTest method testOMLO21WithPatientAndOrderWithPriorOrder.

@Test
public void testOMLO21WithPatientAndOrderWithPriorOrder() 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" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421cb^^ID^UUID|||||||\r" + "OBR|2|8125550e-04db-11ec-a9a8-086d41d421cb^^ID^UUID||57698-3^Lipid panel with direct LDL - Serum or Plasma^LN||||||||||||\r" + "DG1|1||A001^Cholera due to Vibrio cholerae 01, biovar eltor^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;
    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> diagnosisResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
    // from DG1
    assertThat(diagnosisResource).hasSize(2);
    List<Resource> serviceResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // from ORC
    assertThat(serviceResource).hasSize(2);
    List<Resource> diagnosticresource = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    // from OBR
    assertThat(diagnosticresource).hasSize(2);
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticresource.get(0), context);
    Reference ref = diag.getSubject();
    assertThat(ref.isEmpty()).isFalse();
    // Confirm that there are no extra resources
    assertThat(e.size()).isEqualTo(7);
}
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) Test(org.junit.jupiter.api.Test)

Example 49 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7OMLMessageTest method testOMLO21WithSpecimen.

@Test
public void testOMLO21WithSpecimen() 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" + "SPM|1|SpecimenID||BLD|||||||P||||||201410060535|201410060821||Y||||||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> specimenResource = ResourceUtils.getResourceList(e, ResourceType.Specimen);
    // from SPM
    assertThat(specimenResource).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);
    // Verify the specimen reference
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticresource.get(0), context);
    List<Reference> spmRef = diag.getSpecimen();
    assertThat(spmRef.isEmpty()).isFalse();
    // from SPM
    assertThat(spmRef).hasSize(1);
    assertThat(spmRef.get(0).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) Test(org.junit.jupiter.api.Test)

Example 50 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7CustomMessageTest method getBundleEntryFromHL7Message.

// Need custom convert sequence with options that turn off FHIR validation.
private static List<BundleEntryComponent> getBundleEntryFromHL7Message(String hl7message) {
    // Testing loading of config which happens once per instantiation
    HL7ToFHIRConverter ftv = new HL7ToFHIRConverter();
    // Need custom options that turn off FHIR validation.
    String json = ftv.convert(hl7message, OPTIONS);
    assertThat(json).isNotNull();
    FHIRContext context = new FHIRContext();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    return b.getEntry();
}
Also used : FHIRContext(io.github.linuxforhealth.fhir.FHIRContext) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) Bundle(org.hl7.fhir.r4.model.Bundle) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)250 Resource (org.hl7.fhir.r4.model.Resource)163 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)107 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)92 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 ArrayList (java.util.ArrayList)62 Date (java.util.Date)52 Reference (org.hl7.fhir.r4.model.Reference)51 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)47 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Observation (org.hl7.fhir.r4.model.Observation)36 IOException (java.io.IOException)35 Patient (org.hl7.fhir.r4.model.Patient)35 Test (org.junit.Test)35 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Condition (org.hl7.fhir.r4.model.Condition)32 Encounter (org.hl7.fhir.r4.model.Encounter)31 Coding (org.hl7.fhir.r4.model.Coding)29