-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # ONPRC_EHR_ComplianceDB/resources/views/begin.html
- Loading branch information
Showing
27 changed files
with
1,562 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 2 additions & 149 deletions
151
ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
28 changes: 14 additions & 14 deletions
28
...ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceProcedureRecentTests/.qview.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<customView xmlns="http://labkey.org/data/xml/queryCustomView" label="All"> | ||
<columns> | ||
<column name="employeeId/email"/> | ||
<column name="employeeId"/> | ||
<column name="employeeId/lastName"/> | ||
<column name="employeeId/firstName"/> | ||
<column name="employeeId/majorudds"/> | ||
<column name="email"/> | ||
<column name="employeeid"/> | ||
<column name="lastname"/> | ||
<column name="firstname"/> | ||
<column name="host"/> | ||
<column name="unit"/> | ||
<column name="category"/> | ||
<column name="requirementName"/> | ||
<column name="requirementname"/> | ||
<column name="trackingflag"/> | ||
<column name="timesCompleted"/> | ||
<column name="ExpiredPeriod"/> | ||
<column name="NewExpirePeriod"/> | ||
<column name="MostRecentDate"/> | ||
<column name="times_completed"/> | ||
<column name="expired_period"/> | ||
<column name="new_expired_period"/> | ||
<column name="mostrecentcompleted_date"/> | ||
<column name="comment"/> | ||
<column name="MonthsUntilRenewal"/> | ||
<column name="months_until_renewal"/> | ||
<column name="snooze_date"/> | ||
</columns> | ||
<sorts> | ||
<sort column="employeeId/lastName" descending="false"/> | ||
<sort column="employeeId/firstName" descending="false"/> | ||
<sort column="requirementName" descending="false"/> | ||
<sort column="lastname" descending="false"/> | ||
<sort column="firstName" descending="false"/> | ||
<sort column="requirementname" descending="false"/> | ||
</sorts> | ||
</customView> |
28 changes: 14 additions & 14 deletions
28
.../EHR_ComplianceDB/ComplianceProcedureRecentTests/Occupational Health Compliance.qview.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...anceDB/ComplianceProcedureRecentTests/Overdue and Due Soon withNoEHRS OccHealth.qview.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.