mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-07-03 02:52:54 +00:00
refactor: use custum type to wrap raw map
This commit is contained in:
82
src/main/java/dev/pcvolkmer/onco/datamapper/ResultSet.java
Normal file
82
src/main/java/dev/pcvolkmer/onco/datamapper/ResultSet.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package dev.pcvolkmer.onco.datamapper;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set type to wrap <code>Map<String, Object></code>
|
||||||
|
*
|
||||||
|
* @author Paul-Christian Volkmer
|
||||||
|
* @since 0.1
|
||||||
|
*/
|
||||||
|
public class ResultSet {
|
||||||
|
|
||||||
|
private final Map<String, Object> rawData;
|
||||||
|
|
||||||
|
private ResultSet(final Map<String, Object> rawData) {
|
||||||
|
this.rawData = rawData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResultSet from(final Map<String, Object> rawData) {
|
||||||
|
return new ResultSet(rawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getRawData() {
|
||||||
|
return rawData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get column value as String and cast value if possible
|
||||||
|
* @param columnName The name of the column
|
||||||
|
* @return The column value as String
|
||||||
|
*/
|
||||||
|
public String getString(String columnName) {
|
||||||
|
var raw = this.rawData.get(columnName);
|
||||||
|
|
||||||
|
if (raw == null) {
|
||||||
|
return null;
|
||||||
|
} else if (raw instanceof String) {
|
||||||
|
return raw.toString();
|
||||||
|
} else if (raw instanceof Integer) {
|
||||||
|
return ((Integer) raw).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to String");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get column value as Integer and cast value if possible
|
||||||
|
* @param columnName The name of the column
|
||||||
|
* @return The column value as Integer
|
||||||
|
*/
|
||||||
|
public Integer getInteger(String columnName) {
|
||||||
|
var raw = this.rawData.get(columnName);
|
||||||
|
|
||||||
|
if (raw == null) {
|
||||||
|
return null;
|
||||||
|
} else if (raw instanceof Integer) {
|
||||||
|
return ((Integer) raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Integer");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get column value as Date and cast value if possible
|
||||||
|
* @param columnName The name of the column
|
||||||
|
* @return The column value as Date
|
||||||
|
*/
|
||||||
|
public Date getDate(String columnName) {
|
||||||
|
var raw = this.rawData.get(columnName);
|
||||||
|
|
||||||
|
if (raw == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (raw instanceof Date) {
|
||||||
|
return (Date) raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Date");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper;
|
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
|
|
||||||
public class TypeMapper {
|
|
||||||
|
|
||||||
public static String asString(Object raw) {
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (raw instanceof String) {
|
|
||||||
return (String) raw;
|
|
||||||
} else if (raw instanceof Integer) {
|
|
||||||
return ((Integer) raw).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to String");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date asDate(Object raw) {
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (raw instanceof Date) {
|
|
||||||
return (Date) raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Date");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||||
|
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public abstract class AbstractDataCatalogue implements DataCatalogue {
|
|||||||
* @return The procedure id
|
* @return The procedure id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getById(int id) {
|
public ResultSet getById(int id) {
|
||||||
var result = this.jdbcTemplate.queryForList(
|
var result = this.jdbcTemplate.queryForList(
|
||||||
String.format(
|
String.format(
|
||||||
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND prozedur.id = ?",
|
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND prozedur.id = ?",
|
||||||
@ -43,7 +44,7 @@ public abstract class AbstractDataCatalogue implements DataCatalogue {
|
|||||||
throw new DataAccessException("Multiple records found for id: " + id);
|
throw new DataAccessException("Multiple records found for id: " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.get(0);
|
return ResultSet.from(result.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||||
|
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common implementations for all data catalogues used in subforms
|
* Common implementations for all data catalogues used in subforms
|
||||||
@ -25,14 +26,17 @@ public abstract class AbstractSubformDataCatalogue extends AbstractDataCatalogue
|
|||||||
* @param id The procedure id
|
* @param id The procedure id
|
||||||
* @return The procedure id
|
* @return The procedure id
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getAllByMainId(int id) {
|
public List<ResultSet> getAllByMainId(int id) {
|
||||||
return this.jdbcTemplate.queryForList(
|
return this.jdbcTemplate.queryForList(
|
||||||
String.format(
|
String.format(
|
||||||
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND hauptprozedur_id = ?",
|
"SELECT * FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND hauptprozedur_id = ?",
|
||||||
getTableName(),
|
getTableName(),
|
||||||
getTableName()
|
getTableName()
|
||||||
),
|
),
|
||||||
id);
|
id)
|
||||||
|
.stream()
|
||||||
|
.map(ResultSet::from)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||||
|
|
||||||
import java.util.Map;
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for all data catalogues
|
* Common interface for all data catalogues
|
||||||
@ -15,6 +15,6 @@ public interface DataCatalogue {
|
|||||||
* @param id The database id (primary key)
|
* @param id The database id (primary key)
|
||||||
* @return The result set
|
* @return The result set
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getById(int id);
|
ResultSet getById(int id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||||
|
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load raw result sets from database table 'patient'
|
* Load raw result sets from database table 'patient'
|
||||||
*
|
*
|
||||||
@ -25,11 +24,12 @@ public class PatientCatalogue implements DataCatalogue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get patient result set by procedure id
|
* Get patient result set by procedure id
|
||||||
|
*
|
||||||
* @param id The procedure id
|
* @param id The procedure id
|
||||||
* @return The procedure id
|
* @return The procedure id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getById(int id) {
|
public ResultSet getById(int id) {
|
||||||
|
|
||||||
var result = this.jdbcTemplate.queryForList(
|
var result = this.jdbcTemplate.queryForList(
|
||||||
"SELECT * FROM patient WHERE id = ?",
|
"SELECT * FROM patient WHERE id = ?",
|
||||||
@ -41,7 +41,7 @@ public class PatientCatalogue implements DataCatalogue {
|
|||||||
throw new DataAccessException("Multiple patient records found for id: " + id);
|
throw new DataAccessException("Multiple patient records found for id: " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.get(0);
|
return ResultSet.from(result.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import dev.pcvolkmer.mv64e.mtb.Coding;
|
|||||||
import dev.pcvolkmer.mv64e.mtb.MtbDiagnosis;
|
import dev.pcvolkmer.mv64e.mtb.MtbDiagnosis;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
||||||
|
|
||||||
import static dev.pcvolkmer.onco.datamapper.TypeMapper.asString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_kpa'
|
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_kpa'
|
||||||
*
|
*
|
||||||
@ -30,12 +28,12 @@ public class KpaDiagnosisDataMapper implements DataMapper<MtbDiagnosis> {
|
|||||||
public MtbDiagnosis getById(int id) {
|
public MtbDiagnosis getById(int id) {
|
||||||
var data = kpaCatalogue.getById(id);
|
var data = kpaCatalogue.getById(id);
|
||||||
|
|
||||||
var builder = MtbDiagnosis.builder();
|
var builder = MtbDiagnosis.builder();
|
||||||
builder
|
builder
|
||||||
.id(asString(data.get("id")))
|
.id(data.getString("id"))
|
||||||
.code(
|
.code(
|
||||||
Coding.builder()
|
Coding.builder()
|
||||||
.code(asString(data.get("icd10")))
|
.code(data.getString("icd10"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||||
|
|
||||||
import dev.pcvolkmer.mv64e.mtb.*;
|
import dev.pcvolkmer.mv64e.mtb.*;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static dev.pcvolkmer.onco.datamapper.TypeMapper.asDate;
|
|
||||||
import static dev.pcvolkmer.onco.datamapper.TypeMapper.asString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class to load and map patient data from database table 'dk_dnpm_kpa'
|
* Mapper class to load and map patient data from database table 'dk_dnpm_kpa'
|
||||||
*
|
*
|
||||||
@ -34,18 +30,18 @@ public class KpaPatientDataMapper implements DataMapper<Patient> {
|
|||||||
|
|
||||||
var builder = Patient.builder();
|
var builder = Patient.builder();
|
||||||
builder
|
builder
|
||||||
.id(asString(kpaData.get("patient_id")))
|
.id(kpaData.getString("patient_id"))
|
||||||
.gender(getGenderCoding(kpaData))
|
.gender(getGenderCoding(kpaData))
|
||||||
.birthDate(mapDate(asDate(kpaData.get("geburtsdatum"))))
|
.birthDate(mapDate(kpaData.getDate("geburtsdatum")))
|
||||||
.dateOfDeath(mapDate(asDate(kpaData.get("todesdatum"))))
|
.dateOfDeath(mapDate(kpaData.getDate("todesdatum")))
|
||||||
.healthInsurance(getHealthInsurance(kpaData))
|
.healthInsurance(getHealthInsurance(kpaData))
|
||||||
;
|
;
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GenderCoding getGenderCoding(Map<String, Object> data) {
|
private GenderCoding getGenderCoding(ResultSet data) {
|
||||||
var genderCodingBuilder = GenderCoding.builder();
|
var genderCodingBuilder = GenderCoding.builder();
|
||||||
String geschlecht = asString(data.get("geschlecht"));
|
String geschlecht = data.getString("geschlecht");
|
||||||
switch (geschlecht) {
|
switch (geschlecht) {
|
||||||
case "m":
|
case "m":
|
||||||
genderCodingBuilder.code(GenderCodingCode.MALE);
|
genderCodingBuilder.code(GenderCodingCode.MALE);
|
||||||
@ -63,9 +59,9 @@ public class KpaPatientDataMapper implements DataMapper<Patient> {
|
|||||||
return genderCodingBuilder.build();
|
return genderCodingBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HealthInsurance getHealthInsurance(Map<String, Object> data) {
|
private HealthInsurance getHealthInsurance(ResultSet data) {
|
||||||
var healthInsuranceCodingBuilder = HealthInsuranceCoding.builder();
|
var healthInsuranceCodingBuilder = HealthInsuranceCoding.builder();
|
||||||
String healthInsuranceType = asString(data.get("artderkrankenkasse"));
|
String healthInsuranceType = data.getString("artderkrankenkasse");
|
||||||
if (healthInsuranceType == null) {
|
if (healthInsuranceType == null) {
|
||||||
healthInsuranceCodingBuilder.code(HealthInsuranceCodingCode.UNK).build();
|
healthInsuranceCodingBuilder.code(HealthInsuranceCodingCode.UNK).build();
|
||||||
return HealthInsurance.builder().type(healthInsuranceCodingBuilder.build()).build();
|
return HealthInsurance.builder().type(healthInsuranceCodingBuilder.build()).build();
|
||||||
|
@ -4,14 +4,10 @@ import dev.pcvolkmer.mv64e.mtb.Address;
|
|||||||
import dev.pcvolkmer.mv64e.mtb.GenderCoding;
|
import dev.pcvolkmer.mv64e.mtb.GenderCoding;
|
||||||
import dev.pcvolkmer.mv64e.mtb.GenderCodingCode;
|
import dev.pcvolkmer.mv64e.mtb.GenderCodingCode;
|
||||||
import dev.pcvolkmer.mv64e.mtb.Patient;
|
import dev.pcvolkmer.mv64e.mtb.Patient;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.PatientCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.PatientCatalogue;
|
||||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static dev.pcvolkmer.onco.datamapper.TypeMapper.asDate;
|
|
||||||
import static dev.pcvolkmer.onco.datamapper.TypeMapper.asString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_kpa'
|
* Mapper class to load and map diagnosis data from database table 'dk_dnpm_kpa'
|
||||||
*
|
*
|
||||||
@ -33,23 +29,23 @@ public class PatientDataMapper implements DataMapper<Patient> {
|
|||||||
* @return The loaded MtbDiagnosis file
|
* @return The loaded MtbDiagnosis file
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Patient getById(int id) {
|
public Patient getById(final int id) {
|
||||||
var patientData = patientCatalogue.getById(id);
|
var patientData = patientCatalogue.getById(id);
|
||||||
|
|
||||||
var builder = Patient.builder();
|
var builder = Patient.builder();
|
||||||
builder
|
builder
|
||||||
.id(asString(patientData.get("id")))
|
.id(patientData.getString("id"))
|
||||||
.gender(getGenderCoding(patientData))
|
.gender(getGenderCoding(patientData))
|
||||||
.birthDate(mapDate(asDate(patientData.get("geburtsdatum"))))
|
.birthDate(mapDate(patientData.getDate("geburtsdatum")))
|
||||||
.dateOfDeath(mapDate(asDate(patientData.get("sterbedatum"))))
|
.dateOfDeath(mapDate(patientData.getDate("sterbedatum")))
|
||||||
.address(Address.builder().municipalityCode(getMunicipalityCode(patientData)).build())
|
.address(Address.builder().municipalityCode(getMunicipalityCode(patientData)).build())
|
||||||
;
|
;
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GenderCoding getGenderCoding(Map<String, Object> data) {
|
private GenderCoding getGenderCoding(final ResultSet data) {
|
||||||
var genderCodingBuilder = GenderCoding.builder();
|
var genderCodingBuilder = GenderCoding.builder();
|
||||||
String geschlecht = asString(data.get("geschlecht"));
|
String geschlecht = data.getString("geschlecht");
|
||||||
switch (geschlecht) {
|
switch (geschlecht) {
|
||||||
case "M":
|
case "M":
|
||||||
genderCodingBuilder.code(GenderCodingCode.MALE);
|
genderCodingBuilder.code(GenderCodingCode.MALE);
|
||||||
@ -66,8 +62,8 @@ public class PatientDataMapper implements DataMapper<Patient> {
|
|||||||
return genderCodingBuilder.build();
|
return genderCodingBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMunicipalityCode(Map<String, Object> data) {
|
private String getMunicipalityCode(final ResultSet data) {
|
||||||
var gkz = asString(data.get("GKZ"));
|
var gkz = data.getString("GKZ");
|
||||||
if (gkz == null || gkz.trim().length() != 8) {
|
if (gkz == null || gkz.trim().length() != 8) {
|
||||||
throw new DataAccessException("Municipality code not found");
|
throw new DataAccessException("Municipality code not found");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package dev.pcvolkmer.onco.datamapper;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class ResultSetTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnStringValues() {
|
||||||
|
var data = getTestData();
|
||||||
|
|
||||||
|
assertThat(data.getString("null")).isNull();
|
||||||
|
assertThat(data.getString("string")).isEqualTo("TestString");
|
||||||
|
assertThat(data.getString("int")).isEqualTo("42");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnIntegerValues() {
|
||||||
|
var data = getTestData();
|
||||||
|
|
||||||
|
assertThat(data.getInteger("int")).isEqualTo(42);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnDateValues() {
|
||||||
|
var data = getTestData();
|
||||||
|
|
||||||
|
assertThat(data.getDate("date")).isEqualTo(new Date(Date.from(Instant.parse("2025-06-21T12:00:00Z")).getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static ResultSet getTestData() {
|
||||||
|
return ResultSet.from(
|
||||||
|
Map.of(
|
||||||
|
"string", "TestString",
|
||||||
|
"int", 42,
|
||||||
|
"date", new Date(Date.from(Instant.parse("2025-06-21T12:00:00Z")).getTime())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||||
|
|
||||||
import dev.pcvolkmer.mv64e.mtb.MtbDiagnosis;
|
import dev.pcvolkmer.mv64e.mtb.MtbDiagnosis;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -35,11 +36,11 @@ class KpaDiagnosisDataMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreateDiagnosis(@Mock Map<String, Object> resultSet) {
|
void shouldCreateDiagnosis(@Mock ResultSet resultSet) {
|
||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var columnName = invocationOnMock.getArgument(0, String.class);
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
return testData().get(columnName);
|
return testData().get(columnName);
|
||||||
}).when(resultSet).get(anyString());
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> resultSet)
|
doAnswer(invocationOnMock -> resultSet)
|
||||||
.when(kpaCatalogue)
|
.when(kpaCatalogue)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||||
|
|
||||||
import dev.pcvolkmer.mv64e.mtb.*;
|
import dev.pcvolkmer.mv64e.mtb.*;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.KpaCatalogue;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -37,7 +38,7 @@ class KpaPatientDataMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreatePatientAlive(@Mock Map<String, Object> resultSet) {
|
void shouldCreatePatientAlive(@Mock ResultSet resultSet) {
|
||||||
var testData = Map.of(
|
var testData = Map.of(
|
||||||
"patient_id", "1",
|
"patient_id", "1",
|
||||||
"geschlecht", "m",
|
"geschlecht", "m",
|
||||||
@ -49,7 +50,12 @@ class KpaPatientDataMapperTest {
|
|||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var columnName = invocationOnMock.getArgument(0, String.class);
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
return testData.get(columnName);
|
return testData.get(columnName);
|
||||||
}).when(resultSet).get(anyString());
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getDate(anyString());
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> resultSet)
|
doAnswer(invocationOnMock -> resultSet)
|
||||||
.when(kpaCatalogue)
|
.when(kpaCatalogue)
|
||||||
@ -67,7 +73,7 @@ class KpaPatientDataMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreatePatientDead(@Mock Map<String, Object> resultSet) {
|
void shouldCreatePatientDead(@Mock ResultSet resultSet) {
|
||||||
var testData = Map.of(
|
var testData = Map.of(
|
||||||
"patient_id", "1",
|
"patient_id", "1",
|
||||||
"geschlecht", "w",
|
"geschlecht", "w",
|
||||||
@ -78,7 +84,12 @@ class KpaPatientDataMapperTest {
|
|||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var columnName = invocationOnMock.getArgument(0, String.class);
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
return testData.get(columnName);
|
return testData.get(columnName);
|
||||||
}).when(resultSet).get(anyString());
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getDate(anyString());
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> resultSet)
|
doAnswer(invocationOnMock -> resultSet)
|
||||||
.when(kpaCatalogue)
|
.when(kpaCatalogue)
|
||||||
|
@ -3,6 +3,7 @@ package dev.pcvolkmer.onco.datamapper.mapper;
|
|||||||
import dev.pcvolkmer.mv64e.mtb.Address;
|
import dev.pcvolkmer.mv64e.mtb.Address;
|
||||||
import dev.pcvolkmer.mv64e.mtb.GenderCodingCode;
|
import dev.pcvolkmer.mv64e.mtb.GenderCodingCode;
|
||||||
import dev.pcvolkmer.mv64e.mtb.Patient;
|
import dev.pcvolkmer.mv64e.mtb.Patient;
|
||||||
|
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.PatientCatalogue;
|
import dev.pcvolkmer.onco.datamapper.datacatalogues.PatientCatalogue;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -39,7 +40,7 @@ class PatientDataMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreatePatientAlive(@Mock Map<String, Object> resultSet) {
|
void shouldCreatePatientAlive(@Mock ResultSet resultSet) {
|
||||||
var testData = Map.of(
|
var testData = Map.of(
|
||||||
"id", "1",
|
"id", "1",
|
||||||
"geschlecht", "M",
|
"geschlecht", "M",
|
||||||
@ -51,7 +52,12 @@ class PatientDataMapperTest {
|
|||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var columnName = invocationOnMock.getArgument(0, String.class);
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
return testData.get(columnName);
|
return testData.get(columnName);
|
||||||
}).when(resultSet).get(anyString());
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getDate(anyString());
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> resultSet)
|
doAnswer(invocationOnMock -> resultSet)
|
||||||
.when(patientCatalogue)
|
.when(patientCatalogue)
|
||||||
@ -67,7 +73,7 @@ class PatientDataMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreatePatientDead(@Mock Map<String, Object> resultSet) {
|
void shouldCreatePatientDead(@Mock ResultSet resultSet) {
|
||||||
var testData = Map.of(
|
var testData = Map.of(
|
||||||
"id", "1",
|
"id", "1",
|
||||||
"geschlecht", "M",
|
"geschlecht", "M",
|
||||||
@ -78,7 +84,12 @@ class PatientDataMapperTest {
|
|||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var columnName = invocationOnMock.getArgument(0, String.class);
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
return testData.get(columnName);
|
return testData.get(columnName);
|
||||||
}).when(resultSet).get(anyString());
|
}).when(resultSet).getString(anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var columnName = invocationOnMock.getArgument(0, String.class);
|
||||||
|
return testData.get(columnName);
|
||||||
|
}).when(resultSet).getDate(anyString());
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> resultSet)
|
doAnswer(invocationOnMock -> resultSet)
|
||||||
.when(patientCatalogue)
|
.when(patientCatalogue)
|
||||||
|
Reference in New Issue
Block a user