From 4f8051ae93022733f99cddf63d765780a2c30637 Mon Sep 17 00:00:00 2001 From: chgl Date: Fri, 22 Nov 2024 13:03:42 +0100 Subject: [PATCH 1/5] refactor: use day-precision for condition dates and asserted-extension for v2025 compatibility --- .../ume/obdstofhir/FhirProperties.java | 1 + .../obdstofhir/mapper/ObdsToFhirMapper.java | 40 +++++++++++-------- .../mapper/mii/ConditionMapper.java | 23 +++++++---- src/main/resources/application.yml | 1 + .../mapper/ObdsToFhirMapperTests.java | 24 +++++++++++ ...ource.Testpatient_1.xml.approved.fhir.json | 7 +++- ...ource.Testpatient_2.xml.approved.fhir.json | 7 +++- ...ource.Testpatient_3.xml.approved.fhir.json | 7 +++- 8 files changed, 81 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/FhirProperties.java b/src/main/java/org/miracum/streams/ume/obdstofhir/FhirProperties.java index 62a16eaa..0f2b26b0 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/FhirProperties.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/FhirProperties.java @@ -27,6 +27,7 @@ public static class FhirExtensions { private String miiExOnkoStrahlentherapieBestrahlung; private String miiExOnkoHistologyMorphologyBehaviorIcdo3; private String miiExOnkoSystemischeTherapieIntention; + private String conditionAssertedDate; } @Data diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java index 51556727..e1f24371 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java @@ -255,7 +255,19 @@ public static boolean isIcd10GmCode(String value) { public static DateType convertObdsDatumToDateType( DatumTagOderMonatOderJahrOderNichtGenauTyp obdsDatum) { - var date = new DateType(obdsDatum.getValue().toGregorianCalendar().getTime()); + var dateTimeType = convertObdsDatumToDateTimeType(obdsDatum); + var dateType = new DateType(dateTimeType.getValue()); + dateType.setPrecision(dateTimeType.getPrecision()); + return dateType; + } + + public static Optional convertObdsDatumToDateTimeType( + DatumTagOderMonatGenauTyp obdsDatum) { + if (null == obdsDatum) { + return Optional.empty(); + } + + var date = new DateTimeType(obdsDatum.getValue().toGregorianCalendar().getTime()); switch (obdsDatum.getDatumsgenauigkeit()) { // exakt (entspricht taggenau) case E: @@ -265,23 +277,12 @@ public static DateType convertObdsDatumToDateType( case T: date.setPrecision(TemporalPrecisionEnum.MONTH); break; - // Monat geschätzt (entspricht jahrgenau) - case M: - date.setPrecision(TemporalPrecisionEnum.YEAR); - break; - // vollständig geschätzt (genaue Angabe zum Jahr nicht möglich) - case V: - log.warn("Date precision is completely estimated. Likely not a correct value."); } - return date; + return Optional.of(date); } - public static Optional convertObdsDatumToDateTimeType( - DatumTagOderMonatGenauTyp obdsDatum) { - if (null == obdsDatum) { - return Optional.empty(); - } - + public static DateTimeType convertObdsDatumToDateTimeType( + DatumTagOderMonatOderJahrOderNichtGenauTyp obdsDatum) { var date = new DateTimeType(obdsDatum.getValue().toGregorianCalendar().getTime()); switch (obdsDatum.getDatumsgenauigkeit()) { // exakt (entspricht taggenau) @@ -292,8 +293,15 @@ public static Optional convertObdsDatumToDateTimeType( case T: date.setPrecision(TemporalPrecisionEnum.MONTH); break; + // Monat geschätzt (entspricht jahrgenau) + case M: + date.setPrecision(TemporalPrecisionEnum.YEAR); + break; + // vollständig geschätzt (genaue Angabe zum Jahr nicht möglich) + case V: + log.warn("Date precision is completely estimated. Likely not a correct value."); } - return Optional.of(date); + return date; } public static Optional convertObdsDatumToDateTimeType( diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java index 6be632f4..e9460a0a 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java @@ -3,13 +3,15 @@ import de.basisdatensatz.obds.v3.OBDS; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.regex.Pattern; +import org.apache.commons.lang3.Validate; import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Enumerations.ResourceType; import org.miracum.streams.ume.obdstofhir.FhirProperties; import org.miracum.streams.ume.obdstofhir.mapper.ObdsToFhirMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -20,12 +22,19 @@ public class ConditionMapper extends ObdsToFhirMapper { private static final Pattern icdVersionPattern = Pattern.compile("^(10 (?20\\d{2}) ((GM)|(WHO))|Sonstige)$"); - @Autowired public ConditionMapper(FhirProperties fhirProperties) { super(fhirProperties); } public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Reference patient) { + Objects.requireNonNull(meldung); + Objects.requireNonNull(meldung.getTumorzuordnung()); + Objects.requireNonNull(patient); + Validate.isTrue( + Objects.equals( + patient.getReferenceElement().getResourceType(), ResourceType.PATIENT.toCode()), + "The subject reference should point to a Patient resource"); + var condition = new Condition(); if (meldung.getDiagnose().getDiagnosesicherung() != null) { @@ -46,9 +55,6 @@ public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Ref condition.getMeta().addProfile(fhirProperties.getProfiles().getMiiPrOnkoDiagnosePrimaertumor()); var tumorzuordnung = meldung.getTumorzuordnung(); - if (tumorzuordnung == null) { - throw new RuntimeException("Tumorzuordnung ist null"); - } Coding icd = new Coding( @@ -105,8 +111,11 @@ public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Ref } condition.setBodySite(bodySite); - condition.setRecordedDate( - tumorzuordnung.getDiagnosedatum().getValue().toGregorianCalendar().getTime()); + var diagnoseDatum = convertObdsDatumToDateTimeType(tumorzuordnung.getDiagnosedatum()); + condition.setRecordedDateElement(diagnoseDatum); + condition.addExtension( + fhirProperties.getExtensions().getConditionAssertedDate(), diagnoseDatum); + return condition; } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5a577b88..10659562 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,6 +18,7 @@ fhir: mii-ex-onko-strahlentherapie-bestrahlung: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-strahlentherapie-bestrahlung" mii-ex-onko-histology-morphology-behavior-icdo3: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-histology-morphology-behavior-icdo3" mii-ex-onko-systemische-therapie-intention: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-systemische-therapie-intention" + condition-asserted-date: "http://hl7.org/fhir/StructureDefinition/condition-assertedDate" systems: patientId: "${fhir.default.baseSystemUrl}/obds-to-fhir/identifiers/patient-id" identifier-type: "http://terminology.hl7.org/CodeSystem/v2-0203" diff --git a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java index a4a1ce3e..d841538e 100644 --- a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java +++ b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java @@ -5,6 +5,8 @@ import de.basisdatensatz.obds.v3.DatumTagOderMonatGenauTyp; import de.basisdatensatz.obds.v3.DatumTagOderMonatGenauTyp.DatumsgenauigkeitTagOderMonatGenau; +import de.basisdatensatz.obds.v3.DatumTagOderMonatOderJahrOderNichtGenauTyp; +import de.basisdatensatz.obds.v3.DatumTagOderMonatOderJahrOderNichtGenauTyp.DatumsgenauigkeitTagOderMonatOderJahrOderNichtGenau; import java.time.DateTimeException; import java.util.Arrays; import java.util.stream.Stream; @@ -199,4 +201,26 @@ void shouldNotConvertDatumTagOderMonatGenauTypToDateTimeTypeFromNull() { assertThat(actual).isEmpty(); } + + @ParameterizedTest + @CsvSource({ + "2017-07-02,E,2017-07-02", + "1999-12-31,E,1999-12-31", + "2017-07-02,T,2017-07", + "2017-07-02,M,2017", + "1999-12-31,M,1999", + }) + void shouldConvertDatumTagOderMonatOderJahrOderNichtGenauTypToDateType( + String input, + DatumsgenauigkeitTagOderMonatOderJahrOderNichtGenau genauigkeit, + String expected) { + var calendar = DatatypeFactory.newDefaultInstance().newXMLGregorianCalendar(input); + var datum = new DatumTagOderMonatOderJahrOderNichtGenauTyp(); + datum.setValue(calendar); + datum.setDatumsgenauigkeit(genauigkeit); + + var actual = ObdsToFhirMapper.convertObdsDatumToDateType(datum); + + assertThat(actual.asStringValue()).isEqualTo(expected); + } } diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json index 730a438e..e27bb91f 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json @@ -12,6 +12,9 @@ "code": "8010/3" } ] } + }, { + "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", + "valueDateTime": "2020-03-01" } ], "verificationStatus": { "coding": [ { @@ -44,5 +47,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2020-03-01T00:00:00+01:00" -} \ No newline at end of file + "recordedDate": "2020-03-01" +} diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json index 1408005a..8fe6358e 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json @@ -12,6 +12,9 @@ "code": "8140/3" } ] } + }, { + "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", + "valueDateTime": "2021-07-08" } ], "verificationStatus": { "coding": [ { @@ -44,5 +47,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2021-07-08T00:00:00+02:00" -} \ No newline at end of file + "recordedDate": "2021-07-08" +} diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json index 6842b6ab..acfc94bc 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json @@ -12,6 +12,9 @@ "code": "8461/3" } ] } + }, { + "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", + "valueDateTime": "2017-07-02" } ], "verificationStatus": { "coding": [ { @@ -44,5 +47,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2017-07-02T00:00:00+02:00" -} \ No newline at end of file + "recordedDate": "2017-07-02" +} From 32d4db23c65d39992b41c91a8784b6c2b96d1653 Mon Sep 17 00:00:00 2001 From: chgl Date: Fri, 22 Nov 2024 13:20:16 +0100 Subject: [PATCH 2/5] added test case for V precision --- .../streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java | 6 +++++- .../ume/obdstofhir/mapper/ObdsToFhirMapperTests.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java index e1f24371..b0db25b2 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java @@ -299,7 +299,11 @@ public static DateTimeType convertObdsDatumToDateTimeType( break; // vollständig geschätzt (genaue Angabe zum Jahr nicht möglich) case V: - log.warn("Date precision is completely estimated. Likely not a correct value."); + date.setPrecision(TemporalPrecisionEnum.YEAR); + log.warn( + "Date precision is completely estimated. Likely not a correct value." + + "Defaulting to most granular 'year' precision."); + break; } return date; } diff --git a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java index d841538e..ad904cb1 100644 --- a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java +++ b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapperTests.java @@ -209,6 +209,7 @@ void shouldNotConvertDatumTagOderMonatGenauTypToDateTimeTypeFromNull() { "2017-07-02,T,2017-07", "2017-07-02,M,2017", "1999-12-31,M,1999", + "2000-01-01,V,2000", }) void shouldConvertDatumTagOderMonatOderJahrOderNichtGenauTypToDateType( String input, From 094c568f42588ce3402d03758c2e8e779564c569 Mon Sep 17 00:00:00 2001 From: chgl Date: Fri, 22 Nov 2024 13:31:52 +0100 Subject: [PATCH 3/5] add space --- .../miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java index b0db25b2..817bf3db 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirMapper.java @@ -301,7 +301,7 @@ public static DateTimeType convertObdsDatumToDateTimeType( case V: date.setPrecision(TemporalPrecisionEnum.YEAR); log.warn( - "Date precision is completely estimated. Likely not a correct value." + "Date precision is completely estimated. Likely not a correct value. " + "Defaulting to most granular 'year' precision."); break; } From 03504e1a8c6c17a4d4b9b1e19ea5514377180159 Mon Sep 17 00:00:00 2001 From: chgl Date: Sat, 23 Nov 2024 13:15:33 +0100 Subject: [PATCH 4/5] feat: added Condition.identifier & Condition.id --- .../ume/obdstofhir/mapper/mii/ConditionMapper.java | 9 +++++++++ ...onditionResource.Testpatient_1.xml.approved.fhir.json | 5 +++++ ...onditionResource.Testpatient_2.xml.approved.fhir.json | 5 +++++ ...onditionResource.Testpatient_3.xml.approved.fhir.json | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java index e9460a0a..24fdf7be 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java @@ -29,6 +29,8 @@ public ConditionMapper(FhirProperties fhirProperties) { public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Reference patient) { Objects.requireNonNull(meldung); Objects.requireNonNull(meldung.getTumorzuordnung()); + Objects.requireNonNull(meldung.getDiagnose()); + Objects.requireNonNull(meldung.getMeldungID()); Objects.requireNonNull(patient); Validate.isTrue( Objects.equals( @@ -37,6 +39,13 @@ public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Ref var condition = new Condition(); + var identifier = + new Identifier() + .setSystem(fhirProperties.getSystems().getConditionId()) + .setValue(meldung.getTumorzuordnung().getTumorID()); + condition.addIdentifier(identifier); + condition.setId(computeResourceIdFromIdentifier(identifier)); + if (meldung.getDiagnose().getDiagnosesicherung() != null) { Coding verStatus = new Coding(fhirProperties.getSystems().getConditionVerStatus(), "confirmed", ""); diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json index e27bb91f..95a807b6 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json @@ -1,5 +1,6 @@ { "resourceType": "Condition", + "id": "9896edd80f6833ea17fbb2c5ad5ca42caa1d02f41baea875f4a390be3b372356", "meta": { "profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-diagnose-primaertumor" ] }, @@ -16,6 +17,10 @@ "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", "valueDateTime": "2020-03-01" } ], + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/primaerdiagnose-id", + "value": "101" + } ], "verificationStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json index 8fe6358e..c9af88f5 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json @@ -1,5 +1,6 @@ { "resourceType": "Condition", + "id": "a31f38c3b6c0d35e6f228a50ba288b814250c774b8dc89cf5ae36455eb6d1ea8", "meta": { "profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-diagnose-primaertumor" ] }, @@ -16,6 +17,10 @@ "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", "valueDateTime": "2021-07-08" } ], + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/primaerdiagnose-id", + "value": "111" + } ], "verificationStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json index acfc94bc..ccd4a666 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json @@ -1,5 +1,6 @@ { "resourceType": "Condition", + "id": "ada766c1f2eea7625dc4d9bac33d99d0f2a3606376cfa0798fa7c839be6f1e16", "meta": { "profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-diagnose-primaertumor" ] }, @@ -16,6 +17,10 @@ "url": "http://hl7.org/fhir/StructureDefinition/condition-assertedDate", "valueDateTime": "2017-07-02" } ], + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/primaerdiagnose-id", + "value": "121" + } ], "verificationStatus": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", From 6ace0eb224463f99a403c62deb80fcbdb37352d8 Mon Sep 17 00:00:00 2001 From: chgl Date: Mon, 25 Nov 2024 16:32:41 +0100 Subject: [PATCH 5/5] fix: set recordedDate from MeldungsDatum --- .../ume/obdstofhir/mapper/mii/ConditionMapper.java | 13 +++++++++++-- .../obdstofhir/mapper/mii/ConditionMapperTest.java | 2 +- ...ionResource.Testpatient_1.xml.approved.fhir.json | 2 +- ...ionResource.Testpatient_2.xml.approved.fhir.json | 2 +- ...ionResource.Testpatient_3.xml.approved.fhir.json | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java index 24fdf7be..f067008d 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapper.java @@ -1,10 +1,12 @@ package org.miracum.streams.ume.obdstofhir.mapper.mii; +import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import de.basisdatensatz.obds.v3.OBDS; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.regex.Pattern; +import javax.xml.datatype.XMLGregorianCalendar; import org.apache.commons.lang3.Validate; import org.hl7.fhir.r4.model.*; import org.hl7.fhir.r4.model.Enumerations.ResourceType; @@ -26,12 +28,16 @@ public ConditionMapper(FhirProperties fhirProperties) { super(fhirProperties); } - public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Reference patient) { + public Condition map( + OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, + Reference patient, + XMLGregorianCalendar meldeDatum) { Objects.requireNonNull(meldung); Objects.requireNonNull(meldung.getTumorzuordnung()); Objects.requireNonNull(meldung.getDiagnose()); Objects.requireNonNull(meldung.getMeldungID()); Objects.requireNonNull(patient); + Objects.requireNonNull(meldeDatum); Validate.isTrue( Objects.equals( patient.getReferenceElement().getResourceType(), ResourceType.PATIENT.toCode()), @@ -121,10 +127,13 @@ public Condition map(OBDS.MengePatient.Patient.MengeMeldung.Meldung meldung, Ref condition.setBodySite(bodySite); var diagnoseDatum = convertObdsDatumToDateTimeType(tumorzuordnung.getDiagnosedatum()); - condition.setRecordedDateElement(diagnoseDatum); condition.addExtension( fhirProperties.getExtensions().getConditionAssertedDate(), diagnoseDatum); + var recorded = new DateTimeType(meldeDatum.toGregorianCalendar().getTime()); + recorded.setPrecision(TemporalPrecisionEnum.DAY); + condition.setRecordedDateElement(recorded); + return condition; } } diff --git a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.java b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.java index f00307de..9e56cc21 100644 --- a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.java +++ b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.java @@ -57,7 +57,7 @@ void map_withGivenObds_shouldCreateValidConditionResource(String sourceFile) thr .findFirst() .get(); - final var condition = sut.map(conMeldung, new Reference("Patient/1")); + final var condition = sut.map(conMeldung, new Reference("Patient/1"), obds.getMeldedatum()); var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true); var fhirJson = fhirParser.encodeResourceToString(condition); diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json index 95a807b6..871819ac 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_1.xml.approved.fhir.json @@ -52,5 +52,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2020-03-01" + "recordedDate": "2024-09-19" } diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json index c9af88f5..3574a1b7 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_2.xml.approved.fhir.json @@ -52,5 +52,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2021-07-08" + "recordedDate": "2024-02-16" } diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json index ccd4a666..36ec2e41 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.Testpatient_3.xml.approved.fhir.json @@ -52,5 +52,5 @@ "subject": { "reference": "Patient/1" }, - "recordedDate": "2017-07-02" + "recordedDate": "2024-02-16" }