metaParamIterator = metaDataParamList.iterator(); metaParamIterator.hasNext();) {
+ ParamType metaParamType = metaParamIterator.next();
+ ParamTypeValueBuilder paramValBuilder = new ParamTypeValueBuilder();
+ visitDimensionType.getParam().add(paramValBuilder.buildParamType(metaParamType,"visit_",null,rowSet));
+ }
+
+ }
+
+ if (eventBlobFlag) {
+ if (dbType.equalsIgnoreCase("POSTGRESQL"))
+ {
+ String clob = rowSet.getString("visit_visit_blob");
+ if (clob !=null)
+ {
+ BlobType blobType = new BlobType();
+ blobType.getContent().add(clob);
+ visitDimensionType.setEventBlob(blobType);
+
+ }
+
+ } else {
+
+ Clob visitClob = rowSet.getClob("visit_visit_blob");
+
+ if (visitClob != null) {
+ BlobType visitBlobType = new BlobType();
+ visitBlobType.getContent().add(
+ JDBCUtil.getClobStringWithLinebreak(visitClob));
+ visitDimensionType.setEventBlob(visitBlobType);
+ }
+ }
+ }
+
+
+
+
+ if (eventStatusFlag) {
+ if (rowSet.getTimestamp("visit_update_date") != null) {
+ visitDimensionType.setUpdateDate(dtoFactory
+ .getXMLGregorianCalendar(rowSet.getTimestamp(
+ "visit_update_date").getTime()));
+ }
+
+ if (rowSet.getTimestamp("visit_download_date") != null) {
+ visitDimensionType.setDownloadDate(dtoFactory
+ .getXMLGregorianCalendar(rowSet.getTimestamp(
+ "visit_download_date").getTime()));
+ }
+
+ if (rowSet.getTimestamp("visit_import_date") != null) {
+ visitDimensionType.setImportDate(dtoFactory
+ .getXMLGregorianCalendar(rowSet.getTimestamp(
+ "visit_import_date").getTime()));
+ }
+
+ visitDimensionType.setSourcesystemCd(rowSet
+ .getString("visit_sourcesystem_cd"));
+ visitDimensionType.setUploadId(rowSet
+ .getString("visit_upload_id"));
+ }
+
+ return visitDimensionType;
+ }
+ }
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java
index 81bb7743..d618d8e7
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IMetadataDao.java
@@ -1,19 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.Map;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-
-public interface IMetadataDao {
-
- public Map getMetadataForOptionalField(String tableName) throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.Map;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+
+public interface IMetadataDao {
+
+ public Map getMetadataForOptionalField(String tableName) throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java
index ad6c5ed2..65f44660
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IObservationFactDao.java
@@ -1,32 +1,32 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.exception.I2B2Exception;
-import edu.harvard.i2b2.crc.datavo.pdo.query.FactPrimaryKeyType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.OutputOptionType;
-
-public interface IObservationFactDao {
-
- /**
- * Function returns Observation fact from the primary key.
- * Required fields : patient_num, concept_cd, encounter_num
- *
Optional field : provider_id,start_date
- * @param factPrimaryKey
- * @param factOutputOption
- * @return PatientDataType
- * @throws I2B2Exception
- */
- public PatientDataType getObservationFactByPrimaryKey(
- FactPrimaryKeyType factPrimaryKey, OutputOptionType factOutputOption)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.exception.I2B2Exception;
+import edu.harvard.i2b2.crc.datavo.pdo.query.FactPrimaryKeyType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.OutputOptionType;
+
+public interface IObservationFactDao {
+
+ /**
+ * Function returns Observation fact from the primary key.
+ *
Required fields : patient_num, concept_cd, encounter_num
+ *
Optional field : provider_id,start_date
+ * @param factPrimaryKey
+ * @param factOutputOption
+ * @return PatientDataType
+ * @throws I2B2Exception
+ */
+ public PatientDataType getObservationFactByPrimaryKey(
+ FactPrimaryKeyType factPrimaryKey, OutputOptionType factOutputOption)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java
index c4b9c070..e34f7b39
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPageDao.java
@@ -1,34 +1,34 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.HashMap;
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PanelType;
-
-public interface IPageDao {
-
- public long getTotalForAllPanel(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler)
- throws I2B2DAOException;
-
- public String buildTotalSql(IFactRelatedQueryHandler factHandler,
- PanelType panel) throws I2B2DAOException;
-
- public HashMap getMinIndexAndCountAllPanel(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.HashMap;
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IFactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PanelType;
+
+public interface IPageDao {
+
+ public long getTotalForAllPanel(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler)
+ throws I2B2DAOException;
+
+ public String buildTotalSql(IFactRelatedQueryHandler factHandler,
+ PanelType panel) throws I2B2DAOException;
+
+ public HashMap getMinIndexAndCountAllPanel(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java
index bf852bed..f3fbc476
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryConceptDao.java
@@ -1,63 +1,63 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-
-public interface IPdoQueryConceptDao {
-
- /**
- * Get concepts detail from concept code list
- *
- * @param conceptCdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return {@link PatientDataType.ConceptDimensionSet}
- * @throws I2B2DAOException
- */
- public ConceptSet getConceptByConceptCd(List conceptCdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get concept children by item key
- *
- * @param itemKey
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ConceptSet getChildrentByItemKey(String itemKey, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Get Concept set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ConceptSet getConceptByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
+
+public interface IPdoQueryConceptDao {
+
+ /**
+ * Get concepts detail from concept code list
+ *
+ * @param conceptCdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return {@link PatientDataType.ConceptDimensionSet}
+ * @throws I2B2DAOException
+ */
+ public ConceptSet getConceptByConceptCd(List conceptCdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get concept children by item key
+ *
+ * @param itemKey
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ConceptSet getChildrentByItemKey(String itemKey, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Get Concept set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ConceptSet getConceptByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java
index 9333b244..2eff76f1
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryEidDao.java
@@ -1,81 +1,81 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.EidSet;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EidListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-
-public interface IPdoQueryEidDao {
-
- /**
- * Get Eid set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public EidSet getEidByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return patient dimension data for given list of patient num
- *
- * @param patientNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- public EidSet getEidByEncounterNum(List encounterNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get Patient dimension data based on patientlist present in input option
- * list
- *
- * @param patientListType
- * {@link PatientListType}
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws I2B2DAOException
- */
- public EidSet getEidFromPatientSet(PatientListType patientListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Function to return patient dimension data for given list of pid list
- *
- * @param pidList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- public EidSet getEidByEidList(EidListType eidList, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.EidSet;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EidListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+
+public interface IPdoQueryEidDao {
+
+ /**
+ * Get Eid set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public EidSet getEidByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return patient dimension data for given list of patient num
+ *
+ * @param patientNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ public EidSet getEidByEncounterNum(List encounterNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get Patient dimension data based on patientlist present in input option
+ * list
+ *
+ * @param patientListType
+ * {@link PatientListType}
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws I2B2DAOException
+ */
+ public EidSet getEidFromPatientSet(PatientListType patientListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Function to return patient dimension data for given list of pid list
+ *
+ * @param pidList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ public EidSet getEidByEidList(EidListType eidList, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java
index 290551e8..ebbd28b8
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryModifierDao.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ModifierSet;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-
-public interface IPdoQueryModifierDao {
-
- /**
- * Get modifiers detail from modifier code list
- *
- * @param modifierCdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return {@link PatientDataType.ModifierDimensionSet}
- * @throws I2B2DAOException
- */
- public ModifierSet getModifierByModifierCd(List modifierCdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-
- /**
- * Get Modifier set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ModifierSet getModifierByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ModifierSet;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
+
+public interface IPdoQueryModifierDao {
+
+ /**
+ * Get modifiers detail from modifier code list
+ *
+ * @param modifierCdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return {@link PatientDataType.ModifierDimensionSet}
+ * @throws I2B2DAOException
+ */
+ public ModifierSet getModifierByModifierCd(List modifierCdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+
+ /**
+ * Get Modifier set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ModifierSet getModifierByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java
index a5aaed35..cfe0d6d5
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPatientDao.java
@@ -1,87 +1,87 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientSet;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-
-public interface IPdoQueryPatientDao {
-
- public void setMetaDataParamList(List metaDataParamList);
-
- /**
- * Get Patient set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public PatientSet getPatientByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return patient dimension data for given list of patient num
- *
- * @param patientNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- public PatientSet getPatientByPatientNum(List patientNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get Patient dimension data based on patientlist present in input option
- * list
- *
- * @param patientListType
- * {@link PatientListType}
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws I2B2DAOException
- */
- public PatientSet getPatientFromPatientSet(PatientListType patientListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get Patient dimension data based on visitlist present in input option
- * list
- *
- * @param eventListType
- * {@link EventListType}
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws I2B2DAOException
- */
- public PatientSet getPatientFromVisitSet(EventListType visitListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientSet;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+
+public interface IPdoQueryPatientDao {
+
+ public void setMetaDataParamList(List metaDataParamList);
+
+ /**
+ * Get Patient set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return patient dimension data for given list of patient num
+ *
+ * @param patientNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ public PatientSet getPatientByPatientNum(List patientNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get Patient dimension data based on patientlist present in input option
+ * list
+ *
+ * @param patientListType
+ * {@link PatientListType}
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientFromPatientSet(PatientListType patientListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get Patient dimension data based on visitlist present in input option
+ * list
+ *
+ * @param eventListType
+ * {@link EventListType}
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientFromVisitSet(EventListType visitListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java
index fe1d3970..31a98ebf
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryPidDao.java
@@ -1,81 +1,81 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.PidSet;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType;
-
-public interface IPdoQueryPidDao {
-
- /**
- * Get Pid set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public PidSet getPidByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return patient dimension data for given list of patient num
- *
- * @param patientNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- public PidSet getPidByPatientNum(List patientNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get Patient dimension data based on patientlist present in input option
- * list
- *
- * @param patientListType
- * {@link PatientListType}
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws I2B2DAOException
- */
- public PidSet getPidFromPatientSet(PatientListType patientListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Function to return patient dimension data for given list of pid list
- *
- * @param pidList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- public PidSet getPidByPidList(PidListType pidList, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.PidSet;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType;
+
+public interface IPdoQueryPidDao {
+
+ /**
+ * Get Pid set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public PidSet getPidByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return patient dimension data for given list of patient num
+ *
+ * @param patientNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ public PidSet getPidByPatientNum(List patientNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get Patient dimension data based on patientlist present in input option
+ * list
+ *
+ * @param patientListType
+ * {@link PatientListType}
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws I2B2DAOException
+ */
+ public PidSet getPidFromPatientSet(PatientListType patientListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Function to return patient dimension data for given list of pid list
+ *
+ * @param pidList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ public PidSet getPidByPidList(PidListType pidList, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java
index a990192b..2b62d0b3
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryProviderDao.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ObserverSet;
-
-public interface IPdoQueryProviderDao {
-
- /**
- * Get Observer set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ObserverSet getProviderByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return provider/observer section of plain pdo for the given
- * id list
- *
- * @param providerIdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.ProviderDimensionSet
- * @throws I2B2DAOException
- */
- public ObserverSet getProviderById(List providerIdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ObserverSet;
+
+public interface IPdoQueryProviderDao {
+
+ /**
+ * Get Observer set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ObserverSet getProviderByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return provider/observer section of plain pdo for the given
+ * id list
+ *
+ * @param providerIdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.ProviderDimensionSet
+ * @throws I2B2DAOException
+ */
+ public ObserverSet getProviderById(List providerIdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java
index 8e05afd8..d6812d96
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/IPdoQueryVisitDao.java
@@ -1,83 +1,83 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.EventSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-
-public interface IPdoQueryVisitDao {
-
-
-
- public void setMetaDataParamList(List metaDataParamList);
-
- /**
- * Get Visit set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public EventSet getVisitByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return list of eventset for given encounter number list
- *
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @exception I2B2DAOException
- */
- public EventSet getVisitsByEncounterNum(List encounterNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get visit dimension data base on visit list
- * (InputOptionList.getVisitListType())
- *
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return I2B2DAOException
- * @throws Exception
- */
- public EventSet getVisitDimensionSetFromVisitList(
- EventListType visitListType, boolean detailFlag, boolean blobFlag,
- boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Get visit dimension from patientlist (InputOptionList.getPatientList())
- *
- * @param patientListType
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.VisitDimensionSet
- * @throws I2B2DAOException
- */
- public EventSet getVisitDimensionSetFromPatientList(
- PatientListType patientListType, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.EventSet;
+import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+
+public interface IPdoQueryVisitDao {
+
+
+
+ public void setMetaDataParamList(List metaDataParamList);
+
+ /**
+ * Get Visit set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public EventSet getVisitByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return list of eventset for given encounter number list
+ *
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @exception I2B2DAOException
+ */
+ public EventSet getVisitsByEncounterNum(List encounterNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get visit dimension data base on visit list
+ * (InputOptionList.getVisitListType())
+ *
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return I2B2DAOException
+ * @throws Exception
+ */
+ public EventSet getVisitDimensionSetFromVisitList(
+ EventListType visitListType, boolean detailFlag, boolean blobFlag,
+ boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Get visit dimension from patientlist (InputOptionList.getPatientList())
+ *
+ * @param patientListType
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.VisitDimensionSet
+ * @throws I2B2DAOException
+ */
+ public EventSet getVisitDimensionSetFromPatientList(
+ PatientListType patientListType, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java
index 8f9c308d..5eba84b2
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryConceptDao.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
-
-public interface ITablePdoQueryConceptDao {
-
- /**
- * Get Concept set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ConceptSet getConceptByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function returns concepts based on list of concept codes
- *
- * @param conceptCdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return ConceptSet
- * @throws I2B2DAOException
- */
- public ConceptSet getConceptByConceptCd(List conceptCdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
+
+public interface ITablePdoQueryConceptDao {
+
+ /**
+ * Get Concept set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ConceptSet getConceptByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function returns concepts based on list of concept codes
+ *
+ * @param conceptCdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return ConceptSet
+ * @throws I2B2DAOException
+ */
+ public ConceptSet getConceptByConceptCd(List conceptCdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java
index d84395e5..514fb312
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryModifierDao.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ModifierSet;
-
-public interface ITablePdoQueryModifierDao {
-
- /**
- * Get Concept set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public ModifierSet getModifierByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function returns modifiers based on list of modifier codes
- *
- * @param modifierCdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return ModifierSet
- * @throws I2B2DAOException
- */
- public ModifierSet getModifierByModifierCd(List modifierCdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ModifierSet;
+
+public interface ITablePdoQueryModifierDao {
+
+ /**
+ * Get Concept set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public ModifierSet getModifierByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function returns modifiers based on list of modifier codes
+ *
+ * @param modifierCdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return ModifierSet
+ * @throws I2B2DAOException
+ */
+ public ModifierSet getModifierByModifierCd(List modifierCdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java
old mode 100755
new mode 100644
similarity index 96%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java
index b7a55b6a..629909eb
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryPatientDao.java
@@ -1,84 +1,84 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientSet;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-
-public interface ITablePdoQueryPatientDao {
-
- /**
- * Function returns Patient information for given list of patient number in
- * TablePDO format
- *
- * @param patientNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public PatientSet getPatientByPatientNum(List patientNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- *
- * @param patientListType
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public PatientSet getPatientFromPatientSet(PatientListType patientListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Function returns patient information for given list of encounters
- *
- * @param visitListType
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientSet
- * @throws I2B2DAOException
- */
- public PatientSet getPatientFromVisitSet(EventListType visitListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Get Patient set based on the fact's filter
- *
- * @param panelSqlList
- * @param sqlParamCountList
- * @param inputOptionListHandler
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public PatientSet getPatientByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
-
- public void setMetaDataParamList(List metaDataParamList);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientSet;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+
+public interface ITablePdoQueryPatientDao {
+
+ /**
+ * Function returns Patient information for given list of patient number in
+ * TablePDO format
+ *
+ * @param patientNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientByPatientNum(List patientNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ *
+ * @param patientListType
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientFromPatientSet(PatientListType patientListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Function returns patient information for given list of encounters
+ *
+ * @param visitListType
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientSet
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientFromVisitSet(EventListType visitListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Get Patient set based on the fact's filter
+ *
+ * @param panelSqlList
+ * @param sqlParamCountList
+ * @param inputOptionListHandler
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public PatientSet getPatientByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+
+ public void setMetaDataParamList(List metaDataParamList);
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java
index 61934113..0f7b7c99
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryProviderDao.java
@@ -1,38 +1,38 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.ObserverSet;
-
-public interface ITablePdoQueryProviderDao {
-
- public ObserverSet getProviderByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Returns observerset for the given list of provider id
- *
- * @param providerIdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return ObserverSet
- * @throws I2B2DAOException
- */
- public ObserverSet getProviderById(List providerIdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.ObserverSet;
+
+public interface ITablePdoQueryProviderDao {
+
+ public ObserverSet getProviderByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Returns observerset for the given list of provider id
+ *
+ * @param providerIdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return ObserverSet
+ * @throws I2B2DAOException
+ */
+ public ObserverSet getProviderById(List providerIdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java
index 317a877e..0ca25293
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ITablePdoQueryVisitDao.java
@@ -1,71 +1,71 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.List;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.datavo.pdo.EventSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-
-public interface ITablePdoQueryVisitDao {
-
- /**
- * Function to return EventSet from visit information
- *
- * @param encounterNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return EventSet
- * @throws I2B2DAOException
- */
- public EventSet getVisitsByEncounterNum(List encounterNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException;
-
- /**
- * Function to return EventSet from visit information
- *
- * @param visitListType
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return EventSet
- * @throws I2B2DAOException
- */
- public EventSet getVisitDimensionSetFromVisitList(
- EventListType visitListType, boolean detailFlag, boolean blobFlag,
- boolean statusFlag) throws I2B2DAOException;
-
- /**
- * Function to return EventSet for given patient set
- *
- * @param patientListType
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- public EventSet getVisitDimensionSetFromPatientList(
- PatientListType patientListType, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- public EventSet getVisitByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
-
- public void setMetaDataParamList(List metaDataParamList);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.List;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.datavo.pdo.EventSet;
+import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+
+public interface ITablePdoQueryVisitDao {
+
+ /**
+ * Function to return EventSet from visit information
+ *
+ * @param encounterNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return EventSet
+ * @throws I2B2DAOException
+ */
+ public EventSet getVisitsByEncounterNum(List encounterNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException;
+
+ /**
+ * Function to return EventSet from visit information
+ *
+ * @param visitListType
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return EventSet
+ * @throws I2B2DAOException
+ */
+ public EventSet getVisitDimensionSetFromVisitList(
+ EventListType visitListType, boolean detailFlag, boolean blobFlag,
+ boolean statusFlag) throws I2B2DAOException;
+
+ /**
+ * Function to return EventSet for given patient set
+ *
+ * @param patientListType
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ public EventSet getVisitDimensionSetFromPatientList(
+ PatientListType patientListType, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ public EventSet getVisitByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException;
+
+ public void setMetaDataParamList(List metaDataParamList);
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java
index c16817b3..65aa2fc9
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/MetaDataTypeMapper.java
@@ -1,64 +1,64 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class MetaDataTypeMapper {
-
- /** log **/
- protected final Log log = LogFactory.getLog(getClass());
-
- String stringDataType[] = {"varchar","varchar2","char","nchar"};
- String dateDataType[] = {"date","datetime"};
- String intDataType[] = {"int","number","bigint"};
- String decimalDataType[] = {"number","decimal","float"};
- List stringDataList,dateDataList,intDataList,decimalDataList;
-
- public MetaDataTypeMapper() {
- stringDataList = Arrays.asList(stringDataType);
- dateDataList = Arrays.asList(dateDataType);
- intDataList = Arrays.asList(intDataType);
- decimalDataList = Arrays.asList(decimalDataType);
-
- }
-
- public void fillXmlDataType(MetadataDao.TableMetaData[] tableMetaDataList, boolean tablePDOFlag) {
- for (int i=0;i stringDataList,dateDataList,intDataList,decimalDataList;
+
+ public MetaDataTypeMapper() {
+ stringDataList = Arrays.asList(stringDataType);
+ dateDataList = Arrays.asList(dateDataType);
+ intDataList = Arrays.asList(intDataType);
+ decimalDataList = Arrays.asList(decimalDataType);
+
+ }
+
+ public void fillXmlDataType(MetadataDao.TableMetaData[] tableMetaDataList, boolean tablePDOFlag) {
+ for (int i=0;i PATIENT_DIMENSION_REQUIRED_FIELDS = new ArrayList();
- private ArrayList VISIT_DIMENSION_REQUIRED_FIELDS = new ArrayList();
- private ArrayList VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS = new ArrayList();
- private ArrayList PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS = new ArrayList();
-
- private String[] patient_dim_required_field = new String[] {
- "patient_num", "vital_status_cd", "birth_date", "death_date", "patient_blob", "update_date",
- "download_date", "import_date", "sourcesystem_cd", "upload_id" };
-
- private String[] patient_dim_detail_field = new String[] {
- "vital_status_cd","birth_date"};
-
- private String[] visit_dim_detail_field = new String[] {"active_status_cd"};
-
- private String[] visit_dim_required_field = new String[] { "encounter_num",
- "patient_num", "start_date", "end_date", "active_status_cd", "visit_blob",
- "update_date", "download_date", "import_date", "sourcesystem_cd",
- "upload_id" };
-
- public final static String CRC_COLUMN_DESCRIPTOR = "crc_column_descriptor";
-
-
-
-
- private DataSourceLookup dataSourceLookup = null;
-
- public MetadataDao(DataSourceLookup dataSourceLookup, DataSource dataSource) {
- this.dataSourceLookup = dataSourceLookup;
- setDataSource(dataSource);
- setDbSchemaName(dataSourceLookup.getFullSchema());
- PATIENT_DIMENSION_REQUIRED_FIELDS.addAll(Arrays
- .asList(patient_dim_required_field));
- VISIT_DIMENSION_REQUIRED_FIELDS.addAll(Arrays
- .asList(visit_dim_required_field));
- PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS.addAll(Arrays
- .asList(patient_dim_detail_field));
- VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS.addAll(Arrays
- .asList(visit_dim_detail_field));
- }
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see edu.harvard.i2b2.crc.dao.pdo.IMetadataDao#blah(java.lang.String)
- */
- @Override
- public Map getMetadataForOptionalField(String tableName)
- throws I2B2DAOException {
-
- ArrayList requiredFieldLookupList = null;
- ArrayList requiredDetailFieldLookupList = null;
-
- if (tableName.equalsIgnoreCase(DimensionTable.PATIENT_DIMENSION)) {
- requiredFieldLookupList = PATIENT_DIMENSION_REQUIRED_FIELDS;
- requiredDetailFieldLookupList = PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS;
- } else if (tableName.equalsIgnoreCase(DimensionTable.VISIT_DIMENSION)) {
- requiredFieldLookupList = VISIT_DIMENSION_REQUIRED_FIELDS;
- requiredDetailFieldLookupList = VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS;
- }
-
- Map columnMap = new HashMap();
- Connection conn = null;
- Statement stmt = null;
- try {
- conn = getDataSource().getConnection();
-
- Map columnDescriptorMap = getColumnDescription(conn, tableName) ;
-
- stmt = conn.createStatement();
- // Execute the query
- ResultSet rs = stmt.executeQuery("SELECT * FROM "
- + getDbSchemaName() + tableName + " WHERE 1 = 2");
-
- // Get the metadata
- ResultSetMetaData md = rs.getMetaData();
-
- String columnName = "", columnType = "";
- int columnSize = 0;
- // Print the column labels
- for (int i = 1; i <= md.getColumnCount(); i++) {
- TableMetaData tableMetaData = new TableMetaData();
-
- boolean requiredDetailFieldFlag = false;
- if (requiredDetailFieldLookupList.contains(md.getColumnLabel(i)
- .toLowerCase())) {
- requiredDetailFieldFlag = true;
- }
- if (requiredDetailFieldFlag || (!requiredFieldLookupList.contains(md.getColumnLabel(i)
- .toLowerCase()))) {
- columnName = md.getColumnLabel(i).toLowerCase();
- columnType = md.getColumnTypeName(i).toLowerCase();
- columnSize = md.getColumnDisplaySize(i);
-
- log.debug("column name "
- + columnName);
- log.debug(" column type name"
- + columnType );
- log.debug(" column display type size "
- + columnSize);
- tableMetaData.column_name = columnName;
- tableMetaData.column_type = columnType;
- tableMetaData.column_comment = columnName;
- tableMetaData.column_type_size = String.valueOf(columnSize);
- tableMetaData.column_comment = columnDescriptorMap.get(columnName);
- columnMap.put(columnName, tableMetaData);
- }
- }
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- log.error("", sqlEx);
- throw new I2B2DAOException("", sqlEx);
- } finally {
-
- try {
- JDBCUtil.closeJdbcResource(null, stmt, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return columnMap;
- }
-
- private Map getColumnDescription(Connection conn, String tableName) throws SQLException {
- Map columnDescriptorMap = new HashMap();
- PreparedStatement pStmt = conn.prepareStatement("select * from " + getDbSchemaName() + "code_lookup where lower(table_cd) = ? and lower(code_cd) = ?");
- pStmt.setString(1, tableName.toLowerCase());
- pStmt.setString(2, CRC_COLUMN_DESCRIPTOR);
- ResultSet resultSet = pStmt.executeQuery();
- String columnCd = null, columnDescriptor = null;
- while (resultSet.next()) {
- columnCd = resultSet.getString("column_cd");
- columnDescriptor = resultSet.getString("name_char");
- if (columnCd != null && columnDescriptor != null) {
- columnDescriptorMap.put(columnCd.trim().toLowerCase() , columnDescriptor);
- }
-
- }
- return columnDescriptorMap;
- }
-
- public class TableMetaData {
- public String column_name;
- public String column_type;
- public String column_type_size;
- public String column_comment;
- public String column_xml_type;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.util.db.JDBCUtil;
+import edu.harvard.i2b2.crc.dao.CRCDAO;
+import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
+
+public class MetadataDao extends CRCDAO implements IMetadataDao {
+
+ /** log * */
+ protected final Log log = LogFactory.getLog(getClass());
+
+
+
+ private ArrayList PATIENT_DIMENSION_REQUIRED_FIELDS = new ArrayList();
+ private ArrayList VISIT_DIMENSION_REQUIRED_FIELDS = new ArrayList();
+ private ArrayList VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS = new ArrayList();
+ private ArrayList PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS = new ArrayList();
+
+ private String[] patient_dim_required_field = new String[] {
+ "patient_num", "vital_status_cd", "birth_date", "death_date", "patient_blob", "update_date",
+ "download_date", "import_date", "sourcesystem_cd", "upload_id" };
+
+ private String[] patient_dim_detail_field = new String[] {
+ "vital_status_cd","birth_date"};
+
+ private String[] visit_dim_detail_field = new String[] {"active_status_cd"};
+
+ private String[] visit_dim_required_field = new String[] { "encounter_num",
+ "patient_num", "start_date", "end_date", "active_status_cd", "visit_blob",
+ "update_date", "download_date", "import_date", "sourcesystem_cd",
+ "upload_id" };
+
+ public final static String CRC_COLUMN_DESCRIPTOR = "crc_column_descriptor";
+
+
+
+
+ private DataSourceLookup dataSourceLookup = null;
+
+ public MetadataDao(DataSourceLookup dataSourceLookup, DataSource dataSource) {
+ this.dataSourceLookup = dataSourceLookup;
+ setDataSource(dataSource);
+ setDbSchemaName(dataSourceLookup.getFullSchema());
+ PATIENT_DIMENSION_REQUIRED_FIELDS.addAll(Arrays
+ .asList(patient_dim_required_field));
+ VISIT_DIMENSION_REQUIRED_FIELDS.addAll(Arrays
+ .asList(visit_dim_required_field));
+ PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS.addAll(Arrays
+ .asList(patient_dim_detail_field));
+ VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS.addAll(Arrays
+ .asList(visit_dim_detail_field));
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see edu.harvard.i2b2.crc.dao.pdo.IMetadataDao#blah(java.lang.String)
+ */
+ @Override
+ public Map getMetadataForOptionalField(String tableName)
+ throws I2B2DAOException {
+
+ ArrayList requiredFieldLookupList = null;
+ ArrayList requiredDetailFieldLookupList = null;
+
+ if (tableName.equalsIgnoreCase(DimensionTable.PATIENT_DIMENSION)) {
+ requiredFieldLookupList = PATIENT_DIMENSION_REQUIRED_FIELDS;
+ requiredDetailFieldLookupList = PATIENT_DIMENSION_REQUIRED_DETAIL_FIELDS;
+ } else if (tableName.equalsIgnoreCase(DimensionTable.VISIT_DIMENSION)) {
+ requiredFieldLookupList = VISIT_DIMENSION_REQUIRED_FIELDS;
+ requiredDetailFieldLookupList = VISIT_DIMENSION_REQUIRED_DETAIL_FIELDS;
+ }
+
+ Map columnMap = new HashMap();
+ Connection conn = null;
+ Statement stmt = null;
+ try {
+ conn = getDataSource().getConnection();
+
+ Map columnDescriptorMap = getColumnDescription(conn, tableName) ;
+
+ stmt = conn.createStatement();
+ // Execute the query
+ ResultSet rs = stmt.executeQuery("SELECT * FROM "
+ + getDbSchemaName() + tableName + " WHERE 1 = 2");
+
+ // Get the metadata
+ ResultSetMetaData md = rs.getMetaData();
+
+ String columnName = "", columnType = "";
+ int columnSize = 0;
+ // Print the column labels
+ for (int i = 1; i <= md.getColumnCount(); i++) {
+ TableMetaData tableMetaData = new TableMetaData();
+
+ boolean requiredDetailFieldFlag = false;
+ if (requiredDetailFieldLookupList.contains(md.getColumnLabel(i)
+ .toLowerCase())) {
+ requiredDetailFieldFlag = true;
+ }
+ if (requiredDetailFieldFlag || (!requiredFieldLookupList.contains(md.getColumnLabel(i)
+ .toLowerCase()))) {
+ columnName = md.getColumnLabel(i).toLowerCase();
+ columnType = md.getColumnTypeName(i).toLowerCase();
+ columnSize = md.getColumnDisplaySize(i);
+
+ log.debug("column name "
+ + columnName);
+ log.debug(" column type name"
+ + columnType );
+ log.debug(" column display type size "
+ + columnSize);
+ tableMetaData.column_name = columnName;
+ tableMetaData.column_type = columnType;
+ tableMetaData.column_comment = columnName;
+ tableMetaData.column_type_size = String.valueOf(columnSize);
+ tableMetaData.column_comment = columnDescriptorMap.get(columnName);
+ columnMap.put(columnName, tableMetaData);
+ }
+ }
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ log.error("", sqlEx);
+ throw new I2B2DAOException("", sqlEx);
+ } finally {
+
+ try {
+ JDBCUtil.closeJdbcResource(null, stmt, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return columnMap;
+ }
+
+ private Map getColumnDescription(Connection conn, String tableName) throws SQLException {
+ Map columnDescriptorMap = new HashMap();
+ PreparedStatement pStmt = conn.prepareStatement("select * from " + getDbSchemaName() + "code_lookup where lower(table_cd) = ? and lower(code_cd) = ?");
+ pStmt.setString(1, tableName.toLowerCase());
+ pStmt.setString(2, CRC_COLUMN_DESCRIPTOR);
+ ResultSet resultSet = pStmt.executeQuery();
+ String columnCd = null, columnDescriptor = null;
+ while (resultSet.next()) {
+ columnCd = resultSet.getString("column_cd");
+ columnDescriptor = resultSet.getString("name_char");
+ if (columnCd != null && columnDescriptor != null) {
+ columnDescriptorMap.put(columnCd.trim().toLowerCase() , columnDescriptor);
+ }
+
+ }
+ return columnDescriptorMap;
+ }
+
+ public class TableMetaData {
+ public String column_name;
+ public String column_type;
+ public String column_type_size;
+ public String column_comment;
+ public String column_xml_type;
+ }
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java
index 0b116005..3fdaf61d
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ObservationFactDao.java
@@ -1,319 +1,319 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-/*
-
- *
- * Contributors:
- * Rajesh Kuttan
- */
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.text.SimpleDateFormat;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-
-import javax.sql.DataSource;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axis2.AxisFault;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.exception.I2B2Exception;
-import edu.harvard.i2b2.common.exception.StackTraceUtil;
-import edu.harvard.i2b2.common.util.db.JDBCUtil;
-import edu.harvard.i2b2.common.util.jaxb.JAXBUtilException;
-import edu.harvard.i2b2.crc.dao.CRCDAO;
-import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
-import edu.harvard.i2b2.crc.dao.pdo.output.ObservationFactFactRelated;
-import edu.harvard.i2b2.crc.dao.setfinder.querybuilder.ConceptNotFoundException;
-import edu.harvard.i2b2.crc.dao.setfinder.querybuilder.OntologyException;
-import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
-import edu.harvard.i2b2.crc.datavo.i2b2message.SecurityType;
-import edu.harvard.i2b2.crc.datavo.ontology.DerivedFactColumnsType;
-import edu.harvard.i2b2.crc.datavo.pdo.ObservationSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ObservationType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.FactPrimaryKeyType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.OutputOptionType;
-import edu.harvard.i2b2.crc.delegate.ontology.CallOntologyUtil;
-import edu.harvard.i2b2.crc.util.PMServiceAccountUtil;
-import edu.harvard.i2b2.crc.util.QueryProcessorUtil;
-
-/**
- * DAO class for observation fact $Id: ObservationFactDao.java,v 1.13 2008/07/21
- * 19:53:40 rk903 Exp $
- *
- * @author rkuttan
- * @see FactPrimaryKeyType
- * @see OutputOptionType
- */
-public class ObservationFactDao extends CRCDAO implements IObservationFactDao {
-
- private DataSourceLookup dataSourceLookup = null;
-
- public ObservationFactDao(DataSourceLookup dataSourceLookup,
- DataSource dataSource) {
- setDataSource(dataSource);
- setDbSchemaName(dataSourceLookup.getFullSchema());
- this.dataSourceLookup = dataSourceLookup;
- }
-
- /**
- * Function returns Observation fact from the primary key.
- *
- * Required fields : patient_num, concept_cd, encounter_num
- *
- * Optional field : provider_id,start_date
- *
- * @param factPrimaryKey
- * @param factOutputOption
- * @return PatientDataType
- * @throws I2B2Exception
- */
- @Override
- public PatientDataType getObservationFactByPrimaryKey(
- FactPrimaryKeyType factPrimaryKey, OutputOptionType factOutputOption)
- throws I2B2DAOException {
- PatientDataType patientDataType = new PatientDataType();
-
- ObservationFactFactRelated factRelated = new ObservationFactFactRelated(
- factOutputOption);
-
- String defaultTableName = getDbSchemaName() + "observation_fact";
-
- String sql = " SELECT " + factRelated.getSelectClause() + " \n "
- + " FROM " + defaultTableName + " obs \n"
- + " WHERE obs.encounter_num = ? AND \n "
- + " obs.patient_num = ? AND \n" + " obs.concept_cd = ? \n";
-
- if (factPrimaryKey.getObserverId() != null) {
- sql += " AND obs.provider_id = ? \n";
- }
-
- // make given start date to 'mm-dd-yyyy hh24:mi' format
- if (factPrimaryKey.getStartDate() != null) {
- GregorianCalendar gc = factPrimaryKey.getStartDate()
- .toGregorianCalendar();
- String sqlFormatedStartDate = "";
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.ORACLE)) {
- SimpleDateFormat dateFormat = new SimpleDateFormat(
- "dd-MMM-yyyy HH:mm:ss");
- sqlFormatedStartDate = dateFormat.format(gc.getTime());
- sql += (" AND obs.start_date = to_date('"
- + sqlFormatedStartDate + " ', 'DD-MON-YYYY HH24:MI:SS') ");
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER) || dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.POSTGRESQL)) {
- SimpleDateFormat dateFormat = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss");
- sqlFormatedStartDate = dateFormat.format(gc.getTime());
- sql += (" AND obs.start_date = '" + sqlFormatedStartDate + "'");
- }
- }
-
- if (factPrimaryKey.getModifierCd() != null) {
- sql += " AND obs.modifier_cd = ? ";
- }
- if (factPrimaryKey.getInstanceNum() != null) {
- sql += " AND obs.instance_num = ? ";
- }
-
-// log.info("Pre Sql from ObservationFactDAO[" + sql + "]");
-
-
- int numDerivedTables = 1;
- boolean derivedFactTable = QueryProcessorUtil.getInstance().getDerivedFactTable();
- String finalSql = sql;
- if(derivedFactTable == true){
- // call ONT to get concept info
- DerivedFactColumnsType columns = getFactColumnsFromOntologyCellByCode(factPrimaryKey.getConceptCd());
-
- if(columns != null){
- numDerivedTables = columns.getDerivedFactTableColumn().size();
-// log.info("found " +numDerivedTables + " derived tables");
- // parse through solumns and build up replace string.
-
- Iterator it = columns.getDerivedFactTableColumn().iterator();
- String column = it.next();
-// log.info(column);
- if(column.contains(".")) {
- int lastIndex = column.lastIndexOf(".");
- String tableName = this.getDbSchemaName() + (column.substring(0, lastIndex));
- log.info(tableName);
- finalSql = finalSql.replace(defaultTableName, tableName);
- }
- while(it.hasNext()){
- column = it.next();
- if(column.contains(".")) {
- int lastIndex = column.lastIndexOf(".");
- String table = this.getDbSchemaName() + (column.substring(0, lastIndex));
- if(table != null)
- finalSql += "\n union all \n";
- finalSql += sql.replace(defaultTableName, table);
- }
-
- }
- }
- }
-
-// log.info("Generated Sql from ObservationFactDAO[" + finalSql + "]");
-
- Connection conn = null;
- PreparedStatement stmt = null;
-
- try {
- // get db connection
- // conn = getConnection();
- conn = getDataSource().getConnection();
-
- // create prepared statement
- stmt = conn.prepareStatement(finalSql);
- int index = 1;
- for (int i=0; i<= numDerivedTables -1; i++){
- stmt.setInt(i+index, Integer.parseInt(factPrimaryKey.getEventId()));
- // log.info(i+index + " " + factPrimaryKey.getEventId());
- index++;
- stmt.setInt(i+index , Integer.parseInt(factPrimaryKey.getPatientId()));
- // log.info(i+index +" " + factPrimaryKey.getPatientId());
- index++;
- stmt.setString(i+index, factPrimaryKey.getConceptCd());
- // log.info(i+index + " " + factPrimaryKey.getConceptCd());
- index++;
- // if provider id is not null add it to sql parameter
- if (factPrimaryKey.getObserverId() != null) {
- stmt.setString(i+index, factPrimaryKey.getObserverId());
- // log.info(i+index + " " + factPrimaryKey.getObserverId());
- index++;
- }
- // if modifier cd is not null add it to sql parameter
- if (factPrimaryKey.getModifierCd() != null) {
- stmt.setString(i+index, factPrimaryKey.getModifierCd());
- // log.info(i + index +" " + factPrimaryKey.getModifierCd());
- index++;
- }
- if (factPrimaryKey.getInstanceNum() != null) {
- int instanceNum = Integer.parseInt(factPrimaryKey
- .getInstanceNum());
- stmt.setInt(i+index, instanceNum);
- // log.info(i + index + " " + factPrimaryKey.getInstanceNum());
- index++;
- }
-
- }
-
- // original (pre-OMOP) code
- /* stmt.setInt(1, Integer.parseInt(factPrimaryKey.getEventId()));
- stmt.setInt(2, Integer.parseInt(factPrimaryKey.getPatientId()));
- stmt.setString(3, factPrimaryKey.getConceptCd());
-
- int i = 4;
- String providerId = factPrimaryKey.getObserverId();
-
- // if provider id is not null add it to sql parameter
- if (providerId != null) {
- stmt.setString(i, providerId);
- i++;
- }
-
- // if modifier cd is not null add it to sql parameter
- if (factPrimaryKey.getModifierCd() != null) {
- stmt.setString(i, factPrimaryKey.getModifierCd());
- i++;
- }
-
- if (factPrimaryKey.getInstanceNum() != null) {
- int instanceNum = Integer.parseInt(factPrimaryKey
- .getInstanceNum());
- i++;
- stmt.setInt(i, instanceNum);
- }
- */
-
- ResultSet resultSet = stmt.executeQuery();
- ObservationSet obsFactSet = new ObservationSet();
-
- I2B2PdoFactory.ObservationFactBuilder observationFactBuilder = new I2B2PdoFactory().new ObservationFactBuilder(
- factRelated.isSelectDetail(), factRelated.isSelectBlob(),
- factRelated.isSelectStatus(), dataSourceLookup.getServerType());
- while (resultSet.next()) {
- ObservationType observationFactType = observationFactBuilder
- .buildObservationSet(resultSet);
- obsFactSet.getObservation().add(observationFactType);
- }
-
- patientDataType.getObservationSet().add(obsFactSet);
- } catch (SQLException sqlEx) {
- log.error(sqlEx);
- throw new I2B2DAOException("", sqlEx);
- } catch (IOException ioEx) {
- log.error(ioEx);
- throw new I2B2DAOException("", ioEx);
- } finally {
- try {
- JDBCUtil.closeJdbcResource(null, stmt, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
-
- return patientDataType;
- }
-
-
-
- protected DerivedFactColumnsType getFactColumnsFromOntologyCellByCode(String conceptCd)
- throws ConceptNotFoundException, OntologyException {
- DerivedFactColumnsType factColumns = new DerivedFactColumnsType();
- try {
-
- QueryProcessorUtil qpUtil = QueryProcessorUtil.getInstance();
- String ontologyUrl = qpUtil
- .getCRCPropertyValue(QueryProcessorUtil.ONTOLOGYCELL_ROOT_WS_URL_PROPERTIES);
-
- SecurityType securityType = PMServiceAccountUtil
- .getServiceSecurityType(dataSourceLookup.getDomainId());
-
- factColumns = CallOntologyUtil.callGetFactColumnsByConceptCd(conceptCd,
- securityType, dataSourceLookup.getProjectPath(),
- ontologyUrl +"/getCodeInfo");
- } catch (JAXBUtilException e) {
-
- log.error("Error while fetching metadata [" + conceptCd
- + "] from ontology ", e);
- throw new OntologyException("Error while fetching metadata ["
- + conceptCd + "] from ontology "
- + StackTraceUtil.getStackTrace(e));
- } catch (I2B2Exception e) {
- log.error("Error while fetching metadata from ontology ", e);
- throw new OntologyException("Error while fetching metadata ["
- + conceptCd + "] from ontology "
- + StackTraceUtil.getStackTrace(e));
- } catch (AxisFault e) {
- log.error("Error while fetching metadata from ontology ", e);
- throw new OntologyException("Error while fetching metadata ["
- + conceptCd + "] from ontology "
- + StackTraceUtil.getStackTrace(e));
- } catch (XMLStreamException e) {
- log.error("Error while fetching metadata from ontology ", e);
- throw new OntologyException("Error while fetching metadata ["
- + conceptCd + "] from ontology "
- + StackTraceUtil.getStackTrace(e));
- }
-
- return factColumns;
- }
-
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+/*
+
+ *
+ * Contributors:
+ * Rajesh Kuttan
+ */
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+
+import javax.sql.DataSource;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.AxisFault;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.exception.I2B2Exception;
+import edu.harvard.i2b2.common.exception.StackTraceUtil;
+import edu.harvard.i2b2.common.util.db.JDBCUtil;
+import edu.harvard.i2b2.common.util.jaxb.JAXBUtilException;
+import edu.harvard.i2b2.crc.dao.CRCDAO;
+import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
+import edu.harvard.i2b2.crc.dao.pdo.output.ObservationFactFactRelated;
+import edu.harvard.i2b2.crc.dao.setfinder.querybuilder.ConceptNotFoundException;
+import edu.harvard.i2b2.crc.dao.setfinder.querybuilder.OntologyException;
+import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
+import edu.harvard.i2b2.crc.datavo.i2b2message.SecurityType;
+import edu.harvard.i2b2.crc.datavo.ontology.DerivedFactColumnsType;
+import edu.harvard.i2b2.crc.datavo.pdo.ObservationSet;
+import edu.harvard.i2b2.crc.datavo.pdo.ObservationType;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.FactPrimaryKeyType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.OutputOptionType;
+import edu.harvard.i2b2.crc.delegate.ontology.CallOntologyUtil;
+import edu.harvard.i2b2.crc.util.PMServiceAccountUtil;
+import edu.harvard.i2b2.crc.util.QueryProcessorUtil;
+
+/**
+ * DAO class for observation fact $Id: ObservationFactDao.java,v 1.13 2008/07/21
+ * 19:53:40 rk903 Exp $
+ *
+ * @author rkuttan
+ * @see FactPrimaryKeyType
+ * @see OutputOptionType
+ */
+public class ObservationFactDao extends CRCDAO implements IObservationFactDao {
+
+ private DataSourceLookup dataSourceLookup = null;
+
+ public ObservationFactDao(DataSourceLookup dataSourceLookup,
+ DataSource dataSource) {
+ setDataSource(dataSource);
+ setDbSchemaName(dataSourceLookup.getFullSchema());
+ this.dataSourceLookup = dataSourceLookup;
+ }
+
+ /**
+ * Function returns Observation fact from the primary key.
+ *
+ * Required fields : patient_num, concept_cd, encounter_num
+ *
+ * Optional field : provider_id,start_date
+ *
+ * @param factPrimaryKey
+ * @param factOutputOption
+ * @return PatientDataType
+ * @throws I2B2Exception
+ */
+ @Override
+ public PatientDataType getObservationFactByPrimaryKey(
+ FactPrimaryKeyType factPrimaryKey, OutputOptionType factOutputOption)
+ throws I2B2DAOException {
+ PatientDataType patientDataType = new PatientDataType();
+
+ ObservationFactFactRelated factRelated = new ObservationFactFactRelated(
+ factOutputOption);
+
+ String defaultTableName = getDbSchemaName() + "observation_fact";
+
+ String sql = " SELECT " + factRelated.getSelectClause() + " \n "
+ + " FROM " + defaultTableName + " obs \n"
+ + " WHERE obs.encounter_num = ? AND \n "
+ + " obs.patient_num = ? AND \n" + " obs.concept_cd = ? \n";
+
+ if (factPrimaryKey.getObserverId() != null) {
+ sql += " AND obs.provider_id = ? \n";
+ }
+
+ // make given start date to 'mm-dd-yyyy hh24:mi' format
+ if (factPrimaryKey.getStartDate() != null) {
+ GregorianCalendar gc = factPrimaryKey.getStartDate()
+ .toGregorianCalendar();
+ String sqlFormatedStartDate = "";
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.ORACLE)) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat(
+ "dd-MMM-yyyy HH:mm:ss");
+ sqlFormatedStartDate = dateFormat.format(gc.getTime());
+ sql += (" AND obs.start_date = to_date('"
+ + sqlFormatedStartDate + " ', 'DD-MON-YYYY HH24:MI:SS') ");
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER) || dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.POSTGRESQL)) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ss");
+ sqlFormatedStartDate = dateFormat.format(gc.getTime());
+ sql += (" AND obs.start_date = '" + sqlFormatedStartDate + "'");
+ }
+ }
+
+ if (factPrimaryKey.getModifierCd() != null) {
+ sql += " AND obs.modifier_cd = ? ";
+ }
+ if (factPrimaryKey.getInstanceNum() != null) {
+ sql += " AND obs.instance_num = ? ";
+ }
+
+// log.info("Pre Sql from ObservationFactDAO[" + sql + "]");
+
+
+ int numDerivedTables = 1;
+ boolean derivedFactTable = QueryProcessorUtil.getInstance().getDerivedFactTable();
+ String finalSql = sql;
+ if(derivedFactTable == true){
+ // call ONT to get concept info
+ DerivedFactColumnsType columns = getFactColumnsFromOntologyCellByCode(factPrimaryKey.getConceptCd());
+
+ if(columns != null){
+ numDerivedTables = columns.getDerivedFactTableColumn().size();
+// log.info("found " +numDerivedTables + " derived tables");
+ // parse through solumns and build up replace string.
+
+ Iterator it = columns.getDerivedFactTableColumn().iterator();
+ String column = it.next();
+// log.info(column);
+ if(column.contains(".")) {
+ int lastIndex = column.lastIndexOf(".");
+ String tableName = this.getDbSchemaName() + (column.substring(0, lastIndex));
+ log.info(tableName);
+ finalSql = finalSql.replace(defaultTableName, tableName);
+ }
+ while(it.hasNext()){
+ column = it.next();
+ if(column.contains(".")) {
+ int lastIndex = column.lastIndexOf(".");
+ String table = this.getDbSchemaName() + (column.substring(0, lastIndex));
+ if(table != null)
+ finalSql += "\n union all \n";
+ finalSql += sql.replace(defaultTableName, table);
+ }
+
+ }
+ }
+ }
+
+// log.info("Generated Sql from ObservationFactDAO[" + finalSql + "]");
+
+ Connection conn = null;
+ PreparedStatement stmt = null;
+
+ try {
+ // get db connection
+ // conn = getConnection();
+ conn = getDataSource().getConnection();
+
+ // create prepared statement
+ stmt = conn.prepareStatement(finalSql);
+ int index = 1;
+ for (int i=0; i<= numDerivedTables -1; i++){
+ stmt.setInt(i+index, Integer.parseInt(factPrimaryKey.getEventId()));
+ // log.info(i+index + " " + factPrimaryKey.getEventId());
+ index++;
+ stmt.setInt(i+index , Integer.parseInt(factPrimaryKey.getPatientId()));
+ // log.info(i+index +" " + factPrimaryKey.getPatientId());
+ index++;
+ stmt.setString(i+index, factPrimaryKey.getConceptCd());
+ // log.info(i+index + " " + factPrimaryKey.getConceptCd());
+ index++;
+ // if provider id is not null add it to sql parameter
+ if (factPrimaryKey.getObserverId() != null) {
+ stmt.setString(i+index, factPrimaryKey.getObserverId());
+ // log.info(i+index + " " + factPrimaryKey.getObserverId());
+ index++;
+ }
+ // if modifier cd is not null add it to sql parameter
+ if (factPrimaryKey.getModifierCd() != null) {
+ stmt.setString(i+index, factPrimaryKey.getModifierCd());
+ // log.info(i + index +" " + factPrimaryKey.getModifierCd());
+ index++;
+ }
+ if (factPrimaryKey.getInstanceNum() != null) {
+ int instanceNum = Integer.parseInt(factPrimaryKey
+ .getInstanceNum());
+ stmt.setInt(i+index, instanceNum);
+ // log.info(i + index + " " + factPrimaryKey.getInstanceNum());
+ index++;
+ }
+
+ }
+
+ // original (pre-OMOP) code
+ /* stmt.setInt(1, Integer.parseInt(factPrimaryKey.getEventId()));
+ stmt.setInt(2, Integer.parseInt(factPrimaryKey.getPatientId()));
+ stmt.setString(3, factPrimaryKey.getConceptCd());
+
+ int i = 4;
+ String providerId = factPrimaryKey.getObserverId();
+
+ // if provider id is not null add it to sql parameter
+ if (providerId != null) {
+ stmt.setString(i, providerId);
+ i++;
+ }
+
+ // if modifier cd is not null add it to sql parameter
+ if (factPrimaryKey.getModifierCd() != null) {
+ stmt.setString(i, factPrimaryKey.getModifierCd());
+ i++;
+ }
+
+ if (factPrimaryKey.getInstanceNum() != null) {
+ int instanceNum = Integer.parseInt(factPrimaryKey
+ .getInstanceNum());
+ i++;
+ stmt.setInt(i, instanceNum);
+ }
+ */
+
+ ResultSet resultSet = stmt.executeQuery();
+ ObservationSet obsFactSet = new ObservationSet();
+
+ I2B2PdoFactory.ObservationFactBuilder observationFactBuilder = new I2B2PdoFactory().new ObservationFactBuilder(
+ factRelated.isSelectDetail(), factRelated.isSelectBlob(),
+ factRelated.isSelectStatus(), dataSourceLookup.getServerType());
+ while (resultSet.next()) {
+ ObservationType observationFactType = observationFactBuilder
+ .buildObservationSet(resultSet);
+ obsFactSet.getObservation().add(observationFactType);
+ }
+
+ patientDataType.getObservationSet().add(obsFactSet);
+ } catch (SQLException sqlEx) {
+ log.error(sqlEx);
+ throw new I2B2DAOException("", sqlEx);
+ } catch (IOException ioEx) {
+ log.error(ioEx);
+ throw new I2B2DAOException("", ioEx);
+ } finally {
+ try {
+ JDBCUtil.closeJdbcResource(null, stmt, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+
+ return patientDataType;
+ }
+
+
+
+ protected DerivedFactColumnsType getFactColumnsFromOntologyCellByCode(String conceptCd)
+ throws ConceptNotFoundException, OntologyException {
+ DerivedFactColumnsType factColumns = new DerivedFactColumnsType();
+ try {
+
+ QueryProcessorUtil qpUtil = QueryProcessorUtil.getInstance();
+ String ontologyUrl = qpUtil
+ .getCRCPropertyValue(QueryProcessorUtil.ONTOLOGYCELL_ROOT_WS_URL_PROPERTIES);
+
+ SecurityType securityType = PMServiceAccountUtil
+ .getServiceSecurityType(dataSourceLookup.getDomainId());
+
+ factColumns = CallOntologyUtil.callGetFactColumnsByConceptCd(conceptCd,
+ securityType, dataSourceLookup.getProjectPath(),
+ ontologyUrl +"/getCodeInfo");
+ } catch (JAXBUtilException e) {
+
+ log.error("Error while fetching metadata [" + conceptCd
+ + "] from ontology ", e);
+ throw new OntologyException("Error while fetching metadata ["
+ + conceptCd + "] from ontology "
+ + StackTraceUtil.getStackTrace(e));
+ } catch (I2B2Exception e) {
+ log.error("Error while fetching metadata from ontology ", e);
+ throw new OntologyException("Error while fetching metadata ["
+ + conceptCd + "] from ontology "
+ + StackTraceUtil.getStackTrace(e));
+ } catch (AxisFault e) {
+ log.error("Error while fetching metadata from ontology ", e);
+ throw new OntologyException("Error while fetching metadata ["
+ + conceptCd + "] from ontology "
+ + StackTraceUtil.getStackTrace(e));
+ } catch (XMLStreamException e) {
+ log.error("Error while fetching metadata from ontology ", e);
+ throw new OntologyException("Error while fetching metadata ["
+ + conceptCd + "] from ontology "
+ + StackTraceUtil.getStackTrace(e));
+ }
+
+ return factColumns;
+ }
+
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java
old mode 100755
new mode 100644
similarity index 96%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java
index 161f2d6f..2d884738
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PageTotalDao.java
@@ -1,333 +1,333 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.sql.DataSource;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.util.db.JDBCUtil;
-import edu.harvard.i2b2.crc.dao.CRCDAO;
-import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
-import edu.harvard.i2b2.crc.dao.pdo.input.IFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PanelType;
-
-public class PageTotalDao extends CRCDAO implements IPageDao {
-
- private DataSourceLookup dataSourceLookup = null;
-
- public PageTotalDao(DataSourceLookup dataSourceLookup, DataSource dataSource) {
- setDataSource(dataSource);
- setDbSchemaName(dataSourceLookup.getFullSchema());
- this.dataSourceLookup = dataSourceLookup;
- }
-
- @Override
- public long getTotalForAllPanel(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler)
- throws I2B2DAOException {
-
- long totalAcrossPanel = 0;
- int i = 0, sqlParamCount = 0;
- ResultSet resultSet = null;
- Connection conn = null;
- try {
- // get connection
- conn = this.getDataSource().getConnection();
-
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)
- && inputOptionListHandler.isEnumerationSet()) {
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- // sqlserverLoadTempTable(conn, inputOptionListHandler);
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.ORACLE)
- && inputOptionListHandler.isEnumerationSet()) {
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.POSTGRESQL)
- && inputOptionListHandler.isEnumerationSet()) {
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- // sqlserverLoadTempTable(conn, inputOptionListHandler);
- }
- long startTime = System.currentTimeMillis();
-
- // iterate sql
- for (String singlePanelSql : panelSqlList) {
- sqlParamCount = sqlParamCountList.get(i++);
- resultSet = executeTotalSql(singlePanelSql, conn,
- sqlParamCount, inputOptionListHandler);
- resultSet.next();
- totalAcrossPanel += resultSet.getLong(1);
- }
- long endTime = System.currentTimeMillis();
- long totalTime = endTime - startTime;
- log.debug("********* Time for the Total Sql ************ "
- + totalTime);
- } catch (SQLException sqlEx) {
- throw new I2B2DAOException("", sqlEx);
- } finally {
-
- try {
- inputOptionListHandler.deleteTempTable(conn);
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- // close connection
- try {
- JDBCUtil.closeJdbcResource(null, null, conn);
- } catch (SQLException e) {
- log.error("Error trying to close connection", e);
- }
- }
-
- return totalAcrossPanel;
- }
-
- @Override
- public HashMap getMinIndexAndCountAllPanel(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler)
- throws I2B2DAOException {
-
- int i = 0, sqlParamCount = 0;
- ResultSet resultSet = null;
- Connection conn = null;
- HashMap minAndTotalMap = new HashMap();
- int minIndex = 0, tempMinIndex = 0;
- long minIndexTotal = 0, tempMinIndexTotal = 0;
-
- try {
- // get connection
- conn = this.getDataSource().getConnection();
-
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)
- && inputOptionListHandler.isEnumerationSet()) {
- // upLoadTempTableForMin(conn, inputOptionListHandler);
- // sqlserverLoadTempTable(conn, inputOptionListHandler);
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.ORACLE)
- && inputOptionListHandler.isEnumerationSet()) {
- // oracleLoadTempTable(conn, inputOptionListHandler);
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.POSTGRESQL)
- && inputOptionListHandler.isEnumerationSet()) {
- // upLoadTempTableForMin(conn, inputOptionListHandler);
- // sqlserverLoadTempTable(conn, inputOptionListHandler);
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- }
-
- boolean firstTimeFlag = true;
- // iterate sql
- for (String singlePanelSql : panelSqlList) {
- sqlParamCount = sqlParamCountList.get(i++);
- resultSet = executeTotalSql(singlePanelSql, conn,
- sqlParamCount, inputOptionListHandler);
- resultSet.next();
- tempMinIndex = resultSet.getInt(1);
- tempMinIndexTotal = resultSet.getLong(2);
- if (firstTimeFlag) {
- minIndex = tempMinIndex;
- minIndexTotal = tempMinIndexTotal;
- firstTimeFlag = false;
- } else if (minIndexTotal < tempMinIndexTotal) {
- minIndex = tempMinIndex;
- minIndexTotal = tempMinIndexTotal;
- }
- }
- } catch (SQLException sqlEx) {
- throw new I2B2DAOException("", sqlEx);
- } finally {
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)) {
- deleteTempTable(conn);
- if (inputOptionListHandler.isEnumerationSet()) {
- deleteTemp1Table(conn);
- }
- }
- // close connection
- try {
- JDBCUtil.closeJdbcResource(null, null, conn);
- } catch (SQLException e) {
- log.error("Error trying to close connection", e);
- }
- }
-
- minAndTotalMap.put("MIN_INDEX", minIndex);
- minAndTotalMap.put("MIN_INDEX_TOTAL", minIndexTotal);
-
- return minAndTotalMap;
- }
-
- private ResultSet executeTotalSql(String totalSql, Connection conn,
- int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
- throws SQLException {
-
- PreparedStatement stmt = conn.prepareStatement(totalSql);
- ResultSet resultSet = null;
-
- log.debug(totalSql + " [ " + sqlParamCount + " ]");
- if (inputOptionListHandler.isCollectionId()) {
- for (int i = 1; i <= sqlParamCount; i++) {
- stmt.setInt(i, Integer.parseInt(inputOptionListHandler
- .getCollectionId()));
- }
- }
-
- resultSet = stmt.executeQuery();
-
- return resultSet;
- }
-
- public void sqlserverLoadTempTable(Connection conn,
- IInputOptionListHandler inputOptionListHandler) throws SQLException {
- // sqlserver
- upLoadTempTable(conn, inputOptionListHandler);
-
- }
-
- @Override
- public String buildTotalSql(IFactRelatedQueryHandler factHandler,
- PanelType panel) throws I2B2DAOException {
- // call factrelatedhandler to build sql
- return factHandler.buildTotalQuery(panel,
- PdoQueryHandler.PLAIN_PDO_TYPE);
- }
-
- public void getSelect() {
- }
-
- public void getFrom() {
- }
-
- public void getWhere() {
- }
-
- private void upLoadTempTable(Connection conn,
- IInputOptionListHandler inputOptionListHandler) throws SQLException {
- List enumList = inputOptionListHandler.getEnumerationList();
- // create temp table
- java.sql.Statement tempStmt = conn.createStatement();
- String createTempInputListTable = "create table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " ( char_param1 varchar(100) )";
- tempStmt.executeUpdate(createTempInputListTable);
- // load to temp table
- // TempInputListInsert inputListInserter = new
- // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
- // inputListInserter.setBatchSize(100);
- int i = 0;
- for (String singleValue : enumList) {
- tempStmt.addBatch("insert into "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " values ('" + singleValue + "' )");
- i++;
- if (i % 100 == 0) {
- tempStmt.executeBatch();
-
- }
- }
- tempStmt.executeBatch();
- }
-
- private void upLoadTempTableForMin(Connection conn,
- IInputOptionListHandler inputOptionListHandler) throws SQLException {
- List enumList = inputOptionListHandler.getEnumerationList();
- deleteTempTable(conn);
- // create temp table
- java.sql.Statement tempStmt = conn.createStatement();
- String createTempInputListTable = "create table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " (set_index int, char_param1 varchar(100) )";
- tempStmt.executeUpdate(createTempInputListTable);
- // load to temp table
- // TempInputListInsert inputListInserter = new
- // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
- // inputListInserter.setBatchSize(100);
- int i = 0, j = 1;
- for (String singleValue : enumList) {
- tempStmt.addBatch("insert into "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + "(set_index,char_param1) values (" + j++ + ",'"
- + singleValue + "' )");
- i++;
- if (i % 100 == 0) {
- tempStmt.executeBatch();
-
- }
- }
- tempStmt.executeBatch();
- }
-
- private void deleteTempTable(Connection conn) {
-
- Statement deleteStmt = null;
- try {
- deleteStmt = conn.createStatement();
-
- //conn
- // .createStatement()
- deleteStmt.executeUpdate(
- "drop table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
- } catch (SQLException sqle) {
- ;
- } finally {
- try {
- if(deleteStmt != null)
- deleteStmt.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
-
- private void deleteTemp1Table(Connection conn) {
-
- Statement deleteStmt = null;
- try {
- deleteStmt = conn.createStatement();
- // conn
- // .createStatement()
- deleteStmt.executeUpdate(
- "drop table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
- } catch (SQLException sqle) {
- ;
- } finally {
- try {
- if(deleteStmt != null)
- deleteStmt.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.util.db.JDBCUtil;
+import edu.harvard.i2b2.crc.dao.CRCDAO;
+import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
+import edu.harvard.i2b2.crc.dao.pdo.input.IFactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PanelType;
+
+public class PageTotalDao extends CRCDAO implements IPageDao {
+
+ private DataSourceLookup dataSourceLookup = null;
+
+ public PageTotalDao(DataSourceLookup dataSourceLookup, DataSource dataSource) {
+ setDataSource(dataSource);
+ setDbSchemaName(dataSourceLookup.getFullSchema());
+ this.dataSourceLookup = dataSourceLookup;
+ }
+
+ @Override
+ public long getTotalForAllPanel(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler)
+ throws I2B2DAOException {
+
+ long totalAcrossPanel = 0;
+ int i = 0, sqlParamCount = 0;
+ ResultSet resultSet = null;
+ Connection conn = null;
+ try {
+ // get connection
+ conn = this.getDataSource().getConnection();
+
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)
+ && inputOptionListHandler.isEnumerationSet()) {
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ // sqlserverLoadTempTable(conn, inputOptionListHandler);
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.ORACLE)
+ && inputOptionListHandler.isEnumerationSet()) {
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.POSTGRESQL)
+ && inputOptionListHandler.isEnumerationSet()) {
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ // sqlserverLoadTempTable(conn, inputOptionListHandler);
+ }
+ long startTime = System.currentTimeMillis();
+
+ // iterate sql
+ for (String singlePanelSql : panelSqlList) {
+ sqlParamCount = sqlParamCountList.get(i++);
+ resultSet = executeTotalSql(singlePanelSql, conn,
+ sqlParamCount, inputOptionListHandler);
+ resultSet.next();
+ totalAcrossPanel += resultSet.getLong(1);
+ }
+ long endTime = System.currentTimeMillis();
+ long totalTime = endTime - startTime;
+ log.debug("********* Time for the Total Sql ************ "
+ + totalTime);
+ } catch (SQLException sqlEx) {
+ throw new I2B2DAOException("", sqlEx);
+ } finally {
+
+ try {
+ inputOptionListHandler.deleteTempTable(conn);
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ // close connection
+ try {
+ JDBCUtil.closeJdbcResource(null, null, conn);
+ } catch (SQLException e) {
+ log.error("Error trying to close connection", e);
+ }
+ }
+
+ return totalAcrossPanel;
+ }
+
+ @Override
+ public HashMap getMinIndexAndCountAllPanel(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler)
+ throws I2B2DAOException {
+
+ int i = 0, sqlParamCount = 0;
+ ResultSet resultSet = null;
+ Connection conn = null;
+ HashMap minAndTotalMap = new HashMap();
+ int minIndex = 0, tempMinIndex = 0;
+ long minIndexTotal = 0, tempMinIndexTotal = 0;
+
+ try {
+ // get connection
+ conn = this.getDataSource().getConnection();
+
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)
+ && inputOptionListHandler.isEnumerationSet()) {
+ // upLoadTempTableForMin(conn, inputOptionListHandler);
+ // sqlserverLoadTempTable(conn, inputOptionListHandler);
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.ORACLE)
+ && inputOptionListHandler.isEnumerationSet()) {
+ // oracleLoadTempTable(conn, inputOptionListHandler);
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.POSTGRESQL)
+ && inputOptionListHandler.isEnumerationSet()) {
+ // upLoadTempTableForMin(conn, inputOptionListHandler);
+ // sqlserverLoadTempTable(conn, inputOptionListHandler);
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ }
+
+ boolean firstTimeFlag = true;
+ // iterate sql
+ for (String singlePanelSql : panelSqlList) {
+ sqlParamCount = sqlParamCountList.get(i++);
+ resultSet = executeTotalSql(singlePanelSql, conn,
+ sqlParamCount, inputOptionListHandler);
+ resultSet.next();
+ tempMinIndex = resultSet.getInt(1);
+ tempMinIndexTotal = resultSet.getLong(2);
+ if (firstTimeFlag) {
+ minIndex = tempMinIndex;
+ minIndexTotal = tempMinIndexTotal;
+ firstTimeFlag = false;
+ } else if (minIndexTotal < tempMinIndexTotal) {
+ minIndex = tempMinIndex;
+ minIndexTotal = tempMinIndexTotal;
+ }
+ }
+ } catch (SQLException sqlEx) {
+ throw new I2B2DAOException("", sqlEx);
+ } finally {
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)) {
+ deleteTempTable(conn);
+ if (inputOptionListHandler.isEnumerationSet()) {
+ deleteTemp1Table(conn);
+ }
+ }
+ // close connection
+ try {
+ JDBCUtil.closeJdbcResource(null, null, conn);
+ } catch (SQLException e) {
+ log.error("Error trying to close connection", e);
+ }
+ }
+
+ minAndTotalMap.put("MIN_INDEX", minIndex);
+ minAndTotalMap.put("MIN_INDEX_TOTAL", minIndexTotal);
+
+ return minAndTotalMap;
+ }
+
+ private ResultSet executeTotalSql(String totalSql, Connection conn,
+ int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
+ throws SQLException {
+
+ PreparedStatement stmt = conn.prepareStatement(totalSql);
+ ResultSet resultSet = null;
+
+ log.debug(totalSql + " [ " + sqlParamCount + " ]");
+ if (inputOptionListHandler.isCollectionId()) {
+ for (int i = 1; i <= sqlParamCount; i++) {
+ stmt.setInt(i, Integer.parseInt(inputOptionListHandler
+ .getCollectionId()));
+ }
+ }
+
+ resultSet = stmt.executeQuery();
+
+ return resultSet;
+ }
+
+ public void sqlserverLoadTempTable(Connection conn,
+ IInputOptionListHandler inputOptionListHandler) throws SQLException {
+ // sqlserver
+ upLoadTempTable(conn, inputOptionListHandler);
+
+ }
+
+ @Override
+ public String buildTotalSql(IFactRelatedQueryHandler factHandler,
+ PanelType panel) throws I2B2DAOException {
+ // call factrelatedhandler to build sql
+ return factHandler.buildTotalQuery(panel,
+ PdoQueryHandler.PLAIN_PDO_TYPE);
+ }
+
+ public void getSelect() {
+ }
+
+ public void getFrom() {
+ }
+
+ public void getWhere() {
+ }
+
+ private void upLoadTempTable(Connection conn,
+ IInputOptionListHandler inputOptionListHandler) throws SQLException {
+ List enumList = inputOptionListHandler.getEnumerationList();
+ // create temp table
+ java.sql.Statement tempStmt = conn.createStatement();
+ String createTempInputListTable = "create table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " ( char_param1 varchar(100) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ // load to temp table
+ // TempInputListInsert inputListInserter = new
+ // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
+ // inputListInserter.setBatchSize(100);
+ int i = 0;
+ for (String singleValue : enumList) {
+ tempStmt.addBatch("insert into "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " values ('" + singleValue + "' )");
+ i++;
+ if (i % 100 == 0) {
+ tempStmt.executeBatch();
+
+ }
+ }
+ tempStmt.executeBatch();
+ }
+
+ private void upLoadTempTableForMin(Connection conn,
+ IInputOptionListHandler inputOptionListHandler) throws SQLException {
+ List enumList = inputOptionListHandler.getEnumerationList();
+ deleteTempTable(conn);
+ // create temp table
+ java.sql.Statement tempStmt = conn.createStatement();
+ String createTempInputListTable = "create table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " (set_index int, char_param1 varchar(100) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ // load to temp table
+ // TempInputListInsert inputListInserter = new
+ // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
+ // inputListInserter.setBatchSize(100);
+ int i = 0, j = 1;
+ for (String singleValue : enumList) {
+ tempStmt.addBatch("insert into "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + "(set_index,char_param1) values (" + j++ + ",'"
+ + singleValue + "' )");
+ i++;
+ if (i % 100 == 0) {
+ tempStmt.executeBatch();
+
+ }
+ }
+ tempStmt.executeBatch();
+ }
+
+ private void deleteTempTable(Connection conn) {
+
+ Statement deleteStmt = null;
+ try {
+ deleteStmt = conn.createStatement();
+
+ //conn
+ // .createStatement()
+ deleteStmt.executeUpdate(
+ "drop table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
+ } catch (SQLException sqle) {
+ ;
+ } finally {
+ try {
+ if(deleteStmt != null)
+ deleteStmt.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private void deleteTemp1Table(Connection conn) {
+
+ Statement deleteStmt = null;
+ try {
+ deleteStmt = conn.createStatement();
+ // conn
+ // .createStatement()
+ deleteStmt.executeUpdate(
+ "drop table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
+ } catch (SQLException sqle) {
+ ;
+ } finally {
+ try {
+ if(deleteStmt != null)
+ deleteStmt.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java
index 053c2114..b5dfe512
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/ParamTypeValueBuilder.java
@@ -1,54 +1,54 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.Date;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import edu.harvard.i2b2.common.util.jaxb.DTOFactory;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-
-public class ParamTypeValueBuilder {
- private DTOFactory dtoFactory = new DTOFactory();
-
- public List buildParamType(ResultSet resultSet, MetadataDao.TableMetaData tableMetaData) {
- return null;
- }
-
- public ParamType buildParamType(ParamType metaParamType,String fieldPrefix, String lookupFieldSuffix, ResultSet rowSet) throws SQLException {
- ParamType paramType = new ParamType();
-
- paramType.setColumn(metaParamType.getColumn());
- paramType.setColumnDescriptor(metaParamType.getColumnDescriptor());
-
- if (lookupFieldSuffix != null && !metaParamType.getType().startsWith("defaulted:")) {
- paramType.setName(rowSet.getString(metaParamType.getColumn() + lookupFieldSuffix ));
- }
- if (metaParamType.getType().startsWith("defaulted:")) {
- paramType.setType(metaParamType.getType().substring(10));
- } else {
- paramType.setType(metaParamType.getType());
- }
- //paramType.setValue(rowSet.getString(fieldPrefix + metaParamType.getColumn()));
-
- if (metaParamType.getType().equalsIgnoreCase("dateTime")) {
- Date paramDate = rowSet.getTimestamp(fieldPrefix + metaParamType.getColumn());
- if (paramDate != null) {
- paramType.setValue(dtoFactory.getXMLGregorianCalendar(paramDate.getTime()).toXMLFormat());
- }
- } else {
- paramType.setValue(rowSet.getString(fieldPrefix + metaParamType.getColumn()));
- }
-
- return paramType;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.util.Date;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+import edu.harvard.i2b2.common.util.jaxb.DTOFactory;
+import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
+
+public class ParamTypeValueBuilder {
+ private DTOFactory dtoFactory = new DTOFactory();
+
+ public List buildParamType(ResultSet resultSet, MetadataDao.TableMetaData tableMetaData) {
+ return null;
+ }
+
+ public ParamType buildParamType(ParamType metaParamType,String fieldPrefix, String lookupFieldSuffix, ResultSet rowSet) throws SQLException {
+ ParamType paramType = new ParamType();
+
+ paramType.setColumn(metaParamType.getColumn());
+ paramType.setColumnDescriptor(metaParamType.getColumnDescriptor());
+
+ if (lookupFieldSuffix != null && !metaParamType.getType().startsWith("defaulted:")) {
+ paramType.setName(rowSet.getString(metaParamType.getColumn() + lookupFieldSuffix ));
+ }
+ if (metaParamType.getType().startsWith("defaulted:")) {
+ paramType.setType(metaParamType.getType().substring(10));
+ } else {
+ paramType.setType(metaParamType.getType());
+ }
+ //paramType.setValue(rowSet.getString(fieldPrefix + metaParamType.getColumn()));
+
+ if (metaParamType.getType().equalsIgnoreCase("dateTime")) {
+ Date paramDate = rowSet.getTimestamp(fieldPrefix + metaParamType.getColumn());
+ if (paramDate != null) {
+ paramType.setValue(dtoFactory.getXMLGregorianCalendar(paramDate.getTime()).toXMLFormat());
+ }
+ } else {
+ paramType.setValue(rowSet.getString(fieldPrefix + metaParamType.getColumn()));
+ }
+
+ return paramType;
+ }
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java
index bf7b3538..424f6817
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryConceptDao.java
@@ -1,419 +1,419 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-/*
-
- *
- * Contributors:
- * Rajesh Kuttan
- */
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
-import javax.sql.DataSource;
-
-import oracle.sql.ArrayDescriptor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-//import org.jboss.resource.adapter.jdbc.WrappedConnection;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.util.db.JDBCUtil;
-import edu.harvard.i2b2.crc.dao.CRCDAO;
-import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
-import edu.harvard.i2b2.crc.dao.pdo.input.FactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.output.ConceptFactRelated;
-import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
-import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ConceptType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-
-/**
- * This class handles Concept dimension query's related to PDO request $Id:
- * PdoQueryConceptDao.java,v 1.11 2008/03/19 22:42:08 rk903 Exp $
- *
- * @author rkuttan
- */
-public class PdoQueryConceptDao extends CRCDAO implements IPdoQueryConceptDao {
-
- private DataSourceLookup dataSourceLookup = null;
-
- public PdoQueryConceptDao(DataSourceLookup dataSourceLookup,
- DataSource dataSource) {
- this.dataSourceLookup = dataSourceLookup;
- setDataSource(dataSource);
- setDbSchemaName(dataSourceLookup.getFullSchema());
- }
-
- /** log * */
- protected final Log log = LogFactory.getLog(getClass());
-
- /**
- * Get concepts detail from concept code list
- *
- * @param conceptCdList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return {@link PatientDataType.ConceptDimensionSet}
- * @throws I2B2DAOException
- */
- @Override
- public ConceptSet getConceptByConceptCd(List conceptCdList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException {
-
- ConceptSet conceptDimensionSet = new ConceptSet();
- log.debug("Size of input concept cd list " + conceptCdList.size());
- Connection conn = null;
- PreparedStatement query = null;
- String tempTableName = "";
- try {
- conn = getDataSource().getConnection();
- ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
-
- String selectClause = conceptFactRelated.getSelectClause();
- String serverType = dataSourceLookup.getServerType();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
- // get oracle connection from jboss wrapped connection
- // Otherwise Jboss wrapped connection fails when using oracle
- // Arrays
- oracle.jdbc.driver.OracleConnection conn1 =null;
- //(oracle.jdbc.driver.OracleConnection) ((WrappedConnection) conn)
- // .getUnderlyingConnection();
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept WHERE concept.concept_cd IN (SELECT * FROM TABLE (?))";
- log.debug("Pdo Concept sql [" + finalSql + "]");
- query = conn1.prepareStatement(finalSql);
-
- ArrayDescriptor desc = ArrayDescriptor.createDescriptor(
- "QT_PDO_QRY_STRING_ARRAY", conn1);
-
- oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY(desc, conn1,
- conceptCdList.toArray(new String[] {}));
- query.setArray(1, paramArray);
- } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
- serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
- log.debug("creating temp table");
- java.sql.Statement tempStmt = conn.createStatement();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
- tempTableName = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1);
- else
- tempTableName = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE;
- try {
- tempStmt.executeUpdate("drop table " + tempTableName);
- } catch (SQLException sqlex) {
- ;
- }
-
- uploadTempTable(tempStmt, tempTableName, conceptCdList, serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL));
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept WHERE concept.concept_cd IN (select distinct char_param1 FROM "
- + tempTableName + ") order by concept_path";
- log.debug("Executing [" + finalSql + "]");
-
- query = conn.prepareStatement(finalSql);
-
- }
- ResultSet resultSet = query.executeQuery();
-
- I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
- detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
- while (resultSet.next()) {
- ConceptType conceptDimensionType = conceptBuilder
- .buildConceptSet(resultSet);
- conceptDimensionSet.getConcept().add(conceptDimensionType);
- }
-
- } catch (SQLException sqlEx) {
- log.error("", sqlEx);
- throw new I2B2DAOException("", sqlEx);
- } catch (IOException ioEx) {
- log.error("", ioEx);
- throw new I2B2DAOException("", ioEx);
- } finally {
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)) {
- PdoTempTableUtil tempUtil = new PdoTempTableUtil();
- tempUtil.deleteTempTableSqlServer(conn, tempTableName);
- }
- try {
- JDBCUtil.closeJdbcResource(null, query, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return conceptDimensionSet;
- }
-
- /**
- * Get concept children by item key
- *
- * @param itemKey
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return
- * @throws I2B2DAOException
- */
- @Override
- public ConceptSet getChildrentByItemKey(String itemKey, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
- ConceptSet conceptDimensionSet = new ConceptSet();
- if (itemKey != null) {
- if (itemKey.lastIndexOf('\\') == itemKey.length() - 1) {
- itemKey = itemKey + "%";
- } else {
- log.debug("Adding \\ at the end of the Concept path ");
- itemKey = itemKey + "\\%";
- }
- }
- log.debug("getChildrenByItemKey [" + itemKey + "]");
- Connection conn = null;
- PreparedStatement query = null;
- try {
- conn = getDataSource().getConnection();
- ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
-
- String selectClause = conceptFactRelated.getSelectClause();
- String serverType = dataSourceLookup.getServerType();
- String finalSql = "";
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
- finalSql = "Select * from (SELECT "
- + " RowNum RowNum, "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
-
- } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER)) {
- finalSql = "Select * from ( SELECT "
- + selectClause
- + " ROW_NUMBER() OVER (ORDER BY concept_path) AS RowNum"
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
-
- } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
- finalSql = "Select * from ( SELECT "
- + selectClause
- + " ROW_NUMBER() OVER (ORDER BY concept_path) AS RowNum"
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
- itemKey = itemKey.replaceAll("\\\\", "\\\\\\\\");
- }
- log.debug("Pdo Concept sql [" + finalSql + "]");
- query = conn.prepareStatement(finalSql);
- query.setString(1, itemKey);
- ResultSet resultSet = query.executeQuery();
-
- I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
- detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
- while (resultSet.next()) {
- ConceptType conceptDimensionType = conceptBuilder
- .buildConceptSet(resultSet);
- conceptDimensionSet.getConcept().add(conceptDimensionType);
- }
-
- } catch (SQLException sqlEx) {
- log.error("", sqlEx);
- throw new I2B2DAOException("", sqlEx);
- } catch (IOException ioEx) {
- log.error("", ioEx);
- throw new I2B2DAOException("", ioEx);
- } finally {
-
- try {
- JDBCUtil.closeJdbcResource(null, query, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return conceptDimensionSet;
- }
-
- private void uploadTempTable(Statement tempStmt, String tempTable,
- List patientNumList, boolean isPostgresql) throws SQLException {
- String createTempInputListTable = "create "
- + (isPostgresql ? " temp ": "" )
- + " table " + tempTable
- + " ( char_param1 varchar(100) )";
- tempStmt.executeUpdate(createTempInputListTable);
- log.debug("created temp table" + tempTable);
- PreparedStatement preparedStmt = tempStmt.getConnection()
- .prepareStatement("insert into " + tempTable + " values (?)");
- // load to temp table
- // TempInputListInsert inputListInserter = new
- // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
- // inputListInserter.setBatchSize(100);
- int i = 0;
- for (String singleValue : patientNumList) {
- preparedStmt.setString(1, singleValue);
- preparedStmt.addBatch();
- log.debug("adding batch [" + i + "] " + singleValue);
- i++;
- if (i % 100 == 0) {
- log.debug("batch insert [" + i + "]");
- preparedStmt.executeBatch();
-
- }
- }
- log.debug("batch insert [" + i + "]");
- preparedStmt.executeBatch();
- }
-
- @Override
- public ConceptSet getConceptByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
-
- ConceptSet conceptSet = new ConceptSet();
- I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
- detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
- ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
- String selectClause = conceptFactRelated.getSelectClause();
- String serverType = dataSourceLookup.getServerType();
- String tempTable = "";
- Connection conn = null;
- PreparedStatement query = null;
- try {
- conn = dataSource.getConnection();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
- tempTable = FactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE;
- } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
- serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
- log.debug("creating temp table");
- java.sql.Statement tempStmt = conn.createStatement();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
- tempTable = SQLServerFactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE.substring(1);
- else
- tempTable = SQLServerFactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE;
- try {
- tempStmt.executeUpdate("drop table " + tempTable);
- } catch (SQLException sqlex) {
- ;
- }
- String createTempInputListTable = "create "
- + (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL) ? " temp ": "" )
- + " table "
- + tempTable
- + " ( set_index int, char_param1 varchar(500) )";
-
- tempStmt.executeUpdate(createTempInputListTable);
- log.debug("created temp table" + tempTable);
- }
- // if the inputlist is enumeration, then upload the enumerated input
- // to temp table.
- // the uploaded enumerated input will be used in the fact join.
- if (inputOptionListHandler.isEnumerationSet()) {
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- }
- String insertSql = "";
- int i = 0;
- int sqlParamCount = 0;
- ResultSet resultSet = null;
- for (String panelSql : panelSqlList) {
- insertSql = " insert into "
- + tempTable
- + "(char_param1) select distinct obs_concept_cd from ( "
- + panelSql + ") b";
-
- log.debug("Executing SQL [ " + insertSql + "]");
- sqlParamCount = sqlParamCountList.get(i++);
- // conn.createStatement().executeUpdate(insertSql);
- executeTotalSql(insertSql, conn, sqlParamCount,
- inputOptionListHandler);
-
- }
-
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "concept_dimension concept where concept_cd in (select distinct char_param1 from "
- + tempTable + ") order by concept_path";
- log.debug("Executing SQL [" + finalSql + "]");
-
-
- query = conn.prepareStatement(finalSql);
-
- resultSet = query.executeQuery();
-
- while (resultSet.next()) {
- ConceptType concept = conceptBuilder.buildConceptSet(resultSet);
- conceptSet.getConcept().add(concept);
- }
- } catch (SQLException sqlEx) {
- log.error("", sqlEx);
- throw new I2B2DAOException("sql exception", sqlEx);
- } catch (IOException ioEx) {
- log.error("", ioEx);
- throw new I2B2DAOException("IO exception", ioEx);
- } finally {
- PdoTempTableUtil tempUtil = new PdoTempTableUtil();
- tempUtil.clearTempTable(dataSourceLookup.getServerType(), conn, tempTable);
-
- if (inputOptionListHandler != null
- && inputOptionListHandler.isEnumerationSet()) {
- try {
- inputOptionListHandler.deleteTempTable(conn);
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- }
- try {
-
- JDBCUtil.closeJdbcResource(null, query, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return conceptSet;
- }
-
- private void executeTotalSql(String totalSql, Connection conn,
- int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
- throws SQLException {
-
- PreparedStatement stmt = conn.prepareStatement(totalSql);
-
- log.debug(totalSql + " [ " + sqlParamCount + " ]");
- if (inputOptionListHandler.isCollectionId()) {
- for (int i = 1; i <= sqlParamCount; i++) {
- stmt.setInt(i, Integer.parseInt(inputOptionListHandler
- .getCollectionId()));
- }
- }
-
- stmt.executeUpdate();
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+/*
+
+ *
+ * Contributors:
+ * Rajesh Kuttan
+ */
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import oracle.sql.ArrayDescriptor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+//import org.jboss.resource.adapter.jdbc.WrappedConnection;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.util.db.JDBCUtil;
+import edu.harvard.i2b2.crc.dao.CRCDAO;
+import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
+import edu.harvard.i2b2.crc.dao.pdo.input.FactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.output.ConceptFactRelated;
+import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
+import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
+import edu.harvard.i2b2.crc.datavo.pdo.ConceptType;
+import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
+
+/**
+ * This class handles Concept dimension query's related to PDO request $Id:
+ * PdoQueryConceptDao.java,v 1.11 2008/03/19 22:42:08 rk903 Exp $
+ *
+ * @author rkuttan
+ */
+public class PdoQueryConceptDao extends CRCDAO implements IPdoQueryConceptDao {
+
+ private DataSourceLookup dataSourceLookup = null;
+
+ public PdoQueryConceptDao(DataSourceLookup dataSourceLookup,
+ DataSource dataSource) {
+ this.dataSourceLookup = dataSourceLookup;
+ setDataSource(dataSource);
+ setDbSchemaName(dataSourceLookup.getFullSchema());
+ }
+
+ /** log * */
+ protected final Log log = LogFactory.getLog(getClass());
+
+ /**
+ * Get concepts detail from concept code list
+ *
+ * @param conceptCdList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return {@link PatientDataType.ConceptDimensionSet}
+ * @throws I2B2DAOException
+ */
+ @Override
+ public ConceptSet getConceptByConceptCd(List conceptCdList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException {
+
+ ConceptSet conceptDimensionSet = new ConceptSet();
+ log.debug("Size of input concept cd list " + conceptCdList.size());
+ Connection conn = null;
+ PreparedStatement query = null;
+ String tempTableName = "";
+ try {
+ conn = getDataSource().getConnection();
+ ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+
+ String selectClause = conceptFactRelated.getSelectClause();
+ String serverType = dataSourceLookup.getServerType();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
+ // get oracle connection from jboss wrapped connection
+ // Otherwise Jboss wrapped connection fails when using oracle
+ // Arrays
+ oracle.jdbc.driver.OracleConnection conn1 =null;
+ //(oracle.jdbc.driver.OracleConnection) ((WrappedConnection) conn)
+ // .getUnderlyingConnection();
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept WHERE concept.concept_cd IN (SELECT * FROM TABLE (?))";
+ log.debug("Pdo Concept sql [" + finalSql + "]");
+ query = conn1.prepareStatement(finalSql);
+
+ ArrayDescriptor desc = ArrayDescriptor.createDescriptor(
+ "QT_PDO_QRY_STRING_ARRAY", conn1);
+
+ oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY(desc, conn1,
+ conceptCdList.toArray(new String[] {}));
+ query.setArray(1, paramArray);
+ } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
+ serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
+ log.debug("creating temp table");
+ java.sql.Statement tempStmt = conn.createStatement();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
+ tempTableName = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1);
+ else
+ tempTableName = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE;
+ try {
+ tempStmt.executeUpdate("drop table " + tempTableName);
+ } catch (SQLException sqlex) {
+ ;
+ }
+
+ uploadTempTable(tempStmt, tempTableName, conceptCdList, serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL));
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept WHERE concept.concept_cd IN (select distinct char_param1 FROM "
+ + tempTableName + ") order by concept_path";
+ log.debug("Executing [" + finalSql + "]");
+
+ query = conn.prepareStatement(finalSql);
+
+ }
+ ResultSet resultSet = query.executeQuery();
+
+ I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
+ detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
+ while (resultSet.next()) {
+ ConceptType conceptDimensionType = conceptBuilder
+ .buildConceptSet(resultSet);
+ conceptDimensionSet.getConcept().add(conceptDimensionType);
+ }
+
+ } catch (SQLException sqlEx) {
+ log.error("", sqlEx);
+ throw new I2B2DAOException("", sqlEx);
+ } catch (IOException ioEx) {
+ log.error("", ioEx);
+ throw new I2B2DAOException("", ioEx);
+ } finally {
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)) {
+ PdoTempTableUtil tempUtil = new PdoTempTableUtil();
+ tempUtil.deleteTempTableSqlServer(conn, tempTableName);
+ }
+ try {
+ JDBCUtil.closeJdbcResource(null, query, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return conceptDimensionSet;
+ }
+
+ /**
+ * Get concept children by item key
+ *
+ * @param itemKey
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return
+ * @throws I2B2DAOException
+ */
+ @Override
+ public ConceptSet getChildrentByItemKey(String itemKey, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
+ ConceptSet conceptDimensionSet = new ConceptSet();
+ if (itemKey != null) {
+ if (itemKey.lastIndexOf('\\') == itemKey.length() - 1) {
+ itemKey = itemKey + "%";
+ } else {
+ log.debug("Adding \\ at the end of the Concept path ");
+ itemKey = itemKey + "\\%";
+ }
+ }
+ log.debug("getChildrenByItemKey [" + itemKey + "]");
+ Connection conn = null;
+ PreparedStatement query = null;
+ try {
+ conn = getDataSource().getConnection();
+ ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+
+ String selectClause = conceptFactRelated.getSelectClause();
+ String serverType = dataSourceLookup.getServerType();
+ String finalSql = "";
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
+ finalSql = "Select * from (SELECT "
+ + " RowNum RowNum, "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
+
+ } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER)) {
+ finalSql = "Select * from ( SELECT "
+ + selectClause
+ + " ROW_NUMBER() OVER (ORDER BY concept_path) AS RowNum"
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
+
+ } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
+ finalSql = "Select * from ( SELECT "
+ + selectClause
+ + " ROW_NUMBER() OVER (ORDER BY concept_path) AS RowNum"
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept WHERE concept_path LIKE ? order by concept_path) ";
+ itemKey = itemKey.replaceAll("\\\\", "\\\\\\\\");
+ }
+ log.debug("Pdo Concept sql [" + finalSql + "]");
+ query = conn.prepareStatement(finalSql);
+ query.setString(1, itemKey);
+ ResultSet resultSet = query.executeQuery();
+
+ I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
+ detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
+ while (resultSet.next()) {
+ ConceptType conceptDimensionType = conceptBuilder
+ .buildConceptSet(resultSet);
+ conceptDimensionSet.getConcept().add(conceptDimensionType);
+ }
+
+ } catch (SQLException sqlEx) {
+ log.error("", sqlEx);
+ throw new I2B2DAOException("", sqlEx);
+ } catch (IOException ioEx) {
+ log.error("", ioEx);
+ throw new I2B2DAOException("", ioEx);
+ } finally {
+
+ try {
+ JDBCUtil.closeJdbcResource(null, query, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return conceptDimensionSet;
+ }
+
+ private void uploadTempTable(Statement tempStmt, String tempTable,
+ List patientNumList, boolean isPostgresql) throws SQLException {
+ String createTempInputListTable = "create "
+ + (isPostgresql ? " temp ": "" )
+ + " table " + tempTable
+ + " ( char_param1 varchar(100) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ log.debug("created temp table" + tempTable);
+ PreparedStatement preparedStmt = tempStmt.getConnection()
+ .prepareStatement("insert into " + tempTable + " values (?)");
+ // load to temp table
+ // TempInputListInsert inputListInserter = new
+ // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
+ // inputListInserter.setBatchSize(100);
+ int i = 0;
+ for (String singleValue : patientNumList) {
+ preparedStmt.setString(1, singleValue);
+ preparedStmt.addBatch();
+ log.debug("adding batch [" + i + "] " + singleValue);
+ i++;
+ if (i % 100 == 0) {
+ log.debug("batch insert [" + i + "]");
+ preparedStmt.executeBatch();
+
+ }
+ }
+ log.debug("batch insert [" + i + "]");
+ preparedStmt.executeBatch();
+ }
+
+ @Override
+ public ConceptSet getConceptByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
+
+ ConceptSet conceptSet = new ConceptSet();
+ I2B2PdoFactory.ConceptBuilder conceptBuilder = new I2B2PdoFactory().new ConceptBuilder(
+ detailFlag, blobFlag, statusFlag, dataSourceLookup.getServerType());
+ ConceptFactRelated conceptFactRelated = new ConceptFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+ String selectClause = conceptFactRelated.getSelectClause();
+ String serverType = dataSourceLookup.getServerType();
+ String tempTable = "";
+ Connection conn = null;
+ PreparedStatement query = null;
+ try {
+ conn = dataSource.getConnection();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
+ tempTable = FactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE;
+ } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
+ serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
+ log.debug("creating temp table");
+ java.sql.Statement tempStmt = conn.createStatement();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
+ tempTable = SQLServerFactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE.substring(1);
+ else
+ tempTable = SQLServerFactRelatedQueryHandler.TEMP_FACT_PARAM_TABLE;
+ try {
+ tempStmt.executeUpdate("drop table " + tempTable);
+ } catch (SQLException sqlex) {
+ ;
+ }
+ String createTempInputListTable = "create "
+ + (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL) ? " temp ": "" )
+ + " table "
+ + tempTable
+ + " ( set_index int, char_param1 varchar(500) )";
+
+ tempStmt.executeUpdate(createTempInputListTable);
+ log.debug("created temp table" + tempTable);
+ }
+ // if the inputlist is enumeration, then upload the enumerated input
+ // to temp table.
+ // the uploaded enumerated input will be used in the fact join.
+ if (inputOptionListHandler.isEnumerationSet()) {
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ }
+ String insertSql = "";
+ int i = 0;
+ int sqlParamCount = 0;
+ ResultSet resultSet = null;
+ for (String panelSql : panelSqlList) {
+ insertSql = " insert into "
+ + tempTable
+ + "(char_param1) select distinct obs_concept_cd from ( "
+ + panelSql + ") b";
+
+ log.debug("Executing SQL [ " + insertSql + "]");
+ sqlParamCount = sqlParamCountList.get(i++);
+ // conn.createStatement().executeUpdate(insertSql);
+ executeTotalSql(insertSql, conn, sqlParamCount,
+ inputOptionListHandler);
+
+ }
+
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "concept_dimension concept where concept_cd in (select distinct char_param1 from "
+ + tempTable + ") order by concept_path";
+ log.debug("Executing SQL [" + finalSql + "]");
+
+
+ query = conn.prepareStatement(finalSql);
+
+ resultSet = query.executeQuery();
+
+ while (resultSet.next()) {
+ ConceptType concept = conceptBuilder.buildConceptSet(resultSet);
+ conceptSet.getConcept().add(concept);
+ }
+ } catch (SQLException sqlEx) {
+ log.error("", sqlEx);
+ throw new I2B2DAOException("sql exception", sqlEx);
+ } catch (IOException ioEx) {
+ log.error("", ioEx);
+ throw new I2B2DAOException("IO exception", ioEx);
+ } finally {
+ PdoTempTableUtil tempUtil = new PdoTempTableUtil();
+ tempUtil.clearTempTable(dataSourceLookup.getServerType(), conn, tempTable);
+
+ if (inputOptionListHandler != null
+ && inputOptionListHandler.isEnumerationSet()) {
+ try {
+ inputOptionListHandler.deleteTempTable(conn);
+ } catch (SQLException e) {
+
+ e.printStackTrace();
+ }
+ }
+ try {
+
+ JDBCUtil.closeJdbcResource(null, query, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return conceptSet;
+ }
+
+ private void executeTotalSql(String totalSql, Connection conn,
+ int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
+ throws SQLException {
+
+ PreparedStatement stmt = conn.prepareStatement(totalSql);
+
+ log.debug(totalSql + " [ " + sqlParamCount + " ]");
+ if (inputOptionListHandler.isCollectionId()) {
+ for (int i = 1; i <= sqlParamCount; i++) {
+ stmt.setInt(i, Integer.parseInt(inputOptionListHandler
+ .getCollectionId()));
+ }
+ }
+
+ stmt.executeUpdate();
+
+ }
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java
old mode 100755
new mode 100644
similarity index 97%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java
index 0d5265a6..75ad0a0d
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryEidDao.java
@@ -1,623 +1,623 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-/*
-
- *
- * Contributors:
- * Rajesh Kuttan
- */
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import oracle.sql.ArrayDescriptor;
-
-//import org.jboss.resource.adapter.jdbc.WrappedConnection;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.util.db.JDBCUtil;
-import edu.harvard.i2b2.crc.dao.CRCDAO;
-import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
-import edu.harvard.i2b2.crc.dao.pdo.input.EidListTypeHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.FactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.PatientListTypeHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.output.EidFactRelated;
-import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
-import edu.harvard.i2b2.crc.datavo.pdo.EidSet;
-import edu.harvard.i2b2.crc.datavo.pdo.EidType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EidListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType.Pid;
-import edu.harvard.i2b2.crc.loader.delegate.LoaderQueryRequestDelegate;
-
-/**
- * Class to build patient section of plain pdo $Id: PdoQueryPatientDao.java,v
- * 1.11 2008/03/19 22:42:08 rk903 Exp $
- *
- * @author rkuttan
- */
-public class PdoQueryEidDao extends CRCDAO implements IPdoQueryEidDao {
-
- private DataSourceLookup dataSourceLookup = null;
- protected static Log logesapi = LogFactory.getLog(PdoQueryEidDao.class);
-
- public PdoQueryEidDao(DataSourceLookup dataSourceLookup,
- DataSource dataSource) {
- setDataSource(dataSource);
- setDbSchemaName(dataSourceLookup.getFullSchema());
- this.dataSourceLookup = dataSourceLookup;
- }
-
- /**
- * Function to return patient dimension data for given list of patient num
- *
- * @param patientNumList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- @Override
- public EidSet getEidByEncounterNum(List encounterNumList,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException {
-
- Connection conn = null;
- PreparedStatement query = null;
- EidSet eidSet = new EidSet();
-
- try {
- // execute fullsql
- conn = getDataSource().getConnection();
- EidFactRelated eidRelated = new EidFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
- String selectClause = eidRelated.getSelectClause();
- ResultSet resultSet = null;
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.ORACLE)) {
-
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "encounter_mapping em WHERE em.encounter_num IN (SELECT * FROM TABLE (cast (? as QT_PDO_QRY_STRING_ARRAY))) order by em_encounter_num";
- log.debug("Executing [" + finalSql + "]");
-
- oracle.jdbc.driver.OracleConnection conn1 = null;// (oracle.jdbc.driver.OracleConnection) ((WrappedConnection) conn)
- // .getUnderlyingConnection();
- query = conn.prepareStatement(finalSql);
- ArrayDescriptor desc = ArrayDescriptor.createDescriptor(
- "QT_PDO_QRY_STRING_ARRAY", conn1);
-
- oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY(desc, conn1,
- encounterNumList.toArray(new String[] {}));
- query.setArray(1, paramArray);
- resultSet = query.executeQuery();
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER) || dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.POSTGRESQL) ) {
- // create temp table
- // load to temp table
- // execute sql
- log.debug("creating temp table");
- java.sql.Statement tempStmt = conn.createStatement();
-
- uploadTempTable(tempStmt, encounterNumList, dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL));
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "encounter_mapping em WHERE em.encounter_num IN (select distinct char_param1 FROM "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + ") order by em_encounter_num";
- log.debug("Size of the encounter list "
- + encounterNumList.size());
- log.debug("Executing [" + finalSql + "]");
-
- query = conn.prepareStatement(finalSql);
- resultSet = query.executeQuery();
- }
-
- RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
- detailFlag, blobFlag, statusFlag);
- eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
-
- } catch (SQLException ex) {
- log.error("", ex);
- throw new I2B2DAOException("sql exception", ex);
- } catch (IOException ioex) {
- log.error("", ioex);
- throw new I2B2DAOException("io exception", ioex);
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)) {
- deleteTempTable(
- conn,
- SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
- }
- try {
- JDBCUtil.closeJdbcResource(null, query, conn);
-
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
-
- }
- return eidSet;
- }
-
- /**
- * Get Patient dimension data based on patientlist present in input option
- * list
- *
- * @param patientListType
- * {@link PatientListType}
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws I2B2DAOException
- */
- @Override
- public EidSet getEidFromPatientSet(PatientListType patientListType,
- boolean detailFlag, boolean blobFlag, boolean statusFlag)
- throws I2B2DAOException {
-
- PatientListTypeHandler patientListTypeHandler = new PatientListTypeHandler(
- dataSourceLookup, patientListType);
- String inSqlClause = patientListTypeHandler.generateWhereClauseSql();
-
- EidFactRelated eidRelated = new EidFactRelated(buildOutputOptionType(
- detailFlag, blobFlag, statusFlag));
- String selectClause = eidRelated.getSelectClause();
- String mainSqlString = " SELECT " + selectClause + " FROM "
- + getDbSchemaName() + "encounter_mapping em,"
- + getDbSchemaName()
- + "visit_dimension vd WHERE vd.patient_num IN ( ";
- mainSqlString += inSqlClause;
- mainSqlString += " ) and vd.encounter_num = em.encounter_num order by em_encounter_num \n";
-
- EidSet eidSet = new EidSet();
- Connection conn = null;
- PreparedStatement preparedStmt = null;
- try {
- // execute fullsql
- conn = getDataSource().getConnection();
-
- log.debug("Executing sql[" + mainSqlString + "]");
-
- if (patientListTypeHandler.isCollectionId()) {
- String patientSetCollectionId = patientListTypeHandler
- .getCollectionId();
- preparedStmt = conn.prepareStatement(mainSqlString);
- preparedStmt.setString(1, patientSetCollectionId);
-
- } else if (patientListTypeHandler.isEnumerationSet()) {
- String serverType = dataSourceLookup.getServerType();
- patientListTypeHandler.uploadEnumerationValueToTempTable(conn);
- preparedStmt = conn.prepareStatement(mainSqlString);
-
- } else {
- preparedStmt = conn.prepareStatement(mainSqlString);
- }
- ResultSet resultSet = preparedStmt.executeQuery();
- RPDRPdoFactory.EidBuilder pidBuilder = new RPDRPdoFactory.EidBuilder(
- detailFlag, blobFlag, statusFlag);
- eidSet = buildEidSetFromResultSet(resultSet, pidBuilder);
-
- } catch (SQLException sqlEx) {
- log.error("", sqlEx);
- throw new I2B2DAOException("SQLException", sqlEx);
- } catch (IOException ioex) {
- log.error("", ioex);
- throw new I2B2DAOException("io exception", ioex);
- } finally {
- if (patientListTypeHandler.isEnumerationSet()) {
- try {
- patientListTypeHandler.deleteTempTable(conn);
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- }
- try {
- JDBCUtil.closeJdbcResource(null, preparedStmt, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return eidSet;
- }
-
- /**
- * Function to return patient dimension data for given list of pid list
- *
- * @param pidList
- * @param detailFlag
- * @param blobFlag
- * @param statusFlag
- * @return PatientDataType.PatientDimensionSet
- * @throws Exception
- */
- @Override
- public EidSet getEidByEidList(EidListType eidList, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
-
- Connection conn = null;
- PreparedStatement query = null;
- EidSet eidSet = new EidSet();
- EidListTypeHandler eidListHandler = new EidListTypeHandler(
- dataSourceLookup, eidList);
- try {
- // execute fullsql
- conn = getDataSource().getConnection();
- EidFactRelated eidRelated = new EidFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
- String selectClause = eidRelated.getSelectClause();
-
- ResultSet resultSet = null;
-
- // create temp table
- // load to temp table
- // execute sql
- log.debug("creating temp table");
- java.sql.Statement tempStmt = conn.createStatement();
-
- eidListHandler.uploadEnumerationValueToTempTable(conn);
- String tempTableName = eidListHandler.getTempTableName();
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "encounter_mapping em where encounter_num in ( "
- + " select encounter_num FROM "
- + getDbSchemaName()
- + "encounter_mapping em "
- + " WHERE exists "
- + "(select char_param2 FROM "
- + tempTableName
- + " where em.encounter_ide = char_param1 and em.encounter_ide_source = char_param2 ) "
- + ") order by em_encounter_num";
- log.debug("Executing [" + finalSql + "]");
-
- query = conn.prepareStatement(finalSql);
- resultSet = query.executeQuery();
-
- RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
- detailFlag, blobFlag, statusFlag);
- eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
-
- } catch (SQLException ex) {
- log.error("", ex);
- throw new I2B2DAOException("sql exception", ex);
- } catch (IOException ioex) {
- log.error("", ioex);
- throw new I2B2DAOException("io exception", ioex);
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
-
- try {
- eidListHandler.deleteTempTable(conn);
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
-
- try {
- JDBCUtil.closeJdbcResource(null, query, conn);
-
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
-
- }
- return eidSet;
- }
-
- private EidSet buildEidSetFromResultSet(ResultSet resultSet,
- RPDRPdoFactory.EidBuilder eidBuilder) throws SQLException,
- IOException {
- String prevPatientNum = "";
- EidType eidType = new EidType();
- EidSet eidSet = new EidSet();
- boolean firstFlag = true;
- EidType.EventId singleEventId = new EidType.EventId();
- EidType singleEidType = null;
- EidType.EventMapId eidMapId = null;
- String tempSinglePidType = null;
- while (resultSet.next()) {
- singleEidType = eidBuilder.buildEidSet(resultSet);
- eidMapId = singleEidType.getEventMapId().get(0);
- log.debug("Building pidMapId " + eidMapId.getValue()
- + " " + singleEidType.getEventId().getValue() + " "
- + eidMapId.getSource());
- tempSinglePidType = singleEidType.getEventId().getValue();
-
- if (prevPatientNum.equals(singleEidType.getEventId().getValue())) {
- if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
- eidType.getEventMapId().add(eidMapId);
- }
- } else {
- if (firstFlag) {
- if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
- eidType.getEventMapId().add(eidMapId);
- }
-
- // pidType.getPatientMapId().add(pidMapId);
- firstFlag = false;
- } else {
-
- eidSet.getEid().add(eidType);
- singleEventId = new EidType.EventId();
- eidType = new EidType();
- if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
- eidType.getEventMapId().add(eidMapId);
- }
- }
- }
- if (eidMapId.getSource().equalsIgnoreCase("hive")) {
- singleEventId.setSource(eidMapId.getSource());
- singleEventId.setValue(eidMapId.getValue());
- singleEventId.setPatientId(eidMapId.getPatientId());
- singleEventId.setPatientIdSource(eidMapId.getPatientIdSource());
- singleEventId.setSourcesystemCd(eidMapId.getSourcesystemCd());
- singleEventId.setStatus(eidMapId.getStatus());
- singleEventId.setUploadId(eidMapId.getUploadId());
- singleEventId.setUpdateDate(eidMapId.getUpdateDate());
- singleEventId.setImportDate(eidMapId.getImportDate());
- singleEventId.setDownloadDate(eidMapId.getDownloadDate());
- eidType.setEventId(singleEventId);
- }
- prevPatientNum = tempSinglePidType;
-
- }
- // eidType.setEventId(singleEventId);
- if ((eidType.getEventId() != null && eidType.getEventId().getValue() != null)
- || (eidType.getEventMapId() != null && eidType.getEventMapId()
- .size() > 0)) {
- eidSet.getEid().add(eidType);
- }
- return eidSet;
- }
-
- private void uploadTempTable(Statement tempStmt, List patientNumList, boolean isPostgresql)
- throws SQLException {
- String createTempInputListTable = "create "
- + (isPostgresql ? " temp ": "" )
- + " table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " ( char_param1 varchar(100) )";
- tempStmt.executeUpdate(createTempInputListTable);
- log.debug("created temp table"
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
- // load to temp table
- // TempInputListInsert inputListInserter = new
- // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
- // inputListInserter.setBatchSize(100);
- int i = 0;
- for (String singleValue : patientNumList) {
- tempStmt.addBatch("insert into "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " values ('" + singleValue + "' )");
- log.debug("adding batch" + singleValue);
- i++;
- if (i % 100 == 0) {
- log.debug("batch insert");
- tempStmt.executeBatch();
-
- }
- }
- log.debug("batch insert1");
- tempStmt.executeBatch();
- }
-
- private void deleteTempTable(Connection conn, String tempTableName) {
-
- Statement deleteStmt = null;
- try {
- deleteStmt = conn.createStatement();
- //conn.createStatement().executeUpdate("drop table " + tempTableName);
- deleteStmt.executeUpdate("drop table " + tempTableName);
-
- } catch (SQLException sqle) {
- ;
- } finally {
- try {
- if(deleteStmt != null)
- deleteStmt.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
-
- private void upLoadEidListToTempTable(Connection conn,
- String tempTableName, PidListType pidListType) throws SQLException {
-
- // create temp table
- java.sql.Statement tempStmt = conn.createStatement();
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)) {
- String createTempInputListTable = "create table "
- + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
- + " (set_index int, char_param1 varchar(200), char_param2 varchar(200) )";
- tempStmt.executeUpdate(createTempInputListTable);
- }
- // load to temp table
- // TempInputListInsert inputListInserter = new
- // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
- // inputListInserter.setBatchSize(100);
- int i = 0, j = 1;
- for (Pid pid : pidListType.getPid()) {
- tempStmt.addBatch("insert into " + tempTableName
- + "(set_index,char_param1,char_param2) values ("
- + pid.getIndex() + ",'" + pid.getSource() + "','"
- + pid.getValue() + "')");
- i++;
- if (i % 100 == 0) {
- tempStmt.executeBatch();
-
- }
- }
- tempStmt.executeBatch();
- }
-
- @Override
- public EidSet getEidByFact(List panelSqlList,
- List sqlParamCountList,
- IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
- boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
- EidSet eidSet = new EidSet();
- RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
- detailFlag, blobFlag, statusFlag);
- EidFactRelated eidFactRelated = new EidFactRelated(
- buildOutputOptionType(detailFlag, blobFlag, statusFlag));
- String selectClause = eidFactRelated.getSelectClause();
-
- String serverType = dataSourceLookup.getServerType();
- String tempTable = "";
- Connection conn = null;
- PreparedStatement query = null;
- try {
- conn = dataSource.getConnection();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
- tempTable = FactRelatedQueryHandler.TEMP_PARAM_TABLE;
- } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
- serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
- log.debug("creating temp table");
- java.sql.Statement tempStmt = conn.createStatement();
- if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
- tempTable = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1);
- else
- tempTable = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE;
- try {
- tempStmt.executeUpdate("drop table " + tempTable);
- } catch (SQLException sqlex) {
- ;
- }
- String createTempInputListTable = "create table " + tempTable
- + " ( set_index int, char_param1 varchar(500) )";
- tempStmt.executeUpdate(createTempInputListTable);
- log.debug("created temp table" + tempTable);
- }
- // if the inputlist is enumeration, then upload the enumerated input
- // to temp table.
- // the uploaded enumerated input will be used in the fact join.
- if (inputOptionListHandler.isEnumerationSet()) {
- inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
- }
- String insertSql = "";
- int i = 0;
- int sqlParamCount = 0;
- ResultSet resultSet = null;
- for (String panelSql : panelSqlList) {
- insertSql = " insert into "
- + tempTable
- + "(char_param1) select distinct obs_encounter_num from ( "
- + panelSql + ") b";
-
- log.debug("Executing SQL [ " + insertSql + "]");
- sqlParamCount = sqlParamCountList.get(i++);
- // conn.createStatement().executeUpdate(insertSql);
- executeUpdateSql(insertSql, conn, sqlParamCount,
- inputOptionListHandler);
-
- }
-
- String finalSql = "SELECT "
- + selectClause
- + " FROM "
- + getDbSchemaName()
- + "encounter_mapping em "
- + " where encounter_num in (select distinct char_param1 from "
- + tempTable + ") order by encounter_num";
- log.debug("Executing SQL [" + finalSql + "]");
- log.debug("Final Sql " + finalSql);
-
- query = conn.prepareStatement(finalSql);
-
- resultSet = query.executeQuery();
-
- // while (resultSet.next()) {
- // EidType eid = eidBuilder.buildEidSet(resultSet);
- // eidSet.getEid().add(eid);
- // }
- eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
- } catch (SQLException sqlEx) {
- log.error("", sqlEx);
- throw new I2B2DAOException("sql exception", sqlEx);
- } catch (IOException ioEx) {
- log.error("", ioEx);
- throw new I2B2DAOException("IO exception", ioEx);
- } finally {
-
- PdoTempTableUtil tempUtil = new PdoTempTableUtil();
- tempUtil.clearTempTable(dataSourceLookup.getServerType(), conn, tempTable);
-
- if (inputOptionListHandler != null
- && inputOptionListHandler.isEnumerationSet()) {
- try {
- inputOptionListHandler.deleteTempTable(conn);
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- }
- try {
-
- JDBCUtil.closeJdbcResource(null, query, conn);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- }
- }
- return eidSet;
-
- }
-
-
-
- private void executeUpdateSql(String totalSql, Connection conn,
- int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
- throws SQLException {
-
- PreparedStatement stmt = conn.prepareStatement(totalSql);
-
- log.debug(totalSql + " [ " + sqlParamCount + " ]");
- if (inputOptionListHandler.isCollectionId()) {
- for (int i = 1; i <= sqlParamCount; i++) {
- stmt.setInt(i, Integer.parseInt(inputOptionListHandler
- .getCollectionId()));
- }
- }
-
- int updatedRow = stmt.executeUpdate();
- log.debug("Total encounter num inserted [" + updatedRow + "]");
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006-2018 Massachusetts General Hospital
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
+ * the terms of the Healthcare Disclaimer.
+ ******************************************************************************/
+/*
+
+ *
+ * Contributors:
+ * Rajesh Kuttan
+ */
+package edu.harvard.i2b2.crc.dao.pdo;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import oracle.sql.ArrayDescriptor;
+
+//import org.jboss.resource.adapter.jdbc.WrappedConnection;
+
+import edu.harvard.i2b2.common.exception.I2B2DAOException;
+import edu.harvard.i2b2.common.util.db.JDBCUtil;
+import edu.harvard.i2b2.crc.dao.CRCDAO;
+import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
+import edu.harvard.i2b2.crc.dao.pdo.input.EidListTypeHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.FactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.PatientListTypeHandler;
+import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
+import edu.harvard.i2b2.crc.dao.pdo.output.EidFactRelated;
+import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
+import edu.harvard.i2b2.crc.datavo.pdo.EidSet;
+import edu.harvard.i2b2.crc.datavo.pdo.EidType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.EidListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType;
+import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType.Pid;
+import edu.harvard.i2b2.crc.loader.delegate.LoaderQueryRequestDelegate;
+
+/**
+ * Class to build patient section of plain pdo $Id: PdoQueryPatientDao.java,v
+ * 1.11 2008/03/19 22:42:08 rk903 Exp $
+ *
+ * @author rkuttan
+ */
+public class PdoQueryEidDao extends CRCDAO implements IPdoQueryEidDao {
+
+ private DataSourceLookup dataSourceLookup = null;
+ protected static Log logesapi = LogFactory.getLog(PdoQueryEidDao.class);
+
+ public PdoQueryEidDao(DataSourceLookup dataSourceLookup,
+ DataSource dataSource) {
+ setDataSource(dataSource);
+ setDbSchemaName(dataSourceLookup.getFullSchema());
+ this.dataSourceLookup = dataSourceLookup;
+ }
+
+ /**
+ * Function to return patient dimension data for given list of patient num
+ *
+ * @param patientNumList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ @Override
+ public EidSet getEidByEncounterNum(List encounterNumList,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException {
+
+ Connection conn = null;
+ PreparedStatement query = null;
+ EidSet eidSet = new EidSet();
+
+ try {
+ // execute fullsql
+ conn = getDataSource().getConnection();
+ EidFactRelated eidRelated = new EidFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+ String selectClause = eidRelated.getSelectClause();
+ ResultSet resultSet = null;
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.ORACLE)) {
+
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "encounter_mapping em WHERE em.encounter_num IN (SELECT * FROM TABLE (cast (? as QT_PDO_QRY_STRING_ARRAY))) order by em_encounter_num";
+ log.debug("Executing [" + finalSql + "]");
+
+ oracle.jdbc.driver.OracleConnection conn1 = null;// (oracle.jdbc.driver.OracleConnection) ((WrappedConnection) conn)
+ // .getUnderlyingConnection();
+ query = conn.prepareStatement(finalSql);
+ ArrayDescriptor desc = ArrayDescriptor.createDescriptor(
+ "QT_PDO_QRY_STRING_ARRAY", conn1);
+
+ oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY(desc, conn1,
+ encounterNumList.toArray(new String[] {}));
+ query.setArray(1, paramArray);
+ resultSet = query.executeQuery();
+ } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER) || dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.POSTGRESQL) ) {
+ // create temp table
+ // load to temp table
+ // execute sql
+ log.debug("creating temp table");
+ java.sql.Statement tempStmt = conn.createStatement();
+
+ uploadTempTable(tempStmt, encounterNumList, dataSourceLookup.getServerType().equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL));
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "encounter_mapping em WHERE em.encounter_num IN (select distinct char_param1 FROM "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + ") order by em_encounter_num";
+ log.debug("Size of the encounter list "
+ + encounterNumList.size());
+ log.debug("Executing [" + finalSql + "]");
+
+ query = conn.prepareStatement(finalSql);
+ resultSet = query.executeQuery();
+ }
+
+ RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
+ detailFlag, blobFlag, statusFlag);
+ eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
+
+ } catch (SQLException ex) {
+ log.error("", ex);
+ throw new I2B2DAOException("sql exception", ex);
+ } catch (IOException ioex) {
+ log.error("", ioex);
+ throw new I2B2DAOException("io exception", ioex);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)) {
+ deleteTempTable(
+ conn,
+ SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
+ }
+ try {
+ JDBCUtil.closeJdbcResource(null, query, conn);
+
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+
+ }
+ return eidSet;
+ }
+
+ /**
+ * Get Patient dimension data based on patientlist present in input option
+ * list
+ *
+ * @param patientListType
+ * {@link PatientListType}
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws I2B2DAOException
+ */
+ @Override
+ public EidSet getEidFromPatientSet(PatientListType patientListType,
+ boolean detailFlag, boolean blobFlag, boolean statusFlag)
+ throws I2B2DAOException {
+
+ PatientListTypeHandler patientListTypeHandler = new PatientListTypeHandler(
+ dataSourceLookup, patientListType);
+ String inSqlClause = patientListTypeHandler.generateWhereClauseSql();
+
+ EidFactRelated eidRelated = new EidFactRelated(buildOutputOptionType(
+ detailFlag, blobFlag, statusFlag));
+ String selectClause = eidRelated.getSelectClause();
+ String mainSqlString = " SELECT " + selectClause + " FROM "
+ + getDbSchemaName() + "encounter_mapping em,"
+ + getDbSchemaName()
+ + "visit_dimension vd WHERE vd.patient_num IN ( ";
+ mainSqlString += inSqlClause;
+ mainSqlString += " ) and vd.encounter_num = em.encounter_num order by em_encounter_num \n";
+
+ EidSet eidSet = new EidSet();
+ Connection conn = null;
+ PreparedStatement preparedStmt = null;
+ try {
+ // execute fullsql
+ conn = getDataSource().getConnection();
+
+ log.debug("Executing sql[" + mainSqlString + "]");
+
+ if (patientListTypeHandler.isCollectionId()) {
+ String patientSetCollectionId = patientListTypeHandler
+ .getCollectionId();
+ preparedStmt = conn.prepareStatement(mainSqlString);
+ preparedStmt.setString(1, patientSetCollectionId);
+
+ } else if (patientListTypeHandler.isEnumerationSet()) {
+ String serverType = dataSourceLookup.getServerType();
+ patientListTypeHandler.uploadEnumerationValueToTempTable(conn);
+ preparedStmt = conn.prepareStatement(mainSqlString);
+
+ } else {
+ preparedStmt = conn.prepareStatement(mainSqlString);
+ }
+ ResultSet resultSet = preparedStmt.executeQuery();
+ RPDRPdoFactory.EidBuilder pidBuilder = new RPDRPdoFactory.EidBuilder(
+ detailFlag, blobFlag, statusFlag);
+ eidSet = buildEidSetFromResultSet(resultSet, pidBuilder);
+
+ } catch (SQLException sqlEx) {
+ log.error("", sqlEx);
+ throw new I2B2DAOException("SQLException", sqlEx);
+ } catch (IOException ioex) {
+ log.error("", ioex);
+ throw new I2B2DAOException("io exception", ioex);
+ } finally {
+ if (patientListTypeHandler.isEnumerationSet()) {
+ try {
+ patientListTypeHandler.deleteTempTable(conn);
+ } catch (SQLException e) {
+
+ e.printStackTrace();
+ }
+ }
+ try {
+ JDBCUtil.closeJdbcResource(null, preparedStmt, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return eidSet;
+ }
+
+ /**
+ * Function to return patient dimension data for given list of pid list
+ *
+ * @param pidList
+ * @param detailFlag
+ * @param blobFlag
+ * @param statusFlag
+ * @return PatientDataType.PatientDimensionSet
+ * @throws Exception
+ */
+ @Override
+ public EidSet getEidByEidList(EidListType eidList, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
+
+ Connection conn = null;
+ PreparedStatement query = null;
+ EidSet eidSet = new EidSet();
+ EidListTypeHandler eidListHandler = new EidListTypeHandler(
+ dataSourceLookup, eidList);
+ try {
+ // execute fullsql
+ conn = getDataSource().getConnection();
+ EidFactRelated eidRelated = new EidFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+ String selectClause = eidRelated.getSelectClause();
+
+ ResultSet resultSet = null;
+
+ // create temp table
+ // load to temp table
+ // execute sql
+ log.debug("creating temp table");
+ java.sql.Statement tempStmt = conn.createStatement();
+
+ eidListHandler.uploadEnumerationValueToTempTable(conn);
+ String tempTableName = eidListHandler.getTempTableName();
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "encounter_mapping em where encounter_num in ( "
+ + " select encounter_num FROM "
+ + getDbSchemaName()
+ + "encounter_mapping em "
+ + " WHERE exists "
+ + "(select char_param2 FROM "
+ + tempTableName
+ + " where em.encounter_ide = char_param1 and em.encounter_ide_source = char_param2 ) "
+ + ") order by em_encounter_num";
+ log.debug("Executing [" + finalSql + "]");
+
+ query = conn.prepareStatement(finalSql);
+ resultSet = query.executeQuery();
+
+ RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
+ detailFlag, blobFlag, statusFlag);
+ eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
+
+ } catch (SQLException ex) {
+ log.error("", ex);
+ throw new I2B2DAOException("sql exception", ex);
+ } catch (IOException ioex) {
+ log.error("", ioex);
+ throw new I2B2DAOException("io exception", ioex);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+
+ try {
+ eidListHandler.deleteTempTable(conn);
+ } catch (SQLException e) {
+
+ e.printStackTrace();
+ }
+
+ try {
+ JDBCUtil.closeJdbcResource(null, query, conn);
+
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+
+ }
+ return eidSet;
+ }
+
+ private EidSet buildEidSetFromResultSet(ResultSet resultSet,
+ RPDRPdoFactory.EidBuilder eidBuilder) throws SQLException,
+ IOException {
+ String prevPatientNum = "";
+ EidType eidType = new EidType();
+ EidSet eidSet = new EidSet();
+ boolean firstFlag = true;
+ EidType.EventId singleEventId = new EidType.EventId();
+ EidType singleEidType = null;
+ EidType.EventMapId eidMapId = null;
+ String tempSinglePidType = null;
+ while (resultSet.next()) {
+ singleEidType = eidBuilder.buildEidSet(resultSet);
+ eidMapId = singleEidType.getEventMapId().get(0);
+ log.debug("Building pidMapId " + eidMapId.getValue()
+ + " " + singleEidType.getEventId().getValue() + " "
+ + eidMapId.getSource());
+ tempSinglePidType = singleEidType.getEventId().getValue();
+
+ if (prevPatientNum.equals(singleEidType.getEventId().getValue())) {
+ if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
+ eidType.getEventMapId().add(eidMapId);
+ }
+ } else {
+ if (firstFlag) {
+ if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
+ eidType.getEventMapId().add(eidMapId);
+ }
+
+ // pidType.getPatientMapId().add(pidMapId);
+ firstFlag = false;
+ } else {
+
+ eidSet.getEid().add(eidType);
+ singleEventId = new EidType.EventId();
+ eidType = new EidType();
+ if (!eidMapId.getSource().equalsIgnoreCase("hive")) {
+ eidType.getEventMapId().add(eidMapId);
+ }
+ }
+ }
+ if (eidMapId.getSource().equalsIgnoreCase("hive")) {
+ singleEventId.setSource(eidMapId.getSource());
+ singleEventId.setValue(eidMapId.getValue());
+ singleEventId.setPatientId(eidMapId.getPatientId());
+ singleEventId.setPatientIdSource(eidMapId.getPatientIdSource());
+ singleEventId.setSourcesystemCd(eidMapId.getSourcesystemCd());
+ singleEventId.setStatus(eidMapId.getStatus());
+ singleEventId.setUploadId(eidMapId.getUploadId());
+ singleEventId.setUpdateDate(eidMapId.getUpdateDate());
+ singleEventId.setImportDate(eidMapId.getImportDate());
+ singleEventId.setDownloadDate(eidMapId.getDownloadDate());
+ eidType.setEventId(singleEventId);
+ }
+ prevPatientNum = tempSinglePidType;
+
+ }
+ // eidType.setEventId(singleEventId);
+ if ((eidType.getEventId() != null && eidType.getEventId().getValue() != null)
+ || (eidType.getEventMapId() != null && eidType.getEventMapId()
+ .size() > 0)) {
+ eidSet.getEid().add(eidType);
+ }
+ return eidSet;
+ }
+
+ private void uploadTempTable(Statement tempStmt, List patientNumList, boolean isPostgresql)
+ throws SQLException {
+ String createTempInputListTable = "create "
+ + (isPostgresql ? " temp ": "" )
+ + " table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " ( char_param1 varchar(100) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ log.debug("created temp table"
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE);
+ // load to temp table
+ // TempInputListInsert inputListInserter = new
+ // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
+ // inputListInserter.setBatchSize(100);
+ int i = 0;
+ for (String singleValue : patientNumList) {
+ tempStmt.addBatch("insert into "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " values ('" + singleValue + "' )");
+ log.debug("adding batch" + singleValue);
+ i++;
+ if (i % 100 == 0) {
+ log.debug("batch insert");
+ tempStmt.executeBatch();
+
+ }
+ }
+ log.debug("batch insert1");
+ tempStmt.executeBatch();
+ }
+
+ private void deleteTempTable(Connection conn, String tempTableName) {
+
+ Statement deleteStmt = null;
+ try {
+ deleteStmt = conn.createStatement();
+ //conn.createStatement().executeUpdate("drop table " + tempTableName);
+ deleteStmt.executeUpdate("drop table " + tempTableName);
+
+ } catch (SQLException sqle) {
+ ;
+ } finally {
+ try {
+ if(deleteStmt != null)
+ deleteStmt.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private void upLoadEidListToTempTable(Connection conn,
+ String tempTableName, PidListType pidListType) throws SQLException {
+
+ // create temp table
+ java.sql.Statement tempStmt = conn.createStatement();
+ if (dataSourceLookup.getServerType().equalsIgnoreCase(
+ DAOFactoryHelper.SQLSERVER)) {
+ String createTempInputListTable = "create table "
+ + SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE
+ + " (set_index int, char_param1 varchar(200), char_param2 varchar(200) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ }
+ // load to temp table
+ // TempInputListInsert inputListInserter = new
+ // TempInputListInsert(dataSource,TEMP_PDO_INPUTLIST_TABLE);
+ // inputListInserter.setBatchSize(100);
+ int i = 0, j = 1;
+ for (Pid pid : pidListType.getPid()) {
+ tempStmt.addBatch("insert into " + tempTableName
+ + "(set_index,char_param1,char_param2) values ("
+ + pid.getIndex() + ",'" + pid.getSource() + "','"
+ + pid.getValue() + "')");
+ i++;
+ if (i % 100 == 0) {
+ tempStmt.executeBatch();
+
+ }
+ }
+ tempStmt.executeBatch();
+ }
+
+ @Override
+ public EidSet getEidByFact(List panelSqlList,
+ List sqlParamCountList,
+ IInputOptionListHandler inputOptionListHandler, boolean detailFlag,
+ boolean blobFlag, boolean statusFlag) throws I2B2DAOException {
+ EidSet eidSet = new EidSet();
+ RPDRPdoFactory.EidBuilder eidBuilder = new RPDRPdoFactory.EidBuilder(
+ detailFlag, blobFlag, statusFlag);
+ EidFactRelated eidFactRelated = new EidFactRelated(
+ buildOutputOptionType(detailFlag, blobFlag, statusFlag));
+ String selectClause = eidFactRelated.getSelectClause();
+
+ String serverType = dataSourceLookup.getServerType();
+ String tempTable = "";
+ Connection conn = null;
+ PreparedStatement query = null;
+ try {
+ conn = dataSource.getConnection();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.ORACLE)) {
+ tempTable = FactRelatedQueryHandler.TEMP_PARAM_TABLE;
+ } else if (serverType.equalsIgnoreCase(DAOFactoryHelper.SQLSERVER) ||
+ serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL)) {
+ log.debug("creating temp table");
+ java.sql.Statement tempStmt = conn.createStatement();
+ if (serverType.equalsIgnoreCase(DAOFactoryHelper.POSTGRESQL))
+ tempTable = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE.substring(1);
+ else
+ tempTable = SQLServerFactRelatedQueryHandler.TEMP_PDO_INPUTLIST_TABLE;
+ try {
+ tempStmt.executeUpdate("drop table " + tempTable);
+ } catch (SQLException sqlex) {
+ ;
+ }
+ String createTempInputListTable = "create table " + tempTable
+ + " ( set_index int, char_param1 varchar(500) )";
+ tempStmt.executeUpdate(createTempInputListTable);
+ log.debug("created temp table" + tempTable);
+ }
+ // if the inputlist is enumeration, then upload the enumerated input
+ // to temp table.
+ // the uploaded enumerated input will be used in the fact join.
+ if (inputOptionListHandler.isEnumerationSet()) {
+ inputOptionListHandler.uploadEnumerationValueToTempTable(conn);
+ }
+ String insertSql = "";
+ int i = 0;
+ int sqlParamCount = 0;
+ ResultSet resultSet = null;
+ for (String panelSql : panelSqlList) {
+ insertSql = " insert into "
+ + tempTable
+ + "(char_param1) select distinct obs_encounter_num from ( "
+ + panelSql + ") b";
+
+ log.debug("Executing SQL [ " + insertSql + "]");
+ sqlParamCount = sqlParamCountList.get(i++);
+ // conn.createStatement().executeUpdate(insertSql);
+ executeUpdateSql(insertSql, conn, sqlParamCount,
+ inputOptionListHandler);
+
+ }
+
+ String finalSql = "SELECT "
+ + selectClause
+ + " FROM "
+ + getDbSchemaName()
+ + "encounter_mapping em "
+ + " where encounter_num in (select distinct char_param1 from "
+ + tempTable + ") order by encounter_num";
+ log.debug("Executing SQL [" + finalSql + "]");
+ log.debug("Final Sql " + finalSql);
+
+ query = conn.prepareStatement(finalSql);
+
+ resultSet = query.executeQuery();
+
+ // while (resultSet.next()) {
+ // EidType eid = eidBuilder.buildEidSet(resultSet);
+ // eidSet.getEid().add(eid);
+ // }
+ eidSet = buildEidSetFromResultSet(resultSet, eidBuilder);
+ } catch (SQLException sqlEx) {
+ log.error("", sqlEx);
+ throw new I2B2DAOException("sql exception", sqlEx);
+ } catch (IOException ioEx) {
+ log.error("", ioEx);
+ throw new I2B2DAOException("IO exception", ioEx);
+ } finally {
+
+ PdoTempTableUtil tempUtil = new PdoTempTableUtil();
+ tempUtil.clearTempTable(dataSourceLookup.getServerType(), conn, tempTable);
+
+ if (inputOptionListHandler != null
+ && inputOptionListHandler.isEnumerationSet()) {
+ try {
+ inputOptionListHandler.deleteTempTable(conn);
+ } catch (SQLException e) {
+
+ e.printStackTrace();
+ }
+ }
+ try {
+
+ JDBCUtil.closeJdbcResource(null, query, conn);
+ } catch (SQLException sqlEx) {
+ sqlEx.printStackTrace();
+ }
+ }
+ return eidSet;
+
+ }
+
+
+
+ private void executeUpdateSql(String totalSql, Connection conn,
+ int sqlParamCount, IInputOptionListHandler inputOptionListHandler)
+ throws SQLException {
+
+ PreparedStatement stmt = conn.prepareStatement(totalSql);
+
+ log.debug(totalSql + " [ " + sqlParamCount + " ]");
+ if (inputOptionListHandler.isCollectionId()) {
+ for (int i = 1; i <= sqlParamCount; i++) {
+ stmt.setInt(i, Integer.parseInt(inputOptionListHandler
+ .getCollectionId()));
+ }
+ }
+
+ int updatedRow = stmt.executeUpdate();
+ log.debug("Total encounter num inserted [" + updatedRow + "]");
+ }
+
+}
diff --git a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java
old mode 100755
new mode 100644
similarity index 96%
rename from edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java
rename to edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java
index ca029b75..f304cd05
--- a/edu.harvard.i2b2.crc/src/server/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java
+++ b/edu.harvard.i2b2.crc/src/main/java/edu/harvard/i2b2/crc/dao/pdo/PdoQueryHandler.java
@@ -1,1075 +1,1075 @@
-/*******************************************************************************
- * Copyright (c) 2006-2018 Massachusetts General Hospital
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Mozilla Public License,
- * v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at http://mozilla.org/MPL/2.0/. I2b2 is also distributed under
- * the terms of the Healthcare Disclaimer.
- ******************************************************************************/
-/*
-
- *
- * Contributors:
- * Rajesh Kuttan
- */
-package edu.harvard.i2b2.crc.dao.pdo;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import edu.harvard.i2b2.common.exception.I2B2DAOException;
-import edu.harvard.i2b2.common.exception.I2B2Exception;
-import edu.harvard.i2b2.crc.dao.DAOFactoryHelper;
-import edu.harvard.i2b2.crc.dao.PatientDataDAOFactory;
-import edu.harvard.i2b2.crc.dao.pdo.input.FactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.IInputOptionListHandler;
-import edu.harvard.i2b2.crc.dao.pdo.input.PDOFactory;
-import edu.harvard.i2b2.crc.dao.pdo.input.SQLServerFactRelatedQueryHandler;
-import edu.harvard.i2b2.crc.dao.pdo.output.ConceptFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.EidFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.ModifierFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.ObservationFactFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.PatientFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.PidFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.ProviderFactRelated;
-import edu.harvard.i2b2.crc.dao.pdo.output.VisitFactRelated;
-import edu.harvard.i2b2.crc.datavo.db.DataSourceLookup;
-import edu.harvard.i2b2.crc.datavo.ontology.XmlValueType;
-import edu.harvard.i2b2.crc.datavo.pdo.ConceptSet;
-import edu.harvard.i2b2.crc.datavo.pdo.EidSet;
-import edu.harvard.i2b2.crc.datavo.pdo.EventSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ModifierSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ObservationSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ObserverSet;
-import edu.harvard.i2b2.crc.datavo.pdo.ParamType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientDataType;
-import edu.harvard.i2b2.crc.datavo.pdo.PatientSet;
-import edu.harvard.i2b2.crc.datavo.pdo.PidSet;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EidListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.EventListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.FilterListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.InputOptionListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.OutputOptionListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PanelType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PatientListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType;
-import edu.harvard.i2b2.crc.datavo.pdo.query.PidListType.Pid;
-
-/**
- * Main class for PDO queries.
- *
- *
- * The is the main class to handle pdo query's. It reads input,filter and output
- * option list from pdo request and delegate to following class to build
- * individual PDO sections.
- *
- * Observation Fact = {@link FactRelatedQueryHandler} PatientSet = {@list
- * PatientSection} ObservationSet ={@list ObservationSection} ObserverSet =
- * {@list ObserverSection} ConceptSet = {@list ConceptSection}
- *
- *
- * Sample PDO request sections:
- *
- * Input list:
- * 184
- *
- *
- *
- * Filter list: \i2b2\Diagnoses\
- *
- *
- *
- * Output Option List:
- * $Id: PdoQueryHandler.java,v 1.12 2008/07/21 19:53:40
- * rk903 Exp $
- *
- * @author rkuttan
- * @see FactRelatedQueryHandler
- * @see PatientFactRelated
- * @see ProviderFactRelated
- * @see VisitFactRelated
- * @see ObservationFactFactRelated
- */
-public class PdoQueryHandler {
- /** logger **/
- protected final Log log = LogFactory.getLog(getClass());
-
- /** Table pdo type value used internally **/
- public static final String TABLE_PDO_TYPE = "TABLE_PDO_TYPE";
- /** Plain pdo type value used internally **/
- public static final String PLAIN_PDO_TYPE = "PLAIN_PDO_TYPE";
- /** PDO request input list **/
- private InputOptionListType inputList = null;
- /** PDO request input list before paging **/
- private InputOptionListType origInputList = null;
- /** PDO request filter list **/
- private FilterListType filterList = null;
- /** PDO output option list **/
- private OutputOptionListType outputOptionList = null;
- /** Observation helper to build observation section in pdo **/
- private VisitFactRelated visitFactRelated = null;
- /** Observer helper class to build Observer section in pdo **/
- private ProviderFactRelated providerFactRelated = null;
- /** Patient helper class to build patient section in pdo **/
- private PatientFactRelated patientFactRelated = null;
- /** Concept helper class to build concept section in pdo **/
- private ConceptFactRelated conceptFactRelated = null;
- /** Modifier helper class to build concept section in pdo **/
- private ModifierFactRelated modifierFactRelated = null;
- /** Observation fact helper class to build observationfact **/
- private ObservationFactFactRelated obsFactFactRelated = null;
- private PidFactRelated pidFactRelated = null;
- private EidFactRelated eidFactRelated = null;
- /** instance variable for pdo type **/
- private String pdoType = null;
- /** instance variable to hold plain pdo **/
- private PatientDataType plainPdoType = null;
- /** instance variable to hold table pdo **/
- private PatientDataType tablePdoType = null;
-
- private PatientDataDAOFactory pdoDaoFactory = null;
-
- private Map projectParamMap = null;
- private Map modifierMetadataXmlMap = null;
- private String requestVersion = "";
- private List patientMetaDataParamType = null, visitMetaDataParamType = null;
-
-
-
- /**
- * Parameter constructor to initialize helper classes
- *
- * @param pdoType
- * @param inputList
- * @param filterList
- * @param outputOptionList
- * @throws I2B2Exception
- */
- public PdoQueryHandler(PatientDataDAOFactory pdoDaoFactory, String pdoType,
- InputOptionListType origInputList, InputOptionListType inputList,
- FilterListType filterList, OutputOptionListType outputOptionList)
- throws I2B2DAOException {
- if (pdoType == null) {
- throw new I2B2DAOException("Input pdoType should not be null");
- }
-
- if (!(pdoType.equalsIgnoreCase(PLAIN_PDO_TYPE) || pdoType
- .equalsIgnoreCase(TABLE_PDO_TYPE))) {
- throw new I2B2DAOException("Invalid pdoType : " + pdoType);
- }
-
- if (outputOptionList == null) {
- throw new I2B2DAOException(
- "Input output option list should not be null");
- }
-
-
- this.pdoDaoFactory = pdoDaoFactory;
- this.pdoType = pdoType;
- this.origInputList = origInputList;
- this.inputList = inputList;
- this.filterList = filterList;
- this.outputOptionList = outputOptionList;
-
- visitFactRelated = new VisitFactRelated(outputOptionList.getEventSet());
- providerFactRelated = new ProviderFactRelated(outputOptionList
- .getObserverSetUsingFilterList());
- patientFactRelated = new PatientFactRelated(outputOptionList
- .getPatientSet());
- conceptFactRelated = new ConceptFactRelated(outputOptionList
- .getConceptSetUsingFilterList());
- modifierFactRelated = new ModifierFactRelated(outputOptionList
- .getModifierSetUsingFilterList());
- obsFactFactRelated = new ObservationFactFactRelated(outputOptionList
- .getObservationSet());
- pidFactRelated = new PidFactRelated(outputOptionList.getPidSet());
- eidFactRelated = new EidFactRelated(outputOptionList.getEidSet());
-
- }
-
- public void setProjectParamMap(Map projectParamMap) {
- this.projectParamMap = projectParamMap;
- }
-
- public void setModifierMetadataXmlMap(Map modifierMetadataXmlMap) {
- this.modifierMetadataXmlMap = modifierMetadataXmlMap;
- }
-
- public void setRequestVersion(String requestVersion) {
- this.requestVersion = requestVersion;
- }
-
- public void setDimensionMetaDataParamList(List patientMetaDataParamType, List visitMetaDataParamType) {
- this.patientMetaDataParamType = patientMetaDataParamType;
- this.visitMetaDataParamType = visitMetaDataParamType;
-
- }
-
- /**
- * Method to find if input list is pid set
- *
- * @return boolean
- */
- public boolean isGetPDOFromPIDSet() {
- if (inputList.getPidList() != null) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Method to find if input list is patient set
- *
- * @return boolean
- */
- public boolean isGetPDOFromPatientSet() {
- if (inputList.getPatientList() != null) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Method to find if input list is visit set
- *
- * @return boolean
- */
- public boolean isGetPDOFromVisitSet() {
- if (inputList.getEventList() != null) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Method to find if input list is pid set
- *
- * @return boolean
- */
- public boolean isGetPDOFromPidSet() {
- if (inputList.getPidList() != null) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Method to find if input list is eid set
- *
- * @return boolean
- */
- public boolean isGetPDOFromEidSet() {
- if (inputList.getEidList() != null) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Returns TablePDO
- *
- * @return TablePatientDataType
- */
- public PatientDataType getTablePdo() {
- return tablePdoType;
- }
-
- /**
- * Returns PlainPDO
- *
- * @return PatientDataType
- */
- public PatientDataType getPlainPdo() {
- return plainPdoType;
- }
-
-
- /**
- *
- * @throws Exception
- */
- public void processPDORequest() throws Exception {
- tablePdoType = new PatientDataType();
- plainPdoType = new PatientDataType();
-
- // check if obsrvation_fact tag present
- boolean obsFactSelected = obsFactFactRelated.isSelected();
-
- // check if provider or concept present
- boolean providerSelected = providerFactRelated.isSelected();
- boolean conceptSelected = conceptFactRelated.isSelected();
- boolean modifierSelected = modifierFactRelated.isSelected();
-
- // check if patient present
- boolean patientSelected = patientFactRelated.isSelected();
-
- // check if visit present
- boolean visitSelected = visitFactRelated.isSelected();
- boolean pidSelected = pidFactRelated.isSelected();
- boolean eidSelected = eidFactRelated.isSelected();
-
- boolean patientFromFact = patientFactRelated.isFactRelated();
- boolean visitFromFact = visitFactRelated.isFactRelated();
- boolean pidFromFact = pidFactRelated.isFactRelated();
- boolean eidFromFact = eidFactRelated.isFactRelated();
-
- IFactRelatedQueryHandler factRelatedQry = null;
-
- // PatientDataType patientDataType = new PatientDataType();
-
- // check if this is a fact related query
- if (obsFactSelected || providerSelected || conceptSelected
- || patientFromFact || visitFromFact || pidFromFact
- || eidFromFact || modifierSelected) {
-
- DataSourceLookup dataSourceLookup = pdoDaoFactory
- .getDataSourceLookup();
- if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.ORACLE) ||
- dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.POSTGRESQL)) {
- factRelatedQry = new FactRelatedQueryHandler(pdoDaoFactory
- .getDataSourceLookup(), inputList, filterList,
- outputOptionList);
- } else if (dataSourceLookup.getServerType().equalsIgnoreCase(
- DAOFactoryHelper.SQLSERVER)) {
- factRelatedQry = new SQLServerFactRelatedQueryHandler(
- pdoDaoFactory.getDataSourceLookup(), inputList,
- filterList, outputOptionList);
- }
- //set project param map
- factRelatedQry.setProjectParamMap(this.projectParamMap);
- factRelatedQry.setModifierMetadataXmlMap(modifierMetadataXmlMap);
- factRelatedQry.setRequestVersion(this.requestVersion);
-
- // execute query
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- List tableObservationSet = factRelatedQry
- .getTablePdoObservationFact();
- if (obsFactSelected) {
- tablePdoType.getObservationSet()
- .addAll(tableObservationSet);
- }
- } else {
- List plainPdoObservationSet = factRelatedQry
- .getPdoObservationFact();
-
- if (obsFactSelected) {
- plainPdoType.getObservationSet().addAll(
- plainPdoObservationSet);
- }
- }
- }
-
- // check if observer section is specified in outputoption
- if (providerSelected) {
- ProviderSection providerSection = new ProviderSection(pdoType,
- factRelatedQry);
- providerSection.generateSet();
-
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setObserverSet(providerSection
- .getTableProviderSet());
- } else {
- plainPdoType.setObserverSet(providerSection
- .getPlainProviderSet());
- }
- }
-
- // check if concept section is specified in outputoption
- if (conceptSelected) {
- ConceptSection cs = new ConceptSection(pdoType, factRelatedQry);
- cs.generateSet();
-
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setConceptSet(cs.getTableConceptSet());
- } else {
- plainPdoType.setConceptSet(cs.getPlainConceptSet());
- }
- }
-
- // check if modifier section is specified in outputoption
- if (modifierSelected) {
- ModifierSection ms = new ModifierSection(pdoType, factRelatedQry);
- ms.generateSet();
-
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setModifierSet(ms.getTableModifierSet());
- } else {
- plainPdoType.setModifierSet(ms.getPlainModifierSet());
- }
- }
-
- // check if patient section is specified in outputoption
- if (patientSelected) {
- PatientSection ps = new PatientSection(pdoType, factRelatedQry,
- patientFromFact, isGetPDOFromVisitSet(),
- isGetPDOFromPatientSet(), isGetPDOFromPIDSet(), patientMetaDataParamType);
- ps.generateSet();
-
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setPatientSet(ps.getTablePatientSet());
- } else {
- plainPdoType.setPatientSet(ps.getPlainPatientSet());
- }
- }
-
- // check if observation section is specified in outputoption
- if (visitSelected) {
- VisitSection vs = new VisitSection(pdoType, factRelatedQry,
- visitFromFact, isGetPDOFromVisitSet(),
- isGetPDOFromPatientSet(),visitMetaDataParamType);
- vs.generateSet();
-
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setEventSet(vs.getTableEventSet());
- } else {
- plainPdoType.setEventSet(vs.getPlainVisitSet());
- }
- }
-
- // check if pid section is specified in outputoption
- if (pidSelected) {
- PidSection pids = new PidSection(pdoType, factRelatedQry,
- pidFromFact, isGetPDOFromPatientSet(), isGetPDOFromPidSet());
- pids.generateSet();
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setPidSet(pids.getPidSet());
- } else {
- plainPdoType.setPidSet(pids.getPidSet());
- }
- }
-
- // check if eid section is specified in outputoption
- if (eidSelected) {
- EidSection eids = new EidSection(pdoType, factRelatedQry,
- eidFromFact, isGetPDOFromPatientSet(), isGetPDOFromEidSet());
- eids.generateSet();
- if (pdoType.equalsIgnoreCase(TABLE_PDO_TYPE)) {
- tablePdoType.setEidSet(eids.getEidSet());
- } else {
- plainPdoType.setEidSet(eids.getEidSet());
-
- }
- }
-
- }
-
- private class EidSection {
- IFactRelatedQueryHandler factRelatedQry = null;
- EidSet eidSet = null;
- String pType = null;
- boolean pidFromFact = false;
- boolean fromPatientSet = false;
- boolean fromEidSet = false;
-
- // TODO , boolean fromPidSet
- public EidSection(String pType,
- IFactRelatedQueryHandler factRelatedQry, boolean pidFromFact,
- boolean fromPatientSet, boolean fromEidSet) {
- this.factRelatedQry = factRelatedQry;
- this.pType = pType;
- this.pidFromFact = pidFromFact;
- this.fromPatientSet = fromPatientSet;
- this.fromEidSet = fromEidSet;
- }
-
- /**
- *
- * @throws I2B2Exception
- */
- public void generateSet() throws I2B2Exception {
- // check if provider selected
- IPdoQueryEidDao eidDao = pdoDaoFactory.getPdoQueryEidDAO();
-
- boolean detailFlag = pidFactRelated.isSelectDetail();
- boolean blobFlag = pidFactRelated.isSelectBlob();
- boolean statusFlag = pidFactRelated.isSelectStatus();
- if (pidFromFact) {
- List encounterNumFactList = factRelatedQry
- .getVisitFactList();
- List