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

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

parent f3fc3461
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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);
		}
	}
+7 −0
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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 ){
+9 −0
Original line number Diff line number Diff line
@@ -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());
		}
	}

}
+1 −1
Original line number Diff line number Diff line
@@ -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 -->

Loading