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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations