Commit 8b392d75 authored by R.W.Majeed's avatar R.W.Majeed

allow simple mapping operations for visit.location, visit.provider, etc.

parent 5141888e
package de.sekmi.histream.etl;
/**
* Feedback from mapping operation. E.g. drop fact or override concept.
*
* @author R.W.Majeed
*
*/
// TODO allow different subclasses of feedback. some places allow mapping, but drop-fact does not make sense (e.g. gender, location). In some cases, action might drop value, modifier or whole observation.
public class MapFeedback {
private boolean drop;
private String concept;
......
......@@ -154,9 +154,10 @@ public abstract class Column<T> {
}
/**
* Process and return the column value from a table row without map rule processing.
* This method behaves as if {@link #valueOf(ColumnMap, Object[], MapFeedback)} was called
* with the last argument set to {@code null}.
* Process and return the column value from a table row with limited map rule processing.
* The mapping operation is allowed, but does not allow actions (like drop fact) or concept modification
* In contrast to {@link #valueOf(ColumnMap, Object[], MapFeedback)} with the last argument set to {@code null} (thus not allowing any map operation)
* this method allows mapping.
*
* @see #valueOf(Object)
* @param colMap column map
......@@ -165,9 +166,14 @@ public abstract class Column<T> {
* @throws ParseException parse errors
*/
public T valueOf(ColumnMap colMap, Object[] row) throws ParseException{
return valueOf(colMap, row, null);
MapFeedback mf = new MapFeedback();
T value = valueOf(colMap, row, mf);
if( mf.isActionDrop() || mf.getConceptOverride() != null ){
throw new ParseException("concept override or drop not allowed for column "+getName());
}
return value;
}
private T processedValue(String val, MapFeedback mapFeedback) throws ParseException{
T ret;
// apply regular expression replacements
......@@ -177,7 +183,7 @@ public abstract class Column<T> {
// apply map rules
if( map != null ){
if( mapFeedback == null ){
throw new ParseException("map element allowed for column "+getName());
throw new ParseException("map element not supported for column "+getName());
}
applyMapRules(val, mapFeedback);
// use value override, if present
......
......@@ -98,11 +98,7 @@ public class PatientTable extends Table<PatientRow> implements ConceptTable{
patient.setDeathDate(idat.deathdate.valueOf(map, row, null));
}
if( idat.gender != null ){
MapFeedback mf = new MapFeedback();
String genderCode = idat.gender.valueOf(map, row, mf);
if( mf.isActionDrop() || mf.getConceptOverride() != null ){
throw new ParseException("concept override or drop not allowed for patient gender");
}
String genderCode = idat.gender.valueOf(map, row);
// gender may omitted
if( genderCode != null ){
try{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment