From 5d003ecf650a6cc312d7242b2639fc7b7767e112 Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 12:22:05 -0700 Subject: [PATCH 1/4] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- onprc_ehr/resources/queries/study/clinremarks/.qview.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml index 9f5ac339e..1196a662a 100644 --- a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml +++ b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml @@ -10,6 +10,8 @@ + + From 061a102b0682a271a02c23dcd38c075a3e36615c Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 16:35:40 -0700 Subject: [PATCH 2/4] Created a program scripts to removed unused stored procedure, and temp tables. --- ...omplianceProcedureRecentTestsorg.query.xml | 126 ------------ .../ComplianceProcedureRecentTestsorg.sql | 148 -------------- .../.qview.xml | 25 --- .../Occupational Health Compliance.qview.xml | 28 --- ...nd Due Soon withNoEHRS OccHealth.qview.xml | 16 -- .../Overdue and Due Soon.qview.xml | 12 -- .../ComplianceRecentTestsorg.query.xml | 121 ----------- .../ComplianceRecentTestsorg.sql | 192 ------------------ .../ComplianceRecentTestsorg/.qview.xml | 23 --- .../sqlserver/onprc_ehr-26.001-26.002.sql | 64 ++++++ .../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 2 +- 11 files changed, 65 insertions(+), 692 deletions(-) delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql delete mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml create mode 100644 onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml deleted file mode 100644 index b3e75afd8..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Employee Requirement Summary -- Original version - - - Employee ID - true - - ehr_compliancedb - employees - employeeId - - - - - Row ID - - - Requirement Name - 250 - - ehr_compliancedb - requirements - requirementName - - ALWAYS_OFF - - - Times Completed - 50 - /query/executeQuery.view?schemaName=ehr_compliancedb& - query.queryName=CompletionDates& - query.EmployeeId~eq=${employeeId}& - query.requirementName~eq=${requirementName}& - - - - Expire Period (Months) - 70 - - - New Expire Period (Months) - 70 - - - - Email - 70 - - - - Last Name - 110 - - - - First Name - 110 - - - - Host - 110 - - - Supervisor - 150 - - - - Unit - 210 - - - Most Recent Date - yyyy-MM-dd - 70 - - - Comments - 70 - - - Category - 70 - - - - Trainee Type - 70 - - - Requirement Name Type - 180 - - - Months Until Renewal - 60 - - - - - - FBEC5D - - - - - - Essential - 60 - ALWAYS_OFF - - - Snooze Until - 60 - ALWAYS_OFF - - - -
-
-
-
diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql deleted file mode 100644 index 585ed1c0e..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2010-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - --- Modified: 6-14-2022 R.Blasa ComplianceRecentTests.sql --- Training that was completed by an employee and being recorded as completed as a Unit or Category -select b.requirementname, - a.employeeid, - group_concat(distinct a.unit,chr(10)) as unit, - group_concat(distinct a.category,chr(10)) as category, - group_concat(distinct b.trackingflag) as trackingflag, - - - (select count(zz.date) from completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as timesCompleted, - - (select k.expireperiod from Requirements k where k.requirementname = b.requirementname) as ExpiredPeriod, - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) as NewExpirePeriod, - - (select max(zz.date) from completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as MostRecentDate, - - (Select group_concat(distinct yy.comment, chr(10)) from completiondates yy where yy.date in (select max(zz.date) from completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= b.requirementname and yy.employeeid= a.employeeid ) as comment, - (Select group_concat(distinct yy.snooze_date , chr(10)) from completiondates yy where yy.date in (select max(zz.date) from completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= b.requirementname and yy.employeeid= a.employeeid ) as snooze_date, - - CAST( - CASE - - WHEN (select max(st.date) from completiondates st where st.requirementname = b.requirementname and st.employeeid = a.employeeid ) IS NULL then 0 - WHEN ( select (tt.expireperiod) from ehr_compliancedb.requirements tt where tt.requirementname = b.requirementname group by tt.expireperiod ) = 0 then Null - - - WHEN ( select count(*) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) ) > 0 THEN - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate) - (TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now()) ) ) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - ELSE ( select (tt.expireperiod) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now())) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod ) - - END AS DECIMAL ) AS MonthsUntilRenewal - - - -from employeeperunit a ,requirementspercategory b -where ( a.unit = b.unit or a.category = b.category ) - And b.requirementname not in (select distinct t.requirementname from ehr_compliancedb.employeerequirementexemptions t Where a.employeeid = t.employeeid - And b.requirementname = t.requirementname) - And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And b.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = b.requirementname And q.dateDisabled is null ) - - - - - group by b.requirementname,a.employeeid - - -union - --- Training that was completed by an employee but not recorded as being completed as a Unit or Category -select a.requirementname, - a.employeeid, - null as unit, - null as category, - 'No' as trackingflag, - - - (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) as timesCompleted, - - (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = a.requirementname) as ExpiredPeriod, - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) as NewExpirePeriod, - - (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) as MostRecentDate, - - (Select group_concat(distinct yy.comment, chr(10)) from completiondates yy where yy.date in (select max(zz.date) from completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= a.requirementname and yy.employeeid= a.employeeid ) as comment, - - (Select group_concat(distinct yy.snooze_date , chr(10)) from completiondates yy where yy.date in (select max(zz.date) from completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= a.requirementname and yy.employeeid= a.employeeid ) as snooze_date, - - CAST( - CASE - WHEN (select max(st.date) from completiondates st where st.requirementname = a.requirementname and st.employeeid = a.employeeid ) IS NULL then 0 - WHEN ( select (tt.expireperiod) from ehr_compliancedb.requirements tt where tt.requirementname = a.requirementname group by tt.expireperiod ) = 0 then Null - - - WHEN ( select count(*) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) ) > 0 THEN - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now()) ) ) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now())) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod ) - - END AS DECIMAL) AS MonthsUntilRenewal - - - from ehr_compliancedb.completiondates a -where a.requirementname not in (select distinct h.requirementname from ehr_compliancedb.employeeperunit k, ehr_compliancedb.requirementspercategory h Where (k.unit = h.unit - or k.category = h.category) And a.employeeid = k.employeeid ) - And a.requirementname not in (select distinct t.requirementname from ehr_compliancedb.employeerequirementexemptions t Where a.employeeid = t.employeeid - And a.requirementname = t.requirementname) - And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And a.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = a.requirementname And q.dateDisabled is null ) - -group by a.requirementname,a.employeeid - -UNION - --- Additional requirements for employees that have not completed training, but is required -select j.requirementname, - j.employeeid, - null as unit, - null as category, - 'Yes' as trackingflag, - null as timesCompleted, - null as ExpiredPeriod, - null as NewExpirePeriod, - null as MostRecentDate, - '' as comment, - null as snooze_date, - null AS MonthsUntilRenewal - - -from ehr_compliancedb.RequirementsPerEmployee j -Where j.requirementname not in (select z.requirementname from ehr_compliancedb.completiondates z where z.requirementname = j.requirementname - and z.employeeid = j.employeeid and z.date is not null) - And j.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And j.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = j.requirementname And q.dateDisabled is null ) - - - -group by j.requirementname,j.employeeid - - - - - diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml deleted file mode 100644 index 82fc59d49..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml deleted file mode 100644 index 97934dc5a..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml deleted file mode 100644 index 192608c90..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml deleted file mode 100644 index bc93d1734..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml deleted file mode 100644 index 46cb8fc00..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Employee Requirement Summary - Original version - - - Employee ID - true - - ehr_compliancedb - employees - employeeId - - - - - Row ID - - - Requirement Name - 90 - - ehr_compliancedb - requirements - requirementName - - ALWAYS_OFF - - - Times Completed - 50 - /query/executeQuery.view?schemaName=ehr_compliancedb& - query.queryName=CompletionDates& - query.EmployeeId~eq=${employeeId}& - query.requirementName~eq=${requirementName}& - - - - Expire Period (Months) - 70 - - - New Expire Period (Months) - 70 - - - - Email - 70 - - - - Last Name - 110 - - - - First Name - 110 - - - - Host - 110 - - - Supervisor - 150 - - - - Unit - 210 - - - Most Recent Date - yyyy-MM-dd - 70 - - - Comments - 70 - - - Category - 70 - - - - Trainee Type - 70 - - - Requirement Name Type - 180 - - - Months Until Renewal - 60 - - - - - - FBEC5D - - - - - - Essential - 60 - ALWAYS_OFF - - - -
-
-
-
diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql deleted file mode 100644 index 1ff4baac6..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2010-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - --- Modified: 6-14-2022 R.Blasa ComplianceRecentTests.sql --- Training that was completed by an employee and being recorded as completed as a Unit or Category -select b.requirementname, - a.employeeid, - group_concat(distinct b.unit,chr(10)) as unit, - group_concat(distinct a.category,chr(10)) as category, - group_concat(distinct b.trackingflag) as trackingflag, - - - (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as timesCompleted, - - (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = b.requirementname) as ExpiredPeriod, - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) as NewExpirePeriod, - - (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as MostRecentDate, - - (Select group_concat(distinct yy.comment, chr(10)) from ehr_compliancedb.completiondates yy where yy.date in (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= b.requirementname and yy.employeeid= a.employeeid ) as comment, - CAST( - CASE - WHEN (select max(st.date) from ehr_compliancedb.completiondates st where st.requirementname = b.requirementname and st.employeeid = a.employeeid ) IS NULL then 0 - WHEN ( select (tt.expireperiod) from ehr_compliancedb.requirements tt where tt.requirementname = b.requirementname group by tt.expireperiod ) = 0 then Null - - - WHEN ( select count(*) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) ) > 0 THEN - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate) - (TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now()) ) ) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - ELSE ( select (tt.expireperiod) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now())) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = b.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod ) - - END AS double) AS MonthsUntilRenewal - - - -from employeeperunit a ,requirementspercategory b -where ( a.unit = b.unit or a.category = b.category ) - And b.requirementname not in (select distinct t.requirementname from ehr_compliancedb.employeerequirementexemptions t Where a.employeeid = t.employeeid - And b.requirementname = t.requirementname) - And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And b.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = b.requirementname And q.dateDisabled is null ) - - - -group by b.requirementname,a.employeeid - -union - --- Training that was completed by an employee but not recorded as being completed as a Unit or Category -select a.requirementname, - a.employeeid, - null as unit, - null as category, - 'No' as trackingflag, - - - (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) as timesCompleted, - - (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = a.requirementname) as ExpiredPeriod, - - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) as NewExpirePeriod, - - (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) as MostRecentDate, - - (Select group_concat(distinct yy.comment, chr(10)) from ehr_compliancedb.completiondates yy where yy.date in (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= a.requirementname and zz.employeeid= a.employeeid ) - And yy.requirementname= a.requirementname and yy.employeeid= a.employeeid ) as comment, - - - - CAST( - CASE - WHEN (select max(st.date) from ehr_compliancedb.completiondates st where st.requirementname = a.requirementname and st.employeeid = a.employeeid ) IS NULL then 0 - WHEN ( select (tt.expireperiod) from ehr_compliancedb.requirements tt where tt.requirementname = a.requirementname group by tt.expireperiod ) = 0 then Null - - - WHEN ( select count(*) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) ) > 0 THEN - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now()) ) ) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now())) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = a.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = a.employeeid group by tt.expireperiod ) - - END AS double) AS MonthsUntilRenewal - -from ehr_compliancedb.completiondates a -where a.requirementname not in (select distinct h.requirementname from ehr_compliancedb.employeeperunit k, ehr_compliancedb.requirementspercategory h Where (k.unit = h.unit - or k.category = h.category) And a.employeeid = k.employeeid ) - And a.requirementname not in (select distinct t.requirementname from ehr_compliancedb.employeerequirementexemptions t Where a.employeeid = t.employeeid - And a.requirementname = t.requirementname) - And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And a.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = a.requirementname And q.dateDisabled is null ) - - -group by a.requirementname,a.employeeid - - -union - --- Training that was completed by as an employee training exemptions, and at least completed one, or more times -select j.requirementname, - j.employeeid, - null as unit, - null as category, - 'No' as trackingflag, - - - (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= j.requirementname and zz.employeeid= j.employeeid ) as timesCompleted, - - (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = j.requirementname) as ExpiredPeriod, - - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = j.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = j.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) as NewExpirePeriod, - - (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= j.requirementname and zz.employeeid= j.employeeid ) as MostRecentDate, - - (Select group_concat(distinct yy.comment, chr(10)) from ehr_compliancedb.completiondates yy where yy.date in (select max(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= j.requirementname and zz.employeeid= j.employeeid ) - And yy.requirementname= j.requirementname and yy.employeeid= j.employeeid ) as comment, - - - - CAST( - CASE - WHEN (select max(st.date) from ehr_compliancedb.completiondates st where st.requirementname = j.requirementname and st.employeeid = j.employeeid ) IS NULL then 0 - WHEN ( select (tt.expireperiod) from ehr_compliancedb.requirements tt where tt.requirementname = j.requirementname group by tt.expireperiod ) = 0 then Null - - - WHEN ( select count(*) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = j.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = j.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) ) > 0 THEN - - ( select ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now()) ) ) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = j.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = j.employeeid group by tt.expireperiod, tt.reviewdate - having (tt.expireperiod) > ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( TIMESTAMPDIFF('SQL_TSI_MONTH', max(pq.date), Now())) from ehr_compliancedb.requirements tt, ehr_compliancedb.completiondates pq where tt.requirementname = j.requirementname and pq.requirementname = tt.requirementname and pq.employeeid = j.employeeid group by tt.expireperiod ) - - END AS double) AS MonthsUntilRenewal - -from ehr_compliancedb.employeerequirementexemptions j - Where j.requirementname in (select z.requirementname from ehr_compliancedb.completiondates z where z.requirementname = j.requirementname - and z.employeeid = j.employeeid and z.date is not null) - And j.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And j.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = j.requirementname And q.dateDisabled is null ) - - - -group by j.requirementname,j.employeeid - -UNION - --- Additional requirements for employees that have not completed training, but is required -select j.requirementname, - j.employeeid, - null as unit, - null as category, - 'Yes' as trackingflag, - null as timesCompleted, - null as ExpiredPeriod, - null as NewExpirePeriod, - null as MostRecentDate, - '' as comment, - null AS MonthsUntilRenewal - - -from ehr_compliancedb.RequirementsPerEmployee j -Where j.requirementname NOT in (select z.requirementname from ehr_compliancedb.completiondates z where z.requirementname = j.requirementname - and z.employeeid = j.employeeid and z.date is not null) - And j.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate is null) - And j.requirementname in (select q.requirementname from ehr_compliancedb.Requirements q where q.requirementname = j.requirementname And q.dateDisabled is null ) - - - -group by j.requirementname,j.employeeid - diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml deleted file mode 100644 index 750c4460d..000000000 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql new file mode 100644 index 000000000..977635f59 --- /dev/null +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql @@ -0,0 +1,64 @@ +/* + Created: 7-16-2026 R. Blasa Process to removed temp tables, and stored prcoedure that are no longer needed + + */ +---Dropping user defined sql queries + --- ComplianceProcedureRecenttTestsorg.sql +---- ComplianceProcedureRecentTestsorg --> directory and xml files + +--- ComplianceRecenttTestsorg.sql +---- ComplianceRecentTestsorg --> directory and xml files + + +EXEC core.fn_dropifexists 's_JmacRemovalDateProcess','onprc_ehr','TABLE'; + + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'sp_Compliance_requirementname_Update_Process','onprc_ehr','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 's_JmacRemovalDateProcess','onprc_ehr','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'p_EnvironmentalHistoricalUpdates','onprc_ehr','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'p_Environmental_Update_Process','onprc_ehr','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'sp_RpSLASummaryCensus','dbo','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'RptMergeChargetypeUpdateSP','dbo','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'RptMergeChargetypeUpdateSP','dbo','PROCEDURE'; + +----Drop corresponding temp tables + +--Drop stored procedures +EXEC core.fn_dropifexists 'p_ComplianceTranslatestringUpdate','onprc_ehr_compliancedb','PROCEDURE'; + + + + +GO + + + + + diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java index 6e766bdc6..5d014e1b8 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -124,7 +124,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 25.005; + return 26.002; } @Override From d4127d3482fb6c7ccfa0e83afdb69bfce493aec9 Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 16:48:00 -0700 Subject: [PATCH 3/4] Created a program scripts to removed unused stored procedure, and temp tables. --- .../schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql index 977635f59..171a3de3f 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql @@ -10,7 +10,9 @@ ---- ComplianceRecentTestsorg --> directory and xml files -EXEC core.fn_dropifexists 's_JmacRemovalDateProcess','onprc_ehr','TABLE'; + +----Drop corresponding temp tables + ----Drop corresponding temp tables From 4bbe4381b20712954941d7e95d689a274ac5f6bb Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 15 Jul 2026 16:58:49 -0700 Subject: [PATCH 4/4] Removed stored procedures that are no longer needed. --- .../sqlserver/onprc_ehr-26.001-26.002.sql | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql index 171a3de3f..a570c5c96 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.001-26.002.sql @@ -10,54 +10,48 @@ ---- ComplianceRecentTestsorg --> directory and xml files - -----Drop corresponding temp tables - - - ----Drop corresponding temp tables - + ---- No temp tables to include here --Drop stored procedures EXEC core.fn_dropifexists 'sp_Compliance_requirementname_Update_Process','onprc_ehr','PROCEDURE'; - +GO ----Drop corresponding temp tables - +EXEC core.fn_dropifexists 'Rpt_TempJmacDate','onprc_ehr','TABLE'; +GO --Drop stored procedures EXEC core.fn_dropifexists 's_JmacRemovalDateProcess','onprc_ehr','PROCEDURE'; - +GO ----Drop corresponding temp tables - + ---- No temp tables to include here --Drop stored procedures EXEC core.fn_dropifexists 'p_EnvironmentalHistoricalUpdates','onprc_ehr','PROCEDURE'; - +GO ----Drop corresponding temp tables - + ---- No temp tables to include here --Drop stored procedures EXEC core.fn_dropifexists 'p_Environmental_Update_Process','onprc_ehr','PROCEDURE'; - +GO ----Drop corresponding temp tables - +EXEC core.fn_dropifexists 'Rpt_SLaCensus','dbo','TABLE'; +GO --Drop stored procedures EXEC core.fn_dropifexists 'sp_RpSLASummaryCensus','dbo','PROCEDURE'; +GO ----Drop corresponding temp tables - +EXEC core.fn_dropifexists 'Rpt_Labwork_MergeUpdate','dbo','TABLE'; +GO +EXEC core.fn_dropifexists 'Rpt_Labwork_MergeUpdatelog','dbo','TABLE'; +GO --Drop stored procedures EXEC core.fn_dropifexists 'RptMergeChargetypeUpdateSP','dbo','PROCEDURE'; +GO -----Drop corresponding temp tables - ---Drop stored procedures -EXEC core.fn_dropifexists 'RptMergeChargetypeUpdateSP','dbo','PROCEDURE'; ----Drop corresponding temp tables - +---- No temp tables to include here --Drop stored procedures EXEC core.fn_dropifexists 'p_ComplianceTranslatestringUpdate','onprc_ehr_compliancedb','PROCEDURE'; - - - - GO