From 66cfb0dc3fcceacdcf0221e4c2d3b2f804cf11ce Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:45:33 -0800 Subject: [PATCH 1/3] Created scripting program to update compliance string "ARRS " to "DCM" (#1207) * Created scripting program to update compliance string "ARRS " to "DCM" * Modified Compliance translation string from "arrs" to "dcm" * Modified Compliance translation from "ARRS" to "DCM" * Modified Compliance translation from "ARRS" to "DCM" --- .../onprc_ehr_compliancedb-24.004-24.005.sql | 250 ++++++++++++++++++ .../ONPRC_EHR_ComplianceDBModule.java | 2 +- 2 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.004-24.005.sql diff --git a/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.004-24.005.sql b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.004-24.005.sql new file mode 100644 index 000000000..4c2b7aa50 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.004-24.005.sql @@ -0,0 +1,250 @@ + + +EXEC core.fn_dropifexists 'p_ComplianceAccesscontainerUpdate', 'onprc_ehr_compliancedb', 'PROCEDURE'; +GO + +-- Author: R. Blasa +-- Created: 12-10-2024 + +/* +** +** Created by +** Blasa 12-10-2024 Storedprocedure to update string name "ARRS" to "DCM" +** +** +** +** +*/ + +CREATE Procedure onprc_ehr_compliancedb.p_ComplianceTranslatestringUpdate + + +AS + + + +BEGIN + + ------ Update container value and include as part of the main Compliance module + +If exists(select * from ehr_compliancedb.EmployeePerUnit ------> count= 496 + where unit like '%arrs%' + ) +BEGIN + + Update ehr_compliancedb.EmployeePerUnit + set unit = replace(unit,'arrs', 'DCM') + + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + If exists(select * from ehr_compliancedb.EmployeePerUnit ------> count= 496 + where category like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.EmployeePerUnit + set category = replace(category,'arrs', 'DCM') + + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + If exists(select * from ehr_compliancedb.Employees + where majorudds like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.Employees + set majorudds = replace(majorudds,'arrs', 'DCM') + + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + If exists(select * from ehr_compliancedb.Employees + where unit like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.Employees + set unit = replace(unit,'arrs', 'DCM') + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + If exists(select * from ehr_compliancedb.Employees + where category like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.Employees + set category = replace(category,'arrs', 'DCM') + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + If exists(select * from ehr_compliancedb.requirements + where requirementname like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.requirements + set requirementname = replace(requirementname,'arrs', 'DCM') + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + If exists(select * from ehr_compliancedb.EmployeeRequirementExemptions + where requirementname like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.EmployeeRequirementExemptions + set requirementname = replace(requirementname,'arrs', 'DCM') + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + + If exists(select * from ehr_compliancedb.unit_names + where unit like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.unit_names + set unit = replace(unit,'arrs', 'DCM') + + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + If exists(select * from ehr_compliancedb.RequirementsPerCategory + where RequirementName like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.RequirementsPerCategory + set requirementname = replace(requirementname,'arrs', 'DCM') + + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + If exists(select * from ehr_compliancedb.RequirementsPerCategory + where category like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.RequirementsPerCategory + set category = replace(category,'arrs', 'DCM') + + If @@Error <> 0 + GoTo Err_Proc + + END + + + If exists(select * from ehr_compliancedb.RequirementsPerCategory + where unit like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.RequirementsPerCategory + set unit = replace(unit,'arrs', 'DCM') + + + If @@Error <> 0 + GoTo Err_Proc + + END + + If exists(select * from ehr_compliancedb.completiondates + where requirementname like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.completiondates + set requirementname = replace(requirementname,'arrs', 'DCM') + + + If @@Error <> 0 + GoTo Err_Proc + + END + + If exists(select * from ehr_compliancedb.EmployeeCategory + where categoryname like '%arrs%' + ) + BEGIN + + Update ehr_compliancedb.EmployeeCategory + set categoryname = replace(categoryname ,'arrs', 'DCM') + + + If @@Error <> 0 + GoTo Err_Proc + + END + + + + + + + + +No_Records: + + RETURN 0 + + +Err_Proc: + -- + RETURN 1 + + +END + +GO \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java b/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java index 52b481fdf..5979aa20f 100644 --- a/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java +++ b/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java @@ -55,7 +55,7 @@ public String getName() @Override public Double getSchemaVersion() { - return 24.004; + return 24.005; } @Override From 36896afcf2a95db2b2ac33161603eb706939f9fb Mon Sep 17 00:00:00 2001 From: Brent Logan Date: Thu, 26 Dec 2024 13:00:24 -0800 Subject: [PATCH 2/3] Process treatment_orders with a NULL enddate (#1197) * allow enddate to be NULL * replace enddateCoalesced with alternate * fix typo * cast enddate as DATE * Use parallel enddate IS NULL Adopt Ben Bimber's suggestion to modify both enddate comparisons to the same solution and use the one that is transparent about the problem being solved. * Reformat * Accommodate NULL treatment-order enddates * Remove added blank lines --- .../resources/queries/study/TreatmentSchedulePostOps.sql | 4 ++-- onprc_ehr/resources/queries/study/treatmentSchedule.sql | 4 ++-- onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql | 4 ++-- .../resources/queries/study/treatmentScheduleUpdate.sql | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql index ece5f0b8e..dd7919804 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql @@ -64,7 +64,7 @@ FROM ( FROM ehr_lookups.dateRange dr Join study."Treatment Orders" t1 - ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND + ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0 ) @@ -93,7 +93,7 @@ WHERE t1.date is not null ) s ON (s.animalid = h.id) WHERE h.calculated_status = 'Alive' --account for date/time in schedule - and s.date >= s.startDate and s.date <= s.enddate + AND s.date >= s.startDate AND (s.date <= s.enddate OR s.enddate IS NULL) -- /* diff --git a/onprc_ehr/resources/queries/study/treatmentSchedule.sql b/onprc_ehr/resources/queries/study/treatmentSchedule.sql index 6a0e2e993..2fc4bc5bd 100644 --- a/onprc_ehr/resources/queries/study/treatmentSchedule.sql +++ b/onprc_ehr/resources/queries/study/treatmentSchedule.sql @@ -85,7 +85,7 @@ FROM ehr_lookups.dateRange dr JOIN study."Treatment Orders" t1 --NOTE: should the enddate consider date/time? - ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND + ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND --technically the first day of the treatment is day 1, not day 0 ( (mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0 And t1.frequency.intervalindays is not null And t1.frequency.dayofweek is null ) @@ -116,4 +116,4 @@ WHERE (d.lastDayatCenter Is Null or d.lastDayAtCenter > s.enddate) --account for date/time in schedule -and s.date >= s.startDate and s.date <= s.enddate \ No newline at end of file + AND s.date >= s.startDate AND (s.date <= s.enddate OR s.enddate IS NULL) -- some treatment_orders can have NULL enddates diff --git a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql index 56a16d278..2d513e4bb 100644 --- a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql +++ b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql @@ -62,7 +62,7 @@ FROM study.demographics h JOIN ( FROM ehr_lookups.dateRange dr Join study."Treatment Orders" t1 - ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND + ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0 ) @@ -92,4 +92,4 @@ WHERE h.calculated_status = 'Alive' --account for date/time in schedule --and s.date >= s.startDate and s.date <= s.enddate --Added the enddate = null clause by Kollil, 10/25/24. Refer to ticket #11471 - and s.date >= s.startDate and (s.date <= s.enddate or s.enddate is null) + AND s.date >= s.startDate AND (s.date <= s.enddate OR s.enddate is null) diff --git a/treatmentETL/resources/queries/study/treatmentScheduleUpdate.sql b/treatmentETL/resources/queries/study/treatmentScheduleUpdate.sql index 4efde2469..c8e70c90a 100644 --- a/treatmentETL/resources/queries/study/treatmentScheduleUpdate.sql +++ b/treatmentETL/resources/queries/study/treatmentScheduleUpdate.sql @@ -85,7 +85,7 @@ FROM dateRangedata dr JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study."Treatment Orders" t1 --NOTE: should the enddate consider date/time? - ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND + ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND --technically the first day of the treatment is day 1, not day 0 mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0 OR (t1.frequency.dayofweek is not null And t1.frequency.intervalindays is null And dr.DayOfWeek in (select k.value from onprc_ehr.Frequency_DayofWeek k where k.FreqKey = t1.frequency.rowid )) @@ -115,4 +115,4 @@ WHERE --d.calculated_status = 'Alive' --account for date/time in schedule --and -s.date >= s.startDate and s.date <= s.enddate +s.date >= s.startDate AND (s.date <= s.enddate OR s.enddate IS NULL) -- some treatment_orders can have NULL enddates From c818022986822d8eb561cea00c6ad047ebb9abdd Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Wed, 8 Jan 2025 11:40:29 -0800 Subject: [PATCH 3/3] 23.11 fb compliance procedure test translation (#1140) * Created a new probram that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Created a new program that translated the Compliance Procedure Recent.sql to a static set of data set values. * Modified version of the Compliance Overdue/Soon Reports * Modified Compliance query to remove sql reusltset errors * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified xml file to reflect new temp tables configurations * Modified Compliance reporting formats. * Modified Compliance reporting formats. * Modified Compliance Report overdue/soon * Modified Compliance Report overdue/soon * Modified Compliance Report overdue/soon * Modified Compliance Report overdue/soon * Modified Compliance Overdue/Soon reports data type * Modified Compliance OVerdue/Soon reports sql program. * Modified Compliance OVerdue/Soon reports sql program. * Modified Compliance OVerdue/Soon reports sql program. * Modified Compliance OVerdue/Soon reports sql program. * Modified Compliance OVerdue/Soon reports sql program. * Modified Compliance Overdue/Soon reports queries. * Modified Compliance Overdue/Soon reports queries. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report faster version. * Modified Compliance Overdue/Soon report code changes. * Modified Compliance Overdue/Soon report code changes. * Modified Compliance Overdue/Soon reports. * Modified Compliance Overdue/Soon reports. * Modified Compliance Overdue/Soon reports. * Modified Compliance Overdue/Soon reports. * Modified Compliance Overdue/Soon reports. --- .../ComplianceProcedureRecentTests.query.xml | 57 ++- .../ComplianceProcedureRecentTests.sql | 151 +------- .../ComplianceProcedureRecentTests/.qview.xml | 28 +- .../Occupational Health Compliance.qview.xml | 28 +- ...nd Due Soon withNoEHRS OccHealth.qview.xml | 12 +- .../Overdue and Due Soon.qview.xml | 10 +- ...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 + .../ComplianceRecentTests.query.xml | 60 ++- .../ComplianceRecentTests.sql | 166 +-------- .../ComplianceRecentTests/.qview.xml | 29 +- .../ComplianceRecentTestsorg.query.xml | 121 ++++++ .../ComplianceRecentTestsorg.sql | 192 ++++++++++ .../ComplianceRecentTestsorg/.qview.xml | 23 ++ .../onprc_ehr_compliancedb-24.005-24.006.sql | 261 +++++++++++++ .../onprc_ehr_compliancedb-24.006-24.007.sql | 349 ++++++++++++++++++ .../schemas/onprc_ehr_compliancedb.xml | 96 +++++ .../resources/views/begin.html | 3 +- .../ONPRC_EHR_ComplianceDBModule.java | 2 +- 23 files changed, 1555 insertions(+), 388 deletions(-) create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql create mode 100644 ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml create mode 100644 ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.005-24.006.sql create mode 100644 ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.006-24.007.sql diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.query.xml index 43b1f7031..63925bc28 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.query.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.query.xml @@ -4,7 +4,7 @@ Employee Requirement Summary - + Employee ID true @@ -14,9 +14,12 @@ - + + Row ID + + Requirement Name - 90 + 250 ehr_compliancedb requirements @@ -24,7 +27,7 @@ ALWAYS_OFF - + Times Completed 50 /query/executeQuery.view?schemaName=ehr_compliancedb& @@ -33,21 +36,46 @@ 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 - 70 + 210 - + Most Recent Date + yyyy-MM-dd 70 @@ -58,7 +86,16 @@ Category 70 - + + + Trainee Type + 70 + + + Requirement Name Type + 180 + + Months Until Renewal 60 diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.sql index 795082a50..c2ac75974 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.sql +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.sql @@ -1,149 +1,2 @@ -/* - * 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 (age_in_months(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) > (age_in_months(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) > (age_in_months(max(pq.date), tt.reviewdate) )) > 0 THEN - - ( select ( age_in_months(max(pq.date), tt.reviewdate) - ( age_in_months(max(pq.date), curdate())) )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) > (age_in_months(max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( age_in_months(max(pq.date), curdate())) 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 b.requirementname in ( select k.requirementname from ehr_compliancedb.requirements k where k.datedisabled is null) - - And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where p.enddate 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 (age_in_months(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) > (age_in_months(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) > (age_in_months(max(pq.date), tt.reviewdate) )) > 0 THEN - - ( select ( age_in_months(max(pq.date), tt.reviewdate) - ( age_in_months(max(pq.date), curdate())) )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) > (age_in_months(max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( age_in_months(max(pq.date), curdate())) 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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = a.requirementname And k.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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = j.requirementname And k.datedisabled is null) - - -group by j.requirementname,j.employeeid - - - - - +Select * +from onprc_ehr_compliancedb.ComplianceProcedureReport diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/.qview.xml index 82fc59d49..c2b48d9ac 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/.qview.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/.qview.xml @@ -1,25 +1,25 @@ - - - - - + + + + + - + - - - - + + + + - + - - - + + + \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Occupational Health Compliance.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Occupational Health Compliance.qview.xml index 97934dc5a..cebd0518f 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Occupational Health Compliance.qview.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Occupational Health Compliance.qview.xml @@ -1,26 +1,26 @@ - - - - - + + + + + - + - - - - + + + + - - - + + + - + diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon withNoEHRS OccHealth.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon withNoEHRS OccHealth.qview.xml index 192608c90..99f13ff8e 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon withNoEHRS OccHealth.qview.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon withNoEHRS OccHealth.qview.xml @@ -1,15 +1,13 @@ - - - + + + - - - - + + diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon.qview.xml index bc93d1734..9c5d83de1 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon.qview.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/Overdue and Due Soon.qview.xml @@ -1,12 +1,12 @@ - - - + + + - - + + \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml new file mode 100644 index 000000000..b3e75afd8 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.query.xml @@ -0,0 +1,126 @@ + + + +
+ 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 new file mode 100644 index 000000000..585ed1c0e --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg.sql @@ -0,0 +1,148 @@ +/* + * 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 new file mode 100644 index 000000000..82fc59d49 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/.qview.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..97934dc5a --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Occupational Health Compliance.qview.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..192608c90 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon withNoEHRS OccHealth.qview.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..bc93d1734 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTestsorg/Overdue and Due Soon.qview.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.query.xml index de9c0af17..d85eb7bac 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.query.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.query.xml @@ -4,7 +4,7 @@ Employee Requirement Summary - + Employee ID true @@ -14,7 +14,10 @@ - + + Row ID + + Requirement Name 90 @@ -24,7 +27,7 @@ ALWAYS_OFF - + Times Completed 50 /query/executeQuery.view?schemaName=ehr_compliancedb& @@ -33,21 +36,46 @@ 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 - 70 + 210 - + Most Recent Date + yyyy-MM-dd 70 @@ -58,7 +86,16 @@ Category 70 - + + + Trainee Type + 70 + + + Requirement Name Type + 180 + + Months Until Renewal 60 @@ -76,6 +113,11 @@ 60 ALWAYS_OFF + + Snooze Until + 60 + ALWAYS_OFF +
diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.sql index e20555134..1e12aa52e 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.sql +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests.sql @@ -1,164 +1,2 @@ -/* - * 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 (age_in_months(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) > (age_in_months(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, - 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) > (age_in_months(max(pq.date), tt.reviewdate) )) > 0 THEN - - ( select ( age_in_months(max(pq.date), tt.reviewdate) - ( age_in_months(max(pq.date), curdate())) )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) > (age_in_months(max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - ELSE ( select (tt.expireperiod) - ( age_in_months(max(pq.date), curdate())) 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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = b.requirementname And k.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 (age_in_months(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) > (age_in_months(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, - - - - 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) > (age_in_months(max(pq.date), tt.reviewdate) )) > 0 THEN - - ( select ( age_in_months(max(pq.date), tt.reviewdate) - ( age_in_months(max(pq.date), curdate())) )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) > (age_in_months(max(pq.date), tt.reviewdate)) and (tt.reviewdate is not null) ) - - - - - ELSE ( select (tt.expireperiod) - ( age_in_months(max(pq.date), curdate())) 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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = a.requirementname And k.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 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 (age_in_months(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) > (age_in_months(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 completiondates yy where yy.date in (select max(zz.date) from completiondates zz where zz.requirementname= j.requirementname and zz.employeeid= j.employeeid ) - And yy.requirementname= j.requirementname and yy.employeeid= j.employeeid ) as comment, - null 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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = j.requirementname And k.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 k.requirementname from ehr_compliancedb.requirements k where k.requirementname = j.requirementname And k.datedisabled is null) - - -group by j.requirementname,j.employeeid - +Select * +from onprc_ehr_compliancedb.ComplianceRecentReport \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests/.qview.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests/.qview.xml index 750c4460d..b2c68ae6f 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests/.qview.xml +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTests/.qview.xml @@ -1,23 +1,24 @@ - - - - - - + + + + + - - - - - + + + + + + + - - - + + + diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml new file mode 100644 index 000000000..46cb8fc00 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.query.xml @@ -0,0 +1,121 @@ + + + + + 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 new file mode 100644 index 000000000..1ff4baac6 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg.sql @@ -0,0 +1,192 @@ +/* + * 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 new file mode 100644 index 000000000..750c4460d --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceRecentTestsorg/.qview.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.005-24.006.sql b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.005-24.006.sql new file mode 100644 index 000000000..0a739ae44 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.005-24.006.sql @@ -0,0 +1,261 @@ +-- Author: R. Blasa +-- Created: 9-20-2024-2024 +-- Description: Stored procedure program to create a static data set for Compliance Procedure Recent Test .sql + + + CREATE TABLE onprc_ehr_compliancedb.ComplianceProcedureReport( + [rowid] [int] IDENTITY(1,1) NOT NULL, + [employeeid] varchar(300) NULL, + [requirementname] [varchar](4000) NULL, + [unit] [varchar](500) NULL, + [category] [varchar](500) NULL, + [trackingflag] [varchar](100) NULL, + [email] [varchar](500) NULL, + [lastname] [varchar](500) NULL, + [firstname] [varchar](500) NULL, + [host] [varchar](500) NULL, + [supervisor] [varchar](500) NULL, + [trainee_type] [varchar](500) NULL, + [times_completed] [smallint] NULL, + [expired_period] [smallint] NULL, + [new_expired_period] [smallint] NULL, + [mostrecentcompleted_date] [smalldatetime] NULL, + [comment] [varchar](4000) NULL, + [snooze_date] [smalldatetime] NULL, + [months_until_renewal] [Float] NULL, + [requirement_name_type] [varchar](1000) NULL + + ) ON [PRIMARY] + GO + +-- Author: R. Blasa +-- Created: 9-20-2024 + +/* +** +** Created by +** Blasa 9-20-2024 Created a storedprocedure to create a static set of data from +** the ComplianceProcedureRecentTest.sql query +** +** +** +*/ + +CREATE Procedure onprc_ehr_compliancedb.p_ComplianceProcedureOverDueSoon_Process + + +AS + + + ----- Reset Reporting table + Delete onprc_ehr_compliancedb.ComplianceProcedureReport + + If @@Error <> 0 + GoTo Err_Proc + + + +BEGIN + + Insert into onprc_ehr_compliancedb.ComplianceProcedureReport + ( + requirementname, + employeeid, + unit, + category, + trackingflag, + email, + lastname, + firstname, + host, + supervisor, + trainee_type, + requirement_name_type, + times_completed, + expired_period, + new_expired_Period, + mostrecentcompleted_date, + comment, + snooze_date, + months_until_renewal + + ) + + + + + + select b.requirementname, + a.employeeid, + string_agg(a.unit,char(10)) as unit, + string_agg(a.category,char(10)) as category, + (select top 1 h.trackingflag from ehr_compliancedb.requirementspercategory h where h.requirementname = b.requirementname) as trackingflag, + (select h.email from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = b.requirementname) as requirement_type, + + (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as times_Completed, + + (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = b.requirementname) as ExpiredPeriod, + + ( select (datediff(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) > (datediff(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 mostrecentcompleted_date, + + (Select distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > ( datediff(month,max(pq.date), tt.reviewdate) )) > 0 THEN + + ( select (datediff(month,max(pq.date), tt.reviewdate) - ( datediff(month,max(pq.date), getdate()) ) )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) > ( datediff(month,max(pq.date), tt.reviewdate) ) ) + + + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate()) ) 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 Float) AS MonthsUntilRenewal + + + + from ehr_Compliancedb.employeeperunit a ,ehr_compliancedb.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 a.employeeid = p.employeeid And 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 + + select a.requirementname, + a.employeeid, + null as unit, + null as category, + 'No' as trackingflag, + (select h.email from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = a.requirementname) as requirement_type, ----- type trainee, or trainer + + + (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 (datediff(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) > (datediff(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 distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > ( datediff(month,max(pq.date), tt.reviewdate) )) > 0 THEN + + ( select ( datediff(month,max(pq.date), tt.reviewdate) - ( datediff(month,max(pq.date), getdate())) )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) > ( datediff(month,max(pq.date), tt.reviewdate) ) ) + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate()) ) 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 Float) 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 a.employeeid = p.employeeid And 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, + (select h.email from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = j.requirementname) as requirement_type, ----- type trainee, or trainer + 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 j.employeeid = p.employeeid And 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 + + order by employeeid,requirementname, mostrecentcompleted_date desc + + + If @@Error <> 0 + GoTo Err_Proc + + + + + RETURN 0 + + +Err_Proc: + + RETURN 1 + + +END + +GO \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.006-24.007.sql b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.006-24.007.sql new file mode 100644 index 000000000..24134b431 --- /dev/null +++ b/ONPRC_EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/onprc_ehr_compliancedb-24.006-24.007.sql @@ -0,0 +1,349 @@ +-- Author: R. Blasa +-- Created: 9-20-2024-2024 +-- Description: Stored procedure program to create a static data set for Compliance Recent Test .sql + + + CREATE TABLE onprc_ehr_compliancedb.ComplianceRecentReport( + [rowid] [int] IDENTITY(1,1) NOT NULL, + [employeeid] varchar(300) NULL, + [requirementname] [varchar](4000) NULL, + [unit] [varchar](500) NULL, + [category] [varchar](500) NULL, + [trackingflag] [varchar](100) NULL, + [email] [varchar](500) NULL, + [lastname] [varchar](500) NULL, + [firstname] [varchar](500) NULL, + [host] [varchar](500) NULL, + [supervisor] [varchar](500) NULL, + [trainee_type] [varchar](500) NULL, + [times_completed] [smallint] NULL, + [expired_period] [smallint] NULL, + [new_expired_period] [smallint] NULL, + [mostrecentcompleted_date] [smalldatetime] NULL, + [comment] [varchar](4000) NULL, + [snooze_date] [smalldatetime] NULL, + [months_until_renewal] [FLOAT] NULL, + [requirement_name_type] [varchar](1000) NULL + + ) ON [PRIMARY] + GO + + +-- Author: R. Blasa +-- Created: 9-20-2024 + +/* +** +** Created by +** Blasa 9-20-2024 Created a storedprocedure to create a static set of data from +** the ComplianceRecentTest.sql query +** +** +** +*/ + +CREATE Procedure onprc_ehr_compliancedb.p_ComplianceRecentOverDueSoon_Process + + +AS + + + + ----- Reset Reporting table + Delete onprc_ehr_compliancedb.ComplianceRecentReport + + If @@Error <> 0 + GoTo Err_Proc + + + +BEGIN + + Insert into onprc_ehr_compliancedb.ComplianceRecentReport + ( + requirementname, + employeeid, + unit, + category, + trackingflag, + email, + lastname, + firstname, + host, + supervisor, + trainee_type, + requirement_name_type, + times_completed, + expired_period, + new_expired_Period, + mostrecentcompleted_date, + comment, + snooze_date, + months_until_renewal + + ) + + + + + select b.requirementname, + a.employeeid, + string_agg(a.unit,char(10)) as unit, + string_agg(a.category,char(10)) as category, + (select top 1 h.trackingflag from ehr_compliancedb.requirementspercategory h where h.requirementname = b.requirementname) as trackingflag, + (select h.email from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = b.requirementname) as requirement_type, ----- type trainee, or trainer + + + (select count(zz.date) from ehr_compliancedb.completiondates zz where zz.requirementname= b.requirementname and zz.employeeid= a.employeeid ) as times_Completed, + + (select k.expireperiod from ehr_compliancedb.Requirements k where k.requirementname = b.requirementname) as ExpiredPeriod, + + ( select (datediff(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) > (datediff(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 mostrecentcompleted_date, + + (Select distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > ( datediff(month,max(pq.date), tt.reviewdate) ) ) > 0 THEN + + ( select (datediff(month,max(pq.date), tt.reviewdate) - ( datediff(month,max(pq.date), getdate())) ) 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) > (datediff(month,max(pq.date), tt.reviewdate) ) ) + + + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate())) 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 FLOAT) AS MonthsUntilRenewal + + + + from ehr_Compliancedb.employeeperunit a ,ehr_compliancedb.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 a.employeeid = p.employeeid And 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 + + select a.requirementname, + a.employeeid, + null as unit, + null as category, + 'No' as trackingflag, + (select h.email from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = a.requirementname) as requirement_type, ----- type trainee, or trainer + + + (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 (datediff(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) > (datediff(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 distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > (datediff(month,max(pq.date), tt.reviewdate) )) > 0 THEN + + ( select (datediff(month,max(pq.date), tt.reviewdate) - ( datediff(month,max(pq.date), getdate())) ) 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) > (datediff(month,max(pq.date), tt.reviewdate) ) ) + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate())) 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 FLOAT) 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 a.employeeid = p.employeeid And 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 a.requirementname, + a.employeeid, + null as unit, + null as category, + 'No' as trackingflag, + (select h.email from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = a.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = a.requirementname) as requirement_type, ----- type trainee, or trainer + + + (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 (datediff(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) > (datediff(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 distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > (datediff(month,max(pq.date), tt.reviewdate) )) > 0 THEN + + ( select ( datediff(month,max(pq.date), tt.reviewdate) - (datediff(month,max(pq.date), getdate())) )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) > (datediff(month,max(pq.date), tt.reviewdate)) ) + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate())) 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.employeerequirementexemptions a + Where a.requirementname in (select z.requirementname from ehr_compliancedb.completiondates z where z.requirementname = a.requirementname + and z.employeeid = a.employeeid and z.date is not null) + And a.employeeid in (select p.employeeid from ehr_compliancedb.employees p where a.employeeid = p.employeeid And 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, + (select h.email from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as email, + (select h.lastname from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as lastname, + (select h.firstname from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as firstname, + (select h.majorudds from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as host, + (select h.supervisor from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as supervisor, + (select h.type from ehr_compliancedb.employees h where h.employeeid = j.employeeid) as trainee_type, ----- type trainee, or trainer + (select h.type from ehr_compliancedb.Requirements h where h.requirementname = j.requirementname) as requirement_type, ----- type trainee, or trainer + + (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 (datediff(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) > (datediff(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 distinct string_agg(yy.comment, char(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, + + (Select distinct string_agg(yy.snooze_date, char(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 snooze_date, + + 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) > (datediff(month,max(pq.date), tt.reviewdate) )) > 0 THEN + + ( select ( datediff(month,max(pq.date), tt.reviewdate) - (datediff(month,max(pq.date), getdate())) )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) > (datediff(month,max(pq.date), tt.reviewdate)) ) + + + ELSE ( select (tt.expireperiod) - ( datediff(month,max(pq.date), getdate())) 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 DECIMAL) 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 j.employeeid = p.employeeid And 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 + + order by employeeid,requirementname, mostrecentcompleted_date desc + + + If @@Error <> 0 + GoTo Err_Proc + + + + + RETURN 0 + + +Err_Proc: + + RETURN 1 + + +END + +GO diff --git a/ONPRC_EHR_ComplianceDB/resources/schemas/onprc_ehr_compliancedb.xml b/ONPRC_EHR_ComplianceDB/resources/schemas/onprc_ehr_compliancedb.xml index 3e14b18cc..dd608fe56 100644 --- a/ONPRC_EHR_ComplianceDB/resources/schemas/onprc_ehr_compliancedb.xml +++ b/ONPRC_EHR_ComplianceDB/resources/schemas/onprc_ehr_compliancedb.xml @@ -157,5 +157,101 @@ + + Compliance Procedure Report + + DETAILED + + + Search ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Compliance Recent Report + + DETAILED + + + Search ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/ONPRC_EHR_ComplianceDB/resources/views/begin.html b/ONPRC_EHR_ComplianceDB/resources/views/begin.html index da05f329a..57a80f02f 100644 --- a/ONPRC_EHR_ComplianceDB/resources/views/begin.html +++ b/ONPRC_EHR_ComplianceDB/resources/views/begin.html @@ -21,7 +21,7 @@ sections: [{ header: 'Reports', items: [{ - name: 'Summary of Requirements By Employee', url: '<%=contextPath%>/query' + container + '/executeQuery.view?schemaName=ehr_compliancedb&query.queryName=ComplianceRecentTests&query.employeeid/isActive~eq=true' + name: 'Summary of Requirements By Employee', url: '<%=contextPath%>/query' + container + '/executeQuery.view?schemaName=ehr_compliancedb&query.queryName=ComplianceRecentTests&query.employeeid/isActive~eq=true' },{ name: 'Requirements Overdue/Due Soon', url: '<%=contextPath%>/query' + container + '/executeQuery.view?schemaName=ehr_compliancedb&query.queryName=ComplianceProcedureRecentTests&query.viewName=Overdue and Due Soon' },{ @@ -30,6 +30,7 @@ name: 'Occupational Health - Requirements Overdue/Due Soon', url: '<%=contextPath%>/query' + container + '/executeQuery.view?schemaName=ehr_compliancedb&query.queryName=ComplianceProcedureRecentTests&query.viewName=Occupational%20Health%20Compliance' },{ name: 'Occupational Health - Measles Overdue/Due Soon', url: '<%=contextPath%>/query' + container + '/executeQuery.view?schemaName=ehr_compliancedb&query.queryName=Measles45DayAlert&query.DaysOverDue~neqornull=-1' + },{ name: 'Requirements Overdue/Due Soon (Full SSRS Reports)', url: ctx['SSRSServerURL'] +'%2fPrime+Reports%2fCompliance%2fOverdue_Soon_Report&rs:Command=Render' },{ diff --git a/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java b/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java index 5979aa20f..a03021ffb 100644 --- a/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java +++ b/ONPRC_EHR_ComplianceDB/src/org/labkey/ONPRCEHR_ComplianceDB/ONPRC_EHR_ComplianceDBModule.java @@ -55,7 +55,7 @@ public String getName() @Override public Double getSchemaVersion() { - return 24.005; + return 24.007; } @Override