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 817bf3db..6ed29110 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 @@ -2,6 +2,7 @@ import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import com.google.common.hash.Hashing; +import de.basisdatensatz.obds.v3.AllgemeinerLeistungszustandTyp; import de.basisdatensatz.obds.v3.DatumTagOderMonatGenauTyp; import de.basisdatensatz.obds.v3.DatumTagOderMonatOderJahrOderNichtGenauTyp; import java.nio.charset.StandardCharsets; @@ -317,4 +318,33 @@ public static Optional convertObdsDatumToDateTimeType( date.setPrecision(TemporalPrecisionEnum.DAY); return Optional.of(date); } + + /** + * Transforms AllgemeinerLeistungszustandTyp to another AllgemeinerLeistungszustandTyp using ECOG. + * + * @param value The value to be transformed + * @return Returns AllgemeinerLeistungszustandTyp for ECOG or U (unknown) + */ + public static AllgemeinerLeistungszustandTyp allgemeinerLeistungszustandToEcog( + AllgemeinerLeistungszustandTyp value) { + switch (value) { + case AllgemeinerLeistungszustandTyp.KARNOFSKY_100: + case AllgemeinerLeistungszustandTyp.KARNOFSKY_90: + return AllgemeinerLeistungszustandTyp.ECOG_0; + case AllgemeinerLeistungszustandTyp.KARNOFSKY_80: + case AllgemeinerLeistungszustandTyp.KARNOFSKY_70: + return AllgemeinerLeistungszustandTyp.ECOG_1; + case AllgemeinerLeistungszustandTyp.KARNOFSKY_60: + case AllgemeinerLeistungszustandTyp.KARNOFSKY_50: + return AllgemeinerLeistungszustandTyp.ECOG_2; + case AllgemeinerLeistungszustandTyp.KARNOFSKY_40: + case AllgemeinerLeistungszustandTyp.KARNOFSKY_30: + return AllgemeinerLeistungszustandTyp.ECOG_3; + case AllgemeinerLeistungszustandTyp.KARNOFSKY_20: + case AllgemeinerLeistungszustandTyp.KARNOFSKY_10: + return AllgemeinerLeistungszustandTyp.ECOG_4; + default: + return value; + } + } } diff --git a/src/main/resources/schema/oBDS_v3.0.3.bindings.xjb b/src/main/resources/schema/oBDS_v3.0.3.bindings.xjb index c0d970ef..100619f6 100644 --- a/src/main/resources/schema/oBDS_v3.0.3.bindings.xjb +++ b/src/main/resources/schema/oBDS_v3.0.3.bindings.xjb @@ -37,5 +37,25 @@ + + + + + + + + + + + + + + + + + + + + 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 ad904cb1..04767da8 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 @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import de.basisdatensatz.obds.v3.AllgemeinerLeistungszustandTyp; import de.basisdatensatz.obds.v3.DatumTagOderMonatGenauTyp; import de.basisdatensatz.obds.v3.DatumTagOderMonatGenauTyp.DatumsgenauigkeitTagOderMonatGenau; import de.basisdatensatz.obds.v3.DatumTagOderMonatOderJahrOderNichtGenauTyp; @@ -224,4 +225,44 @@ void shouldConvertDatumTagOderMonatOderJahrOderNichtGenauTypToDateType( assertThat(actual.asStringValue()).isEqualTo(expected); } + + @ParameterizedTest + @MethodSource("allgemeinerLeistungszustandTestData") + void shouldMapAllegemeinerLeistungszustandToEcog( + AllgemeinerLeistungszustandTyp in, AllgemeinerLeistungszustandTyp expected) { + var actual = ObdsConditionMapper.allgemeinerLeistungszustandToEcog(in); + assertThat(actual).isEqualTo(expected); + } + + static Stream allgemeinerLeistungszustandTestData() { + return Stream.of( + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_100, AllgemeinerLeistungszustandTyp.ECOG_0), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_90, AllgemeinerLeistungszustandTyp.ECOG_0), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_80, AllgemeinerLeistungszustandTyp.ECOG_1), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_70, AllgemeinerLeistungszustandTyp.ECOG_1), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_60, AllgemeinerLeistungszustandTyp.ECOG_2), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_50, AllgemeinerLeistungszustandTyp.ECOG_2), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_40, AllgemeinerLeistungszustandTyp.ECOG_3), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_30, AllgemeinerLeistungszustandTyp.ECOG_3), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_20, AllgemeinerLeistungszustandTyp.ECOG_4), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_10, AllgemeinerLeistungszustandTyp.ECOG_4), + Arguments.of( + AllgemeinerLeistungszustandTyp.KARNOFSKY_40, AllgemeinerLeistungszustandTyp.ECOG_3), + Arguments.of(AllgemeinerLeistungszustandTyp.U, AllgemeinerLeistungszustandTyp.U), + Arguments.of(AllgemeinerLeistungszustandTyp.ECOG_0, AllgemeinerLeistungszustandTyp.ECOG_0), + Arguments.of(AllgemeinerLeistungszustandTyp.ECOG_1, AllgemeinerLeistungszustandTyp.ECOG_1), + Arguments.of(AllgemeinerLeistungszustandTyp.ECOG_2, AllgemeinerLeistungszustandTyp.ECOG_2), + Arguments.of(AllgemeinerLeistungszustandTyp.ECOG_3, AllgemeinerLeistungszustandTyp.ECOG_3), + Arguments.of(AllgemeinerLeistungszustandTyp.ECOG_4, AllgemeinerLeistungszustandTyp.ECOG_4)); + } }