Search in sources :

Example 31 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project fhir-bridge by ehrbase.

the class BefundJedesEreignisPointEventConverter method convertInternal.

@Override
protected BefundJedesEreignisPointEvent convertInternal(Observation observation) throws FHIRException {
    Specimen specimen = observation.getSpecimenTarget();
    BefundJedesEreignisPointEvent befundevent = new BefundJedesEreignisPointEvent();
    if (checkLabortestbezeichnung(observation)) {
        befundevent.setLabortestBezeichnungDefiningCode(LabortestBezeichnungDefiningCode.DETECTION_OF_VIRUS_PROCEDURE);
    } else {
        throw new ConversionException("createLabortestBezeichnungDefiningCode failed as snomedct-subcategory Code was not 122442008.");
    }
    mapProbe(specimen).ifPresent(befundevent::setProbe);
    List<ProAnalytCluster> proAnalytClusterlist = new ArrayList<>();
    LabortestPanelCluster labortestPanelCluster = new LabortestPanelCluster();
    proAnalytClusterlist.add(new ProAnalytClusterConverter().convert(observation));
    labortestPanelCluster.setProAnalyt(proAnalytClusterlist);
    befundevent.setLabortestPanel(labortestPanelCluster);
    return befundevent;
}
Also used : BefundJedesEreignisPointEvent(org.ehrbase.fhirbridge.ehr.opt.virologischerbefundcomposition.definition.BefundJedesEreignisPointEvent) ConversionException(org.ehrbase.fhirbridge.ehr.converter.ConversionException) Specimen(org.hl7.fhir.r4.model.Specimen) ArrayList(java.util.ArrayList) LabortestPanelCluster(org.ehrbase.fhirbridge.ehr.opt.virologischerbefundcomposition.definition.LabortestPanelCluster) ProAnalytCluster(org.ehrbase.fhirbridge.ehr.opt.virologischerbefundcomposition.definition.ProAnalytCluster)

Example 32 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project pathling by aehrc.

the class MemberOfFunctionTest method memberOfCodeableConcept.

@Test
void memberOfCodeableConcept() {
    final Coding coding1 = new Coding(LOINC_URL, "10337-4", "Procollagen type I [Mass/volume] in Serum");
    final Coding coding2 = new Coding(LOINC_URL, "10428-1", "Varicella zoster virus immune globulin given [Volume]");
    final Coding coding3 = new Coding(LOINC_URL, "10555-1", null);
    final Coding coding4 = new Coding(LOINC_URL, "10665-8", "Fungus colony count [#/volume] in Unspecified specimen by Environmental culture");
    final Coding coding5 = new Coding(SNOMED_URL, "416399002", "Procollagen type I amino-terminal propeptide level");
    final CodeableConcept codeableConcept1 = new CodeableConcept(coding1);
    codeableConcept1.addCoding(coding5);
    final CodeableConcept codeableConcept2 = new CodeableConcept(coding2);
    final CodeableConcept codeableConcept3 = new CodeableConcept(coding3);
    final CodeableConcept codeableConcept4 = new CodeableConcept(coding3);
    final CodeableConcept codeableConcept5 = new CodeableConcept(coding4);
    final CodeableConcept codeableConcept6 = new CodeableConcept(coding1);
    final Optional<ElementDefinition> optionalDefinition = FhirHelpers.getChildOfResource(fhirContext, "DiagnosticReport", "code");
    assertTrue(optionalDefinition.isPresent());
    final ElementDefinition definition = optionalDefinition.get();
    final Dataset<Row> inputDataset = new DatasetBuilder(spark).withIdColumn().withStructTypeColumns(codeableConceptStructType()).withRow("diagnosticreport-1", rowFromCodeableConcept(codeableConcept1)).withRow("diagnosticreport-2", rowFromCodeableConcept(codeableConcept2)).withRow("diagnosticreport-3", rowFromCodeableConcept(codeableConcept3)).withRow("diagnosticreport-4", rowFromCodeableConcept(codeableConcept4)).withRow("diagnosticreport-5", rowFromCodeableConcept(codeableConcept5)).withRow("diagnosticreport-6", rowFromCodeableConcept(codeableConcept6)).withRow("diagnosticreport-7", null).buildWithStructValue();
    final ElementPath inputExpression = new ElementPathBuilder(spark).dataset(inputDataset).idAndValueColumns().expression("DiagnosticReport.code").singular(true).definition(definition).buildDefined();
    final StringLiteralPath argumentExpression = StringLiteralPath.fromString("'" + MY_VALUE_SET_URL + "'", inputExpression);
    // Setup mocks
    when(terminologyService.intersect(any(), any())).thenReturn(setOfSimpleFrom(codeableConcept1, codeableConcept3, codeableConcept4));
    // Prepare the inputs to the function.
    final ParserContext parserContext = new ParserContextBuilder(spark, fhirContext).terminologyClientFactory(terminologyServiceFactory).build();
    final NamedFunctionInput memberOfInput = new NamedFunctionInput(parserContext, inputExpression, Collections.singletonList(argumentExpression));
    // Invoke the function.
    final FhirPath result = new MemberOfFunction().invoke(memberOfInput);
    final Dataset<Row> expectedResult = new DatasetBuilder(spark).withIdColumn().withColumn(DataTypes.BooleanType).withRow("diagnosticreport-1", true).withRow("diagnosticreport-2", false).withRow("diagnosticreport-3", true).withRow("diagnosticreport-4", true).withRow("diagnosticreport-5", false).withRow("diagnosticreport-6", true).withRow("diagnosticreport-7", null).build();
    // Check the result.
    assertTrue(result instanceof BooleanPath);
    assertThat((BooleanPath) result).hasExpression("DiagnosticReport.code.memberOf('" + MY_VALUE_SET_URL + "')").isSingular().hasFhirType(FHIRDefinedType.BOOLEAN).isElementPath(BooleanPath.class).selectOrderedResult().hasRows(expectedResult);
    verify(terminologyService).intersect(eq(MY_VALUE_SET_URL), eq(setOfSimpleFrom(coding1, coding2, coding3, coding4, coding5)));
    verifyNoMoreInteractions(terminologyService);
}
Also used : StringLiteralPath(au.csiro.pathling.fhirpath.literal.StringLiteralPath) FhirPath(au.csiro.pathling.fhirpath.FhirPath) BooleanPath(au.csiro.pathling.fhirpath.element.BooleanPath) ParserContextBuilder(au.csiro.pathling.test.builders.ParserContextBuilder) ElementPath(au.csiro.pathling.fhirpath.element.ElementPath) NamedFunctionInput(au.csiro.pathling.fhirpath.function.NamedFunctionInput) Coding(org.hl7.fhir.r4.model.Coding) SparkHelpers.rowFromCoding(au.csiro.pathling.test.helpers.SparkHelpers.rowFromCoding) ElementDefinition(au.csiro.pathling.fhirpath.element.ElementDefinition) Row(org.apache.spark.sql.Row) DatasetBuilder(au.csiro.pathling.test.builders.DatasetBuilder) ParserContext(au.csiro.pathling.fhirpath.parser.ParserContext) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) SparkHelpers.rowFromCodeableConcept(au.csiro.pathling.test.helpers.SparkHelpers.rowFromCodeableConcept) ElementPathBuilder(au.csiro.pathling.test.builders.ElementPathBuilder) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 33 with Specimen

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

the class RdfParser method composeSpecimenSpecimenContainerComponent.

protected void composeSpecimenSpecimenContainerComponent(Complex parent, String parentType, String name, Specimen.SpecimenContainerComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "container", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Specimen", "identifier", element.getIdentifier().get(i), i);
    if (element.hasDescriptionElement())
        composeString(t, "Specimen", "description", element.getDescriptionElement(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "Specimen", "type", element.getType(), -1);
    if (element.hasCapacity())
        composeQuantity(t, "Specimen", "capacity", element.getCapacity(), -1);
    if (element.hasSpecimenQuantity())
        composeQuantity(t, "Specimen", "specimenQuantity", element.getSpecimenQuantity(), -1);
    if (element.hasAdditive())
        composeType(t, "Specimen", "additive", element.getAdditive(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 34 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);
    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.hasEncounter())
        composeReference(t, "DiagnosticReport", "encounter", element.getEncounter(), -1);
    if (element.hasEffective())
        composeType(t, "DiagnosticReport", "effective", element.getEffective(), -1);
    if (element.hasIssuedElement())
        composeInstant(t, "DiagnosticReport", "issued", element.getIssuedElement(), -1);
    if (element.hasPerformer())
        composeReference(t, "DiagnosticReport", "performer", element.getPerformer(), -1);
    for (int i = 0; i < element.getRequest().size(); i++) composeReference(t, "DiagnosticReport", "request", element.getRequest().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.dstu2016may.formats.RdfGenerator.Complex)

Example 35 with Specimen

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

the class RdfParser method composeSequence.

protected void composeSequence(Complex parent, String parentType, String name, Sequence element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Sequence", name, element, index);
    if (element.hasTypeElement())
        composeEnum(t, "Sequence", "type", element.getTypeElement(), -1);
    if (element.hasPatient())
        composeReference(t, "Sequence", "patient", element.getPatient(), -1);
    if (element.hasSpecimen())
        composeReference(t, "Sequence", "specimen", element.getSpecimen(), -1);
    if (element.hasDevice())
        composeReference(t, "Sequence", "device", element.getDevice(), -1);
    if (element.hasQuantity())
        composeQuantity(t, "Sequence", "quantity", element.getQuantity(), -1);
    if (element.hasSpecies())
        composeCodeableConcept(t, "Sequence", "species", element.getSpecies(), -1);
    for (int i = 0; i < element.getReferenceSeq().size(); i++) composeSequenceSequenceReferenceSeqComponent(t, "Sequence", "referenceSeq", element.getReferenceSeq().get(i), i);
    if (element.hasVariation())
        composeSequenceSequenceVariationComponent(t, "Sequence", "variation", element.getVariation(), -1);
    for (int i = 0; i < element.getQuality().size(); i++) composeSequenceSequenceQualityComponent(t, "Sequence", "quality", element.getQuality().get(i), i);
    if (element.hasAllelicState())
        composeCodeableConcept(t, "Sequence", "allelicState", element.getAllelicState(), -1);
    if (element.hasAllelicFrequencyElement())
        composeDecimal(t, "Sequence", "allelicFrequency", element.getAllelicFrequencyElement(), -1);
    if (element.hasCopyNumberEvent())
        composeCodeableConcept(t, "Sequence", "copyNumberEvent", element.getCopyNumberEvent(), -1);
    if (element.hasReadCoverageElement())
        composeInteger(t, "Sequence", "readCoverage", element.getReadCoverageElement(), -1);
    for (int i = 0; i < element.getRepository().size(); i++) composeSequenceSequenceRepositoryComponent(t, "Sequence", "repository", element.getRepository().get(i), i);
    for (int i = 0; i < element.getPointer().size(); i++) composeReference(t, "Sequence", "pointer", element.getPointer().get(i), i);
    if (element.hasObservedSeqElement())
        composeString(t, "Sequence", "observedSeq", element.getObservedSeqElement(), -1);
    if (element.hasObservation())
        composeReference(t, "Sequence", "observation", element.getObservation(), -1);
    if (element.hasStructureVariation())
        composeSequenceSequenceStructureVariationComponent(t, "Sequence", "structureVariation", element.getStructureVariation(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.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