Commit d18591ff authored by R.W.Majeed's avatar R.W.Majeed

verify patient id for visit retrieval and throw error on mismatch

parent b94854d2
...@@ -77,6 +77,7 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements ...@@ -77,6 +77,7 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
//private static char[] map_death_chars = {}; //private static char[] map_death_chars = {};
private Hashtable<Integer, I2b2Visit> visitCache; private Hashtable<Integer, I2b2Visit> visitCache;
private Hashtable<String, I2b2Visit> idCache; private Hashtable<String, I2b2Visit> idCache;
private boolean verifyPatientId;
private PreparedStatement insert; private PreparedStatement insert;
private PreparedStatement insertMapping; private PreparedStatement insertMapping;
...@@ -121,6 +122,7 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements ...@@ -121,6 +122,7 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
this.idSourceDefault = "HIVE"; this.idSourceDefault = "HIVE";
this.idSourceSeparator = ':'; this.idSourceSeparator = ':';
this.fetchSize = 1000; this.fetchSize = 1000;
this.verifyPatientId = true;
} }
public void open(Connection connection, String projectId) throws SQLException{ public void open(Connection connection, String projectId) throws SQLException{
visitCache = new Hashtable<>(); visitCache = new Hashtable<>();
...@@ -452,11 +454,19 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements ...@@ -452,11 +454,19 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
// commonly, the item is modified after a call to this method, // commonly, the item is modified after a call to this method,
// but changes are written later via a call to update. // but changes are written later via a call to update.
// (otherwise, the instance would need to know whether to perform INSERT or UPDATE) // (otherwise, the instance would need to know whether to perform INSERT or UPDATE)
}else if( verifyPatientId ){
// visit already existing
// verify that the patient number from the visit matches with the observation
if( visit.getPatientNum() != patient.getNum() ){
// throw exception to abort processing
throw new AssertionError("Patient_num mismatch between observation and visit", null);
}
} }
return visit; return visit;
} }
@Override @Override
public I2b2Visit createInstance(Observation fact) { public I2b2Visit createInstance(Observation fact){
return getOrCreateInstance(fact.getEncounterId(), fact.getExtension(I2b2Patient.class), fact.getSource()); return getOrCreateInstance(fact.getEncounterId(), fact.getExtension(I2b2Patient.class), fact.getSource());
} }
......
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