Commit cc9bcccd authored by R.W.Majeed's avatar R.W.Majeed

#feature na-action added for all column elements (e.g value)

parent 75851ab1
......@@ -36,4 +36,11 @@ public class MapFeedback {
public boolean isActionDrop(){
return drop;
}
/**
* Reset/clear value override
*/
public void resetValue(){
this.value = null;
}
}
package de.sekmi.histream.etl.config;
import java.util.Arrays;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAttribute;
......@@ -59,6 +60,9 @@ public abstract class Column<T> {
@XmlElement(required=false)
MapRules map;
@XmlAttribute(name="na-action")
String naAction;
/**
* Column name to use for reading input values
* @return column name
......@@ -237,6 +241,22 @@ public abstract class Column<T> {
ret = valueOf(rowval); // use value directly
}
}
// process na-action
if( ret == null && naAction != null ){
// got NA value and naAction to process
switch( naAction ){
case "drop-fact":
mapFeedback.dropFact();
break;
case "warning":
// TODO use warning handler
// TODO use more context information in warning
System.err.println("Warning: no value (NA) for column '"+getName()+"'! Full row: "+Arrays.toString(row));
break;
default:
throw new ParseException("Unsupported na-action '"+naAction+"' in column "+getName());
}
}
return ret;
}
......
......@@ -72,16 +72,19 @@ public class Concept{
* @throws ParseException parse
*/
protected Observation createObservation(String patid, String visit, ObservationFactory factory, ColumnMap map, Object[] row) throws ParseException{
DateTimeAccuracy start = this.start.valueOf(map,row);
String concept = this.id;
MapFeedback mf = new MapFeedback();
DateTimeAccuracy start = this.start.valueOf(map,row, mf);
mf.resetValue();
String concept = this.id;
// parse value
String unit = null;
if( this.unit != null ){
unit = this.unit.valueOf(map, row);
unit = this.unit.valueOf(map, row, mf);
mf.resetValue();
}
// TODO: use type of column this.value to infer value type
Object val = null;
if( this.value != null ){
......
......@@ -32,8 +32,13 @@ public class TestValidator {
v.setErrorHandler(e -> {throw new RuntimeException(e);});
Streams.transfer(os, v);
}catch( RuntimeException e ){
Assert.assertTrue(e.getCause() instanceof DuplicatePatientException);
return;
if( e.getCause() instanceof DuplicatePatientException ){
// expected behaviour
return;
}else{
// unexpected exceptoin
throw e;
}
}
Assert.fail("Exception expected");
}
......
......@@ -86,7 +86,7 @@
<start column="zeitpunkt" format="d.M.u[ H[:m[:s]]]" na="" />
</concept>
<concept id="bun">
<value column="bun\ /,.]+" na="" xsi:type="decimal"/>
<value column="bun\ /,.]+" na="@" xsi:type="decimal" na-action="drop-fact" />
</concept>
</mdat>
......
patid fallnr zeitpunkt na k co2 cl glucose ca bun\ /,.]+ creatinine en
p1 v1 01.01.2010 124 5.8 25 101 107 10.1 17 0.9 1
p1 v2 02.01.2010 123 5.7 28 101 106 9.8 15 1.3 2
p2 v3 03.01.2010 124 5.8 25 101 107 10.1 17 0.9 1
p2 v3 03.01.2010 124 5.8 25 101 107 10.1 @ 0.9 1
p3 v4 124 5.8 25 101 107 10.1 17 0.9 1
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