Commit 381b966a authored by R.W.Majeed's avatar R.W.Majeed

allow widetable immplementations without patient id column. in these cases,...

allow widetable immplementations without patient id column. in these cases, only visit id is used for matching
parent 1dd487ac
...@@ -251,7 +251,10 @@ public class FactGroupingQueue implements Supplier<Observation>{ ...@@ -251,7 +251,10 @@ public class FactGroupingQueue implements Supplier<Observation>{
currentRows.remove(tableIndex); currentRows.remove(tableIndex);
factTables.remove(tableIndex); factTables.remove(tableIndex);
continue; // index will now point to next table continue; // index will now point to next table
}else if( row.getPatientId().equals(currentPatient.getPatientId()) && compareWithNulls(row.getVisitId(), currentVisitId) == 0 ){ }if( (row.getPatientId() == null || row.getPatientId().equals(currentPatient.getPatientId())) && compareWithNulls(row.getVisitId(), currentVisitId) == 0 ){
// if the row does not have a patient id, it is assumed that the visit id is unique and sufficient for matching
// if the row has both patient id and visit id, both are used for matching
// row fits into current group // row fits into current group
addFactsToWorkQueue(row); addFactsToWorkQueue(row);
// prefetch next row // prefetch next row
......
...@@ -24,13 +24,15 @@ public class WideTable extends Table<WideRow> implements ConceptTable{ ...@@ -24,13 +24,15 @@ public class WideTable extends Table<WideRow> implements ConceptTable{
ColumnMap map = new ColumnMap(headers); ColumnMap map = new ColumnMap(headers);
if( idat.patientId == null ){ if( idat.patientId == null ){
throw new ParseException("datasource/wide-table/idat/patient-id column not specified"); // missing patientId column is allowed. In these cases visitId should be unique for identification
// TODO write INFO message that patient-id is not available and visit-id is used for matching
}else {
map.registerColumn(idat.patientId);
} }
if( idat.visitId == null ){ if( idat.visitId == null ){
throw new ParseException("datasource/wide-table/idat/visit-id column not specified"); throw new ParseException("datasource/wide-table/idat/visit-id column not specified");
} }
map.registerColumn(idat.patientId);
map.registerColumn(idat.visitId); map.registerColumn(idat.visitId);
for( Concept c : concepts ){ for( Concept c : concepts ){
...@@ -45,8 +47,16 @@ public class WideTable extends Table<WideRow> implements ConceptTable{ ...@@ -45,8 +47,16 @@ public class WideTable extends Table<WideRow> implements ConceptTable{
@Override @Override
public WideRow fillRecord(ColumnMap map, Object[] row, ObservationFactory factory) throws ParseException { public WideRow fillRecord(ColumnMap map, Object[] row, ObservationFactory factory) throws ParseException {
String patid = idat.patientId.valueOf(map, row);
String visit = idat.visitId.valueOf(map, row); String visit = idat.visitId.valueOf(map, row);
String patid;
if( idat.patientId == null ) {
// if there is no patient id in this table,
// we can get the patient id by lookup by visit
System.out.println("No patient");
patid = null;
}else {
patid = idat.patientId.valueOf(map, row);
}
WideRow rec = new WideRow(patid,visit); WideRow rec = new WideRow(patid,visit);
for( Concept c : concepts ){ for( Concept c : concepts ){
Observation o = c.createObservation(patid, visit, factory, map, row); Observation o = c.createObservation(patid, visit, factory, map, row);
......
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