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

Fill observation from context as methodÃ

parent 5d8301bc
......@@ -351,5 +351,36 @@ public class ObservationImpl implements Observation, Cloneable{
this.source = s;
}
}
/**
* Fill some information from the provided context
* @param patientId patient context
* @param encounterId visit context
* @param startTime start time context
* @param source source context
*/
public void fillFromContext(String patientId, String encounterId, DateTimeAccuracy startTime, ExternalSourceType source) {
if( this.source == null ){
setSource(source);
}else if( source != null ){
if( this.source.getSourceId() == null && source.getSourceId() != null ){
this.source.setSourceId(source.getSourceId());
}
if( this.source.getSourceTimestamp() == null && source.getSourceTimestamp() != null ){
this.source.setSourceTimestamp(source.getSourceTimestamp());
}
}
if( this.patientId == null ){
setPatientId(patientId);
}
if( this.encounterId == null ){
setEncounterId(encounterId);
}
if( this.startTime == null ){
this.startTime = startTime;
}
}
}
......@@ -215,24 +215,8 @@ public class JAXBObservationSupplier implements ObservationSupplier {
throw new XMLStreamException("Fact patid differs from patient id", reader.getLocation());
}
if( fact.getSource() == null ){
fact.setSource(meta.source);
}else{
if( fact.getSource().getSourceId() == null && meta.source.getSourceId() != null ){
fact.getSource().setSourceId(meta.source.getSourceId());
}
if( fact.getSource().getSourceTimestamp() == null && meta.source.getSourceTimestamp() != null ){
fact.getSource().setSourceTimestamp(meta.source.getSourceTimestamp());
}
}
fact.fillFromContext(patientId, encounterId, encounterStart, meta.source);
fact.setPatientId(patientId);
fact.setEncounterId(encounterId);
if( fact.getStartTime() == null ){
fact.setStartTime(encounterStart);
fact.setEndTime(encounterEnd);
}
// TODO set etc. from visit
// set ObservationFactory, initialize extensions
......
......@@ -190,6 +190,12 @@ public class ObservationImplJAXBTest {
o.removeContext(null, null, new ExternalSourceImpl("source1", Instant.parse("2000-01-01T00:00:00Z")));
Assert.assertNull(o.getSource());
}
@Test
public void testFillContext(){
// TODO implement test
}
/*
@Test
public void testModifierListBug() throws JAXBException{
......
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