mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-07-04 19:32:55 +00:00
feat: add performance status mapping
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
package dev.pcvolkmer.onco.datamapper.mapper;
|
||||
|
||||
import dev.pcvolkmer.mv64e.mtb.EcogCoding;
|
||||
import dev.pcvolkmer.mv64e.mtb.EcogCodingCode;
|
||||
import dev.pcvolkmer.mv64e.mtb.PerformanceStatus;
|
||||
import dev.pcvolkmer.mv64e.mtb.Reference;
|
||||
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||
import dev.pcvolkmer.onco.datamapper.datacatalogues.EcogCatalogue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Mapper class to load and map prozedur data from database table 'dk_dnpm_uf_ecog'
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1
|
||||
*/
|
||||
public class KpaEcogDataMapper implements SubformDataMapper<PerformanceStatus> {
|
||||
|
||||
private final EcogCatalogue catalogue;
|
||||
|
||||
public KpaEcogDataMapper(final EcogCatalogue catalogue) {
|
||||
this.catalogue = catalogue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and maps Prozedur related by database id
|
||||
*
|
||||
* @param id The database id of the procedure data set
|
||||
* @return The loaded data set
|
||||
*/
|
||||
@Override
|
||||
public PerformanceStatus getById(final int id) {
|
||||
var data = catalogue.getById(id);
|
||||
return this.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PerformanceStatus> getByParentId(final int parentId) {
|
||||
return catalogue.getAllByParentId(parentId)
|
||||
.stream()
|
||||
.map(this::map)
|
||||
.sorted(Comparator.comparing(PerformanceStatus::getEffectiveDate))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private PerformanceStatus map(final ResultSet resultSet) {
|
||||
var builder = PerformanceStatus.builder();
|
||||
builder
|
||||
.id(resultSet.getProcedureId().toString())
|
||||
.patient(Reference.builder().id(resultSet.getString("patient_id")).build())
|
||||
.effectiveDate(resultSet.getDate("datum"))
|
||||
.value(getEcogCoding(resultSet.getString("ecog")))
|
||||
;
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private EcogCoding getEcogCoding(final String value) {
|
||||
if (value == null || !Arrays.stream(EcogCodingCode.values()).map(EcogCodingCode::toValue).collect(Collectors.toSet()).contains(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var resultBuilder = EcogCoding.builder();
|
||||
try {
|
||||
resultBuilder.code(EcogCodingCode.forValue(value));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("No valid code found");
|
||||
}
|
||||
|
||||
return resultBuilder.build();
|
||||
}
|
||||
|
||||
}
|
@ -46,12 +46,6 @@ public class KpaTumorausbreitungDataMapper implements SubformDataMapper<TumorSta
|
||||
}
|
||||
|
||||
private TumorStaging map(final ResultSet resultSet) {
|
||||
var diseases = catalogue.getDiseases(resultSet.getProcedureId());
|
||||
|
||||
if (diseases.size() != 1) {
|
||||
throw new IllegalStateException(String.format("No unique disease for procedure %s", resultSet.getProcedureId()));
|
||||
}
|
||||
|
||||
var builder = TumorStaging.builder();
|
||||
builder
|
||||
.date(resultSet.getDate("zeitpunkt"))
|
||||
@ -60,7 +54,6 @@ public class KpaTumorausbreitungDataMapper implements SubformDataMapper<TumorSta
|
||||
.tnmClassification(getTnmClassification(resultSet))
|
||||
;
|
||||
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user