From 7a448c0f9156e1250a3e644044463da324a92a75 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 20 Aug 2025 11:49:20 +0200 Subject: [PATCH] feat: add custom metadata request --- README.md | 17 ++++ .../onco/datamapper/CustomMetadata.java | 47 ++++++++++ .../mapper/CustomMetadataDataMapper.java | 85 +++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 src/main/java/dev/pcvolkmer/onco/datamapper/CustomMetadata.java create mode 100644 src/main/java/dev/pcvolkmer/onco/datamapper/mapper/CustomMetadataDataMapper.java diff --git a/README.md b/README.md index 2090a6f..5eb406e 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,20 @@ enthalten. Diese Liste der Gene unterliegt der folgenden Lizenz und ist frei verfügbar: [Creative Commons Public Domain (CC0) License](https://creativecommons.org/public-domain/cc0/). + +## Zusätzliche Informationen + +Weitere benötigte Informationen können ebenfalls abgerufen werden. + +```java +var customMetadataMapper = new CustomMetadataDataMapper( + KpaCatalogue.create(new JdbcTemplate(datasource)), + PatientCatalogue.create(new JdbcTemplate(datasource)) +); + +var additional1 = customMetadataMapper.getByCaseId("16000123"); +// oder +var additional2 = customMetadataMapper.getLatestByPatientIdAndTumorId("2000123456", 1); +``` + +Aktuell wird hier die Fallnummer und Krankenversicherungsnummer abgerufen. diff --git a/src/main/java/dev/pcvolkmer/onco/datamapper/CustomMetadata.java b/src/main/java/dev/pcvolkmer/onco/datamapper/CustomMetadata.java new file mode 100644 index 0000000..3df07e8 --- /dev/null +++ b/src/main/java/dev/pcvolkmer/onco/datamapper/CustomMetadata.java @@ -0,0 +1,47 @@ +/* + * 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 . + * + */ + +package dev.pcvolkmer.onco.datamapper; + +/** + * Custom metadata containing additional information + * + * @author Paul-Christian Volkmer + * @since 0.1 + */ +public class CustomMetadata { + + private final String fallnummer; + private final String kvnr; + + public CustomMetadata(String fallnummer, String kvnr) { + this.fallnummer = fallnummer; + this.kvnr = kvnr; + } + + public String getFallnummer() { + return fallnummer; + } + + public String getKvnr() { + return kvnr; + } + +} diff --git a/src/main/java/dev/pcvolkmer/onco/datamapper/mapper/CustomMetadataDataMapper.java b/src/main/java/dev/pcvolkmer/onco/datamapper/mapper/CustomMetadataDataMapper.java new file mode 100644 index 0000000..c79a3a3 --- /dev/null +++ b/src/main/java/dev/pcvolkmer/onco/datamapper/mapper/CustomMetadataDataMapper.java @@ -0,0 +1,85 @@ +/* + * 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 . + * + */ + +package dev.pcvolkmer.onco.datamapper.mapper; + +import dev.pcvolkmer.mv64e.mtb.Mtb; +import dev.pcvolkmer.onco.datamapper.CustomMetadata; +import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue; +import dev.pcvolkmer.onco.datamapper.datacatalogues.PatientCatalogue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Mapper class to load and map custom metadata from database + * + * @author Paul-Christian Volkmer + * @since 0.1 + */ +public class CustomMetadataDataMapper implements DataMapper { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final KpaCatalogue kpaCatalogue; + private final PatientCatalogue patientCatalogue; + + public CustomMetadataDataMapper(final KpaCatalogue kpaCatalogue, final PatientCatalogue patientCatalogue) { + this.kpaCatalogue = kpaCatalogue; + this.patientCatalogue = patientCatalogue; + } + + + @Override + public CustomMetadata getById(int id) { + var kpaData = kpaCatalogue.getById(id); + var patientData = patientCatalogue.getById(kpaData.getInteger("patient_id")); + + return new CustomMetadata( + kpaData.getString("fallnummermv"), + patientData.getString("verischerungsnummer") + ); + } + + /** + * Loads and maps using the case id + * + * @param caseId The case id + * @return The loaded Mtb file + */ + public CustomMetadata getByCaseId(String caseId) { + return this.getById( + this.kpaCatalogue.getProcedureIdByCaseId(caseId) + ); + } + + /** + * Loads and maps using the patient id and tumor id + * + * @param patientId The patients id (not database id) + * @param tumorId The tumor identification + * @return The loaded Mtb file + */ + public CustomMetadata getLatestByPatientIdAndTumorId(String patientId, int tumorId) { + return this.getById( + this.kpaCatalogue + .getLatestProcedureIdByPatientIdAndTumor(patientId, tumorId) + ); + } +}