1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-07-03 19:12:55 +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 dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
import java.sql.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**

View File

@ -1,33 +1,20 @@
package dev.pcvolkmer.onco.datamapper.mapper; package dev.pcvolkmer.onco.datamapper.mapper;
import java.util.Date;
/** /**
* General interface for all data mappers * General interface for all data mappers
* *
* @since 0.1
* @author Paul-Christian Volkmer
* @param <T> The destination type * @param <T> The destination type
* @author Paul-Christian Volkmer
* @since 0.1
*/ */
public interface DataMapper<T> { public interface DataMapper<T> {
/** /**
* Loads a data set from database and maps it into destination data type * Loads a data set from database and maps it into destination data type
*
* @param id The database id of the root procedure data set * @param id The database id of the root procedure data set
* @return The data set to be loaded * @return The data set to be loaded
*/ */
T getById(int id); 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 builder
.id(kpaData.getString("patient_id")) .id(kpaData.getString("patient_id"))
.gender(getGenderCoding(kpaData)) .gender(getGenderCoding(kpaData))
.birthDate(mapDate(kpaData.getDate("geburtsdatum"))) .birthDate(kpaData.getDate("geburtsdatum"))
.dateOfDeath(mapDate(kpaData.getDate("todesdatum"))) .dateOfDeath(kpaData.getDate("todesdatum"))
.healthInsurance(getHealthInsurance(kpaData)) .healthInsurance(getHealthInsurance(kpaData))
; ;
return builder.build(); return builder.build();

View File

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