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("| Resource Id | Start Date | End Date | Name | Alias | Quantity | Comments | Color | Room | Bldg |
");
+
+ ts3.forEach(new Selector.ForEachBlock() {
+ @Override
+ public void exec(ResultSet object) throws SQLException {
+ Results rs1 = new ResultsImpl(object, colMap1);
+ msg.append("");
+ msg.append("| " + PageFlowUtil.filter(rs1.getString("resourceid")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("startdate")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("enddate")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("name")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("alias")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("quantity")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("comments")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("color")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("room")) + " | ");
+ msg.append("" + PageFlowUtil.filter(rs1.getString("bldg")) + " | ");
+ msg.append("
");
}
- }
+ });
+ msg.append("
");
}
+
}
//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("");
diff --git a/sla/resources/queries/sla/PlandProtocols.sql b/sla/resources/queries/sla/PlandProtocols.sql
index 26d5091ff..508ba6041 100644
--- a/sla/resources/queries/sla/PlandProtocols.sql
+++ b/sla/resources/queries/sla/PlandProtocols.sql
@@ -1,42 +1,87 @@
-
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
+ 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
- (
+-- 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..88c336188 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 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.
- (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 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
- (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
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');
+ }
+ }
+
+});
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
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