diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/input/FactRelatedQueryHandler.java b/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/input/FactRelatedQueryHandler.java index c568d7ed..015e10b4 100755 --- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/input/FactRelatedQueryHandler.java +++ b/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/input/FactRelatedQueryHandler.java @@ -690,8 +690,10 @@ public String buildQuery(PanelType panel, String pdoType) // String mainQuerySql = "SELECT a.* " + mainSelectBlobClause + " FROM " // + this.getDbSchemaName() + "observation_FACT obs ,( \n"; - String mainQuerySql = "SELECT a.* " + mainSelectBlobClause + " FROM " - + this.getDbSchemaName() + getFactTable() + " obs ,( \n"; + String mainQuerySql = obsFactFactRelated.isSelectBlob() ? + "SELECT a.* " + mainSelectBlobClause + " FROM " + this.getDbSchemaName() + getFactTable() + " obs ,( \n" + + : "( \n"; try { if (panel != null) { @@ -720,10 +722,17 @@ public String buildQuery(PanelType panel, String pdoType) throw new I2B2DAOException(i2b2Ex.getMessage(), i2b2Ex); } - mainQuerySql += " ) a "; - - mainQuerySql += " where obs.encounter_num = a.obs_encounter_num and obs.patient_num = a.obs_patient_num "; - mainQuerySql += " and obs.concept_cd = a.obs_concept_cd and obs.provider_id = a.obs_provider_id and obs.start_date = a.obs_start_date and obs.modifier_cd = a.obs_modifier_cd and obs.instance_num = a.obs_instance_num "; + mainQuerySql += obsFactFactRelated.isSelectBlob() ? + " ) a " + + " where obs.encounter_num = a.obs_encounter_num " + + " and obs.patient_num = a.obs_patient_num " + + " and obs.concept_cd = a.obs_concept_cd " + + " and obs.provider_id = a.obs_provider_id " + + " and obs.start_date = a.obs_start_date " + + " and obs.modifier_cd = a.obs_modifier_cd " + + " and obs.instance_num = a.obs_instance_num " + + : " ) "; if (panel != null) { TotalItemOccurrences totOccurance = panel.getTotalItemOccurrences();