Commit 4f406301 authored by R.W.Majeed's avatar R.W.Majeed

Parsing and test of observation endDate, location

parent c420b26f
......@@ -33,6 +33,7 @@ public interface Observation extends ConceptValuePair, ExternalSourceType{
<T> void setExtension(Class<T> extensionType, T extension) throws IllegalArgumentException;
void setEncounterId(String encounterId);
void setLocationId(String locationId);
boolean hasModifiers();
Modifier getModifier(String modifierId);
......
......@@ -158,6 +158,11 @@ public class ObservationImpl implements Observation{
return m;
}
@Override
public void setLocationId(String locationId) {
this.locationId = locationId;
}
}
......@@ -289,6 +289,10 @@ public class FlatObservationProvider extends AbstractObservationParser implement
fact.setSourceId(sourceId);
fact.setSourceTimestamp(sourceTimestamp);
fact.setValue( parseValue(record) );
if( record.getEndDate() != null ){
fact.setEndTime(DateTimeAccuracy.parsePartialIso8601(record.getEndDate()));
}
fact.setLocationId(record.getLocation());
if( ts == sourceTs ){
// try to use visit timestamp
......
......@@ -94,7 +94,7 @@ class XMLObservationParser extends AbstractObservationParser{
fact = factory.createObservation(visitData.get("patid"), atts.getValue("concept"), start);
// set encounter id to visitData.get("encounter")
fact.setEncounterId(visitData.get("encounter"));
fact.setLocationId(atts.getValue("location"));
// set source information
fact.setSourceId(sourceId);
fact.setSourceTimestamp(sourceTimestamp);
......@@ -174,6 +174,7 @@ class XMLObservationParser extends AbstractObservationParser{
fact.setEndTime(DateTimeAccuracy.parsePartialIso8601(ts));
}
}
protected void parseSource(AttributeAccessor atts){
......
......@@ -81,6 +81,21 @@ public class FileObservationProviderTest {
Assert.assertEquals(new BigDecimal("123.456"), o.getValue().getNumericValue());
Assert.assertEquals("mm", o.getValue().getUnits());
},
(Observation o) -> {
Assert.assertEquals("T:full", o.getConceptId());
Assert.assertEquals(Value.Type.Numeric, o.getValue().getType());
Assert.assertEquals(new BigDecimal("123.456"), o.getValue().getNumericValue());
Assert.assertEquals("mm", o.getValue().getUnits());
Assert.assertEquals(ChronoUnit.YEARS, o.getStartTime().getAccuracy());
Assert.assertEquals(2010, o.getStartTime().getLong(ChronoField.YEAR));
Assert.assertEquals(ChronoUnit.YEARS, o.getEndTime().getAccuracy());
Assert.assertEquals(2011, o.getEndTime().getLong(ChronoField.YEAR));
Assert.assertEquals("T:LOC", o.getLocationId());
// TODO test provider, flag
},
(Observation o) -> {
Assert.assertEquals("T:group:1", o.getConceptId());
Assert.assertEquals(Value.Type.None, o.getValue().getType());
......
......@@ -36,6 +36,7 @@
<eav-item concept="T:type:int" type="xsi:integer">123</eav-item>
<!-- value attributes can be used in elements eav-item and value -->
<eav-item concept="T:type:dec" type="xsi:decimal" unit="mm" flag="A">123.456</eav-item>
<eav-item concept="T:full" start="2010" end="2011" type="xsi:decimal" unit="mm" flag="A" location="T:LOC">123.456</eav-item>
<!--
<eav-item concept="T:type:enum" type="xsi:integer">1</eav-item>
-->
......
......@@ -35,6 +35,7 @@ XX12345 XXE12345 T:type:str str abc123
XX12345 XXE12345 T:type:int int 123
# value attributes can be used in elements eav-item and value -->
XX12345 XXE12345 T:type:dec dec 123.456 mm
XX12345 XXE12345 T:full dec 123.456 mm 2010 2011 T:PROV T:LOC A
# test group items
#@group(start)
XX12345 XXE12345 T:group: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