mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-07-03 02:52:54 +00:00
feat: add genetic counseling recommendation
This commit is contained in:
@ -121,4 +121,29 @@ public class ResultSet {
|
|||||||
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Date");
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,13 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
|||||||
.procedureRecommendations(einzelempfehlungProzedurDataMapper.getByParentId(id))
|
.procedureRecommendations(einzelempfehlungProzedurDataMapper.getByParentId(id))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// Formularfeld "protokollauszug"
|
||||||
if (therapieplanData.getString("protokollauszug") != null) {
|
if (therapieplanData.getString("protokollauszug") != null) {
|
||||||
// TODO see https://github.com/dnpm-dip/mtb-model/issues/8
|
// TODO see https://github.com/dnpm-dip/mtb-model/issues/8
|
||||||
builder.notes(List.of(therapieplanData.getString("protokollauszug")));
|
builder.notes(List.of(therapieplanData.getString("protokollauszug")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Formularfeld "status_begruendung"
|
||||||
if (
|
if (
|
||||||
null != therapieplanData.getString("status_begruendung")
|
null != therapieplanData.getString("status_begruendung")
|
||||||
&& therapieplanData.getString("status_begruendung").equals(MtbCarePlanRecommendationsMissingReasonCodingCode.NO_TARGET.toValue())
|
&& 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();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,4 +114,21 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
|||||||
return resultBuilder.build();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user