1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-09-13 16:02:52 +00:00

feat: additional mapping in TherapieplanDataMapper

This commit is contained in:
2025-06-30 00:46:07 +02:00
parent d53c2074e4
commit 5692dfbdc7
5 changed files with 165 additions and 37 deletions

View File

@@ -1,10 +1,12 @@
package dev.pcvolkmer.onco.datamapper.mapper;
import dev.pcvolkmer.mv64e.mtb.MtbMedicationRecommendation;
import dev.pcvolkmer.mv64e.mtb.Reference;
import dev.pcvolkmer.mv64e.mtb.*;
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
import dev.pcvolkmer.onco.datamapper.ResultSet;
import dev.pcvolkmer.onco.datamapper.datacatalogues.EinzelempfehlungCatalogue;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -18,13 +20,19 @@ import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReferen
*/
public class EinzelempfehlungWirkstoffDataMapper extends AbstractEinzelempfehlungDataMapper<MtbMedicationRecommendation> {
public EinzelempfehlungWirkstoffDataMapper(EinzelempfehlungCatalogue einzelempfehlungCatalogue) {
private final PropertyCatalogue propertyCatalogue;
public EinzelempfehlungWirkstoffDataMapper(
EinzelempfehlungCatalogue einzelempfehlungCatalogue,
PropertyCatalogue propertyCatalogue
) {
super(einzelempfehlungCatalogue);
this.propertyCatalogue = propertyCatalogue;
}
@Override
protected MtbMedicationRecommendation map(ResultSet resultSet) {
return MtbMedicationRecommendation.builder()
var resultBuilder = MtbMedicationRecommendation.builder()
.id(resultSet.getString("id"))
.patient(getPatientReference(resultSet.getString("patient_id")))
// TODO Fix id?
@@ -37,8 +45,31 @@ public class EinzelempfehlungWirkstoffDataMapper extends AbstractEinzelempfehlun
)
)
.medication(JsonToMedicationMapper.map(resultSet.getString("wirkstoffe_json")))
.levelOfEvidence(getLevelOfEvidence(resultSet))
.build();
.levelOfEvidence(getLevelOfEvidence(resultSet));
if (null != resultSet.getString("art_der_therapie")) {
resultBuilder.category(
getMtbMedicationRecommendationCategoryCoding(
resultSet.getString("art_der_therapie"),
resultSet.getInteger("art_der_therapie_propcat_version")
)
);
}
if (null != resultSet.getString("empfehlungsart")) {
resultBuilder.useType(
getMtbMedicationRecommendationUseTypeCoding(
resultSet.getString("empfehlungsart"),
resultSet.getInteger("empfehlungsart_propcat_version")
)
);
}
if (null != resultSet.getString("st_mol_alt_variante")) {
// Empty for now
}
return resultBuilder.build();
}
@Override
@@ -51,13 +82,47 @@ public class EinzelempfehlungWirkstoffDataMapper extends AbstractEinzelempfehlun
return catalogue.getAllByParentId(parentId)
.stream()
// Filter Wirkstoffempfehlung (Systemische Therapie)
.filter(it -> it.getString("art_der_therapie") == null
|| it.getString("art_der_therapie").isBlank())
.filter(it -> it.getString("empfehlungskategorie") == null
|| it.getString("empfehlungskategorie").isBlank()
|| "systemisch".equals(it.getString("empfehlungskategorie")))
.filter(it -> "systemisch".equals(it.getString("empfehlungskategorie")))
.map(this::map)
.collect(Collectors.toList());
}
private MtbMedicationRecommendationCategoryCoding getMtbMedicationRecommendationCategoryCoding(String code, int version) {
if (code == null || !Arrays.stream(MtbMedicationRecommendationCategoryCodingCode.values()).map(MtbMedicationRecommendationCategoryCodingCode::toValue).collect(Collectors.toSet()).contains(code)) {
return null;
}
var resultBuilder = MtbMedicationRecommendationCategoryCoding.builder()
.system("dnpm-dip/mtb/recommendation/systemic-therapy/category");
try {
resultBuilder
.code(MtbMedicationRecommendationCategoryCodingCode.forValue(code))
.display(propertyCatalogue.getByCodeAndVersion(code, version).getShortdesc());
} catch (IOException e) {
return null;
}
return resultBuilder.build();
}
private MtbMedicationRecommendationUseTypeCoding getMtbMedicationRecommendationUseTypeCoding(String code, int version) {
if (code == null || !Arrays.stream(MtbMedicationRecommendationUseTypeCodingCode.values()).map(MtbMedicationRecommendationUseTypeCodingCode::toValue).collect(Collectors.toSet()).contains(code)) {
return null;
}
var resultBuilder = MtbMedicationRecommendationUseTypeCoding.builder()
.system("dnpm-dip/mtb/recommendation/systemic-therapy/use-type");
try {
resultBuilder
.code(MtbMedicationRecommendationUseTypeCodingCode.forValue(code))
.display(propertyCatalogue.getByCodeAndVersion(code, version).getShortdesc());
} catch (IOException e) {
return null;
}
return resultBuilder.build();
}
}

View File

@@ -86,6 +86,8 @@ public class MtbDataMapper implements DataMapper<Mtb> {
var therapieplanCatalogue = catalogueFactory.catalogue(TherapieplanCatalogue.class);
var therapieplanDataMapper = new TherapieplanDataMapper(
therapieplanCatalogue,
catalogueFactory.catalogue(RebiopsieCatalogue.class),
catalogueFactory.catalogue(ReevaluationCatalogue.class),
einzelempfehlungCatalogue,
propertyCatalogue
);

View File

@@ -2,8 +2,7 @@ package dev.pcvolkmer.onco.datamapper.mapper;
import dev.pcvolkmer.mv64e.mtb.*;
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
import dev.pcvolkmer.onco.datamapper.datacatalogues.EinzelempfehlungCatalogue;
import dev.pcvolkmer.onco.datamapper.datacatalogues.TherapieplanCatalogue;
import dev.pcvolkmer.onco.datamapper.datacatalogues.*;
import java.io.IOException;
import java.util.Arrays;
@@ -21,6 +20,8 @@ import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReferen
public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
private final TherapieplanCatalogue therapieplanCatalogue;
private final RebiopsieCatalogue rebiopsieCatalogue;
private final ReevaluationCatalogue reevaluationCatalogue;
private final PropertyCatalogue propertyCatalogue;
private final EinzelempfehlungProzedurDataMapper einzelempfehlungProzedurDataMapper;
@@ -29,14 +30,18 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
public TherapieplanDataMapper(
final TherapieplanCatalogue therapieplanCatalogue,
final RebiopsieCatalogue rebiopsieCatalogue,
final ReevaluationCatalogue reevaluationCatalogue,
final EinzelempfehlungCatalogue einzelempfehlungCatalogue,
final PropertyCatalogue propertyCatalogue
) {
this.therapieplanCatalogue = therapieplanCatalogue;
this.rebiopsieCatalogue = rebiopsieCatalogue;
this.reevaluationCatalogue = reevaluationCatalogue;
this.propertyCatalogue = propertyCatalogue;
this.einzelempfehlungProzedurDataMapper = new EinzelempfehlungProzedurDataMapper(einzelempfehlungCatalogue);
this.einzelempfehlungWirkstoffDataMapper = new EinzelempfehlungWirkstoffDataMapper(einzelempfehlungCatalogue);
this.einzelempfehlungWirkstoffDataMapper = new EinzelempfehlungWirkstoffDataMapper(einzelempfehlungCatalogue, propertyCatalogue);
this.einzelempfehlungStudieDataMapper = new EinzelempfehlungStudieDataMapper(einzelempfehlungCatalogue);
}
@@ -55,6 +60,16 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
.id(therapieplanData.getString("id"))
.patient(getPatientReference(therapieplanData.getString("patient_id")))
.issuedOn(therapieplanData.getDate("datum"))
.histologyReevaluationRequests(getHistologyReevaluationRequests(id))
.rebiopsyRequests(
getRebiopsyRequest(
id,
Reference.builder()
.id(therapieplanData.getString("ref_dnpm_klinikanamnese"))
.type("MTBDiagnosis")
.build()
)
)
;
if (therapieplanData.isTrue("mit_einzelempfehlung")) {
@@ -137,4 +152,30 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
return resultBuilder.build();
}
private List<RebiopsyRequest> getRebiopsyRequest(int parentId, Reference diagnosisReference) {
return this.rebiopsieCatalogue.getAllByParentId(parentId).stream()
.map(resultSet ->
RebiopsyRequest.builder()
.id(resultSet.getString("id"))
.patient(getPatientReference(resultSet.getString("patient_id")))
.issuedOn(resultSet.getDate("datum"))
.tumorEntity(diagnosisReference)
.build()
)
.collect(Collectors.toList());
}
private List<HistologyReevaluationRequest> getHistologyReevaluationRequests(int parentId) {
return this.reevaluationCatalogue.getAllByParentId(parentId).stream()
.map(resultSet ->
HistologyReevaluationRequest.builder()
.id(resultSet.getString("id"))
.patient(getPatientReference(resultSet.getString("patient_id")))
.issuedOn(resultSet.getDate("datum"))
.specimen(Reference.builder().id(resultSet.getString("ref_molekulargenetik")).build())
.build()
)
.collect(Collectors.toList());
}
}