From 4f7ca6d257cdb0cf5dd82f140d51f20222e2fa0a Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Tue, 20 Apr 2021 11:59:08 -0700 Subject: [PATCH 01/12] Added the webpart for PMIC wiki --- onprc_ehr/resources/views/PMIC_Wiki.html | 47 +++++++++++++++++++ onprc_ehr/resources/views/PMIC_Wiki.view.xml | 5 ++ .../resources/views/PMIC_Wiki.webpart.xml | 6 +++ 3 files changed, 58 insertions(+) create mode 100644 onprc_ehr/resources/views/PMIC_Wiki.html create mode 100644 onprc_ehr/resources/views/PMIC_Wiki.view.xml create mode 100644 onprc_ehr/resources/views/PMIC_Wiki.webpart.xml diff --git a/onprc_ehr/resources/views/PMIC_Wiki.html b/onprc_ehr/resources/views/PMIC_Wiki.html new file mode 100644 index 000000000..59393b2f2 --- /dev/null +++ b/onprc_ehr/resources/views/PMIC_Wiki.html @@ -0,0 +1,47 @@ +

This page contains the links related to the PMIC data entry services.

+

 

+ +

This screen contains the PMIC services request data entry form

+ +

This screen contains the data entry panels for PET Scan, CT Scan, SPECT, Angio, Ultrasound and DEXA procedures.

+ +

New tabs are created for each PMIC procedure under "Imaging" tab on the Animal history form. 

+
    +
  1. PMIC - PET:  Click on this tab to view the animal's PET Imaging data.
  2. +
  3. PMIC - CT:  Click on this tab to view the animal's CT Imaging data.
  4. +
  5. PMIC - SPECT:  Click on this tab to view the animal's SPECT Imaging data.
  6. +
  7. PMIC - Angio:  Click on this tab to view the animal's Angio Imaging data.
  8. +
  9. PMIC - Ultrasound:  Click on this tab to view the animal's Ultrasound Imaging data.
  10. +
  11. PMIC - DEXA:  Click on this tab to view the animal's DEXA Imaging data.
  12. +
+ +

This is the maintenance screen for the PMIC reference data such as PET radioisotopes, SPECT radioisotopes, Ultrasound procedures, DEXA values & Animal position values and etc. The PMIC admin can add/edit any of these items.

+

A new item is added by clicking the "IMPORT BULK DATA" on the top panel and entering valid "Value" and "Name" fields with a blank "End Date" field .

+

An item can be disabled by clicking the "EDIT" button and set a valid "End Date". The item will be deleted from the appropriate drop down list(s). 

+ +
    +
  1. Click here to view, Today's scheduled events
  2. +
  3. Click here to view, Weekly scheduled events 
  4. +
+

 

+

 

\ No newline at end of file diff --git a/onprc_ehr/resources/views/PMIC_Wiki.view.xml b/onprc_ehr/resources/views/PMIC_Wiki.view.xml new file mode 100644 index 000000000..c35f7ebb7 --- /dev/null +++ b/onprc_ehr/resources/views/PMIC_Wiki.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/onprc_ehr/resources/views/PMIC_Wiki.webpart.xml b/onprc_ehr/resources/views/PMIC_Wiki.webpart.xml new file mode 100644 index 000000000..c732962af --- /dev/null +++ b/onprc_ehr/resources/views/PMIC_Wiki.webpart.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From d13b9f02a489f1f4736d36129e7b2ea956a7c3af Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Wed, 21 Apr 2021 21:36:15 -0700 Subject: [PATCH 02/12] Added groups info to SLA purchase data and changed the billing container in PMIC --- .../queries/study/PMIC_ChargeTypes.sql | 2 +- sla/resources/queries/sla/PlandProtocols.sql | 106 +++-- .../queries/sla/ProtocolProjectsUsage.sql | 371 ++++++++++++------ 3 files changed, 333 insertions(+), 146 deletions(-) diff --git a/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql b/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql index 02ca552fa..77a0c4145 100644 --- a/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql +++ b/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql @@ -1,3 +1,3 @@ SELECT chargetype -From Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.onprc_billing.chargeUnits +From Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public'}.onprc_billing.chargeUnits Where servicecenter is null or servicecenter like 'PMIC' \ No newline at end of file diff --git a/sla/resources/queries/sla/PlandProtocols.sql b/sla/resources/queries/sla/PlandProtocols.sql index 26d5091ff..9988c6aea 100644 --- a/sla/resources/queries/sla/PlandProtocols.sql +++ b/sla/resources/queries/sla/PlandProtocols.sql @@ -1,42 +1,86 @@ - SELECT a.project as ProjectID, -aa.species, -a.account as Alias, -y.grantNumber as OGAGrantNumber, -a.protocol as ParentIACUC, -a.title as Title, -a.name as IACUCCode, -a.startdate as StartDate, -a.enddate as EndDate, -i.FirstName, -i.LastName, -i.Division, -p.external_id, -i.LastName + ': ' + a.name + '('+ p.external_id +')' + ' - ' + a.title + ' (Species: ' + aa.species + ')' as PIIacuc + aa.species, + a.account as Alias, + y.grantNumber as OGAGrantNumber, + a.protocol as ParentIACUC, + a.title as Title, + a.name as IACUCCode, + a.startdate as StartDate, + a.enddate as EndDate, + i.FirstName, + i.LastName, + i.Division, + p.external_id, + i.LastName + ': ' + a.name + '('+ p.external_id +')' + ' Group Id & Name - ' + aa. Group_Id + ', '+ aa.Group_Name + ' - ' + a.title + ' (Species: ' + aa.species + ')' as PIIacuc FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol -LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId -LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol -LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = a.account + LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId + LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol + LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = a.account WHERE - -- filter based on the current date compared with the start and end dates - ( +-- filter based on the current date compared with the start and end dates + ( (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR (now() between aa.StartDate AND aa.EndDate) - ) + ) AND - --Check for the project enddate. Added by LK on 1/16/2019 - (now() between a.StartDate AND a.EndDate) - -- and filtered based on dataAccess for the given user +--Check for the project enddate. Added by LK on 1/16/2019 + (now() between a.StartDate AND a.EndDate) +-- and filtered based on dataAccess for the given user AND - ( + ( (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da - -- current logged in user is the dataAccess user - WHERE isMemberOf(da.userid) - -- has access to all data - AND (da.allData = true - -- has access to the specified investigatorId and the specified project (if applicable) - OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- current logged in user is the dataAccess user + WHERE isMemberOf(da.userid) +-- has access to all data + AND (da.allData = true +-- has access to the specified investigatorId and the specified project (if applicable) + OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) ) IS NOT NULL - ) + ) + + + +-- +-- SELECT a.project as ProjectID, +-- aa.species, +-- a.account as Alias, +-- y.grantNumber as OGAGrantNumber, +-- a.protocol as ParentIACUC, +-- a.title as Title, +-- a.name as IACUCCode, +-- a.startdate as StartDate, +-- a.enddate as EndDate, +-- i.FirstName, +-- i.LastName, +-- i.Division, +-- p.external_id, +-- i.LastName + ': ' + a.name + '('+ p.external_id +')' + ' - ' + a.title + ' (Species: ' + aa.species + ')' as PIIacuc +-- FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol +-- LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol +-- LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = a.account +-- WHERE +-- -- filter based on the current date compared with the start and end dates +-- ( +-- (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR +-- (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR +-- (now() between aa.StartDate AND aa.EndDate) +-- ) +-- AND +-- --Check for the project enddate. Added by LK on 1/16/2019 +-- (now() between a.StartDate AND a.EndDate) +-- -- and filtered based on dataAccess for the given user +-- AND +-- ( +-- (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da +-- -- current logged in user is the dataAccess user +-- WHERE isMemberOf(da.userid) +-- -- has access to all data +-- AND (da.allData = true +-- -- has access to the specified investigatorId and the specified project (if applicable) +-- OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- ) IS NOT NULL +-- ) diff --git a/sla/resources/queries/sla/ProtocolProjectsUsage.sql b/sla/resources/queries/sla/ProtocolProjectsUsage.sql index f7f7aab1f..49c9eac5e 100644 --- a/sla/resources/queries/sla/ProtocolProjectsUsage.sql +++ b/sla/resources/queries/sla/ProtocolProjectsUsage.sql @@ -1,143 +1,286 @@ - - +--SLA usage numbers including Breeding groups data SELECT -a.project as ProjectID, -a.name AS Project, -p.external_id as eIACUCNum, -a.title as Title, -i.LastName || ', ' || i.FirstName AS PIName, -x.account as Alias, -y.projectNumber as OGAProjectNumber, -y.grantNumber as OGAGrantNumber, -f.lastname || ', ' || f.firstName as FiscalAuthorityName, -aa.Species, -aa.Gender, -aa.Strain, -aa.Allowed AS NumAllowed, -calc.NumUsed, -aa.StartDate, -aa.EndDate + a.project as ProjectID, + a.name AS Project, + p.external_id as eIACUCNum, + a.title as Title, + i.LastName || ', ' || i.FirstName AS PIName, + x.account as Alias, + y.projectNumber as OGAProjectNumber, + y.grantNumber as OGAGrantNumber, + f.lastname || ', ' || f.firstName as FiscalAuthorityName, + aa.Species, + aa.Gender, + aa.Strain, + aa.Allowed AS NumAllowed, + calc.NumUsed, + aa.StartDate, + aa.EndDate, + CASE + WHEN aa.BreedingAllowed = '1' THEN 'Yes' + ELSE 'No' + END AS BreedingAllowed, + aa.Group_Id, + aa.Group_Name FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol -LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId -LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst -LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol -LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project -LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account -LEFT JOIN ( --- SELECT i.protocol,species,gender,sum(animalsreceived) AS NumUsed --- FROM sla.purchasedetails pd, sla.purchase p --- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i ON p.project = i.project --- WHERE p.objectid = pd.purchaseid AND animalsreceived IS NOT NULL --- GROUP BY i.protocol,species,gender - ---Changed by LK on 5/30 to get the accurate numused. + LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId + LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst + LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol + LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project + LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = x.account + LEFT JOIN ( + --Changed by LK on 5/30 to get the accurate numused. --Ignore the gender when counting the usage if the approval data gender is: "Male or Female". Count both Male and Female usage. - (SELECT i.protocol,pd.species,sum(animalsreceived) AS NumUsed - FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, - Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa1 - Where p.project = i.project AND p.objectid = pd.purchaseid - AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = 'Male or Female' - AND animalsreceived IS NOT NULL - AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() - GROUP BY i.protocol, pd.species) + (SELECT i.protocol,pd.species,sum(animalsreceived) AS NumUsed + FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, + Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa1 + Where p.project = i.project AND p.objectid = pd.purchaseid + AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = 'Male or Female' + AND animalsreceived IS NOT NULL + AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() + GROUP BY i.protocol, pd.species) -) AS calc ON a.protocol = calc.protocol - AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) - --AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) - --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) + ) AS calc ON a.protocol = calc.protocol + AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) + --AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) + --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) WHERE - -- filter based on the current date compared with the start and end dates - ( +-- filter based on the current date compared with the start and end dates + ( (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR (aa.StartDate IS NOT NULL AND aa.EndDate IS NOT NULL AND now() between aa.StartDate AND aa.EndDate) - AND (aa.gender = 'Male or Female') - ) + AND (aa.gender = 'Male or Female') + ) AND - --Check for the project enddate. Added by LK on 1/16/2019 - (now() between a.StartDate AND a.EndDate) - -- and filtered based on dataAccess for the given user +--Check for the project enddate. Added by LK on 1/16/2019 + (now() between a.StartDate AND a.EndDate) +-- and filtered based on dataAccess for the given user AND - ( + ( (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da - -- current logged in user is the dataAccess user - WHERE isMemberOf(da.userid) - -- has access to all data - AND (da.allData = true - -- has access to the specified investigatorId and the specified project (if applicable) - OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- current logged in user is the dataAccess user + WHERE isMemberOf(da.userid) +-- has access to all data + AND (da.allData = true +-- has access to the specified investigatorId and the specified project (if applicable) + OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) ) IS NOT NULL - ) + ) UNION ALL SELECT -a.project as ProjectID, -a.name AS Project, -p.external_id as eIACUCNum, -a.title as Title, -i.LastName || ', ' || i.FirstName AS PIName, -x.account as Alias, -y.projectNumber as OGAProjectNumber, -y.grantNumber as OGAGrantNumber, -f.lastname || ', ' || f.firstName as FiscalAuthorityName, -aa.Species, -aa.Gender, -aa.Strain, -aa.Allowed AS NumAllowed, -calc.NumUsed, -aa.StartDate, -aa.EndDate + a.project as ProjectID, + a.name AS Project, + p.external_id as eIACUCNum, + a.title as Title, + i.LastName || ', ' || i.FirstName AS PIName, + x.account as Alias, + y.projectNumber as OGAProjectNumber, + y.grantNumber as OGAGrantNumber, + f.lastname || ', ' || f.firstName as FiscalAuthorityName, + aa.Species, + aa.Gender, + aa.Strain, + aa.Allowed AS NumAllowed, + calc.NumUsed, + aa.StartDate, + aa.EndDate, + CASE + WHEN aa.BreedingAllowed = '1' THEN 'Yes' + ELSE 'No' + END AS BreedingAllowed, + aa.Group_Id, + aa.Group_Name + FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol -LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId -LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst -LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol -LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project -LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account -LEFT JOIN ( --- SELECT i.protocol,species,gender,sum(animalsreceived) AS NumUsed --- FROM sla.purchasedetails pd, sla.purchase p --- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i ON p.project = i.project --- WHERE p.objectid = pd.purchaseid AND animalsreceived IS NOT NULL --- GROUP BY i.protocol,species,gender - ---Changed by LK on 5/30 to get the accurate numused. + LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId + LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst + LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol + LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project + LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = x.account + LEFT JOIN ( + --Changed by LK on 5/30 to get the accurate numused. -- Count only the usage for the "Male" or "Female" gender - (SELECT i.protocol,pd.species,pd.gender,sum(animalsreceived) AS NumUsed - FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, - Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa1 - Where p.project = i.project AND p.objectid = pd.purchaseid - AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = pd.gender AND aa1.gender <> 'Male or Female' - AND animalsreceived IS NOT NULL - AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() - GROUP BY i.protocol, pd.species, pd.gender) + (SELECT i.protocol,pd.species,pd.gender,sum(animalsreceived) AS NumUsed + FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, + Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa1 + Where p.project = i.project AND p.objectid = pd.purchaseid + AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = pd.gender AND aa1.gender <> 'Male or Female' + AND animalsreceived IS NOT NULL + AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() + GROUP BY i.protocol, pd.species, pd.gender) -) AS calc ON a.protocol = calc.protocol - AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) - AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) - --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) + ) AS calc ON a.protocol = calc.protocol + AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) + AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) + --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) WHERE - -- filter based on the current date compared with the start and end dates - ( +-- filter based on the current date compared with the start and end dates + ( (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR (aa.StartDate IS NOT NULL AND aa.EndDate IS NOT NULL AND now() between aa.StartDate AND aa.EndDate) - AND (aa.gender <> 'Male or Female') - ) + AND (aa.gender <> 'Male or Female') + ) AND - --Check for the project enddate. Added by LK on 1/16/2019 - (now() between a.StartDate AND a.EndDate) - -- and filtered based on dataAccess for the given user +--Check for the project enddate. Added by LK on 1/16/2019 + (now() between a.StartDate AND a.EndDate) +-- and filtered based on dataAccess for the given user AND - ( + ( (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da - -- current logged in user is the dataAccess user - WHERE isMemberOf(da.userid) - -- has access to all data - AND (da.allData = true - -- has access to the specified investigatorId and the specified project (if applicable) - OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- current logged in user is the dataAccess user + WHERE isMemberOf(da.userid) +-- has access to all data + AND (da.allData = true +-- has access to the specified investigatorId and the specified project (if applicable) + OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) ) IS NOT NULL - ) \ No newline at end of file + ) + +/* +-- SELECT +-- a.project as ProjectID, +-- a.name AS Project, +-- p.external_id as eIACUCNum, +-- a.title as Title, +-- i.LastName || ', ' || i.FirstName AS PIName, +-- x.account as Alias, +-- y.projectNumber as OGAProjectNumber, +-- y.grantNumber as OGAGrantNumber, +-- f.lastname || ', ' || f.firstName as FiscalAuthorityName, +-- aa.Species, +-- aa.Gender, +-- aa.Strain, +-- aa.Allowed AS NumAllowed, +-- calc.NumUsed, +-- aa.StartDate, +-- aa.EndDate +-- FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol +-- LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId +-- LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol +-- LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project +-- LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account +-- LEFT JOIN ( +-- -- SELECT i.protocol,species,gender,sum(animalsreceived) AS NumUsed +-- -- FROM sla.purchasedetails pd, sla.purchase p +-- -- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i ON p.project = i.project +-- -- WHERE p.objectid = pd.purchaseid AND animalsreceived IS NOT NULL +-- -- GROUP BY i.protocol,species,gender +-- +-- --Changed by LK on 5/30 to get the accurate numused. +-- --Ignore the gender when counting the usage if the approval data gender is: "Male or Female". Count both Male and Female usage. +-- (SELECT i.protocol,pd.species,sum(animalsreceived) AS NumUsed +-- FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, +-- Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa1 +-- Where p.project = i.project AND p.objectid = pd.purchaseid +-- AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = 'Male or Female' +-- AND animalsreceived IS NOT NULL +-- AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() +-- GROUP BY i.protocol, pd.species) +-- +-- ) AS calc ON a.protocol = calc.protocol +-- AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) +-- --AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) +-- --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) +-- WHERE +-- -- filter based on the current date compared with the start and end dates +-- ( +-- (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR +-- (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR +-- (aa.StartDate IS NOT NULL AND aa.EndDate IS NOT NULL AND now() between aa.StartDate AND aa.EndDate) +-- AND (aa.gender = 'Male or Female') +-- ) +-- AND +-- --Check for the project enddate. Added by LK on 1/16/2019 +-- (now() between a.StartDate AND a.EndDate) +-- -- and filtered based on dataAccess for the given user +-- AND +-- ( +-- (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da +-- -- current logged in user is the dataAccess user +-- WHERE isMemberOf(da.userid) +-- -- has access to all data +-- AND (da.allData = true +-- -- has access to the specified investigatorId and the specified project (if applicable) +-- OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- ) IS NOT NULL +-- ) +-- +-- UNION ALL +-- +-- SELECT +-- a.project as ProjectID, +-- a.name AS Project, +-- p.external_id as eIACUCNum, +-- a.title as Title, +-- i.LastName || ', ' || i.FirstName AS PIName, +-- x.account as Alias, +-- y.projectNumber as OGAProjectNumber, +-- y.grantNumber as OGAGrantNumber, +-- f.lastname || ', ' || f.firstName as FiscalAuthorityName, +-- aa.Species, +-- aa.Gender, +-- aa.Strain, +-- aa.Allowed AS NumAllowed, +-- calc.NumUsed, +-- aa.StartDate, +-- aa.EndDate +-- FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project a +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol +-- LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId +-- LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst +-- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa ON a.protocol = aa.protocol +-- LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project +-- LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account +-- LEFT JOIN ( +-- -- SELECT i.protocol,species,gender,sum(animalsreceived) AS NumUsed +-- -- FROM sla.purchasedetails pd, sla.purchase p +-- -- LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i ON p.project = i.project +-- -- WHERE p.objectid = pd.purchaseid AND animalsreceived IS NOT NULL +-- -- GROUP BY i.protocol,species,gender +-- +-- --Changed by LK on 5/30 to get the accurate numused. +-- -- Count only the usage for the "Male" or "Female" gender +-- (SELECT i.protocol,pd.species,pd.gender,sum(animalsreceived) AS NumUsed +-- FROM sla.purchasedetails pd, sla.purchase p, Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project i, +-- Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals aa1 +-- Where p.project = i.project AND p.objectid = pd.purchaseid +-- AND aa1.protocol = i.protocol AND aa1.species = pd.species AND aa1.gender = pd.gender AND aa1.gender <> 'Male or Female' +-- AND animalsreceived IS NOT NULL +-- AND (p.orderdate between aa1.StartDate AND aa1.EndDate) AND aa1.enddate > now() +-- GROUP BY i.protocol, pd.species, pd.gender) +-- +-- ) AS calc ON a.protocol = calc.protocol +-- AND (aa.species = calc.species OR (aa.species IS NULL AND calc.species IS NULL)) +-- AND (aa.gender = calc.gender OR (aa.gender IS NULL AND calc.gender IS NULL)) +-- --AND (aa.strain = calc.strain OR (aa.strain IS NULL AND calc.strain IS NULL)) +-- WHERE +-- -- filter based on the current date compared with the start and end dates +-- ( +-- (aa.StartDate IS NOT NULL AND aa.EndDate IS NULL AND now() > aa.StartDate) OR +-- (aa.StartDate IS NULL AND aa.EndDate IS NOT NULL AND now() < aa.EndDate) OR +-- (aa.StartDate IS NOT NULL AND aa.EndDate IS NOT NULL AND now() between aa.StartDate AND aa.EndDate) +-- AND (aa.gender <> 'Male or Female') +-- ) +-- AND +-- --Check for the project enddate. Added by LK on 1/16/2019 +-- (now() between a.StartDate AND a.EndDate) +-- -- and filtered based on dataAccess for the given user +-- AND +-- ( +-- (SELECT max(rowid) as expr FROM onprc_billing.dataAccess da +-- -- current logged in user is the dataAccess user +-- WHERE isMemberOf(da.userid) +-- -- has access to all data +-- AND (da.allData = true +-- -- has access to the specified investigatorId and the specified project (if applicable) +-- OR (da.investigatorId = i.rowId AND (da.project IS NULL OR da.project = a.project))) +-- ) IS NOT NULL +-- ) \ No newline at end of file From f246fc2ea075fc8b643a0439f87daaf417d306b4 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Thu, 22 Apr 2021 14:59:20 -0700 Subject: [PATCH 03/12] URL path updated --- onprc_ehr/resources/views/PMIC_Wiki.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/onprc_ehr/resources/views/PMIC_Wiki.html b/onprc_ehr/resources/views/PMIC_Wiki.html index 59393b2f2..db50c8c4e 100644 --- a/onprc_ehr/resources/views/PMIC_Wiki.html +++ b/onprc_ehr/resources/views/PMIC_Wiki.html @@ -2,19 +2,19 @@

 

This screen contains the PMIC services request data entry form

This screen contains the data entry panels for PET Scan, CT Scan, SPECT, Angio, Ultrasound and DEXA procedures.

New tabs are created for each PMIC procedure under "Imaging" tab on the Animal history form. 

@@ -28,7 +28,7 @@

Click here to go to, PMIC Reference Data

+

Click here to maintain the PMIC Reference Data

This is the maintenance screen for the PMIC reference data such as PET radioisotopes, SPECT radioisotopes, Ultrasound procedures, DEXA values & Animal position values and etc. The PMIC admin can add/edit any of these items.

@@ -36,12 +36,12 @@

Click here to maintain the  

    -
  1. Click here to view, Today's scheduled events
  2. -
  3. Click here to view, Weekly scheduled events 
  4. +
  5. Click here to view, Today's scheduled events
  6. +
  7. Click here to view, Weekly scheduled events 

 

 

\ No newline at end of file From 7a1952a5a10c8552ce72828f88411442a679b21e Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Fri, 23 Apr 2021 15:14:50 -0700 Subject: [PATCH 04/12] Added webpart for SLA landing page and updated PMIC service request form. --- .../dataentry/PMICRequestFormType.java | 15 ++++++++++ sla/resources/views/SLA_LandingPage.html | 29 +++++++++++++++++++ sla/resources/views/SLA_LandingPage.view.xml | 5 ++++ .../views/SLA_LandingPage.webpart.xml | 6 ++++ 4 files changed, 55 insertions(+) create mode 100644 sla/resources/views/SLA_LandingPage.html create mode 100644 sla/resources/views/SLA_LandingPage.view.xml create mode 100644 sla/resources/views/SLA_LandingPage.webpart.xml diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/PMICRequestFormType.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/PMICRequestFormType.java index 1ab3e5eff..a263f146b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/PMICRequestFormType.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/PMICRequestFormType.java @@ -15,6 +15,7 @@ */ package org.labkey.onprc_ehr.dataentry; +import org.json.JSONObject; import org.labkey.api.ehr.dataentry.AnimalDetailsFormSection; import org.labkey.api.ehr.dataentry.DataEntryFormContext; import org.labkey.api.ehr.dataentry.FormSection; @@ -24,6 +25,8 @@ import org.labkey.api.view.template.ClientDependency; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; //Created: 5/23/2019 Kollil public class PMICRequestFormType extends RequestForm @@ -48,6 +51,18 @@ public PMICRequestFormType(DataEntryFormContext ctx, Module owner) } + //This function has a property that allows to schedule PMIC service requests in future with no num days restriction - By Kollil, 4/20/21 + @Override + public JSONObject toJSON() + { + JSONObject ret = super.toJSON(); + Map map = new HashMap<>(); + map.put("allowRequestsInDistantFuture", true); + ret.put("extraContext", map); + return ret; + } + + // // Added: 12-5-2019 R.Blasa Allow access only to PMIC Access group. // @Override // protected boolean canInsert() diff --git a/sla/resources/views/SLA_LandingPage.html b/sla/resources/views/SLA_LandingPage.html new file mode 100644 index 000000000..466b19567 --- /dev/null +++ b/sla/resources/views/SLA_LandingPage.html @@ -0,0 +1,29 @@ +

SLA Purchase

+

SLA purchase module is for PIs and staff to initiate purchase orders for rodents. It is administered by SLAU staff to ensure quality control and compliance with applicable federal regulations and guidelines. Only authorized personnel are allowed to place rodent orders. If you need access to the module, please contact sla_services@ohsu.edu.

+

Click here to go to SLA Purchase Module

+
+

SLA Census

+

SLA census module is used by SLAU staff to maintain rodent demographic and location data and billing. Please click on the links below for specific operations.

+
+

Entering Animals

+
+

SLA Census - Entry Screen

+

SLA Census - Edit Previous Record Menu  - Choose "All Tasks" navigational tab and click the mouse on the task id to edit a record.

+

SLA Census - Bulk Editing Grid  - Allows editing more than one Census records.

+

SLA - Entry Grid for Rabbits / Guinea Pigs  - Web link to enter new Rabbits and Guinea Pig records.

+
+

Entering Charges

+
+

Misc Charges - Grid - This format is best for export to Excel.

+

Misc Charges - Entry Form

+

Return to "My Task/All Task" Page 

+
+

Reports

+
+

SLA Census - Grid

+

SLA Census - Printed Report - Center Project & Date Range required.

+

SLA Census - Summary Printed Report - Center Project & Date Range required.

+

Monthly Census - Mouse Sheets

+

Monthly Census - Rat Sheets

+

Monthly Census - Rabbit or GP Sheets

+
\ No newline at end of file diff --git a/sla/resources/views/SLA_LandingPage.view.xml b/sla/resources/views/SLA_LandingPage.view.xml new file mode 100644 index 000000000..297678ea8 --- /dev/null +++ b/sla/resources/views/SLA_LandingPage.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/sla/resources/views/SLA_LandingPage.webpart.xml b/sla/resources/views/SLA_LandingPage.webpart.xml new file mode 100644 index 000000000..a21b09d25 --- /dev/null +++ b/sla/resources/views/SLA_LandingPage.webpart.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 32e5842ac392ab38ce6a9c758f60558f28787db6 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Fri, 23 Apr 2021 15:35:44 -0700 Subject: [PATCH 05/12] SLA allowable data dates validation. --- sla/resources/queries/sla/allowableAnimals.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sla/resources/queries/sla/allowableAnimals.js b/sla/resources/queries/sla/allowableAnimals.js index 8df5c7872..bc0ed9c35 100644 --- a/sla/resources/queries/sla/allowableAnimals.js +++ b/sla/resources/queries/sla/allowableAnimals.js @@ -1,7 +1,38 @@ +// var console = require("console"); +// var LABKEY = require("labkey"); +// +// +// function beforeInsert(row, errors){ +// row.objectid = row.objectid || LABKEY.Utils.generateUUID().toUpperCase(); +// } + var console = require("console"); var LABKEY = require("labkey"); +require("ehr/triggers").initScript(this); +var triggerHelper = new org.labkey.onprc_ehr.query.ONPRC_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id); function beforeInsert(row, errors){ row.objectid = row.objectid || LABKEY.Utils.generateUUID().toUpperCase(); } + +//Validate dates. Kollil, 1/19/2021 +EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'sla', 'allowableAnimals', function(helper, scriptErrors, row, oldRow) +{ + var start = row.startdate; + var end = row.enddate; + //console.log ("In 1"); + + // Check if startdate and enddate are not empty + if ((start == null && end == null) || (start == null && end != null) || (start != null && end == null)) { + EHR.Server.Utils.addError(scriptErrors, 'startdate', 'Must enter Start and End dates', 'ERROR'); + } + + //enddate: verify enddate not prior to startdate + if (start != null && end != null) { + if (start.getTime() > end.getTime()) { + EHR.Server.Utils.addError(scriptErrors, 'enddate', 'End date must be after the Start date', 'ERROR'); + } + } + +}); From c2e3810bb40867f6175988e2937ac6012b22f476 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Fri, 23 Apr 2021 16:57:59 -0700 Subject: [PATCH 06/12] Enhanced the PMIC alerts and housing alerts code. --- .../ColonyAlertsNotification.java | 175 +++++++++--------- 1 file changed, 89 insertions(+), 86 deletions(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java index 832cd6336..1e9f12afa 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/ColonyAlertsNotification.java @@ -1110,18 +1110,31 @@ protected void pmicSchedulerAlert(final Container c, User u, final StringBuilder TableSelector ts1 = new TableSelector(ti1, null, null); long count1 = ts1.getRowCount(); - if (count > 0) {//Daily events count - msg.append("There are " + count + " PMIC events scheduled for today:"); - msg.append("

Click here to view them

\n"); + //Daily events count + if (count > 0) { + msg.append("" + count + " PMIC event(s) scheduled for today:"); + msg.append("

Click here to view the events in PRIME

\n"); + msg.append("
"); + } + else { + msg.append(" There are no PMIC events scheduled today! "); + msg.append("
"); + } + + //Weekly events count + if (count1 > 0) { + msg.append("" + count1 + " PMIC event(s) scheduled this week:"); + msg.append("

Click here to view the events in PRIME

\n"); msg.append("
"); } - if (count1 > 0) {//Weekly events count - msg.append("There are " + count1 + " PMIC events scheduled this week:"); - msg.append("

Click here to view them

\n"); + else { + msg.append(" There are no PMIC events scheduled this week! "); msg.append("
"); } + //Display the daily report in the email - if (count > 0) { + if (count > 0) + { Set columns = new HashSet<>(); columns.add(FieldKey.fromString("resourceid")); columns.add(FieldKey.fromString("startdate")); @@ -1136,86 +1149,76 @@ protected void pmicSchedulerAlert(final Container c, User u, final StringBuilder final Map colMap = QueryService.get().getColumns(ti, columns); TableSelector ts2 = new TableSelector(ti, colMap.values(), null, null); - count = ts2.getRowCount(); - if (count == 0) { - msg.append("There are no scheduled PMIC events"); - } - else { - msg.append("
Daily PMIC events:

\n"); - msg.append(""); - msg.append(""); - msg.append(""); - - ts2.forEach(new Selector.ForEachBlock() { - @Override - public void exec(ResultSet object) throws SQLException { - Results rs = new ResultsImpl(object, colMap); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - } - }); - msg.append("
Resource Id Start Date End Date Name Alias Quantity Comments Color Room Bldg
" + PageFlowUtil.filter(rs.getString("resourceid")) + "" + PageFlowUtil.filter(rs.getString("startdate")) + "" + PageFlowUtil.filter(rs.getString("enddate")) + "" + PageFlowUtil.filter(rs.getString("name")) + "" + PageFlowUtil.filter(rs.getString("alias")) + "" + PageFlowUtil.filter(rs.getString("quantity")) + "" + PageFlowUtil.filter(rs.getString("comments")) + "" + PageFlowUtil.filter(rs.getString("color")) + "" + PageFlowUtil.filter(rs.getString("room")) + "" + PageFlowUtil.filter(rs.getString("bldg")) + "
"); - } - //Display the weekly report in the email - if (count1 > 0) { - Set columns1 = new HashSet<>(); - columns1.add(FieldKey.fromString("resourceid")); - columns1.add(FieldKey.fromString("startdate")); - columns1.add(FieldKey.fromString("enddate")); - columns1.add(FieldKey.fromString("name")); - columns1.add(FieldKey.fromString("alias")); - columns1.add(FieldKey.fromString("quantity")); - columns1.add(FieldKey.fromString("comments")); - columns1.add(FieldKey.fromString("color")); - columns1.add(FieldKey.fromString("room")); - columns1.add(FieldKey.fromString("bldg")); - - final Map colMap1 = QueryService.get().getColumns(ti1, columns1); - TableSelector ts3 = new TableSelector(ti1, colMap1.values(), null, null); - count1 = ts3.getRowCount(); - - if (count1 == 0) { - msg.append("There are no scheduled PMIC events"); + msg.append("
Daily PMIC events:

\n"); + msg.append(""); + msg.append(""); + msg.append(""); + + ts2.forEach(new Selector.ForEachBlock() { + @Override + public void exec(ResultSet object) throws SQLException { + Results rs = new ResultsImpl(object, colMap); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); } - else { - msg.append("

Weekly PMIC events:

\n"); - msg.append("
Resource Id Start Date End Date Name Alias Quantity Comments Color Room Bldg
" + PageFlowUtil.filter(rs.getString("resourceid")) + "" + PageFlowUtil.filter(rs.getString("startdate")) + "" + PageFlowUtil.filter(rs.getString("enddate")) + "" + PageFlowUtil.filter(rs.getString("name")) + "" + PageFlowUtil.filter(rs.getString("alias")) + "" + PageFlowUtil.filter(rs.getString("quantity")) + "" + PageFlowUtil.filter(rs.getString("comments")) + "" + PageFlowUtil.filter(rs.getString("color")) + "" + PageFlowUtil.filter(rs.getString("room")) + "" + PageFlowUtil.filter(rs.getString("bldg")) + "
"); - msg.append(""); - msg.append(""); - - ts3.forEach(new Selector.ForEachBlock() { - @Override - public void exec(ResultSet object) throws SQLException { - Results rs1 = new ResultsImpl(object, colMap1); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - msg.append(""); - } - }); - msg.append("
Resource Id Start Date End Date Name Alias Quantity Comments Color Room Bldg
" + PageFlowUtil.filter(rs1.getString("resourceid")) + "" + PageFlowUtil.filter(rs1.getString("startdate")) + "" + PageFlowUtil.filter(rs1.getString("enddate")) + "" + PageFlowUtil.filter(rs1.getString("name")) + "" + PageFlowUtil.filter(rs1.getString("alias")) + "" + PageFlowUtil.filter(rs1.getString("quantity")) + "" + PageFlowUtil.filter(rs1.getString("comments")) + "" + PageFlowUtil.filter(rs1.getString("color")) + "" + PageFlowUtil.filter(rs1.getString("room")) + "" + PageFlowUtil.filter(rs1.getString("bldg")) + "
"); + }); + msg.append(""); + } + + //Display the weekly report in the email + if (count1 > 0) { + Set columns1 = new HashSet<>(); + columns1.add(FieldKey.fromString("resourceid")); + columns1.add(FieldKey.fromString("startdate")); + columns1.add(FieldKey.fromString("enddate")); + columns1.add(FieldKey.fromString("name")); + columns1.add(FieldKey.fromString("alias")); + columns1.add(FieldKey.fromString("quantity")); + columns1.add(FieldKey.fromString("comments")); + columns1.add(FieldKey.fromString("color")); + columns1.add(FieldKey.fromString("room")); + columns1.add(FieldKey.fromString("bldg")); + + final Map colMap1 = QueryService.get().getColumns(ti1, columns1); + TableSelector ts3 = new TableSelector(ti1, colMap1.values(), null, null); + + msg.append("
Weekly PMIC events:

\n"); + msg.append(""); + msg.append(""); + msg.append(""); + + ts3.forEach(new Selector.ForEachBlock() { + @Override + public void exec(ResultSet object) throws SQLException { + Results rs1 = new ResultsImpl(object, colMap1); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); + msg.append(""); } - } + }); + msg.append("
Resource Id Start Date End Date Name Alias Quantity Comments Color Room Bldg
" + PageFlowUtil.filter(rs1.getString("resourceid")) + "" + PageFlowUtil.filter(rs1.getString("startdate")) + "" + PageFlowUtil.filter(rs1.getString("enddate")) + "" + PageFlowUtil.filter(rs1.getString("name")) + "" + PageFlowUtil.filter(rs1.getString("alias")) + "" + PageFlowUtil.filter(rs1.getString("quantity")) + "" + PageFlowUtil.filter(rs1.getString("comments")) + "" + PageFlowUtil.filter(rs1.getString("color")) + "" + PageFlowUtil.filter(rs1.getString("room")) + "" + PageFlowUtil.filter(rs1.getString("bldg")) + "
"); } + } //End of PMIC alert @@ -1259,12 +1262,12 @@ protected void housingTransferAlert(final Container c, User u, final StringBuild if (count > 0) {//transfers count msg.append("
Housing Transfers:

"); msg.append("" + count + " animal transfers were found in last 24 hours:"); - msg.append("

Click here to view them

\n"); + msg.append("

Click here to view the transfers in PRIME

\n"); msg.append("
"); } if (count == 0) { - msg.append("There were no animal transfers!"); + msg.append("There are no animal transfers today!
"); } //Display the daily report in the email @@ -1294,7 +1297,7 @@ protected void housingTransferAlert(final Container c, User u, final StringBuild msg.append(""); msg.append(" Yellow row indicates animal transferred into an empty room. "); msg.append(""); - msg.append(" Blue cell indicates animal has active Clinical treatments. "); + msg.append(" Blue cell indicates animal has active Clinical treatments with no Diets. "); msg.append(""); msg.append(" Orange cell indicates animal has active Clinical treatments including Diets (or) just Diets. "); msg.append(""); From 39e7b23ef0836cb8e6690d7d0809534f0ad1dbed Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Fri, 23 Apr 2021 17:49:00 -0700 Subject: [PATCH 07/12] NHP allowable data dates validation is added. --- .../resources/queries/ehr/protocol_counts.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/ehr/protocol_counts.js b/onprc_ehr/resources/queries/ehr/protocol_counts.js index 13bd324a8..6b199fc88 100644 --- a/onprc_ehr/resources/queries/ehr/protocol_counts.js +++ b/onprc_ehr/resources/queries/ehr/protocol_counts.js @@ -10,4 +10,24 @@ function onUpsert(helper, scriptErrors, row, oldRow){ if (row && row.project){ EHR.Server.Utils.addError(scriptErrors, 'project', 'You should probably leave this field blank. Animal counts are usually associated with the IACUC itself. The project field was left in place to support IRIS data, but should not be used unless there is a good reason to do so.', 'INFO'); } -} \ No newline at end of file +} +//Validate dates. Kollil, 1/19/2021 +EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'ehr', 'protocol_counts', function(helper, scriptErrors, row, oldRow) +{ + var start = row.start; + var end = row.enddate; + //console.log ("In 11"); + + // Check if startdate and enddate are not empty + if ((start == null && end == null) || (start == null && end != null) || (start != null && end == null)) { + EHR.Server.Utils.addError(scriptErrors, 'start', 'Must enter Start and End dates', 'ERROR'); + } + + //enddate: verify enddate not prior to startdate + if (start != null && end != null) { + if (start.getTime() > end.getTime()) { + EHR.Server.Utils.addError(scriptErrors, 'enddate', 'End date must be after Start date', 'ERROR'); + } + } + +}); \ No newline at end of file From 5860d69be4bafd84ece3631aa7ac7e0f8393a30c Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 26 Apr 2021 18:36:52 -0700 Subject: [PATCH 08/12] Fix malformed XML --- .../resources/queries/onprc_ehr/housing_transfers.query.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml b/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml index c90fabf37..2d304d87a 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml +++ b/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml @@ -38,13 +38,13 @@ Housing Type - column> + Housing Condition - column> + Reason For Move - column> + From 2c58b10bdb080fceb18d9104eda95a4e128f1426 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Tue, 27 Apr 2021 11:05:14 -0700 Subject: [PATCH 09/12] Fixed the xml --- .../resources/queries/onprc_ehr/housing_transfers.query.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml b/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml index c90fabf37..2d304d87a 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml +++ b/onprc_ehr/resources/queries/onprc_ehr/housing_transfers.query.xml @@ -38,13 +38,13 @@ Housing Type - column> + Housing Condition - column> + Reason For Move - column> + From 47812212614792097377ca8603f12adcd40d32be Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com> Date: Tue, 27 Apr 2021 11:20:36 -0700 Subject: [PATCH 10/12] Update onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql Co-authored-by: Josh Eckels --- onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql b/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql index 77a0c4145..90edf3d2a 100644 --- a/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql +++ b/onprc_ehr/resources/queries/study/PMIC_ChargeTypes.sql @@ -1,3 +1,3 @@ SELECT chargetype -From Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public'}.onprc_billing.chargeUnits -Where servicecenter is null or servicecenter like 'PMIC' \ No newline at end of file +From Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing.chargeUnits +Where servicecenter is null or servicecenter like 'PMIC' From 54b8f5b2b5a80337264497cc697f7af4b197f0c8 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Tue, 27 Apr 2021 11:28:59 -0700 Subject: [PATCH 11/12] Changed the aliases table reference code --- sla/resources/queries/sla/PlandProtocols.sql | 3 ++- sla/resources/queries/sla/ProtocolProjectsUsage.sql | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sla/resources/queries/sla/PlandProtocols.sql b/sla/resources/queries/sla/PlandProtocols.sql index 9988c6aea..508ba6041 100644 --- a/sla/resources/queries/sla/PlandProtocols.sql +++ b/sla/resources/queries/sla/PlandProtocols.sql @@ -16,7 +16,8 @@ FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.project LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.protocol p ON p.protocol = a.protocol LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol - LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = a.account + --LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = a.account + LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = a.account WHERE -- filter based on the current date compared with the start and end dates ( diff --git a/sla/resources/queries/sla/ProtocolProjectsUsage.sql b/sla/resources/queries/sla/ProtocolProjectsUsage.sql index 49c9eac5e..88c336188 100644 --- a/sla/resources/queries/sla/ProtocolProjectsUsage.sql +++ b/sla/resources/queries/sla/ProtocolProjectsUsage.sql @@ -28,7 +28,7 @@ LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.pr LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project - LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = x.account + LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account LEFT JOIN ( --Changed by LK on 5/30 to get the accurate numused. --Ignore the gender when counting the usage if the approval data gender is: "Male or Female". Count both Male and Female usage. @@ -101,7 +101,7 @@ LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr.pr LEFT JOIN onprc_billing.fiscalAuthorities f ON f.rowid = i.financialanalyst LEFT JOIN Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals_BreedingGroups aa ON a.protocol = aa.protocol LEFT JOIN (select * from onprc_billing.projectAccountHistory z where (z.StartDate IS NOT NULL AND z.EndDate IS NOT NULL AND now() between z.StartDate AND z.EndDate)) x ON a.project = x.project - LEFT JOIN "/onprc/admin/finance/public".onprc_billing_public.aliases y ON y.alias = x.account + LEFT JOIN Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases y ON y.alias = x.account LEFT JOIN ( --Changed by LK on 5/30 to get the accurate numused. -- Count only the usage for the "Male" or "Female" gender From fd078199e76edd4819bb2fb451995ccd018aebf0 Mon Sep 17 00:00:00 2001 From: Lakshmi Kolli Date: Tue, 27 Apr 2021 13:23:39 -0700 Subject: [PATCH 12/12] Added new query that retrieves breeding groups data from eIACUC tables. --- .../sla/allowableAnimals_BreedingGroups.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql diff --git a/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql b/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql new file mode 100644 index 000000000..bc203f417 --- /dev/null +++ b/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql @@ -0,0 +1,14 @@ +SELECT a.protocol, + a.species, + a.gender, + a.strain, + a.age, + a.allowed, + a.startdate, + a.enddate, + b.group_id, + b.group_name, + b.breeding_colony as BreedingAllowed +FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.allowableAnimals a, + Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.onprc_ehr.eIACUC_PRIME_VIEW_ANIMAL_GROUPS b +Where a.protocol.displayname = b.parent_protocol \ No newline at end of file