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

removed ExternalSourceType interface from Observation

parent f818d3d1
......@@ -116,9 +116,10 @@ public class I2b2Inserter extends AbstractObservationHandler implements Observat
}
@Override
public void preprocess(Observation fact) throws SQLException {
if( !purgedSources.contains(fact.getSourceId()) ){
purgedSources.add(fact.getSourceId());
purgeSource(fact.getSourceId());
String sourceId = fact.getSource().getSourceId();
if( !purgedSources.contains(sourceId) ){
purgedSources.add(sourceId);
purgeSource(sourceId);
}
}
......@@ -362,8 +363,8 @@ public class I2b2Inserter extends AbstractObservationHandler implements Observat
// location_cd
insertFact.setString(14, replaceNull(o.getLocationId(),nullLocationCd));
// download_date
insertFact.setTimestamp(15, Timestamp.from(o.getSourceTimestamp()));
insertFact.setString(16, o.getSourceId());
insertFact.setTimestamp(15, Timestamp.from(o.getSource().getSourceTimestamp()));
insertFact.setString(16, o.getSource().getSourceId());
insertFact.executeUpdate();
......
......@@ -621,7 +621,7 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
@Override
public I2b2Patient createInstance(Observation fact) {
return getOrCreateInstance(fact.getPatientId(), fact);
return getOrCreateInstance(fact.getPatientId(), fact.getSource());
}
@Override
......
......@@ -568,7 +568,7 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit>{
}
@Override
public I2b2Visit createInstance(Observation fact) {
return getOrCreateInstance(fact.getEncounterId(), fact.getExtension(I2b2Patient.class), fact);
return getOrCreateInstance(fact.getEncounterId(), fact.getExtension(I2b2Patient.class), fact.getSource());
}
@Override
......
......@@ -34,7 +34,7 @@ import de.sekmi.histream.ext.ExternalSourceType;
* @author Raphael
*
*/
public interface Observation extends ConceptValuePair, ExternalSourceType{
public interface Observation extends ConceptValuePair{
String getPatientId();
String getEncounterId();
String getProviderId();
......@@ -43,6 +43,9 @@ public interface Observation extends ConceptValuePair, ExternalSourceType{
@Override
String getConceptId();
public ExternalSourceType getSource();
public void setSource(ExternalSourceType source);
/**
* Replace the concept id. All modifiers will be removed from the observation.
* @param newConceptId new concept id
......
......@@ -39,6 +39,7 @@ import de.sekmi.histream.Modifier;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ObservationFactory;
import de.sekmi.histream.Value;
import de.sekmi.histream.ext.ExternalSourceType;
/**
* Implementation of {@link Observation}.
......@@ -50,7 +51,7 @@ import de.sekmi.histream.Value;
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(propOrder={"abstractValue","modifierList"})
@XmlSeeAlso({StringValue.class,NumericValue.class})
public class ObservationImpl extends ExternalSourceImpl implements Observation{
public class ObservationImpl implements Observation{
public static final String XML_NAMESPACE="http://sekmi.de/histream/ns/eav-data";
@XmlTransient
protected ObservationFactoryImpl factory;
......@@ -79,6 +80,8 @@ public class ObservationImpl extends ExternalSourceImpl implements Observation{
@XmlAttribute(name="end")
protected DateTimeAccuracy endTime;
// TODO make compatible with JAXB
protected ExternalSourceType source;
/**
* Modifiers
*/
......@@ -270,6 +273,16 @@ public class ObservationImpl extends ExternalSourceImpl implements Observation{
}
@Override
public ExternalSourceType getSource() {
return source;
}
@Override
public void setSource(ExternalSourceType source) {
this.source = source;
}
}
......@@ -50,7 +50,7 @@ public class SimplePatientExtension implements Extension<PatientImpl>{
@Override
public PatientImpl createInstance(Observation observation) {
PatientImpl patient = createInstance(observation.getPatientId(), observation);
PatientImpl patient = createInstance(observation.getPatientId(), observation.getSource());
return patient;
}
......
......@@ -54,7 +54,7 @@ public class SimpleVisitExtension implements Extension<VisitImpl>{
@Override
public VisitImpl createInstance(Observation observation) {
VisitImpl visit = createInstance(observation.getEncounterId(), observation.getExtension(Patient.class), observation);
VisitImpl visit = createInstance(observation.getEncounterId(), observation.getExtension(Patient.class), observation.getSource());
//visit.setId();
//visit.setPatientId(observation.getPatientId());
//visit.setSourceId(observation.getSourceId());
......
......@@ -337,8 +337,7 @@ public class FlatObservationSupplier extends AbstractObservationParser implement
patientAccessor.set(fact, currentPatient);
visitAccessor.set(fact, currentVisit);
// set other fields
fact.setSourceId(sourceId);
fact.setSourceTimestamp(sourceTimestamp);
fact.setSource(this);
fact.setValue( parseValue(record) );
if( record.getEndDate() != null ){
......
......@@ -119,8 +119,7 @@ class XMLObservationParser extends AbstractObservationParser{
fact.setEncounterId(visitData.get("encounter"));
fact.setLocationId(atts.getValue("location"));
// set source information
fact.setSourceId(sourceId);
fact.setSourceTimestamp(sourceTimestamp);
fact.setSource(this);
if( patient == null ){
// this is the first observation
......
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