1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-07-02 02:22:54 +00:00

feat: add genetic counseling recommendation

This commit is contained in:
2025-06-28 22:22:10 +02:00
parent 111b96ee50
commit 798729b874
3 changed files with 107 additions and 0 deletions

View File

@ -121,4 +121,29 @@ public class ResultSet {
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Date");
}
/**
* Check column value is equal to true
*
* @param columnName The name of the column
* @return True if column value is equal to true
*/
public boolean isTrue(String columnName) {
var raw = this.rawData.get(columnName);
if (raw == null) {
return false;
}
if (raw instanceof Boolean) {
return ((Boolean) raw);
} else if (raw instanceof Integer) {
return ((Integer) raw) == 1;
} else if (raw instanceof Long) {
return ((Long) raw) == 1;
} else if (raw instanceof String) {
return raw.toString().equals("1");
}
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Boolean");
}
}

View File

@ -57,11 +57,13 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
.procedureRecommendations(einzelempfehlungProzedurDataMapper.getByParentId(id))
;
// Formularfeld "protokollauszug"
if (therapieplanData.getString("protokollauszug") != null) {
// TODO see https://github.com/dnpm-dip/mtb-model/issues/8
builder.notes(List.of(therapieplanData.getString("protokollauszug")));
}
// Formularfeld "status_begruendung"
if (
null != therapieplanData.getString("status_begruendung")
&& therapieplanData.getString("status_begruendung").equals(MtbCarePlanRecommendationsMissingReasonCodingCode.NO_TARGET.toValue())
@ -77,6 +79,23 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
);
}
// Humangenetische Beratung
if (therapieplanData.isTrue("humangen_beratung")) {
builder.geneticCounselingRecommendation(
GeneticCounselingRecommendation.builder()
.id(therapieplanData.getString("id"))
.patient(getPatientReference(therapieplanData.getString("patient_id")))
.issuedOn(therapieplanData.getDate("datum_tk_humangenber"))
.reason(
getGeneticCounselingRecommendationReasonCoding(
therapieplanData.getString("humangen_ber_grund"),
therapieplanData.getInteger("humangen_ber_grund_propcat_version")
)
)
.build()
);
}
return builder.build();
}
@ -95,4 +114,21 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
return resultBuilder.build();
}
private GeneticCounselingRecommendationReasonCoding getGeneticCounselingRecommendationReasonCoding(String value, int version) {
if (value == null || !Arrays.stream(GeneticCounselingRecommendationReasonCodingCode.values()).map(GeneticCounselingRecommendationReasonCodingCode::toValue).collect(Collectors.toSet()).contains(value)) {
return null;
}
var resultBuilder = GeneticCounselingRecommendationReasonCoding.builder()
.system("dnpm-dip/mtb/recommendation/genetic-counseling/reason");
try {
resultBuilder.code(GeneticCounselingRecommendationReasonCodingCode.forValue(value));
resultBuilder.display(propertyCatalogue.getByCodeAndVersion(value, version).getShortdesc());
} catch (IOException e) {
return null;
}
return resultBuilder.build();
}
}

View File

@ -126,4 +126,50 @@ class TherapieplanDataMapperTest {
);
}
@Test
void shouldMapHumGenBeratung() {
final Map<String, Object> testData = Map.of(
"id", 1,
"patient_id", 42,
"humangen_beratung", 1,
"humangen_ber_grund", "other",
"humangen_ber_grund_propcat_version", 1234
);
doAnswer(invocationOnMock -> ResultSet.from(testData))
.when(therapieplanCatalogue)
.getById(anyInt());
doAnswer(invocationOnMock -> {
var testPropertyData = Map.of(
"other", new PropertyCatalogue.Entry("other", "Andere", "Andere")
);
var code = invocationOnMock.getArgument(0, String.class);
return testPropertyData.get(code);
}
).when(propertyCatalogue).getByCodeAndVersion(anyString(), anyInt());
var actual = this.dataMapper.getById(1);
assertThat(actual).isInstanceOf(MtbCarePlan.class);
assertThat(actual.getId()).isEqualTo("1");
assertThat(actual.getRecommendationsMissingReason()).isNull();
assertThat(actual.getGeneticCounselingRecommendation()).isEqualTo(
GeneticCounselingRecommendation.builder()
.id("1")
.patient(Reference.builder().id("42").type("Patient").build())
.reason(
GeneticCounselingRecommendationReasonCoding.builder()
.code(GeneticCounselingRecommendationReasonCodingCode.OTHER)
.display("Andere")
.system("dnpm-dip/mtb/recommendation/genetic-counseling/reason")
.build()
)
.build()
);
}
}