mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-07-03 19:12:55 +00:00
feat: add initial Therapieplan support
This commit is contained in:
@ -67,6 +67,8 @@ public class DataCatalogueFactory {
|
||||
return VerwandteCatalogue.create(jdbcTemplate);
|
||||
} else if (c == VorbefundeCatalogue.class) {
|
||||
return VorbefundeCatalogue.create(jdbcTemplate);
|
||||
} else if (c == TherapieplanCatalogue.class) {
|
||||
return TherapieplanCatalogue.create(jdbcTemplate);
|
||||
}
|
||||
throw new DataCatalogueCreationException(clazz);
|
||||
});
|
||||
|
@ -0,0 +1,51 @@
|
||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||
|
||||
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||
import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Load raw result sets from database table 'dk_dnpm_therapieplan'
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1
|
||||
*/
|
||||
public class TherapieplanCatalogue extends AbstractDataCatalogue {
|
||||
|
||||
private TherapieplanCatalogue(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableName() {
|
||||
return "dk_dnpm_therapieplan";
|
||||
}
|
||||
|
||||
public static TherapieplanCatalogue create(JdbcTemplate jdbcTemplate) {
|
||||
return new TherapieplanCatalogue(jdbcTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get procedure IDs by related Klinik/Anamnese procedure id
|
||||
*
|
||||
* @param kpaId The procedure id
|
||||
* @return The procedure ids
|
||||
*/
|
||||
public List<Integer> getByKpaId(int kpaId) {
|
||||
return this.jdbcTemplate.queryForList(
|
||||
String.format(
|
||||
"SELECT prozedur.id AS procedure_id FROM %s JOIN prozedur ON (prozedur.id = %s.id) WHERE geloescht = 0 AND ref_dnpm_klinikanamnese = ?",
|
||||
getTableName(),
|
||||
getTableName()
|
||||
),
|
||||
kpaId)
|
||||
.stream()
|
||||
.map(ResultSet::from)
|
||||
.map(rs -> rs.getInteger("procedure_id"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map Mtb files from database
|
||||
@ -78,6 +79,9 @@ public class MtbDataMapper implements DataMapper<Mtb> {
|
||||
catalogueFactory.catalogue(EcogCatalogue.class)
|
||||
);
|
||||
|
||||
var therapieplanCatalogue = catalogueFactory.catalogue(TherapieplanCatalogue.class);
|
||||
var therapieplanDataMapper = new TherapieplanDataMapper(therapieplanCatalogue, propertyCatalogue);
|
||||
|
||||
var resultBuilder = Mtb.builder();
|
||||
|
||||
try {
|
||||
@ -87,10 +91,18 @@ public class MtbDataMapper implements DataMapper<Mtb> {
|
||||
|
||||
resultBuilder
|
||||
.patient(kpaPatient)
|
||||
// DNPM Klinik/Anamnese
|
||||
.diagnoses(List.of(diagnosisDataMapper.getById(kpaId)))
|
||||
.guidelineProcedures(prozedurMapper.getByParentId(kpaId))
|
||||
.guidelineTherapies(therapielinieMapper.getByParentId(kpaId))
|
||||
.performanceStatus(ecogMapper.getByParentId(kpaId))
|
||||
// DNPM Therapieplan
|
||||
.carePlans(
|
||||
therapieplanCatalogue
|
||||
.getByKpaId(kpaId).stream()
|
||||
.map(therapieplanDataMapper::getById)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
;
|
||||
} catch (DataAccessException e) {
|
||||
logger.error("Error while getting Mtb.", e);
|
||||
|
@ -0,0 +1,47 @@
|
||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||
|
||||
import dev.pcvolkmer.mv64e.mtb.MtbCarePlan;
|
||||
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.TherapieplanCatalogue;
|
||||
|
||||
import static dev.pcvolkmer.onco.datamapper.mapper.MapperUtils.getPatientReference;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map patient data from database table 'dk_dnpm_therapieplan'
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1
|
||||
*/
|
||||
public class TherapieplanDataMapper implements DataMapper<MtbCarePlan> {
|
||||
|
||||
private final TherapieplanCatalogue therapieplanCatalogue;
|
||||
private final PropertyCatalogue propertyCatalogue;
|
||||
|
||||
public TherapieplanDataMapper(
|
||||
final TherapieplanCatalogue therapieplanCatalogue,
|
||||
final PropertyCatalogue propertyCatalogue
|
||||
) {
|
||||
this.therapieplanCatalogue = therapieplanCatalogue;
|
||||
this.propertyCatalogue = propertyCatalogue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and maps a ca plan using the database id
|
||||
*
|
||||
* @param id The database id of the procedure data set
|
||||
* @return The loaded Patient data
|
||||
*/
|
||||
@Override
|
||||
public MtbCarePlan getById(int id) {
|
||||
var therapieplanData = therapieplanCatalogue.getById(id);
|
||||
|
||||
var builder = MtbCarePlan.builder();
|
||||
builder
|
||||
.id(therapieplanData.getString("id"))
|
||||
.patient(getPatientReference(therapieplanData.getString("patient_id")))
|
||||
.issuedOn(therapieplanData.getDate("datum"))
|
||||
;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user