mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-09-13 16:02:52 +00:00
feat: use patient id, not patients database id
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
package dev.pcvolkmer.onco.datamapper;
|
||||
|
||||
import dev.pcvolkmer.mv64e.mtb.Reference;
|
||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -62,6 +63,22 @@ public class ResultSet {
|
||||
return procedureId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id
|
||||
*
|
||||
* @return The procedures id
|
||||
*/
|
||||
public Reference getPatientReference() {
|
||||
if (this.getString("patienten_id") == null) {
|
||||
throw new DataAccessException("No patient id found");
|
||||
}
|
||||
return Reference.builder()
|
||||
.id(this.getString("patienten_id"))
|
||||
// Use "Patient" since Onkostar only provides patient data
|
||||
.type("Patient")
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column value as String and cast value if possible
|
||||
*
|
||||
|
@@ -53,7 +53,8 @@ public abstract class AbstractDataCatalogue implements DataCatalogue {
|
||||
public ResultSet getById(int id) {
|
||||
var result = this.jdbcTemplate.queryForList(
|
||||
String.format(
|
||||
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND prozedur.id = ?",
|
||||
"SELECT patient.patienten_id, %s.*, prozedur.* FROM %s JOIN prozedur ON (prozedur.id = %s.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND prozedur.id = ?",
|
||||
getTableName(),
|
||||
getTableName(),
|
||||
getTableName()
|
||||
),
|
||||
|
@@ -49,7 +49,8 @@ public abstract class AbstractSubformDataCatalogue extends AbstractDataCatalogue
|
||||
public List<ResultSet> getAllByParentId(int id) {
|
||||
return this.jdbcTemplate.queryForList(
|
||||
String.format(
|
||||
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND hauptprozedur_id = ?",
|
||||
"SELECT patient.patienten_id, %s.*, prozedur.* FROM %s JOIN prozedur ON (prozedur.id = %s.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND hauptprozedur_id = ?",
|
||||
getTableName(),
|
||||
getTableName(),
|
||||
getTableName()
|
||||
),
|
||||
|
@@ -32,8 +32,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_einzelempfehlung'
|
||||
*
|
||||
@@ -50,7 +48,7 @@ public class EinzelempfehlungProzedurDataMapper extends AbstractEinzelempfehlung
|
||||
protected ProcedureRecommendation map(ResultSet resultSet) {
|
||||
var resultBuilder = ProcedureRecommendation.builder()
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
// TODO Fix id?
|
||||
.reason(Reference.builder().id(resultSet.getString("id")).build())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
|
@@ -28,8 +28,6 @@ import dev.pcvolkmer.onco.datamapper.datacatalogues.EinzelempfehlungCatalogue;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_einzelempfehlung'
|
||||
*
|
||||
@@ -46,7 +44,7 @@ public class EinzelempfehlungStudieDataMapper extends AbstractEinzelempfehlungDa
|
||||
protected MtbStudyEnrollmentRecommendation map(ResultSet resultSet) {
|
||||
return MtbStudyEnrollmentRecommendation.builder()
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
// TODO Fix id?
|
||||
.reason(Reference.builder().id(resultSet.getString("id")).build())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
|
@@ -30,8 +30,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_einzelempfehlung'
|
||||
*
|
||||
@@ -54,7 +52,7 @@ public class EinzelempfehlungWirkstoffDataMapper extends AbstractEinzelempfehlun
|
||||
protected MtbMedicationRecommendation map(ResultSet resultSet) {
|
||||
var resultBuilder = MtbMedicationRecommendation.builder()
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
// TODO Fix id?
|
||||
.reason(Reference.builder().id(resultSet.getString("id")).build())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
|
@@ -32,8 +32,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_kpa'
|
||||
*
|
||||
@@ -72,7 +70,7 @@ public class KpaDiagnosisDataMapper implements DataMapper<MtbDiagnosis> {
|
||||
var builder = MtbDiagnosis.builder();
|
||||
builder
|
||||
.id(data.getString("id"))
|
||||
.patient(getPatientReference(data.getString("patient_id")))
|
||||
.patient(data.getPatientReference())
|
||||
.code(
|
||||
Coding.builder()
|
||||
.code(data.getString("icd10"))
|
||||
|
@@ -32,8 +32,6 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_uf_ecog'
|
||||
*
|
||||
@@ -49,7 +47,7 @@ public class KpaEcogDataMapper extends AbstractSubformDataMapper<PerformanceStat
|
||||
/**
|
||||
* Loads and maps Prozedur related by database id
|
||||
*
|
||||
* @param id The database id of the procedure data set
|
||||
* @param id The patient id of the procedure data set
|
||||
* @return The loaded data set
|
||||
*/
|
||||
@Override
|
||||
@@ -72,7 +70,7 @@ public class KpaEcogDataMapper extends AbstractSubformDataMapper<PerformanceStat
|
||||
var builder = PerformanceStatus.builder();
|
||||
builder
|
||||
.id(resultSet.getId().toString())
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.effectiveDate(resultSet.getDate("datum"))
|
||||
.value(getEcogCoding(resultSet.getString("ecog")))
|
||||
;
|
||||
|
@@ -29,8 +29,6 @@ import dev.pcvolkmer.onco.datamapper.datacatalogues.ProzedurCatalogue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_uf_prozedur'
|
||||
*
|
||||
@@ -66,7 +64,7 @@ public class KpaProzedurDataMapper extends AbstractKpaTherapieverlaufDataMapper<
|
||||
var builder = OncoProcedure.builder();
|
||||
builder
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.basedOn(Reference.builder().id(diseases.get(0).getString("id")).build())
|
||||
.recordedOn(resultSet.getDate("erfassungsdatum"))
|
||||
.therapyLine(resultSet.getLong("therapielinie"))
|
||||
|
@@ -29,8 +29,6 @@ import dev.pcvolkmer.onco.datamapper.datacatalogues.TherapielinieCatalogue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_therapielinie'
|
||||
*
|
||||
@@ -66,7 +64,7 @@ public class KpaTherapielinieDataMapper extends AbstractKpaTherapieverlaufDataMa
|
||||
var builder = MtbSystemicTherapy.builder();
|
||||
builder
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.basedOn(
|
||||
Reference.builder()
|
||||
.id(resultSet.getString("ref_einzelempfehlung"))
|
||||
|
@@ -29,8 +29,6 @@ import dev.pcvolkmer.onco.datamapper.datacatalogues.VerwandteCatalogue;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_uf_verwandte'
|
||||
*
|
||||
@@ -60,7 +58,7 @@ public class KpaVerwandteDataMapper extends AbstractSubformDataMapper<FamilyMemb
|
||||
var builder = FamilyMemberHistory.builder();
|
||||
builder
|
||||
.id(resultSet.getId().toString())
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.relationship(
|
||||
getFamilyMemberHistoryRelationshipTypeCoding(resultSet.getString("verwandtschaftsgrad"))
|
||||
)
|
||||
|
@@ -20,21 +20,13 @@
|
||||
|
||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||
|
||||
import dev.pcvolkmer.mv64e.mtb.EcogCoding;
|
||||
import dev.pcvolkmer.mv64e.mtb.EcogCodingCode;
|
||||
import dev.pcvolkmer.mv64e.mtb.PerformanceStatus;
|
||||
import dev.pcvolkmer.mv64e.mtb.PriorDiagnosticReport;
|
||||
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.EcogCatalogue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_vorbefunde'
|
||||
*
|
||||
@@ -72,7 +64,7 @@ public class KpaVorbefundeDataMapper extends AbstractSubformDataMapper<PriorDiag
|
||||
var builder = PriorDiagnosticReport.builder();
|
||||
builder
|
||||
.id(resultSet.getId().toString())
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
.results(List.of(resultSet.getString("ecog")))
|
||||
;
|
||||
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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.Reference;
|
||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||
|
||||
/**
|
||||
* Utility methods to be used in mappers
|
||||
*/
|
||||
public class MapperUtils {
|
||||
|
||||
private MapperUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Patient Reference based on default column name 'patient_id'
|
||||
*
|
||||
* @return The patient reference
|
||||
*/
|
||||
public static Reference getPatientReference(String patientId) {
|
||||
if (patientId == null) {
|
||||
throw new DataAccessException("No patient id found");
|
||||
}
|
||||
return Reference.builder()
|
||||
.id(patientId)
|
||||
// Use "Patient" since Onkostar only provides patient data
|
||||
.type("Patient")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@@ -29,8 +29,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map patient data from database table 'dk_molekulargenetik'
|
||||
*
|
||||
@@ -76,7 +74,7 @@ public class MolekulargenetikToSpecimenDataMapper implements DataMapper<TumorSpe
|
||||
var builder = TumorSpecimen.builder();
|
||||
builder
|
||||
.id(data.getString("id"))
|
||||
.patient(getPatientReference(data.getString("patient_id")))
|
||||
.patient(data.getPatientReference())
|
||||
.type(getTumorSpecimenCoding(data.getString("materialfixierung")))
|
||||
.collection(getCollection(data))
|
||||
// TODO add diagnosis later
|
||||
|
@@ -28,8 +28,6 @@ import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map patient data from database table 'dk_dnpm_kpa'
|
||||
*
|
||||
@@ -63,7 +61,7 @@ public class MtbEpisodeDataMapper implements DataMapper<MtbEpisodeOfCare> {
|
||||
var builder = MtbEpisodeOfCare.builder();
|
||||
builder
|
||||
.id(kpaData.getString("id"))
|
||||
.patient(getPatientReference(kpaData.getString("patient_id")))
|
||||
.patient(kpaData.getPatientReference())
|
||||
.diagnoses(
|
||||
List.of(
|
||||
Reference.builder()
|
||||
|
@@ -22,15 +22,16 @@ package dev.pcvolkmer.onco.datamapper.mapper;
|
||||
|
||||
import dev.pcvolkmer.mv64e.mtb.*;
|
||||
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.*;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.EinzelempfehlungCatalogue;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.RebiopsieCatalogue;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.ReevaluationCatalogue;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.TherapieplanCatalogue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map patient data from database table 'dk_dnpm_therapieplan'
|
||||
*
|
||||
@@ -78,7 +79,7 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
||||
var builder = MtbCarePlan.builder();
|
||||
builder
|
||||
.id(therapieplanData.getString("id"))
|
||||
.patient(getPatientReference(therapieplanData.getString("patient_id")))
|
||||
.patient(therapieplanData.getPatientReference())
|
||||
.issuedOn(therapieplanData.getDate("datum"))
|
||||
.histologyReevaluationRequests(getHistologyReevaluationRequests(id))
|
||||
.rebiopsyRequests(
|
||||
@@ -125,7 +126,7 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
||||
builder.geneticCounselingRecommendation(
|
||||
GeneticCounselingRecommendation.builder()
|
||||
.id(therapieplanData.getString("id"))
|
||||
.patient(getPatientReference(therapieplanData.getString("patient_id")))
|
||||
.patient(therapieplanData.getPatientReference())
|
||||
.issuedOn(therapieplanData.getDate("datum_tk_humangenber"))
|
||||
.reason(
|
||||
getGeneticCounselingRecommendationReasonCoding(
|
||||
@@ -177,7 +178,7 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
||||
.map(resultSet ->
|
||||
RebiopsyRequest.builder()
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
.tumorEntity(diagnosisReference)
|
||||
.build()
|
||||
@@ -190,7 +191,7 @@ public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
||||
.map(resultSet ->
|
||||
HistologyReevaluationRequest.builder()
|
||||
.id(resultSet.getString("id"))
|
||||
.patient(getPatientReference(resultSet.getString("patient_id")))
|
||||
.patient(resultSet.getPatientReference())
|
||||
.issuedOn(resultSet.getDate("datum"))
|
||||
.specimen(Reference.builder().id(resultSet.getString("ref_molekulargenetik")).build())
|
||||
.build()
|
||||
|
Reference in New Issue
Block a user