From 044320f5fb5e5f99b2b30a9f2dd95ff218b7fd35 Mon Sep 17 00:00:00 2001 From: Dalibor Aksic <93644806+Daksic28@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:24:24 +0100 Subject: [PATCH] =?UTF-8?q?[26835]=20isRisk=20filter=20hinzugef=C3=BCgt=20?= =?UTF-8?q?(#417)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fhir/resources/RiskFactorResource.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/bundles/ch.elexis.mednet.webapi.core/src/ch/elexis/mednet/webapi/core/fhir/resources/RiskFactorResource.java b/bundles/ch.elexis.mednet.webapi.core/src/ch/elexis/mednet/webapi/core/fhir/resources/RiskFactorResource.java index 8bc470179..4fb87f649 100644 --- a/bundles/ch.elexis.mednet.webapi.core/src/ch/elexis/mednet/webapi/core/fhir/resources/RiskFactorResource.java +++ b/bundles/ch.elexis.mednet.webapi.core/src/ch/elexis/mednet/webapi/core/fhir/resources/RiskFactorResource.java @@ -3,13 +3,18 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Reference; +import ch.elexis.core.findings.ICoding; +import ch.elexis.core.findings.IFinding; import ch.elexis.core.findings.IObservation; +import ch.elexis.core.findings.IObservation.ObservationCategory; +import ch.elexis.core.findings.IObservation.ObservationCode; import ch.elexis.core.findings.migration.IMigratorService; import ch.elexis.core.findings.util.FindingsServiceHolder; import ch.elexis.core.model.IPatient; @@ -27,8 +32,9 @@ public static List createRiskFactors(Reference patientReference, IP if (structuredRiskCheck) { List structuredRisks = FindingsServiceHolder.getiFindingsService() .getPatientsFindings(sourcePatient.getId(), IObservation.class); - - for (IObservation structuredRisk : structuredRisks) { + List filteredRisks = structuredRisks.stream().filter(RiskFactorResource::isRisk) + .collect(Collectors.toList()); + for (IObservation structuredRisk : filteredRisks) { Observation riskFactor = resourceFactory.getResource(structuredRisk, IObservation.class, Observation.class); if (riskFactor == null) { @@ -76,4 +82,16 @@ private static void applyStandardCodes(Observation riskFactor, Reference patient .setText(riskDisplay)); riskFactor.setSubject(patientReference); } -} + + private static boolean isRisk(IFinding iFinding) { + if (iFinding instanceof IObservation + && ((IObservation) iFinding).getCategory() == ObservationCategory.SOCIALHISTORY) { + for (ICoding code : ((IObservation) iFinding).getCoding()) { + if (ObservationCode.ANAM_RISK.isSame(code)) { + return true; + } + } + } + return false; + } +} \ No newline at end of file