Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for NullPointerException and org.postgresql.util.PSQLException: ER… #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ public EidSet getEidByEncounterNum(List<String> encounterNumList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "encounter_mapping em WHERE em.encounter_num IN (select distinct char_param1 FROM "
+ SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "encounter_mapping em WHERE em.encounter_num IN (select distinct CAST (char_param1 AS INTEGER) FROM ";
} else {
finalSql += "encounter_mapping em WHERE em.encounter_num IN (select distinct char_param1 FROM ";
}
finalSql += SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ ") order by em_encounter_num";
log.debug("Size of the encounter list "
+ encounterNumList.size());
Expand Down Expand Up @@ -532,9 +536,13 @@ public EidSet getEidByFact(List<String> panelSqlList,
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "encounter_mapping em "
+ " where encounter_num in (select distinct char_param1 from "
+ tempTable + ") order by encounter_num";
+ "encounter_mapping em ";
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += " where encounter_num in (select distinct CAST (char_param1 AS INTEGER) from ";
} else {
finalSql += " where encounter_num in (select distinct char_param1 from ";
}
finalSql += tempTable + ") order by encounter_num";
log.debug("Executing SQL [" + finalSql + "]");
System.out.println("Final Sql " + finalSql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ else if (dataSourceLookup.getServerType().equalsIgnoreCase(
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "patient_dimension patient WHERE patient.patient_num IN (select distinct char_param1 FROM "
+ tempTableName + ") order by patient_num";
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "patient_dimension patient WHERE patient.patient_num IN (select distinct CAST (char_param1 AS INTEGER) FROM ";
} else {
finalSql += "patient_dimension patient WHERE patient.patient_num IN (select distinct char_param1 FROM ";
}
finalSql += tempTableName + ") order by patient_num";
log.debug("Executing [" + finalSql + "]");

query = conn.prepareStatement(finalSql);
Expand Down Expand Up @@ -475,9 +479,13 @@ public PatientSet getPatientByFact(List<String> panelSqlList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "patient_dimension patient where patient_num in (select distinct char_param1 from "
+ factTempTable + ") order by patient_num";
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "patient_dimension patient where patient_num in (select distinct CAST (char_param1 AS INTEGER) from ";
} else {
finalSql += "patient_dimension patient where patient_num in (select distinct char_param1 from ";
}
finalSql += factTempTable + ") order by patient_num";
log.debug("Executing SQL [" + finalSql + "]");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ public PidSet getPidByPatientNum(List<String> patientNumList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "patient_mapping pm WHERE pm.patient_num IN (select distinct char_param1 FROM "
+ SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "patient_mapping pm WHERE pm.patient_num IN (select distinct CAST (char_param1 AS INTEGER) FROM ";
} else {
finalSql += "patient_mapping pm WHERE pm.patient_num IN (select distinct char_param1 FROM ";
}
finalSql += SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ ") order by pm_patient_num";
log.debug("Executing [" + finalSql + "]");

Expand All @@ -136,9 +140,13 @@ public PidSet getPidByPatientNum(List<String> patientNumList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "patient_mapping pm WHERE pm.patient_num IN (select distinct char_param1 FROM "
+ SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1)
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "patient_mapping pm WHERE pm.patient_num IN (select distinct CAST( char_param1 AS INTEGER) FROM ";
} else {
finalSql += "patient_mapping pm WHERE pm.patient_num IN (select distinct char_param1 FROM ";
}
finalSql += SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1)
+ ") order by pm_patient_num";
log.debug("Executing [" + finalSql + "]");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ public EventSet getVisitsByEncounterNum(List<String> encounterNumList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "visit_dimension visit WHERE visit.encounter_num IN (select distinct char_param1 FROM "
+ tempTableName + ") order by encounter_num";
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "visit_dimension visit WHERE visit.encounter_num IN (select distinct CAST (char_param1 AS INTEGER) FROM ";
} else {
finalSql += "visit_dimension visit WHERE visit.encounter_num IN (select distinct char_param1 FROM ";
}
finalSql += tempTableName + ") order by encounter_num";
log.debug("Executing [" + finalSql + "]");

query = conn.prepareStatement(finalSql);
Expand Down Expand Up @@ -420,9 +424,13 @@ public EventSet getVisitByFact(List<String> panelSqlList,
String finalSql = "SELECT "
+ selectClause
+ " FROM "
+ getDbSchemaName()
+ "visit_dimension visit where encounter_num in (select distinct char_param1 from "
+ factTempTable + ") order by encounter_num";
+ getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += "visit_dimension visit where encounter_num in (select distinct CAST (char_param1 AS INTEGER) from ";
} else {
finalSql += "visit_dimension visit where encounter_num in (select distinct char_param1 from ";
}
finalSql += factTempTable + ") order by encounter_num";
log.debug("Executing SQL [" + finalSql + "]");
System.out.println("Final Sql " + finalSql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ public PatientSet getPatientByPatientNum(List<String> patientNumList,
+ " FROM "
+ getDbSchemaName()
+ "patient_dimension patient "
+ joinClause
+ " WHERE patient.patient_num IN (select distinct char_param1 FROM "
+ tempTableName + ") order by patient_num";
+ joinClause;
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += " WHERE patient.patient_num IN (select distinct CAST (char_param1 AS INTEGER) FROM ";
} else {
finalSql += " WHERE patient.patient_num IN (select distinct char_param1 FROM ";
}
finalSql += tempTableName + ") order by patient_num";
log.debug("Executing [" + finalSql + "]");

query = conn.prepareStatement(finalSql);
Expand Down Expand Up @@ -585,9 +589,13 @@ public PatientSet getPatientByFact(List<String> panelSqlList,
+ " FROM "
+ getDbSchemaName()
+ "patient_dimension patient "
+ joinClause
+ " where patient_num in (select distinct char_param1 from "
+ factTempTable + ") order by patient_num";
+ joinClause;
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
finalSql += " where patient_num in (select distinct CAST (char_param1 AS INTEGER) from ";
} else {
finalSql += " where patient_num in (select distinct char_param1 from ";
}
finalSql += factTempTable + ") order by patient_num";
log.debug("Executing SQL [" + finalSql + "]");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ public String generateWhereClauseSql() {

// set sql string
sqlString = "select pset.patient_num from "
+ this.getDbSchemaName()
+ "qt_patient_set_collection pset where pset.result_instance_id = ? ";
+ this.getDbSchemaName();
if (dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
sqlString += "qt_patient_set_collection pset where pset.result_instance_id = CAST ( ? AS INTEGER) ";
} else {
sqlString += "qt_patient_set_collection pset where pset.result_instance_id = ? ";
}

if (minIndex <= maxIndex) {
sqlString += (" and pset.set_index between " + minIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ private String buildQueryCommon(PanelType panel, String pdoType)
}


if (this.outputOptionList.getObservationSet().getSelectionfilter()!= null)
if (this.outputOptionList!=null && this.outputOptionList.getObservationSet()!=null &&
this.outputOptionList.getObservationSet().getSelectionfilter()!= null)
{
//mainQuerySql = "with main_query as (" + mainQuerySql + ") select * from (select f1.*, " +
String newMainQuerySql = "select * from (select f1.*, " +
Expand Down