Commit 2145a3b4 authored by R.W.Majeed's avatar R.W.Majeed

#feature facts with missing/na start timestamps will use the visit start timestamp

parent f3fc3461
......@@ -187,6 +187,12 @@ public class FactGroupingQueue implements Supplier<Observation>{
// set patient extension
patientLookup.assignPatient(f, currentPatientInstance);
visitLookup.assignVisit(f, currentVisitInstance);
// use visit start date if there is no start date in the observation
if( f.getStartTime() == null && currentVisitInstance != null ){
f.setStartTime(currentVisitInstance.getStartTime());
}
// TODO throw error/warning for facts without start date???
workQueue.add(f);
}
}
......
......@@ -96,6 +96,13 @@ public class Concept{
if( mf.isActionDrop() ){
return null; // ignore this fact
}
// if start is null/na, use visit start timestamp
if( start == null ){
// start may be null at this point and will be filled later with the visit timestamp
// see FactGroupingQueue#addFactsToWorkQueue(FactRow)
}
Observation o = factory.createObservation(patid, concept, start);
if( visit != null ){
o.setEncounterId(visit);
......
......@@ -168,6 +168,11 @@ public class EavTable extends Table<EavRow> {
vval = null;
}
if( start == null ){
// start may be null at this point and will be filled later with the visit timestamp
// see FactGroupingQueue#addFactsToWorkQueue(FactRow)
}
Observation fact = factory.createObservation(patid, concept, start);
String visit = idat.visitId.valueOf(colMap, row);
if( visit != null ){
......
......@@ -133,4 +133,13 @@ public class TestETLSupplier {
Assert.assertEquals("v1", v.getId());
Assert.assertEquals(null, v.getLocationId());
}
@Test
public void missingStartTimestampUsesVisitTimestamp() throws IOException, java.text.ParseException{
List<Observation> all = new ArrayList<>();
os.stream().filter( o -> o.getConceptId().equals("natrium") ).forEach(all::add);
for( Observation o : all ){
System.out.println("Natrium-start: "+o.getStartTime());
}
}
}
......@@ -109,7 +109,7 @@
</idat>
<mdat>
<concept column="param"/>
<start column="start_ts" format="u-M-d"/>
<start column="start_ts" format="u-M-d" na="@"/>
<end column="end" format="u-M-d" na="@"/>
<!-- location -->
......
......@@ -15,7 +15,7 @@ p1 v2 L1 u1 f_eav_f 2013-08-18 @ decimal 20.6 @
p1 v2 L1 u1 f_eav_i 2013-08-18 @ decimal 0.36 @
p1 v2 L1 u1 f_eav_l 2013-08-18 @ decimal 1.3 @
p1 v2 L1 u1 f_eav_v 2013-08-18 @ decimal 3.8 @
p1 v2 L1 u1 f_eav_x 2013-08-18 @ integer 0 @
p1 v2 L1 u1 f_eav_x @ @ integer 0 @
p2 v3 L1 u1 f_eav_b 2013-08-24 @ decimal 4.7 @
p2 v3 L1 u1 f_eav_c 2013-08-24 @ decimal 6.9 @
p2 v3 L1 u1 f_eav_d 2013-08-24 @ decimal 56.1 @
......
patid fallnr zeitpunkt na k co2 cl glucose ca bun creatinine en
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
p3 v4 04.01.2010 124 5.8 25 101 107 10.1 17 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