mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-09-13 16:02:52 +00:00
feat: support for multiple choice fields
This commit is contained in:
@@ -26,6 +26,7 @@ import dev.pcvolkmer.onco.datamapper.exceptions.DataAccessException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -183,4 +184,23 @@ public class ResultSet {
|
||||
throw new IllegalArgumentException("Cannot convert " + raw.getClass() + " to Boolean");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Merkmal values as List of Strings
|
||||
*
|
||||
* @param columnName The name of the column
|
||||
* @return The related Merkmal value(s) as List of Strings
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getMerkmalList(String columnName) {
|
||||
var raw = this.rawData.get(columnName);
|
||||
|
||||
if (raw == null) {
|
||||
return List.of();
|
||||
} else if (raw instanceof List) {
|
||||
return (List<String>) raw;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot get " + columnName + " as List of Strings");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,9 +21,11 @@
|
||||
package dev.pcvolkmer.onco.datamapper.datacatalogues;
|
||||
|
||||
import dev.pcvolkmer.onco.datamapper.ResultSet;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -56,8 +58,45 @@ public abstract class AbstractSubformDataCatalogue extends AbstractDataCatalogue
|
||||
),
|
||||
id)
|
||||
.stream()
|
||||
.filter(resultSet -> resultSet.containsKey("id"))
|
||||
.map(ResultSet::from)
|
||||
.peek(resultSet -> {
|
||||
var merkmale = getMerkmaleById(resultSet.getId());
|
||||
if (merkmale.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
merkmale.forEach((key, value) ->
|
||||
resultSet.getRawData().put(key, value)
|
||||
);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get procedure "Merkmale" result by procedure id and form field name
|
||||
*
|
||||
* @param id The parents procedure id
|
||||
* @return The sub procedures
|
||||
*/
|
||||
Map<String, List<String>> getMerkmaleById(int id) {
|
||||
try {
|
||||
var resultSet = this.jdbcTemplate.queryForList(
|
||||
String.format(
|
||||
"SELECT feldname, feldwert FROM %s_merkmale WHERE eintrag_id = ?",
|
||||
getTableName()
|
||||
),
|
||||
id);
|
||||
|
||||
return resultSet.stream()
|
||||
.collect(
|
||||
Collectors.groupingBy(
|
||||
m -> m.get("feldname").toString(),
|
||||
Collectors.mapping(stringObjectMap -> stringObjectMap.get("feldwert").toString(), Collectors.toList())
|
||||
)
|
||||
);
|
||||
} catch (DataAccessException e) {
|
||||
return Map.of();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -63,10 +63,11 @@ public class EinzelempfehlungProzedurDataMapper extends AbstractEinzelempfehlung
|
||||
);
|
||||
}
|
||||
|
||||
if (null != resultSet.getString("art_der_therapie")) {
|
||||
// Nur der erste Eintrag!
|
||||
if (!resultSet.getMerkmalList("art_der_therapie").isEmpty()) {
|
||||
resultBuilder.code(
|
||||
getMtbProcedureRecommendationCategoryCoding(
|
||||
resultSet.getString("art_der_therapie"),
|
||||
resultSet.getMerkmalList("art_der_therapie").get(0),
|
||||
resultSet.getInteger("art_der_therapie_propcat_version")
|
||||
)
|
||||
);
|
||||
@@ -92,7 +93,6 @@ public class EinzelempfehlungProzedurDataMapper extends AbstractEinzelempfehlung
|
||||
return catalogue.getAllByParentId(parentId)
|
||||
.stream()
|
||||
// Filter Prozedurempfehlung (Weitere Empfehlungen)
|
||||
.filter(it -> it.getString("art_der_therapie") != null && !it.getString("art_der_therapie").isBlank())
|
||||
.filter(it -> "sonstige".equals(it.getString("empfehlungskategorie")))
|
||||
.map(this::map)
|
||||
.collect(Collectors.toList());
|
||||
|
@@ -65,12 +65,13 @@ public class EinzelempfehlungWirkstoffDataMapper extends AbstractEinzelempfehlun
|
||||
.medication(JsonToMedicationMapper.map(resultSet.getString("wirkstoffe_json")))
|
||||
.levelOfEvidence(getLevelOfEvidence(resultSet));
|
||||
|
||||
if (null != resultSet.getString("art_der_therapie")) {
|
||||
if (!resultSet.getMerkmalList("art_der_therapie").isEmpty()) {
|
||||
resultBuilder.category(
|
||||
getMtbMedicationRecommendationCategoryCoding(
|
||||
resultSet.getString("art_der_therapie"),
|
||||
resultSet.getInteger("art_der_therapie_propcat_version")
|
||||
resultSet.getMerkmalList("art_der_therapie").stream()
|
||||
.map(value ->
|
||||
getMtbMedicationRecommendationCategoryCoding(value, resultSet.getInteger("art_der_therapie_propcat_version"))
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user