Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: map any AllgemeinerLeistungszustandTyp to ECOG #181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -317,4 +318,33 @@ public static Optional<DateTimeType> 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;
}
}
}
20 changes: 20 additions & 0 deletions src/main/resources/schema/oBDS_v3.0.3.bindings.xjb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,25 @@
<jaxb:bindings node="//xs:complexType[@name='SYST_Typ']//xs:element[@name='Ende_Grund']/xs:simpleType">
<jaxb:typesafeEnumClass name="EndeGrund" />
</jaxb:bindings>
<jaxb:bindings node="//xs:simpleType[@name='Allgemeiner_Leistungszustand_Typ']">
<jaxb:typesafeEnumClass name="Allgemeiner_Leistungszustand_Typ">
<jaxb:typesafeEnumMember value="0" name="ECOG_0"/>
<jaxb:typesafeEnumMember value="1" name="ECOG_1"/>
<jaxb:typesafeEnumMember value="2" name="ECOG_2"/>
<jaxb:typesafeEnumMember value="3" name="ECOG_3"/>
<jaxb:typesafeEnumMember value="4" name="ECOG_4"/>
<jaxb:typesafeEnumMember value="U" name="U"/>
<jaxb:typesafeEnumMember value="10%" name="KARNOFSKY_10"/>
<jaxb:typesafeEnumMember value="20%" name="KARNOFSKY_20"/>
<jaxb:typesafeEnumMember value="30%" name="KARNOFSKY_30"/>
<jaxb:typesafeEnumMember value="40%" name="KARNOFSKY_40"/>
<jaxb:typesafeEnumMember value="50%" name="KARNOFSKY_50"/>
<jaxb:typesafeEnumMember value="60%" name="KARNOFSKY_60"/>
<jaxb:typesafeEnumMember value="70%" name="KARNOFSKY_70"/>
<jaxb:typesafeEnumMember value="80%" name="KARNOFSKY_80"/>
<jaxb:typesafeEnumMember value="90%" name="KARNOFSKY_90"/>
<jaxb:typesafeEnumMember value="100%" name="KARNOFSKY_100"/>
</jaxb:typesafeEnumClass>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Arguments> 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));
}
}
Loading