Search in sources :

Example 6 with Specimen

use of org.hl7.fhir.r4.model.Specimen 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 7 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDiagnosticOrderDiagnosticOrderItemComponent.

protected void composeDiagnosticOrderDiagnosticOrderItemComponent(Complex parent, String parentType, String name, DiagnosticOrder.DiagnosticOrderItemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "item", name, element, index);
    if (element.hasCode())
        composeCodeableConcept(t, "DiagnosticOrder", "code", element.getCode(), -1);
    for (int i = 0; i < element.getSpecimen().size(); i++) composeReference(t, "DiagnosticOrder", "specimen", element.getSpecimen().get(i), i);
    if (element.hasBodySite())
        composeCodeableConcept(t, "DiagnosticOrder", "bodySite", element.getBodySite(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "DiagnosticOrder", "status", element.getStatusElement(), -1);
    for (int i = 0; i < element.getEvent().size(); i++) composeDiagnosticOrderDiagnosticOrderEventComponent(t, "DiagnosticOrder", "event", element.getEvent().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 8 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSpecimenSpecimenProcessingComponent.

protected void composeSpecimenSpecimenProcessingComponent(Complex parent, String parentType, String name, Specimen.SpecimenProcessingComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "processing", name, element, index);
    if (element.hasDescriptionElement())
        composeString(t, "Specimen", "description", element.getDescriptionElement(), -1);
    if (element.hasProcedure())
        composeCodeableConcept(t, "Specimen", "procedure", element.getProcedure(), -1);
    for (int i = 0; i < element.getAdditive().size(); i++) composeReference(t, "Specimen", "additive", element.getAdditive().get(i), i);
    if (element.hasTime())
        composeType(t, "Specimen", "time", element.getTime(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 9 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeObservation.

protected void composeObservation(Complex parent, String parentType, String name, Observation element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Observation", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Observation", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "Observation", "basedOn", element.getBasedOn().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Observation", "status", element.getStatusElement(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "Observation", "category", element.getCategory().get(i), i);
    if (element.hasCode())
        composeCodeableConcept(t, "Observation", "code", element.getCode(), -1);
    if (element.hasSubject())
        composeReference(t, "Observation", "subject", element.getSubject(), -1);
    if (element.hasContext())
        composeReference(t, "Observation", "context", element.getContext(), -1);
    if (element.hasEffective())
        composeType(t, "Observation", "effective", element.getEffective(), -1);
    if (element.hasIssuedElement())
        composeInstant(t, "Observation", "issued", element.getIssuedElement(), -1);
    for (int i = 0; i < element.getPerformer().size(); i++) composeReference(t, "Observation", "performer", element.getPerformer().get(i), i);
    if (element.hasValue())
        composeType(t, "Observation", "value", element.getValue(), -1);
    if (element.hasDataAbsentReason())
        composeCodeableConcept(t, "Observation", "dataAbsentReason", element.getDataAbsentReason(), -1);
    if (element.hasInterpretation())
        composeCodeableConcept(t, "Observation", "interpretation", element.getInterpretation(), -1);
    if (element.hasCommentElement())
        composeString(t, "Observation", "comment", element.getCommentElement(), -1);
    if (element.hasBodySite())
        composeCodeableConcept(t, "Observation", "bodySite", element.getBodySite(), -1);
    if (element.hasMethod())
        composeCodeableConcept(t, "Observation", "method", element.getMethod(), -1);
    if (element.hasSpecimen())
        composeReference(t, "Observation", "specimen", element.getSpecimen(), -1);
    if (element.hasDevice())
        composeReference(t, "Observation", "device", element.getDevice(), -1);
    for (int i = 0; i < element.getReferenceRange().size(); i++) composeObservationObservationReferenceRangeComponent(t, "Observation", "referenceRange", element.getReferenceRange().get(i), i);
    for (int i = 0; i < element.getRelated().size(); i++) composeObservationObservationRelatedComponent(t, "Observation", "related", element.getRelated().get(i), i);
    for (int i = 0; i < element.getComponent().size(); i++) composeObservationObservationComponentComponent(t, "Observation", "component", element.getComponent().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 10 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDiagnosticReport.

protected void composeDiagnosticReport(Complex parent, String parentType, String name, DiagnosticReport element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "DiagnosticReport", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DiagnosticReport", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "DiagnosticReport", "basedOn", element.getBasedOn().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "DiagnosticReport", "status", element.getStatusElement(), -1);
    if (element.hasCategory())
        composeCodeableConcept(t, "DiagnosticReport", "category", element.getCategory(), -1);
    if (element.hasCode())
        composeCodeableConcept(t, "DiagnosticReport", "code", element.getCode(), -1);
    if (element.hasSubject())
        composeReference(t, "DiagnosticReport", "subject", element.getSubject(), -1);
    if (element.hasContext())
        composeReference(t, "DiagnosticReport", "context", element.getContext(), -1);
    if (element.hasEffective())
        composeType(t, "DiagnosticReport", "effective", element.getEffective(), -1);
    if (element.hasIssuedElement())
        composeInstant(t, "DiagnosticReport", "issued", element.getIssuedElement(), -1);
    for (int i = 0; i < element.getPerformer().size(); i++) composeDiagnosticReportDiagnosticReportPerformerComponent(t, "DiagnosticReport", "performer", element.getPerformer().get(i), i);
    for (int i = 0; i < element.getSpecimen().size(); i++) composeReference(t, "DiagnosticReport", "specimen", element.getSpecimen().get(i), i);
    for (int i = 0; i < element.getResult().size(); i++) composeReference(t, "DiagnosticReport", "result", element.getResult().get(i), i);
    for (int i = 0; i < element.getImagingStudy().size(); i++) composeReference(t, "DiagnosticReport", "imagingStudy", element.getImagingStudy().get(i), i);
    for (int i = 0; i < element.getImage().size(); i++) composeDiagnosticReportDiagnosticReportImageComponent(t, "DiagnosticReport", "image", element.getImage().get(i), i);
    if (element.hasConclusionElement())
        composeString(t, "DiagnosticReport", "conclusion", element.getConclusionElement(), -1);
    for (int i = 0; i < element.getCodedDiagnosis().size(); i++) composeCodeableConcept(t, "DiagnosticReport", "codedDiagnosis", element.getCodedDiagnosis().get(i), i);
    for (int i = 0; i < element.getPresentedForm().size(); i++) composeAttachment(t, "DiagnosticReport", "presentedForm", element.getPresentedForm().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Test (org.junit.jupiter.api.Test)19 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)11 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)11 Resource (org.hl7.fhir.r4.model.Resource)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)9 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)9 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 Coding (org.hl7.fhir.r4.model.Coding)8 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)8 Reference (org.hl7.fhir.r4.model.Reference)8 Attachment (org.hl7.fhir.r4.model.Attachment)7 Bundle (org.hl7.fhir.r4.model.Bundle)6 Observation (org.hl7.fhir.r4.model.Observation)6 Specimen (org.hl7.fhir.dstu3.model.Specimen)4 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)4 ResourceModel (io.github.linuxforhealth.api.ResourceModel)3 RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)3 FHIRContext (io.github.linuxforhealth.fhir.FHIRContext)2 File (java.io.File)2 FhirPath (au.csiro.pathling.fhirpath.FhirPath)1