* Some optional columns are used: active_status_cd, start_date, end_date, inout_cd, location_cd, sourcesystem_cd
* <p>
* XXX after loading encounters, the String patientId not set anymore and always null. To determine the patientId, the patientStore is required for lookup of the patientNum
* TODO use encounter_mapping table to map actual (source) patient_ide to internal patient_num for facts.
* <p>
* The variable argument list for {@link #createInstance(Object...)} requires the following arguments:
@@ -137,14 +138,14 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
db.setAutoCommit(true);
prepareStatements();
loadMaxEncounterNum();
batchLoad();
batchLoad();/// XXX loading visits does not set the String patientId, for that, the patientStore would be needed
@@ -451,12 +456,17 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
// commonly, the item is modified after a call to this method,
// but changes are written later via a call to update.
// (otherwise, the instance would need to know whether to perform INSERT or UPDATE)
}elseif(rejectPatientChange){
}else{
// 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
thrownewAssertionError("Patient_num mismatch between observation and visit",null);
if(rejectPatientChange){
thrownewAssertionError("Patient_num mismatch for visit "+encounterId+": history says "+visit.getPatientNum()+" while data says "+patient.getNum(),null);
}else{
log.info("Updating visit #"+visit.getNum()+" for patient change from #"+visit.getPatientNum()+" to #"+patient.getNum());