From 89295c5df516cbdde84344098baba7af4e195180 Mon Sep 17 00:00:00 2001 From: Kate Yang <150059882+kateyang1998@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:46:32 -0500 Subject: [PATCH] fix: fixed some hibernate-query parameter errors, enabled the echart. --- .../dao/CaseManagementNoteDAOImpl.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/oscarehr/casemgmt/dao/CaseManagementNoteDAOImpl.java b/src/main/java/org/oscarehr/casemgmt/dao/CaseManagementNoteDAOImpl.java index 2b7948ee9dd..ccae7c69ca5 100644 --- a/src/main/java/org/oscarehr/casemgmt/dao/CaseManagementNoteDAOImpl.java +++ b/src/main/java/org/oscarehr/casemgmt/dao/CaseManagementNoteDAOImpl.java @@ -186,7 +186,7 @@ public List getCPPNotes(String demoNo, long issueId, String d = cal.getTime(); } - String hql = "select distinct cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ? and cmn.demographic_no = ? and cmn.observation_date >= ? and cmn.id in (select max(cmn.id) from cmn where cmn.demographic_no = ? GROUP BY uuid) ORDER BY cmn.observation_date asc"; + String hql = "select distinct cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ?0 and cmn.demographic_no = ?1 and cmn.observation_date >= ?2 and cmn.id in (select max(cmn.id) from cmn where cmn.demographic_no = ?3 GROUP BY uuid) ORDER BY cmn.observation_date asc"; @SuppressWarnings("unchecked") List result = (List) getHibernateTemplate().find(hql, @@ -217,7 +217,7 @@ public List getNotesByDemographic(String demographic_no, Str MiscUtils.getLogger().error("Error", e); } String hql = "select distinct cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id in (" + list - + ") and cmn.demographic_no = ? and cmn.id in (select max(cmn.id) from cmn where cmn.observation_date >= ? GROUP BY uuid) ORDER BY cmn.observation_date asc"; + + ") and cmn.demographic_no = ?0 and cmn.id in (select max(cmn.id) from cmn where cmn.observation_date >= ?1 GROUP BY uuid) ORDER BY cmn.observation_date asc"; @SuppressWarnings("unchecked") List result = (List) getHibernateTemplate().find(hql, @@ -246,7 +246,7 @@ public List getNotesByDemographic(String demographic_no) { return (List) getHibernateTemplate().findByNamedQuery("mostRecentOra", new Object[] { demographic_no }); } else { - String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; + String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ?0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; return (List) getHibernateTemplate().find(hql, demographic_no); // return getHibernateTemplate().findByNamedQuery("mostRecent", new Object[] { // demographic_no }); @@ -257,35 +257,35 @@ public List getNotesByDemographic(String demographic_no) { @Override public List getNotesByDemographicSince(String demographic_no, Date date) { - String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ? and cmn.update_date > ? and cmn.locked != '1' and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; + String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ?0 and cmn.update_date > ?1 and cmn.locked != '1' and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; return (List) getHibernateTemplate().find(hql, demographic_no, date); } @Override public long getNotesCountByDemographicId(String demographic_no) { - String hql = "select count(*) from CaseManagementNote cmm where cmm.demographic_no = ?"; + String hql = "select count(*) from CaseManagementNote cmm where cmm.demographic_no = ?0"; return ((Long) getHibernateTemplate().find(hql, demographic_no).get(0)).longValue(); } @SuppressWarnings("unchecked") @Override public List getRawNoteInfoByDemographic(String demographic_no) { - String hql = "select cmn.id,cmn.observation_date,cmn.providerNo,cmn.program_no,cmn.reporter_caisi_role,cmn.uuid from CaseManagementNote cmn where cmn.demographic_no = ? order by cmn.update_date DESC"; + String hql = "select cmn.id,cmn.observation_date,cmn.providerNo,cmn.program_no,cmn.reporter_caisi_role,cmn.uuid from CaseManagementNote cmn where cmn.demographic_no = ?0 order by cmn.update_date DESC"; return (List) getHibernateTemplate().find(hql, demographic_no); } @SuppressWarnings("unchecked") @Override public List> getRawNoteInfoMapByDemographic(String demographic_no) { - String hql = "select new map(cmn.id as id,cmn.observation_date as observation_date,cmn.providerNo as providerNo,cmn.program_no as program_no,cmn.reporter_caisi_role as reporter_caisi_role,cmn.uuid as uuid, cmn.update_date as update_date) from CaseManagementNote cmn where cmn.demographic_no = ? order by cmn.update_date DESC"; + String hql = "select new map(cmn.id as id,cmn.observation_date as observation_date,cmn.providerNo as providerNo,cmn.program_no as program_no,cmn.reporter_caisi_role as reporter_caisi_role,cmn.uuid as uuid, cmn.update_date as update_date) from CaseManagementNote cmn where cmn.demographic_no = ?0 order by cmn.update_date DESC"; return (List>) getHibernateTemplate().find(hql, demographic_no); } @SuppressWarnings("unchecked") @Override public List> getUnsignedRawNoteInfoMapByDemographic(String demographic_no) { - String hql = "select new map(cmn.id as id,cmn.observation_date as observation_date,cmn.providerNo as providerNo,cmn.program_no as program_no,cmn.reporter_caisi_role as reporter_caisi_role,cmn.uuid as uuid, cmn.update_date as update_date) from CaseManagementNote cmn where cmn.demographic_no = ? and cmn.signed=? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.update_date DESC"; - return (List>) getHibernateTemplate().find(hql, new Object[] { demographic_no, false }); + String hql = "select new map(cmn.id as id,cmn.observation_date as observation_date,cmn.providerNo as providerNo,cmn.program_no as program_no,cmn.reporter_caisi_role as reporter_caisi_role,cmn.uuid as uuid, cmn.update_date as update_date) from CaseManagementNote cmn where cmn.demographic_no = ?0 and cmn.signed=?1 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.update_date DESC"; + return (List>) getHibernateTemplate().find(hql, new Object[]{demographic_no, false}); } @SuppressWarnings("unchecked") @@ -295,7 +295,7 @@ public List getNotesByDemographic(String demographic_no, Int return (List) getHibernateTemplate().findByNamedQuery("mostRecentOra", new Object[] { demographic_no }); } else { - String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date desc"; + String hql = "select cmn from CaseManagementNote cmn where cmn.demographic_no = ?0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date desc"; HibernateTemplate Hibernatetemplate = getHibernateTemplate(); if (maxNotes != -1) { @@ -338,18 +338,18 @@ public List getActiveNotesByDemographic(String demographic_n list += issues[x]; } hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id in (" + list - + ") and cmn.demographic_no = ? and cmn.archived = 0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) ORDER BY cmn.position, cmn.observation_date desc"; + + ") and cmn.demographic_no = ?0 and cmn.archived = 0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) ORDER BY cmn.position, cmn.observation_date desc"; return (List) this.getHibernateTemplate().find(hql, demographic_no); } else if (issues.length == 1) { long id = Long.parseLong(issues[0]); - hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ? and cmn.demographic_no= ? and cmn.archived=0 order by cmn.position, cmn.observation_date desc"; + hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ?0 and cmn.demographic_no= ?1 and cmn.archived=0 order by cmn.position, cmn.observation_date desc"; List issueList = (List) this.getHibernateTemplate().find(hql, new Object[] { id, demographic_no }); - hql = "select max(cmn.id) from CaseManagementNote cmn where cmn.demographic_no = ? group by cmn.uuid order by max(cmn.id)"; + hql = "select max(cmn.id) from CaseManagementNote cmn where cmn.demographic_no = ?0 group by cmn.uuid order by max(cmn.id)"; List currNoteList = (List) this.getHibernateTemplate().find(hql, new Object[] { demographic_no }); @@ -386,11 +386,11 @@ public List getNotesByDemographic(String demographic_no, Str list += issueIds[x]; } hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id in (" + list - + ") and cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) order by cmn.observation_date desc "; + + ") and cmn.demographic_no = ?0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) order by cmn.observation_date desc "; retList = (List) this.getHibernateTemplate().find(hql, demographic_no); } else if (issueIds.length == 1) { - hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ? and cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) order by cmn.observation_date desc"; + hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ?0 and cmn.demographic_no = ?1 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid) order by cmn.observation_date desc"; long id = Long.parseLong(issueIds[0]); retList = (List) this.getHibernateTemplate().find(hql, new Object[] { id, demographic_no }); @@ -420,11 +420,11 @@ public List getNotesByDemographic(String demographic_no, Str list += issueIds[x]; } hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id in (" + list - + ") and cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid)"; + + ") and cmn.demographic_no = ?0 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid)"; return (List) this.getHibernateTemplate().find(hql, demographic_no); } else if (issueIds.length == 1) { - hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ? and cmn.demographic_no = ? and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid)"; + hql = "select cmn from CaseManagementNote cmn join cmn.issues i where i.issue_id = ?0 and cmn.demographic_no = ?1 and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn.uuid = cmn2.uuid)"; long id = Long.parseLong(issueIds[0]); return (List) this.getHibernateTemplate().find(hql, new Object[] { id, demographic_no }); @@ -666,7 +666,7 @@ public int getNoteCountForProviderForDateRange(String providerNo, Date startDate Connection c = null; try { c = DbConnectionFilter.getThreadLocalDbConnection(); - String sqlCommand = "select count(distinct uuid) from casemgmt_note where provider_no = ? and observation_date >= ? and observation_date <= ?"; + String sqlCommand = "select count(distinct uuid) from casemgmt_note where provider_no = ?1 and observation_date >= ?2 and observation_date <= ?3"; PreparedStatement ps = c.prepareStatement(sqlCommand); ps.setString(1, providerNo); ps.setTimestamp(2, new Timestamp(startDate.getTime())); @@ -705,7 +705,7 @@ public int getNoteCountForProviderForDateRangeWithIssueId(String providerNo, Dat log.debug("issue Code " + issueCode + " id :" + id); - String sqlCommand = "select count(distinct uuid) from casemgmt_issue c, casemgmt_issue_notes cin, casemgmt_note cn where c.issue_id = ? and c.id = cin.id and cin.note_id = cn.note_id and cn.provider_no = ? and observation_date >= ? and observation_date <= ?"; + String sqlCommand = "select count(distinct uuid) from casemgmt_issue c, casemgmt_issue_notes cin, casemgmt_note cn where c.issue_id = ?1 and c.id = cin.id and cin.note_id = cn.note_id and cn.provider_no = ?2 and observation_date >= ?3 and observation_date <= ?4"; log.debug(sqlCommand); ps = c.prepareStatement(sqlCommand); ps.setString(1, id); @@ -726,7 +726,7 @@ public int getNoteCountForProviderForDateRangeWithIssueId(String providerNo, Dat // used by decision support to search through the notes for a string @Override public List searchDemographicNotes(String demographic_no, String searchString) { - String hql = "select distinct cmn from CaseManagementNote cmn where cmn.id in (select max(cmn.id) from cmn where cmn.demographic_no = ? GROUP BY uuid) and cmn.demographic_no = ? and cmn.note like ? and cmn.archived = 0"; + String hql = "select distinct cmn from CaseManagementNote cmn where cmn.id in (select max(cmn.id) from cmn where cmn.demographic_no = ?0 GROUP BY uuid) and cmn.demographic_no = ?1 and cmn.note like ?2 and cmn.archived = 0"; @SuppressWarnings("unchecked") List result = (List) getHibernateTemplate().find(hql, @@ -736,8 +736,8 @@ public List searchDemographicNotes(String demographic_no, St @Override public List getCaseManagementNoteByProgramIdAndObservationDate(Integer programId, - Date minObservationDate, Date maxObservationDate) { - String queryStr = "FROM CaseManagementNote x WHERE x.program_no=? and x.observation_date>=? and x.observation_date<=?"; + Date minObservationDate, Date maxObservationDate) { + String queryStr = "FROM CaseManagementNote x WHERE x.program_no=?0 and x.observation_date>=?1 and x.observation_date<=?2"; @SuppressWarnings("unchecked") List rs = (List) getHibernateTemplate().find(queryStr, @@ -748,7 +748,7 @@ public List getCaseManagementNoteByProgramIdAndObservationDa @Override public List getMostRecentNotesByAppointmentNo(int appointmentNo) { - String hql = "select distinct cmn.uuid from CaseManagementNote cmn where cmn.appointmentNo = ?"; + String hql = "select distinct cmn.uuid from CaseManagementNote cmn where cmn.appointmentNo = ?0"; @SuppressWarnings("unchecked") List tmp = (List) this.getHibernateTemplate().find(hql, appointmentNo); List mostRecents = new ArrayList(); @@ -760,7 +760,7 @@ public List getMostRecentNotesByAppointmentNo(int appointmen @Override public List getMostRecentNotes(Integer demographicNo) { - String hql = "select distinct cmn.uuid from CaseManagementNote cmn where cmn.demographic_no = ?"; + String hql = "select distinct cmn.uuid from CaseManagementNote cmn where cmn.demographic_no = ?0"; @SuppressWarnings("unchecked") List tmp = (List) this.getHibernateTemplate().find(hql, new Object[] { String.valueOf(demographicNo) }); @@ -794,7 +794,7 @@ public List getNotesByFacilitySince(Date date, List programs) } String hql = "select distinct cmn.demographic_no from CaseManagementNote cmn where cmn.program_no in (" + sb.toString() - + ") and cmn.update_date > ? and cmn.locked != '1' and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; + + ") and cmn.update_date > ?0 and cmn.locked != '1' and cmn.id = (select max(cmn2.id) from CaseManagementNote cmn2 where cmn2.uuid = cmn.uuid) order by cmn.observation_date"; List results = (List) getHibernateTemplate().find(hql, date); List results2 = new ArrayList();