mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-09-13 07:52:52 +00:00
feat: add Vorbefunde mapper
This commit is contained in:
@@ -46,10 +46,10 @@ var jsonResult = Converter.toJsonString(
|
|||||||
| Leitlinien-Prozeduren | ✅ | Siehe auch: https://github.com/dnpm-dip/mtb-model/issues/9 |
|
| Leitlinien-Prozeduren | ✅ | Siehe auch: https://github.com/dnpm-dip/mtb-model/issues/9 |
|
||||||
| ECOG-Verlauf | ✅ | |
|
| ECOG-Verlauf | ✅ | |
|
||||||
| Tumor-Proben | ⛅ | Best effort: Formular OS.Molekulargenetik erfüllt nicht alle Anforderungen (1) |
|
| Tumor-Proben | ⛅ | Best effort: Formular OS.Molekulargenetik erfüllt nicht alle Anforderungen (1) |
|
||||||
| vorherige Molekular-Diagnostik | ⌛ | Aktuell in Arbeit |
|
| vorherige Molekular-Diagnostik | ✅ | |
|
||||||
| Histologie-Berichte | ⌛ | Aktuell in Arbeit |
|
| Histologie-Berichte | ⌛ | Aktuell in Arbeit |
|
||||||
| IHC-Berichte | | |
|
| IHC-Berichte | ⌛ | Aktuell in Arbeit |
|
||||||
| MSI-Befunde | | |
|
| MSI-Befunde | ⌛ | Aktuell in Arbeit |
|
||||||
| NGS-Berichte | ⛅ | Best effort: Formular OS.Molekulargenetik erfüllt nicht alle Anforderungen (2) |
|
| NGS-Berichte | ⛅ | Best effort: Formular OS.Molekulargenetik erfüllt nicht alle Anforderungen (2) |
|
||||||
| MTB-Beschlüsse | ✅ | Stützende molekulare Alteration(en) für einfache Variante und CNV (3) |
|
| MTB-Beschlüsse | ✅ | Stützende molekulare Alteration(en) für einfache Variante und CNV (3) |
|
||||||
| Follow-Up Verlauf | | |
|
| Follow-Up Verlauf | | |
|
||||||
|
@@ -23,7 +23,7 @@ package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
|||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load raw result sets from database table 'dk_dnpm_uf_vorbefunde'
|
* Load raw result sets from database table 'dk_dnpm_vorbefunde'
|
||||||
*
|
*
|
||||||
* @author Paul-Christian Volkmer
|
* @author Paul-Christian Volkmer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
@@ -36,7 +36,7 @@ public class VorbefundeCatalogue extends AbstractSubformDataCatalogue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTableName() {
|
protected String getTableName() {
|
||||||
return "dk_dnpm_uf_vorbefunde";
|
return "dk_dnpm_vorbefunde";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VorbefundeCatalogue create(JdbcTemplate jdbcTemplate) {
|
public static VorbefundeCatalogue create(JdbcTemplate jdbcTemplate) {
|
||||||
|
@@ -20,10 +20,14 @@
|
|||||||
|
|
||||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||||
|
|
||||||
import dev.pcvolkmer.mv64e.mtb.PriorDiagnosticReport;
|
import dev.pcvolkmer.mv64e.mtb.*;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
|
||||||
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.EcogCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.EcogCatalogue;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.VorbefundeCatalogue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -35,8 +39,11 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class KpaVorbefundeDataMapper extends AbstractSubformDataMapper<PriorDiagnosticReport> {
|
public class KpaVorbefundeDataMapper extends AbstractSubformDataMapper<PriorDiagnosticReport> {
|
||||||
|
|
||||||
public KpaVorbefundeDataMapper(final EcogCatalogue catalogue) {
|
private final PropertyCatalogue propertyCatalogue;
|
||||||
|
|
||||||
|
public KpaVorbefundeDataMapper(final VorbefundeCatalogue catalogue, PropertyCatalogue propertyCatalogue) {
|
||||||
super(catalogue);
|
super(catalogue);
|
||||||
|
this.propertyCatalogue = propertyCatalogue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,11 +72,36 @@ public class KpaVorbefundeDataMapper extends AbstractSubformDataMapper<PriorDiag
|
|||||||
builder
|
builder
|
||||||
.id(resultSet.getId().toString())
|
.id(resultSet.getId().toString())
|
||||||
.patient(resultSet.getPatientReference())
|
.patient(resultSet.getPatientReference())
|
||||||
.issuedOn(resultSet.getDate("datum"))
|
.issuedOn(resultSet.getDate("erstellungsdatum"))
|
||||||
.results(List.of(resultSet.getString("ecog")))
|
.specimen(Reference.builder().id(resultSet.getString("befundnummer")).type("Specimen").build())
|
||||||
|
.type(
|
||||||
|
getMolecularDiagnosticReportCoding(
|
||||||
|
resultSet.getString("artderdiagnostik"),
|
||||||
|
resultSet.getInteger("artderdiagnostik_propcat_version")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.results(List.of(
|
||||||
|
resultSet.getString("ergebnisse")
|
||||||
|
))
|
||||||
;
|
;
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MolecularDiagnosticReportCoding getMolecularDiagnosticReportCoding(String value, int version) {
|
||||||
|
if (value == null || !Arrays.stream(MolecularDiagnosticReportCodingCode.values()).map(MolecularDiagnosticReportCodingCode::toValue).collect(Collectors.toSet()).contains(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultBuilder = MolecularDiagnosticReportCoding.builder()
|
||||||
|
.display(propertyCatalogue.getByCodeAndVersion(value, version).getShortdesc());
|
||||||
|
try {
|
||||||
|
resultBuilder.code(MolecularDiagnosticReportCodingCode.forValue(value));
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultBuilder.build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -126,6 +126,8 @@ public class MtbDataMapper implements DataMapper<Mtb> {
|
|||||||
|
|
||||||
var kpaMolekulargenetikDataMapper = new KpaMolekulargenetikDataMapper(molekulargenetikCatalogue, catalogueFactory.catalogue(MolekulargenuntersuchungCatalogue.class), propertyCatalogue);
|
var kpaMolekulargenetikDataMapper = new KpaMolekulargenetikDataMapper(molekulargenetikCatalogue, catalogueFactory.catalogue(MolekulargenuntersuchungCatalogue.class), propertyCatalogue);
|
||||||
|
|
||||||
|
var kpaVorbefundeDataMapper = new KpaVorbefundeDataMapper(catalogueFactory.catalogue(VorbefundeCatalogue.class), propertyCatalogue);
|
||||||
|
|
||||||
var resultBuilder = Mtb.builder();
|
var resultBuilder = Mtb.builder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -144,6 +146,8 @@ public class MtbDataMapper implements DataMapper<Mtb> {
|
|||||||
.guidelineTherapies(therapielinieMapper.getByParentId(kpaId))
|
.guidelineTherapies(therapielinieMapper.getByParentId(kpaId))
|
||||||
.performanceStatus(ecogMapper.getByParentId(kpaId))
|
.performanceStatus(ecogMapper.getByParentId(kpaId))
|
||||||
.familyMemberHistories(verwandteDataMapper.getByParentId(kpaId))
|
.familyMemberHistories(verwandteDataMapper.getByParentId(kpaId))
|
||||||
|
// Vorbefunde
|
||||||
|
.priorDiagnosticReports(kpaVorbefundeDataMapper.getByParentId(kpaId))
|
||||||
// DNPM Therapieplan
|
// DNPM Therapieplan
|
||||||
.carePlans(
|
.carePlans(
|
||||||
therapieplanCatalogue
|
therapieplanCatalogue
|
||||||
|
@@ -62,7 +62,7 @@ class VorbefundeCatalogueTest {
|
|||||||
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
||||||
|
|
||||||
assertThat(captor.getValue())
|
assertThat(captor.getValue())
|
||||||
.isEqualTo("SELECT patient.patienten_id, dk_dnpm_uf_vorbefunde.*, prozedur.* FROM dk_dnpm_uf_vorbefunde JOIN prozedur ON (prozedur.id = dk_dnpm_uf_vorbefunde.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND prozedur.id = ?");
|
.isEqualTo("SELECT patient.patienten_id, dk_dnpm_vorbefunde.*, prozedur.* FROM dk_dnpm_vorbefunde JOIN prozedur ON (prozedur.id = dk_dnpm_vorbefunde.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND prozedur.id = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,7 +77,7 @@ class VorbefundeCatalogueTest {
|
|||||||
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
||||||
|
|
||||||
assertThat(captor.getValue())
|
assertThat(captor.getValue())
|
||||||
.isEqualTo("SELECT patient.patienten_id, dk_dnpm_uf_vorbefunde.*, prozedur.* FROM dk_dnpm_uf_vorbefunde JOIN prozedur ON (prozedur.id = dk_dnpm_uf_vorbefunde.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND hauptprozedur_id = ?");
|
.isEqualTo("SELECT patient.patienten_id, dk_dnpm_vorbefunde.*, prozedur.* FROM dk_dnpm_vorbefunde JOIN prozedur ON (prozedur.id = dk_dnpm_vorbefunde.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND hauptprozedur_id = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -95,7 +95,7 @@ class VorbefundeCatalogueTest {
|
|||||||
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
|
||||||
|
|
||||||
assertThat(captor.getValue())
|
assertThat(captor.getValue())
|
||||||
.isEqualTo("SELECT feldname, feldwert FROM dk_dnpm_uf_vorbefunde_merkmale WHERE eintrag_id = ?");
|
.isEqualTo("SELECT feldname, feldwert FROM dk_dnpm_vorbefunde_merkmale WHERE eintrag_id = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of mv64e-onkostar-data
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 Paul-Christian Volkmer
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||||
|
|
||||||
|
import dev.pcvolkmer.mv64e.mtb.MolecularDiagnosticReportCoding;
|
||||||
|
import dev.pcvolkmer.mv64e.mtb.MolecularDiagnosticReportCodingCode;
|
||||||
|
import dev.pcvolkmer.mv64e.mtb.PriorDiagnosticReport;
|
||||||
|
import dev.pcvolkmer.mv64e.mtb.Reference;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.VorbefundeCatalogue;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class KpaVorbefundeDataMapperTest {
|
||||||
|
|
||||||
|
VorbefundeCatalogue catalogue;
|
||||||
|
PropertyCatalogue propertyCatalogue;
|
||||||
|
|
||||||
|
KpaVorbefundeDataMapper dataMapper;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp(
|
||||||
|
@Mock VorbefundeCatalogue catalogue,
|
||||||
|
@Mock PropertyCatalogue propertyCatalogue
|
||||||
|
) {
|
||||||
|
this.catalogue = catalogue;
|
||||||
|
this.propertyCatalogue = propertyCatalogue;
|
||||||
|
this.dataMapper = new KpaVorbefundeDataMapper(catalogue, propertyCatalogue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldMapResultSet(@Mock ResultSet resultSet) {
|
||||||
|
Map<String, Object> testData = Map.of(
|
||||||
|
"id", "1",
|
||||||
|
"patienten_id", "42",
|
||||||
|
"erstellungsdatum", new java.sql.Date(Date.from(Instant.parse("2000-07-06T12:00:00Z")).getTime()),
|
||||||
|
"befundnummer", "X/2025/1234",
|
||||||
|
"ergebnisse", "Befundtext",
|
||||||
|
"artderdiagnostik", "panel",
|
||||||
|
"artderdiagnostik_propcat_version", "1234"
|
||||||
|
);
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> Reference.builder().id(testData.get("patienten_id").toString()).type("Patient").build())
|
||||||
|
.when(resultSet).getPatientReference();
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getDate(anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
|
when(resultSet.getId()).thenReturn(1);
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> List.of(resultSet))
|
||||||
|
.when(catalogue)
|
||||||
|
.getAllByParentId(anyInt());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var testPropertyData = Map.of(
|
||||||
|
"panel", new PropertyCatalogue.Entry("panel", "Panel", "Panel")
|
||||||
|
);
|
||||||
|
|
||||||
|
var code = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testPropertyData.get(code);
|
||||||
|
}
|
||||||
|
).when(propertyCatalogue).getByCodeAndVersion(anyString(), anyInt());
|
||||||
|
|
||||||
|
var actualList = this.dataMapper.getByParentId(1);
|
||||||
|
assertThat(actualList).hasSize(1);
|
||||||
|
|
||||||
|
var actual = actualList.get(0);
|
||||||
|
assertThat(actual).isInstanceOf(PriorDiagnosticReport.class);
|
||||||
|
assertThat(actual.getId()).isEqualTo("1");
|
||||||
|
assertThat(actual.getPatient())
|
||||||
|
.isEqualTo(Reference.builder()
|
||||||
|
.id("42")
|
||||||
|
.type("Patient")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
assertThat(actual.getIssuedOn())
|
||||||
|
.isEqualTo(new java.sql.Date(Date.from(Instant.parse("2000-07-06T12:00:00Z")).getTime()));
|
||||||
|
assertThat(actual.getSpecimen())
|
||||||
|
.isEqualTo(Reference.builder()
|
||||||
|
.id("X/2025/1234")
|
||||||
|
.type("Specimen")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
assertThat(actual.getType())
|
||||||
|
.isEqualTo(MolecularDiagnosticReportCoding.builder()
|
||||||
|
.code(MolecularDiagnosticReportCodingCode.PANEL)
|
||||||
|
.display("Panel")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user