diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql index bb5c09ce8..f427f4157 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql @@ -56,8 +56,7 @@ When a5.id is not Null then (Select c.rowid from Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.onprc_billing.chargeableItems c where c.itemCode = 'ONR41') When (a4.id is not null and (TIMESTAMPDIFF('SQL_TSI_Day',a.date,a.projectedRelease)) <=14 and a.endDate is null and a.ageAtTime.AgeAtTimeYearsRounded < 1) then (Select c.rowid from Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.onprc_billing.chargeableItems c where c.itemCode = 'ONR44') - WHEN (a.duration <= CAST(javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_MAX_DURATION') as INTEGER) AND a.enddate IS NOT NULL AND a.assignCondition = a.releaseCondition) THEN (SELECT rowid FROM onprc_billing_public.chargeableItems ci WHERE ci.active = true AND ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_NAME')) - WHEN (a.duration <= CAST(javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_MAX_DURATION') as INTEGER) AND a.enddate IS NOT NULL AND a.assignCondition = a.releaseCondition) THEN (SELECT rowid FROM onprc_billing_public.chargeableItems ci WHERE ci.active = true AND ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_NAME')) + WHEN (a.duration <= CAST(javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_MAX_DURATION') as INTEGER) AND a.enddate IS NOT NULL AND a.assignCondition = a.releaseCondition) THEN (SELECT rowid FROM onprc_billing_public.chargeableItems ci WHERE ci.active = true AND ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_NAME')) WHEN a2.id IS NOT NULL THEN (SELECT rowid FROM onprc_billing_public.chargeableItems ci WHERE (ci.startDate <= a.date and ci.endDate >= a.date) AND ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.TMB_LEASE_NAME')) ELSE lf.chargeId END as chargeId, @@ -81,7 +80,8 @@ CASE where b.id = a.id and a1.project.protocol = a2.project.protocol) > 0 THEN 0 WHEN (a.duration = 0 AND a.enddate IS NOT NULL AND a.assignCondition = a.releaseCondition) THEN 1 - WHEN (fl.id Is Not Null) THEN 0 + -- Exempt PI-purchased NHPs from lease fees + WHEN (fl.id IS NOT NULL) THEN 0 --This will check for infants born to resource moms and will not charge WHEN (a.duration <= CAST(javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_MAX_DURATION') as INTEGER) AND a.enddate IS NOT NULL AND a.assignCondition = a.releaseCondition) THEN a.duration @@ -139,21 +139,20 @@ LEFT JOIN onprc_billing.leaseFeeDefinition lf ON ( AND lf.active = true ) - - ---adds the reasearch owned animal exemption -LEFT JOIN study.flags fl on - (a.id = fl.id - and fl.flag.code = 4034 - and (a.date >= fl.date and a.date <=COALESCE(fl.enddate,Now()) )) - +-- Add PI-purchased NHP flag data +LEFT JOIN study.flags fl + ON (a.id = fl.id + AND fl.flag.code = 4034 + AND a.date BETWEEN CAST(fl.date AS DATE) AND COALESCE(fl.enddate, now()) + ) WHERE CAST(a.datefinalized AS DATE) >= CAST(STARTDATE as DATE) AND CAST(a.datefinalized AS DATE) <= CAST(ENDDATE as DATE) AND a.qcstate.publicdata = true --and a.participantID.demographics.species.common not in ('Rabbit','Guinea Pigs') ---add setup fees for all starts, except day leases aznd sla +-- Add lease setup fees for all lease starts, except day leases, PI-purchased NHPs, and sla UNION ALL + SELECT a.id, a.date, @@ -168,7 +167,7 @@ SELECT ' ' as ESPFAnimal, 'Lease Setup Fees' as category, (SELECT rowid FROM onprc_billing_public.chargeableItems ci WHERE ci.active = true AND ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.LEASE_SETUP_FEES')) as chargeId, - 1 as quantity, + 1 AS quantity, cast(null as integer) as leaseCharge1, cast(null as integer) as leaseCharge2, a.objectid as sourceRecord, @@ -179,11 +178,19 @@ SELECT FROM study.assignment a +-- Add PI-purchased NHP flag data +LEFT JOIN study.flags fl + ON (a.id = fl.id + AND fl.flag.code = 4034 + AND a.date BETWEEN CAST(fl.date AS DATE) AND COALESCE(fl.enddate, now()) + ) + WHERE CAST(a.datefinalized AS DATE) >= CAST(STARTDATE as DATE) AND CAST(a.datefinalized AS DATE) <= CAST(ENDDATE as DATE) AND a.qcstate.publicdata = true --only charge setup fee for leases >24H. note: duration assumes today as end, so exclude null enddates AND ((a.duration > CAST(javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.DAY_LEASE_MAX_DURATION') as INTEGER)) OR ( a.assignCondition != a.releaseCondition AND a.enddate IS NULL)) and a.id.demographics.species Not IN ('Rabbit','Guinea Pigs') +AND fl.id IS NULL -- Exempt PI-purchased NHPs from lease setup fees --add released animals that need adjustments UNION ALL @@ -208,9 +215,9 @@ a5.id as ESPFAnimal, --////This selectes the charge ID to be used (SELECT max(rowid) as rowid FROM onprc_billing_public.chargeableItems ci WHERE ci.name = javaConstant('org.labkey.onprc_billing.ONPRC_BillingManager.LEASE_FEE_ADJUSTMENT') and ci.active = true) as chargeId, CASE - when (fl.id Is Not Null) then 0 - else 1 - end as quantity, + WHEN (fl.id IS NOT NULL) THEN 0 -- Exempt PI-purchased NHPs from lease fees + ELSE 1 +END AS quantity, lf2.chargeId as leaseCharge1, lf.chargeId as leaseCharge2, a.objectid as sourceRecord, @@ -248,11 +255,12 @@ LEFT join assignment_U42ESPF a5 on and a5.dateonly <=a.dateOnly AND a5.endDateCoalesced >= a.dateOnly) ---adds the reasearch owned animal exemption -LEFT JOIN study.flags fl on - (a.id = fl.id - and fl.flag.code = 4034 - and (a.date >= fl.date and a.date <=COALESCE(fl.enddate,Now()) )) +-- Add PI-purchased NHP flag data +LEFT JOIN study.flags fl + ON (a.id = fl.id + AND fl.flag.code = 4034 + AND a.date BETWEEN CAST(fl.date AS DATE) AND COALESCE(fl.enddate, now()) + ) WHERE a.releaseCondition != a.projectedReleaseCondition and (A.id != A5.id or A5.id is Null) diff --git a/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql b/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql index 3118aca4a..dfd49abd0 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql @@ -14,6 +14,7 @@ select a.Id, from study.ClinpathRuns a, study.chemistryResults b Where a.objectid = b.runid And a.type = 'biochemistry' - And b.qualresult like '%panic%' + And b.qualresult like '%alert%' + And a.qcstate = 18 And b.qcstate = 18 \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/Demographics/BCS Score.qview.xml b/onprc_ehr/resources/queries/study/Demographics/BCS Score.qview.xml new file mode 100644 index 000000000..5e77609ba --- /dev/null +++ b/onprc_ehr/resources/queries/study/Demographics/BCS Score.qview.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js index 7628d6ea3..d382b863b 100644 --- a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js +++ b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js @@ -1381,8 +1381,10 @@ exports.init = function(EHR){ // Added: 10-6-2025 EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.AFTER_UPSERT, 'study', 'chemistryResults', function (helper, scriptErrors, row, oldRow) { - if (row.Id && row.qualresult && row.qualresult.indexOf('panic') !== -1) { - console.log("panic values: " + row.qualresult); + + if (row.Id && row.qualresult && row.qualresult.indexOf('alert') !== -1) { + + console.log("alert values: " + row.qualresult); triggerHelper.sendClinpathPanicEmail(row.Id, row.runid, row.objectid); } }); diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java index fc7964c53..af711cba9 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java @@ -2640,7 +2640,8 @@ public void exec(ResultSet object) throws SQLException public void sendClinpathPanicEmail(String id, String runid, String objectid) { - String subject = "Chemistry Results with Panic values"; + String subject = "Chemistry Results with alert values"; + Container c = getContainer(); @@ -2671,7 +2672,7 @@ public void sendClinpathPanicEmail(String id, String runid, String objectid) if (ts.getRowCount() == 0) { - html.append("There are no Chemistry Panlc Values to display"); + html.append("There are no Chemistry Alert Values to display"); return; } diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java index 7689b7356..05a537821 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_RestrictedIssueTest.java @@ -293,13 +293,16 @@ public void restrictedIssueSearchTest() // verify that we can return links even if the user doesn't have permission to view a restricted issue Assert.assertTrue("Number of search results not expected", resultsPage.getResults().size() == 2); - // verify assigned to users will see both results but shouldn't be able to see details of issues not assigned to them + // verify assigned to users will see both results but shouldn't be able to see details of issues not assigned to them, + // also verify that there is a warning rendered if a search result is restricted impersonate(USER1.getEmail()); + assertTextPresent("Restricted Issue: You do not have access. Contact your administrator for access."); verifyIssueAccess(ISSUE_1, true); verifyIssueAccess(ISSUE_2, false); stopImpersonating(false); impersonate(USER2.getEmail()); + assertTextPresent("Restricted Issue: You do not have access. Contact your administrator for access."); verifyIssueAccess(ISSUE_1, false); verifyIssueAccess(ISSUE_2, true); stopImpersonating();