1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-07-02 02:22:54 +00:00

refactor: return java.util.Date

This commit is contained in:
2025-06-21 16:32:55 +02:00
parent e578d36e1b
commit 76d3245df0
4 changed files with 8 additions and 21 deletions

View File

@ -2,7 +2,7 @@ package dev.pcvolkmer.onco.datamapper;
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
import java.sql.Date;
import java.util.Date;
import java.util.Map;
/**

View File

@ -1,33 +1,20 @@
package dev.pcvolkmer.onco.datamapper.mapper;
import java.util.Date;
/**
* General interface for all data mappers
*
* @since 0.1
* @author Paul-Christian Volkmer
* @param <T> The destination type
* @author Paul-Christian Volkmer
* @since 0.1
*/
public interface DataMapper<T> {
/**
* Loads a data set from database and maps it into destination data type
*
* @param id The database id of the root procedure data set
* @return The data set to be loaded
*/
T getById(int id);
/**
* Maps java.sql.Date to java.util.Date
* @param date
* @return
*/
default Date mapDate(java.sql.Date date) {
if (date == null) {
return null;
}
return new Date(date.getTime());
}
}

View File

@ -32,8 +32,8 @@ public class KpaPatientDataMapper implements DataMapper<Patient> {
builder
.id(kpaData.getString("patient_id"))
.gender(getGenderCoding(kpaData))
.birthDate(mapDate(kpaData.getDate("geburtsdatum")))
.dateOfDeath(mapDate(kpaData.getDate("todesdatum")))
.birthDate(kpaData.getDate("geburtsdatum"))
.dateOfDeath(kpaData.getDate("todesdatum"))
.healthInsurance(getHealthInsurance(kpaData))
;
return builder.build();

View File

@ -36,8 +36,8 @@ public class PatientDataMapper implements DataMapper<Patient> {
builder
.id(patientData.getString("id"))
.gender(getGenderCoding(patientData))
.birthDate(mapDate(patientData.getDate("geburtsdatum")))
.dateOfDeath(mapDate(patientData.getDate("sterbedatum")))
.birthDate(patientData.getDate("geburtsdatum"))
.dateOfDeath(patientData.getDate("sterbedatum"))
.address(Address.builder().municipalityCode(getMunicipalityCode(patientData)).build())
;
return builder.build();