From f0665d85a27894d5abe3504466b996d89fd6e847 Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Thu, 13 Aug 2026 14:27:12 -0700 Subject: [PATCH 01/11] migrate concat operator --- .../resources/queries/onprc_billing/ARTCoreAliases.sql | 2 +- .../queries/onprc_billing/ARTCoreBIllingCharges.sql | 2 +- .../resources/queries/onprc_billing/virologyAliases.sql | 2 +- .../queries/onprc_billing/virologyBillingCharges.sql | 2 +- onprc_billing/resources/queries/virologyAliases.sql | 2 +- onprc_ehr/resources/queries/onprc_ehr/projectLabel.sql | 4 ++-- .../resources/queries/study/AssignmentPoolUnderTheAge.sql | 2 +- .../resources/queries/study/AssignmentsUnderTheAge.sql | 2 +- onprc_ehr/resources/queries/study/LastHousingLocation.sql | 2 +- .../queries/study/TreatmentSchedulePostOpFasts.sql | 6 +++--- .../resources/queries/study/TreatmentSchedulePostOps.sql | 2 +- .../queries/study/demographicsVetReviewObservation.sql | 6 +++--- onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql | 2 +- sla/resources/queries/sla/PlandProtocols.sql | 2 +- .../queries/sla/allowableAnimals_BreedingGroups.sql | 4 ++-- sla/resources/queries/sla/allowableSLA.sql | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/onprc_billing/resources/queries/onprc_billing/ARTCoreAliases.sql b/onprc_billing/resources/queries/onprc_billing/ARTCoreAliases.sql index 567673c84..bcc258501 100644 --- a/onprc_billing/resources/queries/onprc_billing/ARTCoreAliases.sql +++ b/onprc_billing/resources/queries/onprc_billing/ARTCoreAliases.sql @@ -4,7 +4,7 @@ -- The category on the alias table is OHSU GL. There could be other alias that will be used for charges that are not associated with a center project. -- I hope at some point when this is automated, or when ART core understands they can use the center project for charging. -SELECT alias, alias + ' - ' + COALESCE(investigatorName, 'N/A') as aliasPI +SELECT alias, alias || ' - ' || COALESCE(investigatorName, 'N/A') as aliasPI FROM Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases WHERE (budgetstartdate IS NOT NULL AND (budgetEndDate IS NULL OR budgetEndDate >= TIMESTAMPADD('SQL_TSI_DAY', -30, now()) )) diff --git a/onprc_billing/resources/queries/onprc_billing/ARTCoreBIllingCharges.sql b/onprc_billing/resources/queries/onprc_billing/ARTCoreBIllingCharges.sql index 9011f807f..8207e1634 100644 --- a/onprc_billing/resources/queries/onprc_billing/ARTCoreBIllingCharges.sql +++ b/onprc_billing/resources/queries/onprc_billing/ARTCoreBIllingCharges.sql @@ -1,5 +1,5 @@ -- Query to get ART core chargeable items -SELECT rowid, category, activerate.unitCost, itemCode + ' - ' + name + '; Unit Cost - ' + CAST(activerate.unitCost as varchar) as chargeName +SELECT rowid, category, activerate.unitCost, itemCode || ' - ' || name || '; Unit Cost - ' || CAST(activerate.unitCost as varchar) as chargeName FROM Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.chargeableItems -- Changed by kolli, 5/5/22 -- FROM "/onprc/admin/finance/public".onprc_billing_public.chargeableItems WHERE category = 'ART Core' diff --git a/onprc_billing/resources/queries/onprc_billing/virologyAliases.sql b/onprc_billing/resources/queries/onprc_billing/virologyAliases.sql index ccb76df21..4de87e743 100644 --- a/onprc_billing/resources/queries/onprc_billing/virologyAliases.sql +++ b/onprc_billing/resources/queries/onprc_billing/virologyAliases.sql @@ -1,4 +1,4 @@ -SELECT alias, alias + ' - ' + COALESCE(investigatorName, 'N/A') as aliasPI +SELECT alias, alias || ' - ' || COALESCE(investigatorName, 'N/A') as aliasPI FROM Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.aliases --WHERE a.projectStatus in ('Active', 'Partial Setup', 'No Cost Ext', 'Preaward') OR a.alias in ('68119000', '46050050') --WHERE (budgetstartdate IS NOT NULL AND (budgetEndDate IS NULL OR budgetEndDate > now() )) OR alias in ('68119000', '46050050','46030010', '61247550') diff --git a/onprc_billing/resources/queries/onprc_billing/virologyBillingCharges.sql b/onprc_billing/resources/queries/onprc_billing/virologyBillingCharges.sql index cf2d9fba9..b17b20ce7 100644 --- a/onprc_billing/resources/queries/onprc_billing/virologyBillingCharges.sql +++ b/onprc_billing/resources/queries/onprc_billing/virologyBillingCharges.sql @@ -1,4 +1,4 @@ -SELECT rowid, category, activeRate.unitCost, itemCode + ' - ' + name as chargeName +SELECT rowid, category, activeRate.unitCost, itemCode || ' - ' || name as chargeName FROM Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer_Public')}.onprc_billing_public.chargeableItems WHERE category = 'Virology' AND Active = 'true' \ No newline at end of file diff --git a/onprc_billing/resources/queries/virologyAliases.sql b/onprc_billing/resources/queries/virologyAliases.sql index f8ec6e8ea..7396f1fea 100644 --- a/onprc_billing/resources/queries/virologyAliases.sql +++ b/onprc_billing/resources/queries/virologyAliases.sql @@ -1,3 +1,3 @@ -SELECT rowid,aliases.alias, aliases.alias + ' - ' + aliases.investigatorName as aliasPI +SELECT rowid,aliases.alias, aliases.alias || ' - ' || aliases.investigatorName as aliasPI FROM aliases WHERE projectStatus = 'Active' \ No newline at end of file diff --git a/onprc_ehr/resources/queries/onprc_ehr/projectLabel.sql b/onprc_ehr/resources/queries/onprc_ehr/projectLabel.sql index ffdecaa76..503e769c1 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/projectLabel.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/projectLabel.sql @@ -17,8 +17,8 @@ select a.project as project, a.name as centerproject, b.external_id as Protocol, g.lastname as investigator, - ( a.name + '-' + ' [' + g.LastName + ' - ' + b.external_id + ']' ) as projectname , - ( b.external_id + '-' + ' [' + g.LastName + ' - ' + a.name + ']' ) as protocolname , + ( a.name || '-' || ' [' || g.LastName || ' - ' || b.external_id || ']' ) as projectname , + ( b.external_id || '-' || ' [' || g.LastName || ' - ' || a.name || ']' ) as protocolname , a.enddate as enddate from ehr.project a diff --git a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql index a22cad638..7bdd95f10 100644 --- a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql @@ -25,7 +25,7 @@ SELECT /* Concatenate all active projects & investigator into one cell */ ( - SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ') + SELECT GROUP_CONCAT(DISTINCT CAST('[' || d.project.protocol.investigatorId.lastname || ']' || d.project.displayname || '' AS VARCHAR), ', ') FROM housingRoommatesDivider h LEFT JOIN study.assignment d ON d.Id = h.roommateId WHERE h.Id = a.Id diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql index 2f5234fdb..2a1640290 100644 --- a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql @@ -29,7 +29,7 @@ ) AS Cagemates, /* Concatenate all active projects & investigator into one cell */ ( - SELECT GROUP_CONCAT(DISTINCT CAST('[' + d.project.protocol.investigatorId.lastname + ']' + d.project.displayname + '' AS VARCHAR), ', ') + SELECT GROUP_CONCAT(DISTINCT CAST('[' || d.project.protocol.investigatorId.lastname || ']' || d.project.displayname || '' AS VARCHAR), ', ') FROM housingRoommatesDivider h LEFT JOIN study.assignment d ON d.Id = h.roommateId WHERE h.Id = a.Id diff --git a/onprc_ehr/resources/queries/study/LastHousingLocation.sql b/onprc_ehr/resources/queries/study/LastHousingLocation.sql index cd69c30ce..3ccadfd41 100644 --- a/onprc_ehr/resources/queries/study/LastHousingLocation.sql +++ b/onprc_ehr/resources/queries/study/LastHousingLocation.sql @@ -17,7 +17,7 @@ -- Created: 12-19-2018 R.Blasa -select a.Id,(a.room + ' ' + coalesce(a.cage, '')) as location from study.housing a +select a.Id,(a.room || ' ' || coalesce(a.cage, '')) as location from study.housing a where a.date in (Select max( b.date) AS MaxDate from study.housing b where a.Id = b.Id and a.qcstate.publicdata = true ) diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql index adcea672c..4a43dbe9e 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql @@ -18,7 +18,7 @@ Changes made by Kollil on Mar 8th, 2022 */ Select e.Id, - e.Id.curLocation.room + ' ' + e.id.curLocation.cage as location, + e.Id.curLocation.room || ' ' || e.id.curLocation.cage as location, e.date, e.enddate, e.project.name as project, @@ -36,8 +36,8 @@ From encounters e, ehr.requests r Where e.requestid = r.requestid And procedureid in (1804,1807,2440, 3089) -- get these procedures only -And (date < cast(TimeStampAdd('SQL_TSI_DAY',1,cast(cast(now() as date) as varchar(30)) + ' ' + '08:00') as TIMESTAMP) -And date > cast(cast(cast(now() as date) as varchar(30)) + ' ' + '16:00' as TIMESTAMP) ) ---Between 4pm thru 8am +And (date < cast(TimeStampAdd('SQL_TSI_DAY',1,cast(cast(now() as date) as varchar(30)) || ' ' || '08:00') as TIMESTAMP) +And date > cast(cast(cast(now() as date) as varchar(30)) || ' ' || '16:00' as TIMESTAMP) ) ---Between 4pm thru 8am And instructions not in ('Lab staff will pull chow and wash caging') And type = 'Procedure' diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql index dd7919804..786c93b13 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql @@ -58,7 +58,7 @@ FROM ( t1.date as startDate, timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed, t1.enddate, t1.code, t1.volume, t1.vol_units, t1.concentration, t1.conc_units, t1.amountWithUnits, - t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning + ' (' + t1.frequency.times + ')' as frequency, t1.route, + t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning || ' (' || t1.frequency.times || ')' as frequency, t1.route, t1.reason, t1.performedby, t1.remark, t1.qcstate.label as TreatmentStatus FROM ehr_lookups.dateRange dr diff --git a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql index 7e6a8d407..eb70c2f1d 100644 --- a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql +++ b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql @@ -3,14 +3,14 @@ select dem.*, (select s.date from study.mostRecentClinicalObservationsForAnimal s where s.id = dem.id) as mostRecentClinicalObservationsdate, - ( select group_concat(DISTINCT 'BCS: ' + j.observation, chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and j.category = 'BCS' and j.date >= (select max(k.date) AS MaxDate + ( select group_concat(DISTINCT 'BCS: ' || j.observation, chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and j.category = 'BCS' and j.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as mostRecentBCSScore, - ( select group_concat(DISTINCT q.procedureid.name + ' : ' + q.remark , chr(10)) AS c from "Clinical Encounters" q where q.id = dem.id and q.type.value = 'Procedure' + ( select group_concat(DISTINCT q.procedureid.name || ' : ' || q.remark , chr(10)) AS c from "Clinical Encounters" q where q.id = dem.id and q.type.value = 'Procedure' and q.procedureid.name in ('Ultrasound','Ultrasound - Ovaries','Ultrasound - Pregnancy', 'Ultrasound - Uterus','Dental prophylaxis','Palpation, bimanual') and q.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as mostRecentProcedure, - ( select group_concat(DISTINCT 'Observations: ' + t.remark, chr(10)) AS c from "Clinical Observations" t where t.id = dem.id and t.category = 'Observations' and t.remark is not null and t.date >= (select max(k.date) AS MaxDate + ( select group_concat(DISTINCT 'Observations: ' || t.remark, chr(10)) AS c from "Clinical Observations" t where t.id = dem.id and t.category = 'Observations' and t.remark is not null and t.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as observationremarks, ( select group_concat(DISTINCT s.remark, chr(10)) AS c from "Clinical Remarks" s where s.id = dem.id and s.date >= (select max(k.date) AS MaxDate diff --git a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql index 2d513e4bb..4c868e5f8 100644 --- a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql +++ b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql @@ -57,7 +57,7 @@ FROM study.demographics h JOIN ( t1.date as startDate, timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed, t1.enddate, t1.code, t1.volume, t1.vol_units, t1.concentration, t1.conc_units, t1.amountWithUnits, - t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning + ' (' + t1.frequency.times + ')' as frequency, t1.route, + t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning || ' (' || t1.frequency.times || ')' as frequency, t1.route, t1.reason, t1.performedby, t1.remark, t1.qcstate.label as TreatmentStatus FROM ehr_lookups.dateRange dr diff --git a/sla/resources/queries/sla/PlandProtocols.sql b/sla/resources/queries/sla/PlandProtocols.sql index 72b01ae32..423e509f8 100644 --- a/sla/resources/queries/sla/PlandProtocols.sql +++ b/sla/resources/queries/sla/PlandProtocols.sql @@ -20,7 +20,7 @@ SELECT a.project as ProjectID, --i.LastName + ': ' + a.name + '('+ p.external_id +')' + ' ' + aa.Breeding_Info + ' - ' + a.title + ' (Species: ' + aa.species + ')' as PIIacuc --Removed the Breeding info in the protocol field as we are not storing the information when user selects the item from drop down list. Approved by Kati in Tkt #11797 - i.LastName + ': ' + a.name + '('+ p.external_id +')' + ' - ' + a.title + ' (Species: ' + aa.species + ')' as PIIacuc + i.LastName || ': ' || a.name || '('|| p.external_id ||')' || ' - ' || a.title || ' (Species: ' || aa.species || ')' as PIIacuc FROM publicehr.project a LEFT JOIN publicehr.protocol p ON p.protocol = a.protocol LEFT JOIN onprc_ehr.investigators i ON i.rowId = a.investigatorId diff --git a/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql b/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql index 9c212b921..c4a75867c 100644 --- a/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql +++ b/sla/resources/queries/sla/allowableAnimals_BreedingGroups.sql @@ -14,10 +14,10 @@ SELECT a.protocol, --b.Number_Of_Animals_Max as Allowed, a.startdate, a.enddate, - 'Group Id & Name: ' + b.group_id + ', ' + b.group_name + ', Breeding Allowed: ' + (Case When cast (b.breeding_colony AS varchar) = '0' Then 'NO' Else 'YES' END) as Breeding_Info + 'Group Id & Name: ' || b.group_id || ', ' || b.group_name || ', Breeding Allowed: ' || (Case When cast (b.breeding_colony AS varchar) = '0' Then 'NO' Else 'YES' END) as Breeding_Info FROM sla.allowableAnimals a, onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS c, onprc_ehr.eIACUC_PRIME_VIEW_ANIMAL_GROUPS b Where c.Protocol_State = 'Approved' - And (c.protocol_Id = a.protocol.displayname OR c.protocol_Id like '%' + a.protocol.displayname) + And (c.protocol_Id = a.protocol.displayname OR c.protocol_Id like '%' || a.protocol.displayname) And c.protocol_Id = b.parent_protocol And curdate() between a.startdate And a.endDate And b.species = CASE diff --git a/sla/resources/queries/sla/allowableSLA.sql b/sla/resources/queries/sla/allowableSLA.sql index f2705049b..829acb6f6 100644 --- a/sla/resources/queries/sla/allowableSLA.sql +++ b/sla/resources/queries/sla/allowableSLA.sql @@ -13,7 +13,7 @@ SELECT a.protocol, FROM sla.allowableAnimals a, onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS c Where c.Protocol_State = 'Approved' - And (c.protocol_Id = a.protocol.displayname OR c.protocol_Id like '%' + a.protocol.displayname) + And (c.protocol_Id = a.protocol.displayname OR c.protocol_Id like '%' || a.protocol.displayname) -- And (c.protocol_Id = a.protocol OR c.protocol_Id like '%' + a.protocol) And curdate() between a.startdate And a.endDate From 796e8f57eecd641593558610c6a50aa02f7413fe Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Tue, 18 Aug 2026 17:19:13 -0700 Subject: [PATCH 02/11] cast bcs scores to double --- .../queries/EHR_ComplianceDB/Measles45DayAlert.sql | 2 +- onprc_ehr/resources/queries/study/BloodCalcBCS.sql | 2 +- onprc_ehr/resources/queries/study/bloodSummary.sql | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/Measles45DayAlert.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/Measles45DayAlert.sql index 8ba6d22d1..6990d3848 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/Measles45DayAlert.sql +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/Measles45DayAlert.sql @@ -27,7 +27,7 @@ FROM ehr_compliancedb.completiondates c SELECT c1.employeeid, emp.email, - emp.Firstname + ' ' + emp.Lastname as Name, + emp.Firstname || ' ' || emp.Lastname as Name, emp.unit, emp.category, emp.location, diff --git a/onprc_ehr/resources/queries/study/BloodCalcBCS.sql b/onprc_ehr/resources/queries/study/BloodCalcBCS.sql index 13404ba81..8d7ce7dd7 100644 --- a/onprc_ehr/resources/queries/study/BloodCalcBCS.sql +++ b/onprc_ehr/resources/queries/study/BloodCalcBCS.sql @@ -11,7 +11,7 @@ c.bpk, c.interval, c.Percentage, c.CalcMethodReason, -((c.Weight * (113.753+(0.752 * c.Weight ) - (18.919 * c.bcs)))) as BcsTbv, +((c.Weight * (113.753+(0.752 * c.Weight ) - (18.919 * CAST(c.bcs AS DOUBLE))))) as BcsTbv, (c.bpk*c.Weight) as StandardTBV diff --git a/onprc_ehr/resources/queries/study/bloodSummary.sql b/onprc_ehr/resources/queries/study/bloodSummary.sql index 4521a3c43..cf994cd28 100644 --- a/onprc_ehr/resources/queries/study/bloodSummary.sql +++ b/onprc_ehr/resources/queries/study/bloodSummary.sql @@ -117,7 +117,7 @@ SELECT TIMESTAMPDIFF('SQL_TSI_DAY',bcs.date,Now()) as DaysSinceBCS, --This ca;ciates tje tt Case - when TIMESTAMPDIFF('SQL_TSI_DAY',bcs.date,Now()) < 365 THEN round(cast (113.753 + ((0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * bcs.score))as double),2) + when TIMESTAMPDIFF('SQL_TSI_DAY',bcs.date,Now()) < 365 THEN round(cast (113.753 + ((0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * CAST(bcs.score AS DOUBLE)))as double),2) Else (d.species.blood_per_kg * d.id.MostRecentWeight.MostRecentWeight) END as TotalBloodAvailable, @@ -137,11 +137,11 @@ SELECT -- blood volume (ml/kg) ------113.753+(0.752*Wt)- (18.919*BCS) -(113.753+(0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * bcs.score)) as BloodVolume, +(113.753+(0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * CAST(bcs.score AS DOUBLE))) as BloodVolume, --TBV(mnl) -----weight * Blood Volume -(d.id.MostRecentWeight.MostRecentWeight * (113.753+(0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * bcs.score))) as TBV, +(d.id.MostRecentWeight.MostRecentWeight * (113.753+(0.752 * d.id.MostRecentWeight.MostRecentWeight ) - (18.919 * CAST(bcs.score AS DOUBLE)))) as TBV, --Allowable BV -----TBV*.125 From 8f8368d06ffe0d3ae7f6ad7e72b0819422c226da Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Tue, 18 Aug 2026 17:28:52 -0700 Subject: [PATCH 03/11] update timestampdiff to timestampadd --- .../queries/study/demographics_assignedVetNotification.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/queries/study/demographics_assignedVetNotification.sql b/onprc_ehr/resources/queries/study/demographics_assignedVetNotification.sql index ce613375f..844fea17a 100644 --- a/onprc_ehr/resources/queries/study/demographics_assignedVetNotification.sql +++ b/onprc_ehr/resources/queries/study/demographics_assignedVetNotification.sql @@ -8,4 +8,4 @@ d.earliestRemarkSinceReview, d.lastVetReview, v.assignedVet FROM demographicsAssignedVet v join demographics d on v.id = d.id -where d.lastDayAtCenter > TimestampDiff('SQL_TSI_Day', 90, Now()) \ No newline at end of file +where d.lastDayAtCenter > TimestampAdd('SQL_TSI_Day', -90, Now()) \ No newline at end of file From 7849bd1462a75b8d88ebd168e47e23ce0603dc59 Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Wed, 19 Aug 2026 07:00:11 -0700 Subject: [PATCH 04/11] Replace SQL Server character-class LIKE patterns with portable expressions --- .../queries/onprc_billing/LeaseFeeReleaseAdjustment.sql | 2 +- .../queries/onprc_billing/LeaseFee_Demographics.sql | 2 +- .../resources/queries/onprc_billing/leaseFees.sql | 2 +- .../queries/onprc_ehr/PrimaToPrimeCassetteData.sql | 8 ++++++-- onprc_ehr/resources/queries/study/BCS_Recent_Score.sql | 2 +- .../resources/queries/study/blooddrawDemographics.sql | 2 +- .../queries/study/vetAssignment_demographics.sql | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql index a55bc8e42..062e38601 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql @@ -93,4 +93,4 @@ and (a.enddateFinalized >= startDate and a.enddateFinalized <= enddate) AND a.qcstate.publicdata = true and lf.chargeID is not null --AND lf.active = true -AND a2.id IS NULL and a.participantID not like '[a-z]%' \ No newline at end of file +AND a2.id IS NULL and NOT (LOWER(LEFT(a.participantID,1)) BETWEEN 'a' AND 'z') \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql index 06c95cdfe..2668f2e8e 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql @@ -118,4 +118,4 @@ Left outer join Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}. Left outer join Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.tmbDam tmb on tmb.id = a.id and (tmb.date <= a.date and tmb.enddate >= a.date or tmb.endDate is Null) where a.datefinalized >= startDate and (a.datefinalized <= enddate or a.enddate is null) -and a.id not like '[a-z]%' \ No newline at end of file +and NOT (LOWER(LEFT(a.id,1)) BETWEEN 'a' AND 'z') \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql index f427f4157..4c7bc569d 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql @@ -266,4 +266,4 @@ WHERE a.releaseCondition != a.projectedReleaseCondition and (A.id != A5.id or A5.id is Null) AND a.enddatefinalized is not null AND CAST(a.enddatefinalized AS DATE) >= CAST(STARTDATE AS DATE) AND CAST(a.enddatefinalized AS DATE) <= CAST(EndDate as DATE) AND a.qcstate.publicdata = true AND lf.active = true -AND a2.id IS NULL and a.participantID not like '[a-z]%' +AND a2.id IS NULL and NOT (LOWER(LEFT(a.participantID,1)) BETWEEN 'a' AND 'z') diff --git a/onprc_ehr/resources/queries/onprc_ehr/PrimaToPrimeCassetteData.sql b/onprc_ehr/resources/queries/onprc_ehr/PrimaToPrimeCassetteData.sql index 9c8d4920d..85981e302 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/PrimaToPrimeCassetteData.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/PrimaToPrimeCassetteData.sql @@ -15,5 +15,9 @@ FROM Prima_CassetteBases as ctb join Prima_CaseBase cb on cb.Id = ctb.CaseBaseId Join Prima_Animals an on cb.AnimalId = an.Id Where ctb.SavedIdentifier NOT LIKE 'IPC%' - And ctb.SavedIdentifier NOT LIKE '19[0-9][0-9]%' - And ctb.SavedIdentifier NOT LIKE '20[0-9][0-9]%' \ No newline at end of file + And NOT (LEFT(ctb.SavedIdentifier,2) = '19' + AND SUBSTRING(ctb.SavedIdentifier,3,1) BETWEEN '0' AND '9' + AND SUBSTRING(ctb.SavedIdentifier,4,1) BETWEEN '0' AND '9') + And NOT (LEFT(ctb.SavedIdentifier,2) = '20' + AND SUBSTRING(ctb.SavedIdentifier,3,1) BETWEEN '0' AND '9' + AND SUBSTRING(ctb.SavedIdentifier,4,1) BETWEEN '0' AND '9') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql b/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql index 37ff7ed46..1c436454e 100644 --- a/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql +++ b/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql @@ -18,4 +18,4 @@ RIGHT JOIN ) As d ON c.id = d.id And CAST(c.date AS DATE) = d.MaxDate -Where c.category = 'bcs' and c.id not like '[a-z]%' +Where c.category = 'bcs' and NOT (LOWER(LEFT(c.id,1)) BETWEEN 'a' AND 'z') diff --git a/onprc_ehr/resources/queries/study/blooddrawDemographics.sql b/onprc_ehr/resources/queries/study/blooddrawDemographics.sql index 984b48039..fa0b36883 100644 --- a/onprc_ehr/resources/queries/study/blooddrawDemographics.sql +++ b/onprc_ehr/resources/queries/study/blooddrawDemographics.sql @@ -32,4 +32,4 @@ from study.demographics d left outer join study.demographicsMostRecentWeight w on d.id = w.id left outer join demographicsMostRecentBCS mbcs on mbcs.id = d.id where d.calculated_status = 'Alive' -and d.ID not like '[a-z]%' \ No newline at end of file +and NOT (LOWER(LEFT(d.ID,1)) BETWEEN 'a' AND 'z') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql b/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql index ff5df31cf..f79d2d220 100644 --- a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql +++ b/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql @@ -35,5 +35,5 @@ LEFT JOIN CasesData ON Demographics.Id = CasesData.Id LEFT JOIN Study.Housing AS Housing ON Demographics.Id = Housing.Id LEFT JOIN Study.VetAssignment_projects AS AssignedProject ON Demographics.Id = AssignedProject.Id WHERE Demographics.Calculated_Status = 'Alive' - AND Demographics.Id NOT LIKE '[A-Z]%' + AND NOT (LOWER(LEFT(Demographics.Id,1)) BETWEEN 'a' AND 'z') AND Housing.Enddate IS NULL \ No newline at end of file From 1c1f560f7abfef7cb74d0fec6b78bb7db33218f8 Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Wed, 19 Aug 2026 07:06:03 -0700 Subject: [PATCH 05/11] Replace CHARINDEX with LabKey SQL LOCATE --- .../resources/queries/onprc_ehr/Labwork_Requestor_Vets.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/queries/onprc_ehr/Labwork_Requestor_Vets.sql b/onprc_ehr/resources/queries/onprc_ehr/Labwork_Requestor_Vets.sql index 258aa0f9e..1bc6b9db6 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/Labwork_Requestor_Vets.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/Labwork_Requestor_Vets.sql @@ -1,4 +1,4 @@ -select a.*, b.UserId, Left(b.Email,CHARINDEX('@',b.Email)-1) as emailName from Reference_StaffNames a, onprc_ehr.usersActiveNames b -where a.username = Left(b.Email,CHARINDEX('@',b.Email)-1) +select a.*, b.UserId, Left(b.Email,LOCATE('@',b.Email)-1) as emailName from Reference_StaffNames a, onprc_ehr.usersActiveNames b +where a.username = Left(b.Email,LOCATE('@',b.Email)-1) and b.active = 'true' \ No newline at end of file From 884afb7c02000136c241286a1dab7eccaa9756cb Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Wed, 19 Aug 2026 07:20:58 -0700 Subject: [PATCH 06/11] Wrap case-sensitive literal comparisons in LOWER for PostgreSQL --- .../queries/study/dnaFlagSummary.sql | 2 +- .../queries/study/mhcFlagSummary.sql | 2 +- .../ComplianceHostIdentifier.sql | 2 +- .../EHR_ComplianceDB/complianceemployee.sql | 2 +- .../onprc_billing/Activealias_2020.sql | 2 +- .../onprc_billing/LeaseFeeRates_Final.sql | 4 +- .../LeaseFeeReleaseAdjustment.sql | 2 +- .../onprc_billing/LeaseFee_Demographics.sql | 2 +- .../onprc_billing/LeaseFee_LeaseType.sql | 14 ++--- .../queries/onprc_billing/labworkFeeRates.sql | 4 +- .../queries/onprc_billing/leaseFeeRates.sql | 4 +- .../onprc_billing/leaseFee_RateReview.sql | 4 +- .../onprc_billing/miscChargesWithRates.sql | 4 +- .../queries/onprc_billing/perDiemRates.sql | 4 +- .../queries/onprc_billing/perDiemsByDay.sql | 2 +- .../onprc_billing/procedureFeeRates.sql | 4 +- .../queries/onprc_billing/slaPerDiemRates.sql | 4 +- .../resources/queries/virologyAliases.sql | 2 +- .../onprc_ehr/ChemistryPanicNotification.sql | 2 +- .../onprc_ehr/SoonExpiringLongTermMeds.sql | 2 +- .../onprc_ehr/vet_assignmentMissingData.sql | 4 +- .../AlopeciaScoreMissingBehaviorCases.sql | 2 +- .../study/AssignmentPoolUnderTheAge.sql | 4 +- .../study/AssignmentsReleasedInPast1Day.sql | 2 +- .../queries/study/AssignmentsUnderTheAge.sql | 2 +- .../queries/study/BCSScoreWeights.sql | 4 +- .../queries/study/BCS_Recent_Score.sql | 2 +- .../resources/queries/study/BloodCalcBCS.sql | 2 +- .../resources/queries/study/CMU_P2Review.sql | 2 +- .../queries/study/ClinicalCases_Open.sql | 2 +- .../resources/queries/study/ExamVetPE.sql | 2 +- .../study/PMIC_Angio_AnimalHistory.sql | 2 +- .../queries/study/PMIC_CT_AnimalHistory.sql | 2 +- .../queries/study/PMIC_DEXA_AnimalHistory.sql | 2 +- .../queries/study/PMIC_PET_AnimalHistory.sql | 2 +- .../study/PMIC_SPECT_AnimalHistory.sql | 2 +- .../queries/study/PMIC_US_AnimalHistory.sql | 2 +- .../study/TreatmentSchedulePostOpFasts.sql | 2 +- .../study/TreatmentSchedulePostOps.sql | 2 +- .../queries/study/bloodCalcCriteria.sql | 4 +- .../queries/study/bloodCalcFixedRate.sql | 2 +- .../study/bloodCalcTotalAllowableBlood.sql | 4 +- .../queries/study/bloodDrawChanges.sql | 2 +- .../resources/queries/study/bloodSummary.sql | 8 +-- .../queries/study/blooddrawDemographics.sql | 2 +- .../queries/study/clinicalCaseSummary.sql | 2 +- .../resources/queries/study/clinicalCases.sql | 2 +- .../study/consortiumAssignmentData.sql | 2 +- .../queries/study/consortiumBirthData.sql | 2 +- .../queries/study/consortiumRawData.sql | 10 +-- .../study/demographicsActiveTreatments.sql | 4 +- .../queries/study/demographicsCaseHistory.sql | 2 +- .../study/demographicsCurrentRoommates.sql | 2 +- .../queries/study/demographicsDaysAlone.sql | 2 +- .../study/demographicsInfantUnderOne.sql | 2 +- .../queries/study/demographicsLabwork.sql | 8 +-- .../study/demographicsMostRecentBCS.sql | 6 +- .../queries/study/demographicsPE.sql | 4 +- .../queries/study/demographicsPaired.sql | 4 +- .../study/demographicsReturnLocation.sql | 2 +- .../queries/study/demographicsTermination.sql | 2 +- .../study/demographicsTotalOffspring.sql | 2 +- .../demographicsTotalOffspringUnder1Yr.sql | 2 +- .../study/demographicsTreatmentsGiven.sql | 2 +- .../queries/study/demographicsUtilization.sql | 2 +- .../demographicsVetReviewObservation.sql | 6 +- .../queries/study/demographicsViralStatus.sql | 2 +- .../resources/queries/study/dualassigned.sql | 62 +++++++++---------- .../queries/study/kinshipAverage.sql | 8 +-- .../queries/study/medicalCullList.sql | 2 +- .../queries/study/pairingSeparations.sql | 4 +- .../queries/study/pathAssignmentData.sql | 4 +- .../queries/study/pregnancyChecks.sql | 4 +- .../queries/study/processingSerology.sql | 4 +- .../queries/study/researchAssigned.sql | 2 +- .../queries/study/resourceAssigned.sql | 2 +- .../queries/study/surgeryChecklist.sql | 2 +- .../queries/study/treatmentScheduleMPA.sql | 2 +- .../study/vetAssignment_demographics.sql | 2 +- .../study/processingGeneticsBloodDraws.sql | 6 +- 80 files changed, 155 insertions(+), 155 deletions(-) diff --git a/GeneticsCore/resources/queries/study/dnaFlagSummary.sql b/GeneticsCore/resources/queries/study/dnaFlagSummary.sql index 74525845c..254a48e6e 100644 --- a/GeneticsCore/resources/queries/study/dnaFlagSummary.sql +++ b/GeneticsCore/resources/queries/study/dnaFlagSummary.sql @@ -91,7 +91,7 @@ SELECT sum(coalesce(s.quantity, 0)) as totalQuantity FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.DNA_Bank.samples s --include DNA Bank workbook only -WHERE s.dateremoved is null and sampleType = 'Buffy Coat' +WHERE s.dateremoved is null and LOWER(sampleType) = LOWER('Buffy Coat') GROUP BY s.subjectId ) s2 ON (s2.subjectId = d.Id) diff --git a/GeneticsCore/resources/queries/study/mhcFlagSummary.sql b/GeneticsCore/resources/queries/study/mhcFlagSummary.sql index 017e9d223..521805a63 100644 --- a/GeneticsCore/resources/queries/study/mhcFlagSummary.sql +++ b/GeneticsCore/resources/queries/study/mhcFlagSummary.sql @@ -25,7 +25,7 @@ SELECT --NOTE: if changing this logic, processingGeneticsBlooddraws.sql should also be updated CASE WHEN f3.Id is not null THEN false - WHEN (d.species = 'RHESUS MACAQUE' AND d.Id.age.ageInYears <= 5.0 AND d.geographic_origin = 'India' AND (a.Id IS NOT NULL OR d.gender = 'm')) THEN true + WHEN (LOWER(d.species) = LOWER('RHESUS MACAQUE') AND d.Id.age.ageInYears <= 5.0 AND d.geographic_origin = 'India' AND (a.Id IS NOT NULL OR LOWER(d.gender) = LOWER('m'))) THEN true else false END as isMHCRequired, CASE diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceHostIdentifier.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceHostIdentifier.sql index 005fd226c..a3b10306b 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceHostIdentifier.sql +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/ComplianceHostIdentifier.sql @@ -1,4 +1,4 @@ select value from Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.sla.Reference_Data -where columnname = 'employeehost' +where LOWER(columnname) = LOWER('employeehost') And enddate is null \ No newline at end of file diff --git a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/complianceemployee.sql b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/complianceemployee.sql index 33f155238..e01a4baf3 100644 --- a/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/complianceemployee.sql +++ b/ONPRC_EHR_ComplianceDB/resources/queries/EHR_ComplianceDB/complianceemployee.sql @@ -1,3 +1,3 @@ select value from ehr_complianceDB.Compliance_Reference_Data -where columnName = 'employeeHost' +where LOWER(columnName) = LOWER('employeeHost') And endDate is null diff --git a/onprc_billing/resources/queries/onprc_billing/Activealias_2020.sql b/onprc_billing/resources/queries/onprc_billing/Activealias_2020.sql index 6558c1da5..24373b190 100644 --- a/onprc_billing/resources/queries/onprc_billing/Activealias_2020.sql +++ b/onprc_billing/resources/queries/onprc_billing/Activealias_2020.sql @@ -36,4 +36,4 @@ SELECT a.alias, a.FUndingSourceName, a.Org FROM aliases a -where aliasEnabled = 'y' \ No newline at end of file +where LOWER(aliasEnabled) = LOWER('y') \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFeeRates_Final.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFeeRates_Final.sql index 159f2d300..577357ed5 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFeeRates_Final.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFeeRates_Final.sql @@ -28,7 +28,7 @@ cr.unitCost as NIHRate, --case statement when dayeleaselength > 0 then dayleasr leanth else 1 as quantity case when r.DayLeaseLength> 0 then r.dayleaseLength - when r.researchowned = 'Yes' then 0 + when LOWER(r.researchowned) = LOWER('Yes') then 0 when d.birthType = 'Born to Resource Dam' then 0 Else 1 End as Quantity, @@ -66,7 +66,7 @@ When d.creditResource is not Null then d.creditTo End as CreditAccount, case WHen r.releaseType = 'No Charge' then 0 - when r.researchOwned = 'Yes' then 0 + when LOWER(r.researchOwned) = LOWER('Yes') then 0 when r.DayLeaseLength > 0 and r.daylease = 'yes' then (r.dayleaseLength * r.CalculatedRate) when r.revisedrate is not null and r.revisedrate > r.CalculatedRate then (r.revisedRate - r.CalculatedRate) when r.revisedrate is not null and r.revisedrate < r.CalculatedRate then (r.CalculatedRate - r.RevisedRate) diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql index 062e38601..e04588a65 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFeeReleaseAdjustment.sql @@ -29,7 +29,7 @@ a5.id as ESPFAnimal, (SELECT max(rowid) as rowid FROM Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.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 - when (d.researchOwned = 'yes') then 0 + when (LOWER(d.researchOwned) = LOWER('yes')) then 0 else 1 end as quantity, lf2.chargeId as leaseCharge1, diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql index 2668f2e8e..e59f16ec4 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFee_Demographics.sql @@ -42,7 +42,7 @@ Case --When da.id when ( a.date = a.id.birth.date and t.id is not null) then 'TMB Birth' - when a.project.use_category = 'Research' then 'Research' + when LOWER(a.project.use_category) = LOWER('Research') then 'Research' Else a.project.use_category end as AssignmentType, diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFee_LeaseType.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFee_LeaseType.sql index 38e3e595e..1de2b9984 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFee_LeaseType.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFee_LeaseType.sql @@ -37,7 +37,7 @@ b.dam, da.project as DualAssigned, Case --Research Owned Animal - When l.researchowned = 'yes' then 'researchOwned' + When LOWER(l.researchowned) = LOWER('yes') then 'researchOwned' --Adult Research Assignment P51 Animal (animal unassigned and adult) ----**Dual Assigned Obese JMac Control Infant Lease When l.id.age.ageinyears < 3 and da.projectname = '0622-01'and (l.id !=r.id or r.id is null) then 'Obese JMac Control Infant' @@ -50,9 +50,9 @@ Case --Dual assigned ESPF using different Chared Code -- When da.projectName = '0492-03' then 'DualAssignedESPF' --Dual assigned TMB Male on Day Lease - When l.agegroup = 'Adult' and da.projectname = '0300' and l.dayLease = 'yes' then 'TMB Adult Day Lease' + When LOWER(l.agegroup) = LOWER('Adult') and da.projectname = '0300' and l.dayLease = 'yes' then 'TMB Adult Day Lease' --Dual assigned Obese Male Day Lease - When l.agegroup = 'Adult' and da.projectname = '0833' and l.dayLease = 'yes' then 'OBESE Adult Day Lease' + When LOWER(l.agegroup) = LOWER('Adult') and da.projectname = '0833' and l.dayLease = 'yes' then 'OBESE Adult Day Lease' --Full LEase P51 adult When l.id.age.ageinyears > 1 and l.daylease <> 'yes' and (da.projectname <> '0833' or da.projectName is Null) then 'Research Assignment P51 Adult' --**Dual Assigned TMB-Dam Assigned Use lease_TMB as Process -------------------------------------------------------------------------------------------------------- @@ -73,13 +73,13 @@ Case ----**Dual Assigned Obese JMac WSD Infant Lease When l.id.age.ageinyears < 3 and da.projectname = '0622-01'and l.id =r.id then 'Obese JMac WSD Infant' ----**Dual Assigned Obese Adult Day Lease - When l.agegroup = 'adult' and da.projectname = '0833' and l.daylease = 'yes' then 'OBESE Adult Day Lease' + When LOWER(l.agegroup) = LOWER('adult') and da.projectname = '0833' and l.daylease = 'yes' then 'OBESE Adult Day Lease' ----**Dual Assigned Obese Adult Male Lease - When l.agegroup = 'adult' and da.projectname = '0833' and l.daylease = 'no' and Cast(l.projectedReleaseCondition as Varchar(20)) != 'Terminal' then 'OBESE Adult Male Lease' + When LOWER(l.agegroup) = LOWER('adult') and da.projectname = '0833' and l.daylease = 'no' and Cast(l.projectedReleaseCondition as Varchar(20)) != 'Terminal' then 'OBESE Adult Male Lease' ----Dual Assigned Obese Adult Male Terminal Lease - When l.agegroup = 'adult' and da.projectname = '0833' and l.daylease = 'no' and Cast(l.projectedReleaseCondition as Varchar(20)) = 'Terminal' then 'OBESE Adult Terminal Leasel' + When LOWER(l.agegroup) = LOWER('adult') and da.projectname = '0833' and l.daylease = 'no' and Cast(l.projectedReleaseCondition as Varchar(20)) = 'Terminal' then 'OBESE Adult Terminal Leasel' --when Adult Animal Assigned to Research project - when l.agegroup = 'adult' and da.project ='0300' then 'Aninal Lease Fee -TMB' + when LOWER(l.agegroup) = LOWER('adult') and da.project ='0300' then 'Aninal Lease Fee -TMB' --Infant Research Assignment P51 Animal Day Lease ------------------------------------------------------------------------------------------------------- When l.id.age.ageinyears < 1 and l.daylease = 'yes' then 'Day Lease Research Assignment P51 Infant' --Infant Research Assignment P51 Animal------------------------------------------------------------------------------------------------------- diff --git a/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql b/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql index 148bd3211..a6d6a4427 100644 --- a/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql @@ -107,13 +107,13 @@ SELECT CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, CASE WHEN (TIMESTAMPDIFF('SQL_TSI_DAY', p.date, curdate()) > 45) THEN 'Y' ELSE null END as isOldCharge, diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFeeRates.sql b/onprc_billing/resources/queries/onprc_billing/leaseFeeRates.sql index 9ae0ec136..5166e9e2f 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFeeRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFeeRates.sql @@ -213,13 +213,13 @@ SELECT CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFee_RateReview.sql b/onprc_billing/resources/queries/onprc_billing/leaseFee_RateReview.sql index a48b8394e..30e305a92 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFee_RateReview.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFee_RateReview.sql @@ -35,14 +35,14 @@ Case When r.aliasAtTime is Null then 'y' --Alias Accepting Charges CASE WHEN a.aliasEnabled IS NULL THEN 'N' - WHEN a.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(a.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, --Expired Alias CASE WHEN (a.budgetStartDate IS NOT NULL AND CAST(a.budgetStartDate as date) > CAST(r.assignmentdate as date)) THEN 'Prior To Budget Start' WHEN (a.budgetEndDate IS NOT NULL AND Cast(a.budgetEndDate as date ) < CAST(r.assignmentdate as date)) THEN 'After Budget End' - WHEN (a.projectStatus IS NOT NULL AND a.projectStatus != 'ACTIVE' AND a.projectStatus != 'No Cost Ext' AND a.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (a.projectStatus IS NOT NULL AND LOWER(a.projectStatus) != LOWER('ACTIVE') AND a.projectStatus != 'No Cost Ext' AND a.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, -->45 Days Olde diff --git a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql index 8ea778a0a..16437161b 100644 --- a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql @@ -112,13 +112,13 @@ END as matchesProject, CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, CASE WHEN (TIMESTAMPDIFF('SQL_TSI_DAY', p.date, curdate()) > 45) THEN 'Y' ELSE null END as isOldCharge, diff --git a/onprc_billing/resources/queries/onprc_billing/perDiemRates.sql b/onprc_billing/resources/queries/onprc_billing/perDiemRates.sql index 007830756..4ae99ff6f 100644 --- a/onprc_billing/resources/queries/onprc_billing/perDiemRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/perDiemRates.sql @@ -93,13 +93,13 @@ SELECT CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, CASE diff --git a/onprc_billing/resources/queries/onprc_billing/perDiemsByDay.sql b/onprc_billing/resources/queries/onprc_billing/perDiemsByDay.sql index cee121ac8..d3fb13ef3 100644 --- a/onprc_billing/resources/queries/onprc_billing/perDiemsByDay.sql +++ b/onprc_billing/resources/queries/onprc_billing/perDiemsByDay.sql @@ -61,7 +61,7 @@ FROM ( count(*) AS totalAssignmentRecords, group_concat(DISTINCT a2.project.displayName) AS overlappingProjects, count(DISTINCT a2.project) AS totalOverlappingProjects, - sum(CASE WHEN a2.project.use_Category = 'Research' THEN 1 ELSE 0 END) as totalOverlappingResearchProjects, + sum(CASE WHEN LOWER(a2.project.use_Category) = LOWER('Research') THEN 1 ELSE 0 END) as totalOverlappingResearchProjects, group_concat(DISTINCT a2.project.use_category) AS overlappingProjectsCategory, group_concat(DISTINCT a2.project.protocol) AS overlappingProtocols, count(h3.room) AS totalHousingRecords, diff --git a/onprc_billing/resources/queries/onprc_billing/procedureFeeRates.sql b/onprc_billing/resources/queries/onprc_billing/procedureFeeRates.sql index 4e25db749..fe0fe01fc 100644 --- a/onprc_billing/resources/queries/onprc_billing/procedureFeeRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/procedureFeeRates.sql @@ -105,13 +105,13 @@ SELECT CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, CASE WHEN (TIMESTAMPDIFF('SQL_TSI_DAY', p.date, curdate()) > 45) THEN 'Y' ELSE null END as isOldCharge, diff --git a/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql b/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql index ae22b9ffc..f9c4a98aa 100644 --- a/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql @@ -87,13 +87,13 @@ SELECT CASE WHEN alias.fiscalAuthority.faid IS NULL THEN 'Y' ELSE null END as isMissingFaid, CASE WHEN alias.aliasEnabled IS NULL THEN 'N' - WHEN alias.aliasEnabled != 'Y' THEN 'N' + WHEN LOWER(alias.aliasEnabled) != LOWER('Y') THEN 'N' ELSE null END as isAcceptingCharges, CASE WHEN (alias.budgetStartDate IS NOT NULL AND CAST(alias.budgetStartDate as date) > CAST(p.date as date)) THEN 'Prior To Budget Start' WHEN (alias.budgetEndDate IS NOT NULL AND CAST(alias.budgetEndDate as date) < CAST(p.date as date)) THEN 'After Budget End' - WHEN (alias.projectStatus IS NOT NULL AND alias.projectStatus != 'ACTIVE' AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' + WHEN (alias.projectStatus IS NOT NULL AND LOWER(alias.projectStatus) != LOWER('ACTIVE') AND alias.projectStatus != 'No Cost Ext' AND alias.projectStatus != 'Partial Setup') THEN 'Grant Project Not Active' ELSE null END as isExpiredAccount, CASE WHEN (TIMESTAMPDIFF('SQL_TSI_DAY', p.date, curdate()) > 45) THEN 'Y' ELSE null END as isOldCharge, diff --git a/onprc_billing/resources/queries/virologyAliases.sql b/onprc_billing/resources/queries/virologyAliases.sql index 7396f1fea..9b69b6570 100644 --- a/onprc_billing/resources/queries/virologyAliases.sql +++ b/onprc_billing/resources/queries/virologyAliases.sql @@ -1,3 +1,3 @@ SELECT rowid,aliases.alias, aliases.alias || ' - ' || aliases.investigatorName as aliasPI FROM aliases -WHERE projectStatus = 'Active' \ No newline at end of file +WHERE LOWER(projectStatus) = LOWER('Active') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql b/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql index dfd49abd0..c76cc0984 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/ChemistryPanicNotification.sql @@ -13,7 +13,7 @@ select a.Id, from study.ClinpathRuns a, study.chemistryResults b Where a.objectid = b.runid - And a.type = 'biochemistry' + And LOWER(a.type) = LOWER('biochemistry') And b.qualresult like '%alert%' And a.qcstate = 18 diff --git a/onprc_ehr/resources/queries/onprc_ehr/SoonExpiringLongTermMeds.sql b/onprc_ehr/resources/queries/onprc_ehr/SoonExpiringLongTermMeds.sql index 072556c34..c43abee0b 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/SoonExpiringLongTermMeds.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/SoonExpiringLongTermMeds.sql @@ -17,5 +17,5 @@ SELECT FROM study.treatment_order WHERE enddate BETWEEN curdate() AND timestampadd(SQL_TSI_DAY, 7, curdate()) AND age(CAST(date AS DATE), CAST(enddate AS DATE), SQL_TSI_MONTH) >= 1 - AND category = 'clinical' + AND LOWER(category) = LOWER('clinical') AND code.meaning NOT LIKE '%bottle%' diff --git a/onprc_ehr/resources/queries/onprc_ehr/vet_assignmentMissingData.sql b/onprc_ehr/resources/queries/onprc_ehr/vet_assignmentMissingData.sql index 3331fea4e..bfaf094bf 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/vet_assignmentMissingData.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/vet_assignmentMissingData.sql @@ -4,7 +4,7 @@ a.project.protocol.displayName as Item, v.protocol.displayName as Vet_AssignedItem, Count(a.participantId) as totalNHps from study.assignment a left outer join vet_assignment v on a.project.protocol = v.protocol.protocol -where a.project.use_category = 'Research' and a.enddate is null and v.protocol.displayName is null +where LOWER(a.project.use_category) = LOWER('Research') and a.enddate is null and v.protocol.displayName is null group by a.project.protocol.displayname,v.protocol.displayName Union @@ -15,7 +15,7 @@ a.project.protocol.displayName as Item, v.protocol.displayName as Vet_AssignedItem, Count(a.participantId) as totalNHps from study.assignment a left outer join vet_assignment v on a.project.protocol = v.protocol.protocol -where a.project.use_category != 'Research'and a.enddate is null and v.protocol.displayName is null +where LOWER(a.project.use_category) != LOWER('Research')and a.enddate is null and v.protocol.displayName is null group by a.project.protocol.displayname,v.protocol.displayName Union diff --git a/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql index dc670937a..28bfbe7d1 100644 --- a/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql +++ b/onprc_ehr/resources/queries/study/AlopeciaScoreMissingBehaviorCases.sql @@ -41,7 +41,7 @@ FROM ( ) AS mr INNER JOIN study.demographics AS d ON mr.Id = d.Id WHERE - d.calculated_status = 'Alive' + LOWER(d.calculated_status) = LOWER('Alive') AND mr.observation IN ('4', '5') AND NOT EXISTS ( SELECT 1 diff --git a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql index 7bdd95f10..0cb7044d1 100644 --- a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql @@ -44,13 +44,13 @@ WHERE --a.enddate IS NULL --AND a.isActive = 1 --AND a.project.displayname NOT IN ('0492-02', '0492-03') - AND a.Id.demographics.species = 'Rhesus Macaque' + AND LOWER(a.Id.demographics.species) = LOWER('Rhesus Macaque') AND EXISTS ( SELECT 1 FROM study.flags f WHERE f.Id = a.Id AND f.flag.category = 'Assign Alias' - AND f.flag.value = 'Assignment Pool' + AND LOWER(f.flag.value) = LOWER('Assignment Pool') AND f.enddate IS NULL ) diff --git a/onprc_ehr/resources/queries/study/AssignmentsReleasedInPast1Day.sql b/onprc_ehr/resources/queries/study/AssignmentsReleasedInPast1Day.sql index 2c530c3ef..8f9aba1cd 100644 --- a/onprc_ehr/resources/queries/study/AssignmentsReleasedInPast1Day.sql +++ b/onprc_ehr/resources/queries/study/AssignmentsReleasedInPast1Day.sql @@ -27,4 +27,4 @@ Together, they produce exactly the last 24 hours, nothing more. */ WHERE CAST(enddate AS DATE) = TIMESTAMPADD('SQL_TSI_DAY', -1, CAST(NOW() AS DATE)) AND CAST(enddate AS DATE) <= CAST(NOW() AS DATE) - AND Id.demographics.calculated_status = 'Alive' \ No newline at end of file + AND LOWER(Id.demographics.calculated_status) = LOWER('Alive') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql index 2a1640290..e6f0bb5ba 100644 --- a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql @@ -44,7 +44,7 @@ FROM Assignment a WHERE a.Id.Age.ageinyears <= 3 - AND a.Id.demographics.species = 'Rhesus Macaque' + AND LOWER(a.Id.demographics.species) = LOWER('Rhesus Macaque') AND a.enddate IS NULL AND a.isActive = 1 AND a.project.displayname NOT IN ('0492-02', '0492-03') diff --git a/onprc_ehr/resources/queries/study/BCSScoreWeights.sql b/onprc_ehr/resources/queries/study/BCSScoreWeights.sql index 10740bc2d..ebdecab7a 100644 --- a/onprc_ehr/resources/queries/study/BCSScoreWeights.sql +++ b/onprc_ehr/resources/queries/study/BCSScoreWeights.sql @@ -28,9 +28,9 @@ SELECT FROM study.Clinical_Observations p, study.weight K WHERE p.qcstate.publicdata = true And (p.id = k.id) - And p.category = 'BCS' + And LOWER(p.category) = LOWER('BCS') And p.date in (Select max(r.date) AS d from study.Clinical_Observations r - Where r.category = 'BCS' And r.id = p.id + Where LOWER(r.category) = LOWER('BCS') And r.id = p.id And r.QCState.Label = 'Completed' ) And (K.date in diff --git a/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql b/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql index 1c436454e..8f4379a43 100644 --- a/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql +++ b/onprc_ehr/resources/queries/study/BCS_Recent_Score.sql @@ -10,7 +10,7 @@ RIGHT JOIN a.id, MAX(CAST(a.date AS DATE)) as MaxDate From study.clinical_Observations a - Where a.category = 'bcs' + Where LOWER(a.category) = LOWER('bcs') And a.date > TIMESTAMPADD('SQL_TSI_MONTH', -18, Now()) and a.observation is not null --And a.id in ('30661', '16609') diff --git a/onprc_ehr/resources/queries/study/BloodCalcBCS.sql b/onprc_ehr/resources/queries/study/BloodCalcBCS.sql index 8d7ce7dd7..b82b38270 100644 --- a/onprc_ehr/resources/queries/study/BloodCalcBCS.sql +++ b/onprc_ehr/resources/queries/study/BloodCalcBCS.sql @@ -16,4 +16,4 @@ c.CalcMethodReason, FROM bloodCalcCriteria c -WHere c.CalcMethod = 'BCS' \ No newline at end of file +WHere LOWER(c.CalcMethod) = LOWER('BCS') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/CMU_P2Review.sql b/onprc_ehr/resources/queries/study/CMU_P2Review.sql index c9bb59e47..131617c35 100644 --- a/onprc_ehr/resources/queries/study/CMU_P2Review.sql +++ b/onprc_ehr/resources/queries/study/CMU_P2Review.sql @@ -9,5 +9,5 @@ SELECT c.Id, c.history FROM clinremarks c -where c.id.Demographics.calculated_status = 'alive' +where LOWER(c.id.Demographics.calculated_status) = LOWER('alive') And c.date in (Select Max(c1.date) AS MaxDate from clinremarks c1 where c.id = c1.id And c1.p2 is not null) diff --git a/onprc_ehr/resources/queries/study/ClinicalCases_Open.sql b/onprc_ehr/resources/queries/study/ClinicalCases_Open.sql index 1b9b00b03..74ed11180 100644 --- a/onprc_ehr/resources/queries/study/ClinicalCases_Open.sql +++ b/onprc_ehr/resources/queries/study/ClinicalCases_Open.sql @@ -14,4 +14,4 @@ SELECT c.mostRecentCeg_Plan FROM study.cases c -WHERE c.isOpen = true AND c.category = 'Clinical' \ No newline at end of file +WHERE c.isOpen = true AND LOWER(c.category) = LOWER('Clinical') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/ExamVetPE.sql b/onprc_ehr/resources/queries/study/ExamVetPE.sql index 8bd82fbc1..2ff4bdfb9 100644 --- a/onprc_ehr/resources/queries/study/ExamVetPE.sql +++ b/onprc_ehr/resources/queries/study/ExamVetPE.sql @@ -90,6 +90,6 @@ LEFT JOIN ( -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.id, d.id.age.AgeInYears, g.date,g.p2, d.id.assignedVet.assignedVet \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/PMIC_Angio_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_Angio_AnimalHistory.sql index 15edf09d5..f3ca132c8 100644 --- a/onprc_ehr/resources/queries/study/PMIC_Angio_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_Angio_AnimalHistory.sql @@ -22,4 +22,4 @@ from study.PMIC_AngioImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' \ No newline at end of file + and LOWER(e.type) = LOWER('procedure') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/PMIC_CT_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_CT_AnimalHistory.sql index 98f4eea1b..228b91e5e 100644 --- a/onprc_ehr/resources/queries/study/PMIC_CT_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_CT_AnimalHistory.sql @@ -28,4 +28,4 @@ from study.PMIC_CTImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' \ No newline at end of file + and LOWER(e.type) = LOWER('procedure') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/PMIC_DEXA_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_DEXA_AnimalHistory.sql index 83c7fc1b7..5b8b01d52 100644 --- a/onprc_ehr/resources/queries/study/PMIC_DEXA_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_DEXA_AnimalHistory.sql @@ -19,4 +19,4 @@ from study.PMIC_DEXAImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' \ No newline at end of file + and LOWER(e.type) = LOWER('procedure') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/PMIC_PET_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_PET_AnimalHistory.sql index 42a601093..62d337fef 100644 --- a/onprc_ehr/resources/queries/study/PMIC_PET_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_PET_AnimalHistory.sql @@ -28,4 +28,4 @@ from study.PMIC_PETImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' + and LOWER(e.type) = LOWER('procedure') diff --git a/onprc_ehr/resources/queries/study/PMIC_SPECT_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_SPECT_AnimalHistory.sql index e1240f8be..6112c8f76 100644 --- a/onprc_ehr/resources/queries/study/PMIC_SPECT_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_SPECT_AnimalHistory.sql @@ -26,4 +26,4 @@ from study.PMIC_SPECTImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' \ No newline at end of file + and LOWER(e.type) = LOWER('procedure') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/PMIC_US_AnimalHistory.sql b/onprc_ehr/resources/queries/study/PMIC_US_AnimalHistory.sql index d67ce72b1..6b8bdbcf5 100644 --- a/onprc_ehr/resources/queries/study/PMIC_US_AnimalHistory.sql +++ b/onprc_ehr/resources/queries/study/PMIC_US_AnimalHistory.sql @@ -19,4 +19,4 @@ from study.PMIC_USImagingData a, study.encounters e Where a.taskid = e.taskid and a.id = e.id and e.chargetype = 'PMIC' - and e.type = 'procedure' \ No newline at end of file + and LOWER(e.type) = LOWER('procedure') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql index 4a43dbe9e..b993fd41e 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql @@ -39,5 +39,5 @@ And procedureid in (1804,1807,2440, 3089) -- get these procedures only And (date < cast(TimeStampAdd('SQL_TSI_DAY',1,cast(cast(now() as date) as varchar(30)) || ' ' || '08:00') as TIMESTAMP) And date > cast(cast(cast(now() as date) as varchar(30)) || ' ' || '16:00' as TIMESTAMP) ) ---Between 4pm thru 8am And instructions not in ('Lab staff will pull chow and wash caging') -And type = 'Procedure' +And LOWER(type) = LOWER('Procedure') diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql index 786c93b13..c7e145994 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql @@ -91,7 +91,7 @@ WHERE t1.date is not null ) s ) s ON (s.animalid = h.id) - WHERE h.calculated_status = 'Alive' + WHERE LOWER(h.calculated_status) = LOWER('Alive') --account for date/time in schedule AND s.date >= s.startDate AND (s.date <= s.enddate OR s.enddate IS NULL) diff --git a/onprc_ehr/resources/queries/study/bloodCalcCriteria.sql b/onprc_ehr/resources/queries/study/bloodCalcCriteria.sql index 7dc60b4b6..01b9e48f9 100644 --- a/onprc_ehr/resources/queries/study/bloodCalcCriteria.sql +++ b/onprc_ehr/resources/queries/study/bloodCalcCriteria.sql @@ -10,7 +10,7 @@ d.blood_per_kg as bpk, d.blood_draw_interval as interval, d.max_draw_pct as Percentage, Case - When d.species <> 'Rhesus Macaque' then 'Fixed Rate by Speices' + When LOWER(d.species) <> LOWER('Rhesus Macaque') then 'Fixed Rate by Speices' WHen d.score is Null then 'Fixed Rate no BCS' when TIMESTAMPDIFF('SQL_TSI_DAY',d.date,Now()) > 548 Then 'Fixed Rate BCS out of Date' when d.DaysAge < 730 then 'Fixed Rate NHP Too Young' @@ -18,7 +18,7 @@ Case else 'BCS' End as CalcMethodReason, Case - When d.species <> 'Rhesus Macaque' then 'Fr' + When LOWER(d.species) <> LOWER('Rhesus Macaque') then 'Fr' WHen d.score is Null then 'fr' when TIMESTAMPDIFF('SQL_TSI_DAY',d.date,Now()) > 548 Then 'fr' when d.DaysAge < 730 then 'Fr' diff --git a/onprc_ehr/resources/queries/study/bloodCalcFixedRate.sql b/onprc_ehr/resources/queries/study/bloodCalcFixedRate.sql index 1e36afc2b..2d6234681 100644 --- a/onprc_ehr/resources/queries/study/bloodCalcFixedRate.sql +++ b/onprc_ehr/resources/queries/study/bloodCalcFixedRate.sql @@ -14,4 +14,4 @@ c.CalcMethodReason, (c.bpk*c.Weight) as TOtalBloodVolume FROM bloodCalcCriteria c -WHere c.CalcMethod = 'FR' \ No newline at end of file +WHere LOWER(c.CalcMethod) = LOWER('FR') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/bloodCalcTotalAllowableBlood.sql b/onprc_ehr/resources/queries/study/bloodCalcTotalAllowableBlood.sql index cacd9355f..579417b04 100644 --- a/onprc_ehr/resources/queries/study/bloodCalcTotalAllowableBlood.sql +++ b/onprc_ehr/resources/queries/study/bloodCalcTotalAllowableBlood.sql @@ -16,9 +16,9 @@ c.CalcMethod, CAST( Case - When c.CalcMethod = 'fr' then + When LOWER(c.CalcMethod) = LOWER('fr') then (Select (fr.totalBloodVolume * c.percentage) as frtba from study,bloodcalcFixedRate fr where c.id = fr.id) - When c.calcMethod = 'BCS' then + When LOWER(c.calcMethod) = LOWER('BCS') then (Select (b.bcstbv * c.percentage) as bcstba from study.Bloodcalcbcs b where c.id = b.id) End AS DOUBLE) as ABV FROM bloodCalcCriteria c \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/bloodDrawChanges.sql b/onprc_ehr/resources/queries/study/bloodDrawChanges.sql index 2c25a5520..27098434f 100644 --- a/onprc_ehr/resources/queries/study/bloodDrawChanges.sql +++ b/onprc_ehr/resources/queries/study/bloodDrawChanges.sql @@ -48,7 +48,7 @@ FROM ( curdate() as dateOnly, 0 as quantity FROM study.demographics d1 - WHERE d1.calculated_status = 'Alive' + WHERE LOWER(d1.calculated_status) = LOWER('Alive') UNION ALL diff --git a/onprc_ehr/resources/queries/study/bloodSummary.sql b/onprc_ehr/resources/queries/study/bloodSummary.sql index cf994cd28..32b520284 100644 --- a/onprc_ehr/resources/queries/study/bloodSummary.sql +++ b/onprc_ehr/resources/queries/study/bloodSummary.sql @@ -31,7 +31,7 @@ round(b.TBV,2) as TotalBloodVolume, --round((b.TBV*.125),2) as AllowableBlood1, Case - When species<> 'Rhesus Macaque' --'Fixed Rate Process' + When LOWER(species)<> LOWER('Rhesus Macaque') --'Fixed Rate Process' Then round((b.species.blood_per_kg * b.id.MostRecentWeight.MostRecentWeight * b.max_draw_pct),2) When b.DaysSinceBCS > 365 @@ -42,7 +42,7 @@ round(b.TBV,2) as TotalBloodVolume, end As AllowableBlood, Case - When species<> 'Rhesus Macaque' --'Fixed Rate Process' + When LOWER(species)<> LOWER('Rhesus Macaque') --'Fixed Rate Process' Then Case When (b.bloodPrevious>b.bloodFuture) @@ -81,7 +81,7 @@ round(b.TBV,2) as TotalBloodVolume, end As AvailableBlood, Case - When species<> 'Rhesus Macaque' Then 'FR' + When LOWER(species)<> LOWER('Rhesus Macaque') Then 'FR' When b.DaysSinceBCS > 365 Then 'FR' @@ -166,6 +166,6 @@ FROM --NOTE: this uses date part only JOIN (SELECT w.id, MAX(dateOnly) as dateOnly FROM study.weight w WHERE w.qcstate.publicdata = true GROUP BY w.id) lastWeight ON (d.id = lastWeight.id) LEFT OUTER JOIN study.demographicsCurrentBCS bcs on bcs.id = d.id -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') ) b \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/blooddrawDemographics.sql b/onprc_ehr/resources/queries/study/blooddrawDemographics.sql index fa0b36883..f0657c310 100644 --- a/onprc_ehr/resources/queries/study/blooddrawDemographics.sql +++ b/onprc_ehr/resources/queries/study/blooddrawDemographics.sql @@ -31,5 +31,5 @@ from study.demographics d left outer join study.birth b on d.id = b.id left outer join study.demographicsMostRecentWeight w on d.id = w.id left outer join demographicsMostRecentBCS mbcs on mbcs.id = d.id -where d.calculated_status = 'Alive' +where LOWER(d.calculated_status) = LOWER('Alive') and NOT (LOWER(LEFT(d.ID,1)) BETWEEN 'a' AND 'z') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/clinicalCaseSummary.sql b/onprc_ehr/resources/queries/study/clinicalCaseSummary.sql index 5073e5a70..ef735b3c5 100644 --- a/onprc_ehr/resources/queries/study/clinicalCaseSummary.sql +++ b/onprc_ehr/resources/queries/study/clinicalCaseSummary.sql @@ -22,6 +22,6 @@ FROM study.cases c --2 years WHERE timestampdiff('SQL_TSI_DAY', c.date, now()) <= (365 * 2) -AND c.category = 'Clinical' +AND LOWER(c.category) = LOWER('Clinical') GROUP BY c.Id, c.problemCategories \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/clinicalCases.sql b/onprc_ehr/resources/queries/study/clinicalCases.sql index 487cffa1d..50c71c0c6 100644 --- a/onprc_ehr/resources/queries/study/clinicalCases.sql +++ b/onprc_ehr/resources/queries/study/clinicalCases.sql @@ -29,7 +29,7 @@ SELECT c.mostRecentCeg_Plan FROM study.cases c -WHERE c.isActive = true AND c.category = 'Clinical' +WHERE c.isActive = true AND LOWER(c.category) = LOWER('Clinical') UNION ALL diff --git a/onprc_ehr/resources/queries/study/consortiumAssignmentData.sql b/onprc_ehr/resources/queries/study/consortiumAssignmentData.sql index 593649ac9..07e8f23d3 100644 --- a/onprc_ehr/resources/queries/study/consortiumAssignmentData.sql +++ b/onprc_ehr/resources/queries/study/consortiumAssignmentData.sql @@ -16,7 +16,7 @@ SELECT group_concat(DISTINCT a.project.displayName, chr(10)) as overlappingProjects, group_concat(DISTINCT a.project.use_category, (',' || chr(10))) as utilization, - sum(CASE WHEN (a.project.use_category = 'Research') THEN 1 ELSE 0 END) as totalResearchAssignments, + sum(CASE WHEN (LOWER(a.project.use_category) = LOWER('Research')) THEN 1 ELSE 0 END) as totalResearchAssignments, sum(CASE WHEN (a.project.use_category = 'U42') THEN 1 ELSE 0 END) as isU42, sum(CASE WHEN (a.project.use_category = 'U24') THEN 1 ELSE 0 END) as isU24 diff --git a/onprc_ehr/resources/queries/study/consortiumBirthData.sql b/onprc_ehr/resources/queries/study/consortiumBirthData.sql index b0d570b55..56cd47b51 100644 --- a/onprc_ehr/resources/queries/study/consortiumBirthData.sql +++ b/onprc_ehr/resources/queries/study/consortiumBirthData.sql @@ -19,7 +19,7 @@ SELECT group_concat(DISTINCT a.project.investigatorId.lastName, chr(10)) as investigators, group_concat(DISTINCT a.project.investigatorId.division, chr(10)) as divisions, count(a.lsid) as totalAssignments, - sum(CASE WHEN a.project.use_category = 'Research' THEN 1 ELSE 0 END) as totalResearchAssignments, + sum(CASE WHEN LOWER(a.project.use_category) = LOWER('Research') THEN 1 ELSE 0 END) as totalResearchAssignments, sum(CASE WHEN a.project.use_category = 'U42' THEN 1 ELSE 0 END) as isU42, sum(CASE WHEN a.project.use_category = 'U24' THEN 1 ELSE 0 END) as isU24 diff --git a/onprc_ehr/resources/queries/study/consortiumRawData.sql b/onprc_ehr/resources/queries/study/consortiumRawData.sql index 1870d8ba5..1cb5bb459 100644 --- a/onprc_ehr/resources/queries/study/consortiumRawData.sql +++ b/onprc_ehr/resources/queries/study/consortiumRawData.sql @@ -13,16 +13,16 @@ SELECT ELSE null END as isInfant, CASE - WHEN (t1.gender = 'm' AND t1.ageAtTime >= 4.0 ) THEN 1 + WHEN (LOWER(t1.gender) = LOWER('m') AND t1.ageAtTime >= 4.0 ) THEN 1 ELSE null END as isBreedingMale, CASE - WHEN (t1.gender = 'f' AND t1.ageAtTime >= 3.0 ) THEN 1 + WHEN (LOWER(t1.gender) = LOWER('f') AND t1.ageAtTime >= 3.0 ) THEN 1 ELSE null END as isBreedingFemale, CASE - WHEN (t1.gender = 'f' AND t1.ageAtTime >= 1.0 AND t1.ageAtTime < 3.0 ) THEN 1 - WHEN (t1.gender = 'm' AND t1.ageAtTime >= 1.0 AND t1.ageAtTime < 4.0 ) THEN 1 + WHEN (LOWER(t1.gender) = LOWER('f') AND t1.ageAtTime >= 1.0 AND t1.ageAtTime < 3.0 ) THEN 1 + WHEN (LOWER(t1.gender) = LOWER('m') AND t1.ageAtTime >= 1.0 AND t1.ageAtTime < 4.0 ) THEN 1 ELSE null END as isJuvenille @@ -61,7 +61,7 @@ SELECT group_concat(DISTINCT a.project.investigatorId.division, chr(10)) as divisions, count(a.lsid) as totalAssignments, sum(CASE WHEN (h.room.housingType.value = 'Cage Location' AND h.room.area != 'Hospital') THEN 1 ELSE 0 END) as isCaged, - sum(CASE WHEN a.project.use_category = 'Research' THEN 1 ELSE 0 END) as totalResearchAssignments, + sum(CASE WHEN LOWER(a.project.use_category) = LOWER('Research') THEN 1 ELSE 0 END) as totalResearchAssignments, sum(CASE WHEN a.project.use_category = 'U42' THEN 1 ELSE 0 END) as isU42, sum(CASE WHEN a.project.use_category = 'U24' THEN 1 ELSE 0 END) as isU24, group_concat(DISTINCT f.flag.value, chr(10)) as spfStatus diff --git a/onprc_ehr/resources/queries/study/demographicsActiveTreatments.sql b/onprc_ehr/resources/queries/study/demographicsActiveTreatments.sql index 9d7ae5904..4e150c44e 100644 --- a/onprc_ehr/resources/queries/study/demographicsActiveTreatments.sql +++ b/onprc_ehr/resources/queries/study/demographicsActiveTreatments.sql @@ -16,12 +16,12 @@ SELECT t.Id, count(t.Id) as totalTreatments, - COUNT(CASE WHEN t.category = 'Clinical' THEN 1 ELSE null END) as totalClinicalTreatments, + COUNT(CASE WHEN LOWER(t.category) = LOWER('Clinical') THEN 1 ELSE null END) as totalClinicalTreatments, COUNT(CASE WHEN t.category = 'Surgical' THEN 1 ELSE null END) as totalSurgicalTreatments, COUNT(CASE WHEN t.category = 'Research' THEN 1 ELSE null END) as totalResearchTreatments, GROUP_CONCAT(t.code.meaning, chr(10)) as activeTreatments, - GROUP_CONCAT(CASE WHEN t.category = 'Clinical' THEN t.code.meaning ELSE null END, chr(10)) as clinicalTreatments, + GROUP_CONCAT(CASE WHEN LOWER(t.category) = LOWER('Clinical') THEN t.code.meaning ELSE null END, chr(10)) as clinicalTreatments, GROUP_CONCAT(CASE WHEN t.category = 'Surgical' THEN t.code.meaning ELSE null END, chr(10)) as surgicalTreatments, GROUP_CONCAT(CASE WHEN t.category = 'Research' THEN t.code.meaning ELSE null END, chr(10)) as researchTreatments, diff --git a/onprc_ehr/resources/queries/study/demographicsCaseHistory.sql b/onprc_ehr/resources/queries/study/demographicsCaseHistory.sql index f5608792b..ad1222f8d 100644 --- a/onprc_ehr/resources/queries/study/demographicsCaseHistory.sql +++ b/onprc_ehr/resources/queries/study/demographicsCaseHistory.sql @@ -15,7 +15,7 @@ */ SELECT p.Id, - count(CASE WHEN p.category = 'Clinical' THEN 1 ELSE NULL END) as totalClinicalCases, + count(CASE WHEN LOWER(p.category) = LOWER('Clinical') THEN 1 ELSE NULL END) as totalClinicalCases, count(CASE WHEN p.category = 'Behavior' THEN 1 ELSE NULL END) as totalBehaviorCases, count(CASE WHEN p.category = 'Surgery' THEN 1 ELSE NULL END) as totalSurgeryCases, count(*) as totalCases diff --git a/onprc_ehr/resources/queries/study/demographicsCurrentRoommates.sql b/onprc_ehr/resources/queries/study/demographicsCurrentRoommates.sql index ccfc35576..39e71c438 100644 --- a/onprc_ehr/resources/queries/study/demographicsCurrentRoommates.sql +++ b/onprc_ehr/resources/queries/study/demographicsCurrentRoommates.sql @@ -26,6 +26,6 @@ LEFT JOIN ( ) h ON (h.id = d.id) -WHERE d.calculated_status='Alive' +WHERE LOWER(d.calculated_status)=LOWER('Alive') GROUP BY d.id diff --git a/onprc_ehr/resources/queries/study/demographicsDaysAlone.sql b/onprc_ehr/resources/queries/study/demographicsDaysAlone.sql index 362d8e893..565dfa5f9 100644 --- a/onprc_ehr/resources/queries/study/demographicsDaysAlone.sql +++ b/onprc_ehr/resources/queries/study/demographicsDaysAlone.sql @@ -47,6 +47,6 @@ LEFT JOIN study.Housing h2 ON ( AND h2.qcstate.publicdata = true ) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY h1.id, h1.room, h1.cage \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/demographicsInfantUnderOne.sql b/onprc_ehr/resources/queries/study/demographicsInfantUnderOne.sql index 945e70e88..17809193b 100644 --- a/onprc_ehr/resources/queries/study/demographicsInfantUnderOne.sql +++ b/onprc_ehr/resources/queries/study/demographicsInfantUnderOne.sql @@ -14,6 +14,6 @@ FROM study.Demographics d JOIN study.demographicsParents d2 ON (d.Id = d2.sire OR d.Id = d2.dam) -WHERE (d2.Id.age.ageInYears < 1.0) and d2.Id.demographics.calculated_status = 'Alive' +WHERE (d2.Id.age.ageInYears < 1.0) and LOWER(d2.Id.demographics.calculated_status) = LOWER('Alive') GROUP BY d.id diff --git a/onprc_ehr/resources/queries/study/demographicsLabwork.sql b/onprc_ehr/resources/queries/study/demographicsLabwork.sql index 27fd9b9ad..aee2f9921 100644 --- a/onprc_ehr/resources/queries/study/demographicsLabwork.sql +++ b/onprc_ehr/resources/queries/study/demographicsLabwork.sql @@ -18,11 +18,11 @@ SELECT max(CASE WHEN h.type = 'Hematology' THEN h.date ELSE null END) as lastHematologyDate, TIMESTAMPDIFF('SQL_TSI_DAY', max(CASE WHEN h.type = 'Hematology' THEN h.date ELSE null END), now()) as daysSinceCBCExam, - max(CASE WHEN h.type = 'Biochemistry' THEN h.date ELSE null END) as lastBiochemistryDate , - TIMESTAMPDIFF('SQL_TSI_DAY', max(CASE WHEN h.type = 'Biochemistry' THEN h.date ELSE null END), now()) as daysSinceCHEMExam + max(CASE WHEN LOWER(h.type) = LOWER('Biochemistry') THEN h.date ELSE null END) as lastBiochemistryDate , + TIMESTAMPDIFF('SQL_TSI_DAY', max(CASE WHEN LOWER(h.type) = LOWER('Biochemistry') THEN h.date ELSE null END), now()) as daysSinceCHEMExam FROM study.demographics d -LEFT JOIN study.clinpathRuns h ON (d.id = h.id AND (h.type = 'Hematology' OR h.type = 'Biochemistry') And h.QCState.label = 'Completed') -WHERE d.calculated_status = 'Alive' +LEFT JOIN study.clinpathRuns h ON (d.id = h.id AND (h.type = 'Hematology' OR LOWER(h.type) = LOWER('Biochemistry')) And h.QCState.label = 'Completed') +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.id diff --git a/onprc_ehr/resources/queries/study/demographicsMostRecentBCS.sql b/onprc_ehr/resources/queries/study/demographicsMostRecentBCS.sql index e6f6c4ece..d07cc3eca 100644 --- a/onprc_ehr/resources/queries/study/demographicsMostRecentBCS.sql +++ b/onprc_ehr/resources/queries/study/demographicsMostRecentBCS.sql @@ -14,13 +14,13 @@ join ( co.Id, max(co.date) as maxDate FROM study.clinical_observations co - WHERE co.qcstate.publicdata = true AND co.category = 'BCS' + WHERE co.qcstate.publicdata = true AND LOWER(co.category) = LOWER('BCS') GROUP BY co.Id ) co2 ON (co.Id = co2.Id AND co.date = co2.maxDate) -WHERE co.qcstate.publicdata = true AND co.category = 'BCS' +WHERE co.qcstate.publicdata = true AND LOWER(co.category) = LOWER('BCS') And co.observation = (Select Min(b1.observation) from study.clinical_observations b1 where b1.id =co.id -And co.date = b1.date and b1.category = 'bcs' and b1.observation is not null) +And co.date = b1.date and LOWER(b1.category) = LOWER('bcs') and b1.observation is not null) GROUP BY co.Id diff --git a/onprc_ehr/resources/queries/study/demographicsPE.sql b/onprc_ehr/resources/queries/study/demographicsPE.sql index 6fef74d4c..585d708d6 100644 --- a/onprc_ehr/resources/queries/study/demographicsPE.sql +++ b/onprc_ehr/resources/queries/study/demographicsPE.sql @@ -70,7 +70,7 @@ LEFT JOIN ( FROM study.clinpathRuns k WHERE (k.servicerequested = 'Basic Chemistry Panel' or k.servicerequested = 'Comprehensive Chemistry Panel') - And k.type = 'Biochemistry' + And LOWER(k.type) = LOWER('Biochemistry') And k.date in (select max(jj.date) from study.clinpathRuns jj Where ((jj.Id = k.Id) And (jj.servicerequested = 'Basic Chemistry Panel' or jj.servicerequested = 'Comprehensive Chemistry Panel')) ) GROUP BY k.Id, k.date, k.servicerequested ) k ON (k.Id = d.Id) @@ -78,6 +78,6 @@ LEFT JOIN ( -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.id, d.id.age.AgeInYears, g.date,g.p2,k.date, k.servicerequested \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/demographicsPaired.sql b/onprc_ehr/resources/queries/study/demographicsPaired.sql index 7f572f0b7..87b11afad 100644 --- a/onprc_ehr/resources/queries/study/demographicsPaired.sql +++ b/onprc_ehr/resources/queries/study/demographicsPaired.sql @@ -48,7 +48,7 @@ FROM study.housing h --NOTE: this filter is added because otherwise a monkey marked as dead (but still with a housing record) could be JOIN study.housing h2 -ON (h2.Id.demographics.calculated_status = 'Alive' AND h.room = h2.room and (h.effectiveCage.effectiveCage = h2.effectiveCage.effectiveCage OR (h.cage IS NULL and h2.cage IS NULL) OR (h.room.housingType.value != 'Cage Location' AND h.cage = h2.cage))) +ON (LOWER(h2.Id.demographics.calculated_status) = LOWER('Alive') AND h.room = h2.room and (h.effectiveCage.effectiveCage = h2.effectiveCage.effectiveCage OR (h.cage IS NULL and h2.cage IS NULL) OR (h.room.housingType.value != 'Cage Location' AND h.cage = h2.cage))) LEFT JOIN ehr_lookups.cage c ON (h.effectiveCage.effectiveCage = c.cage AND c.room = h.room) @@ -60,4 +60,4 @@ GROUP BY h.id, h.room, h.effectiveCage.effectiveCage, c.divider.countAsPaired, c ) t ON (t.id = d.id) -WHERE d.calculated_status = 'Alive' \ No newline at end of file +WHERE LOWER(d.calculated_status) = LOWER('Alive') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/demographicsReturnLocation.sql b/onprc_ehr/resources/queries/study/demographicsReturnLocation.sql index 22f3ca989..062c6150b 100644 --- a/onprc_ehr/resources/queries/study/demographicsReturnLocation.sql +++ b/onprc_ehr/resources/queries/study/demographicsReturnLocation.sql @@ -32,7 +32,7 @@ LEFT JOIN study.animal_group_members gm ON (d.Id = gm.Id AND gm.isActive = true) LEFT JOIN study.demographicsCurrentLocation cl ON (cl.Id = d.Id) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') ) t diff --git a/onprc_ehr/resources/queries/study/demographicsTermination.sql b/onprc_ehr/resources/queries/study/demographicsTermination.sql index 3811cdfdd..483af7d92 100644 --- a/onprc_ehr/resources/queries/study/demographicsTermination.sql +++ b/onprc_ehr/resources/queries/study/demographicsTermination.sql @@ -26,5 +26,5 @@ group_concat(DISTINCT f.flag.value) as flags FROM study.demographics d LEFT JOIN study.assignment a ON (a.id = d.id AND (a.releaseCondition.meaning = 'Terminal' OR a.projectedReleaseCondition.meaning = 'Terminal')) LEFT JOIN study.flags f ON (f.id = d.id AND f.isActive = true AND f.flag.category = 'Condition' AND f.flag.value in ('Clinically Restricted', 'Terminal')) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.id \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/demographicsTotalOffspring.sql b/onprc_ehr/resources/queries/study/demographicsTotalOffspring.sql index 92edf0c17..71517d364 100644 --- a/onprc_ehr/resources/queries/study/demographicsTotalOffspring.sql +++ b/onprc_ehr/resources/queries/study/demographicsTotalOffspring.sql @@ -8,7 +8,7 @@ SELECT d.id, group_concat(DISTINCT d2.id) as Offspring, count(DISTINCT d2.id) AS TotalOffspring, -SUM(CASE WHEN d2.calculated_status = 'Alive' THEN 1 ELSE 0 END) as TotalLivingOffspring, +SUM(CASE WHEN LOWER(d2.calculated_status) = LOWER('Alive') THEN 1 ELSE 0 END) as TotalLivingOffspring, min(d2.birth) as earliestBirth, max(d2.birth) as latestBirth diff --git a/onprc_ehr/resources/queries/study/demographicsTotalOffspringUnder1Yr.sql b/onprc_ehr/resources/queries/study/demographicsTotalOffspringUnder1Yr.sql index ff97129b1..c24f95e2e 100644 --- a/onprc_ehr/resources/queries/study/demographicsTotalOffspringUnder1Yr.sql +++ b/onprc_ehr/resources/queries/study/demographicsTotalOffspringUnder1Yr.sql @@ -14,7 +14,7 @@ FROM study.Demographics d JOIN study.demographicsParents d2 ON (d.Id = d2.sire OR d.Id = d2.dam) -WHERE d2.Id.age.ageInYears <= 1.0 and d2.Id.demographics.calculated_status = 'Alive' +WHERE d2.Id.age.ageInYears <= 1.0 and LOWER(d2.Id.demographics.calculated_status) = LOWER('Alive') GROUP BY d.id diff --git a/onprc_ehr/resources/queries/study/demographicsTreatmentsGiven.sql b/onprc_ehr/resources/queries/study/demographicsTreatmentsGiven.sql index b0567fa7c..46819d44f 100644 --- a/onprc_ehr/resources/queries/study/demographicsTreatmentsGiven.sql +++ b/onprc_ehr/resources/queries/study/demographicsTreatmentsGiven.sql @@ -20,7 +20,7 @@ SELECT count(t.Id) as totalTreatmentsGiven, COUNT(CASE WHEN t.category = 'Behavior' THEN 1 ELSE null END) as totalBehaviorTreatmentsGiven, - COUNT(CASE WHEN t.category = 'Clinical' THEN 1 ELSE null END) as totalClinicalTreatmentsGiven, + COUNT(CASE WHEN LOWER(t.category) = LOWER('Clinical') THEN 1 ELSE null END) as totalClinicalTreatmentsGiven, COUNT(CASE WHEN t.category = 'Surgical' THEN 1 ELSE null END) as totalSurgicalTreatmentsGiven, diff --git a/onprc_ehr/resources/queries/study/demographicsUtilization.sql b/onprc_ehr/resources/queries/study/demographicsUtilization.sql index a77a76fdd..24c9f524c 100644 --- a/onprc_ehr/resources/queries/study/demographicsUtilization.sql +++ b/onprc_ehr/resources/queries/study/demographicsUtilization.sql @@ -73,5 +73,5 @@ GROUP BY t.Id ) t1 ON (t1.Id = d.Id) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') diff --git a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql index eb70c2f1d..1f6693b5f 100644 --- a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql +++ b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql @@ -3,7 +3,7 @@ select dem.*, (select s.date from study.mostRecentClinicalObservationsForAnimal s where s.id = dem.id) as mostRecentClinicalObservationsdate, - ( select group_concat(DISTINCT 'BCS: ' || j.observation, chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and j.category = 'BCS' and j.date >= (select max(k.date) AS MaxDate + ( select group_concat(DISTINCT 'BCS: ' || j.observation, chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and LOWER(j.category) = LOWER('BCS') and j.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as mostRecentBCSScore, ( select group_concat(DISTINCT q.procedureid.name || ' : ' || q.remark , chr(10)) AS c from "Clinical Encounters" q where q.id = dem.id and q.type.value = 'Procedure' @@ -23,11 +23,11 @@ from study.demographics dem and cln.date >= (select max(r.date) AS MaxDate from "Clinical Observations" r where r.category = 'Vet Review' and r.QCState.Label = 'Completed' and r.Id = cln.Id) ) - Or dem.id in (Select cln.id from "Clinical Observations" cln where cln.category = 'BCS' and cln.observation is not null and cln.QCState.Label = 'Completed' + Or dem.id in (Select cln.id from "Clinical Observations" cln where LOWER(cln.category) = LOWER('BCS') and cln.observation is not null and cln.QCState.Label = 'Completed' and cln.date >= (select max(r.date) AS MaxDate from "Clinical Observations" r where r.category = 'Vet Review' and r.QCState.Label = 'Completed' and r.Id = cln.Id) ) - Or dem.id in (Select rem.id from "Clinical Remarks" rem where rem.category = 'Clinical' and rem.QCState.Label = 'Completed' + Or dem.id in (Select rem.id from "Clinical Remarks" rem where LOWER(rem.category) = LOWER('Clinical') and rem.QCState.Label = 'Completed' and rem.date >= (select max(r.date) AS MaxDate from "Clinical Observations" r where r.category = 'Vet Review' and r.QCState.Label = 'Completed' and rem.id = r.Id) ) diff --git a/onprc_ehr/resources/queries/study/demographicsViralStatus.sql b/onprc_ehr/resources/queries/study/demographicsViralStatus.sql index 95f851e79..fa43fba97 100644 --- a/onprc_ehr/resources/queries/study/demographicsViralStatus.sql +++ b/onprc_ehr/resources/queries/study/demographicsViralStatus.sql @@ -26,7 +26,7 @@ LEFT JOIN ( count(distinct f.flag.value) as total FROM study.flags f - WHERE f.isActive = true AND f.flag.category = 'SPF' and f.id.dataset.demographics.calculated_status = 'Alive' + WHERE f.isActive = true AND f.flag.category = 'SPF' and LOWER(f.id.dataset.demographics.calculated_status) = LOWER('Alive') GROUP BY f.id ) t ON (d.id = t.id) \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/dualassigned.sql b/onprc_ehr/resources/queries/study/dualassigned.sql index 48a02aa0c..896166bf1 100644 --- a/onprc_ehr/resources/queries/study/dualassigned.sql +++ b/onprc_ehr/resources/queries/study/dualassigned.sql @@ -4,55 +4,55 @@ a.id.demographics.gender, a.project as Project1, a2.project as Project2, Case - when a.project.use_category != 'Research' then a.project - when a2.project.use_category != 'Research' then a2.project + when LOWER(a.project.use_category) != LOWER('Research') then a.project + when LOWER(a2.project.use_category) != LOWER('Research') then a2.project else Null end as project, Case - when a.project.use_category != 'Research' then a.project.account.alias - when a2.project.use_category != 'Research' then a2.project.account.alias + when LOWER(a.project.use_category) != LOWER('Research') then a.project.account.alias + when LOWER(a2.project.use_category) != LOWER('Research') then a2.project.account.alias else Null end as projectAccount, Case - when a.project.use_category != 'Research' then a.project.displayname - when a2.project.use_category != 'Research' then a2.project.displayName + when LOWER(a.project.use_category) != LOWER('Research') then a.project.displayname + when LOWER(a2.project.use_category) != LOWER('Research') then a2.project.displayName else Null end as projectName, Case - when a.project.use_category != 'Research' then a.project.use_category - when a2.project.use_category != 'Research' then a2.project.use_category + when LOWER(a.project.use_category) != LOWER('Research') then a.project.use_category + when LOWER(a2.project.use_category) != LOWER('Research') then a2.project.use_category else Null end as projectCategory, --date should be the assignment date of the resource Case - when a.project.use_category != 'Research' then a.date - when a2.project.use_category != 'Research' then a2.date + when LOWER(a.project.use_category) != LOWER('Research') then a.date + when LOWER(a2.project.use_category) != LOWER('Research') then a2.date else Null end as date, Case - when a.project.use_category != 'Research' then a.projectedRelease - when a2.project.use_category != 'Research' then a2.projectedRelease + when LOWER(a.project.use_category) != LOWER('Research') then a.projectedRelease + when LOWER(a2.project.use_category) != LOWER('Research') then a2.projectedRelease else Null end as projectedRelease, Case - when a.project.use_category != 'Research' then a.enddate - when a2.project.use_category != 'Research' then a2.enddate + when LOWER(a.project.use_category) != LOWER('Research') then a.enddate + when LOWER(a2.project.use_category) != LOWER('Research') then a2.enddate else Null end as enddate, Case - when a.project.use_category != 'Research' then a.assignCondition - when a2.project.use_category != 'Research' then a2.assignCondition + when LOWER(a.project.use_category) != LOWER('Research') then a.assignCondition + when LOWER(a2.project.use_category) != LOWER('Research') then a2.assignCondition else Null end as assignCondition, Case - when a.project.use_category != 'Research' then a.projectedReleaseCondition - when a2.project.use_category != 'Research' then a2.projectedReleaseCondition + when LOWER(a.project.use_category) != LOWER('Research') then a.projectedReleaseCondition + when LOWER(a2.project.use_category) != LOWER('Research') then a2.projectedReleaseCondition else Null end as projectedReleaseCondition, @@ -61,38 +61,38 @@ Case --this places the research project as the Dual assigned Case - When a2.project.use_category = 'Research' then a2.project - when a.project.use_category = 'Research' then a.project + When LOWER(a2.project.use_category) = LOWER('Research') then a2.project + when LOWER(a.project.use_category) = LOWER('Research') then a.project Else Null ENd as DualAssignment, --a2.project as DualAssignment, Case - When a2.project.use_category = 'Research' then a2.project.displayName - when a.project.use_category = 'Research' then a.project.DisplayName + When LOWER(a2.project.use_category) = LOWER('Research') then a2.project.displayName + when LOWER(a.project.use_category) = LOWER('Research') then a.project.DisplayName Else Null ENd as DualName, --this places the research project as the Dual assigned Case - When a2.project.use_category = 'Research' then a2.project.use_category - when a.project.use_category = 'Research' then a.project.use_category + When LOWER(a2.project.use_category) = LOWER('Research') then a2.project.use_category + when LOWER(a.project.use_category) = LOWER('Research') then a.project.use_category Else Null ENd as DualProjectCategory, Case - When a2.project.use_category = 'Research' then a2.date - when a.project.use_category = 'Research' then a.date + When LOWER(a2.project.use_category) = LOWER('Research') then a2.date + when LOWER(a.project.use_category) = LOWER('Research') then a.date Else Null ENd as DualStartDate, Case - When a2.project.use_category = 'Research' then a2.projectedRelease - when a.project.use_category = 'Research' then a.projectedRelease + When LOWER(a2.project.use_category) = LOWER('Research') then a2.projectedRelease + when LOWER(a.project.use_category) = LOWER('Research') then a.projectedRelease Else Null ENd as DualProjectedRelease, Case - When a2.project.use_category = 'Research' then a2.enddate - when a.project.use_category = 'Research' then a.enddate + When LOWER(a2.project.use_category) = LOWER('Research') then a2.enddate + when LOWER(a.project.use_category) = LOWER('Research') then a.enddate Else Null ENd as DualEndDate @@ -101,4 +101,4 @@ Case FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.assignment a left outer join Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.assignment a2 on a.id = a2.id -where ( a.project <> a2.project) and a.project.use_category != 'Research' +where ( a.project <> a2.project) and LOWER(a.project.use_category) != LOWER('Research') diff --git a/onprc_ehr/resources/queries/study/kinshipAverage.sql b/onprc_ehr/resources/queries/study/kinshipAverage.sql index ec3067d98..ad6d6e1ae 100644 --- a/onprc_ehr/resources/queries/study/kinshipAverage.sql +++ b/onprc_ehr/resources/queries/study/kinshipAverage.sql @@ -16,9 +16,9 @@ SELECT t.Id, --NOTE: add 0.5 to include kinship with self - CAST((0.5 + coalesce(t.sumCoefficient, 0)) / (select count(*) as total from study.demographics d where d.calculated_status = 'Alive' and d.species = t.species) as double) as avgCoefficient, + CAST((0.5 + coalesce(t.sumCoefficient, 0)) / (select count(*) as total from study.demographics d where LOWER(d.calculated_status) = LOWER('Alive') and d.species = t.species) as double) as avgCoefficient, t.distinctAnimals, - (select count(*) as total from study.demographics d where d.calculated_status = 'Alive' and d.species = t.species) as totalInPopulation, + (select count(*) as total from study.demographics d where LOWER(d.calculated_status) = LOWER('Alive') and d.species = t.species) as totalInPopulation, t.species FROM ( @@ -30,10 +30,10 @@ SELECT count(k.Id2) as distinctAnimals FROM study.demographics d -JOIN study.demographics d2 ON (d2.calculated_status = 'Alive' and d.species = d2.species) +JOIN study.demographics d2 ON (LOWER(d2.calculated_status) = LOWER('Alive') and d.species = d2.species) LEFT JOIN ehr.kinshipSummary k ON (d.Id = k.Id AND d2.Id = k.Id2) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.Id diff --git a/onprc_ehr/resources/queries/study/medicalCullList.sql b/onprc_ehr/resources/queries/study/medicalCullList.sql index 5ff40c1d3..0b7f4cee5 100644 --- a/onprc_ehr/resources/queries/study/medicalCullList.sql +++ b/onprc_ehr/resources/queries/study/medicalCullList.sql @@ -19,4 +19,4 @@ f.date as dateAdded FROM study.demographics d JOIN study.flags f ON (d.id = f.id AND f.isActive = true AND f.flag.value = 'Clinically Restricted') -WHERE d.calculated_status = 'Alive' \ No newline at end of file +WHERE LOWER(d.calculated_status) = LOWER('Alive') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/pairingSeparations.sql b/onprc_ehr/resources/queries/study/pairingSeparations.sql index 4751bcc7f..09c7a2f85 100644 --- a/onprc_ehr/resources/queries/study/pairingSeparations.sql +++ b/onprc_ehr/resources/queries/study/pairingSeparations.sql @@ -22,7 +22,7 @@ SELECT FROM study.pairings p1 LEFT JOIN study.pairings p2 ON (p1.Id = p2.Id AND p2.date > p1.date) WHERE p1.eventType = 'Temporary separation' AND TIMESTAMPDIFF('SQL_TSI_DAY', p1.date, curdate()) > 7 AND p2.Id IS NULL -AND p1.Id.demographics.calculated_status = 'Alive' +AND LOWER(p1.Id.demographics.calculated_status) = LOWER('Alive') UNION ALL @@ -35,4 +35,4 @@ SELECT FROM study.pairings p1 LEFT JOIN study.pairings p2 ON (p1.Id = p2.Id AND p2.date > p1.date) WHERE p1.eventType = 'Extended temporary separation' AND TIMESTAMPDIFF('SQL_TSI_DAY', p1.date, curdate()) > 30 AND p2.Id IS NULL -AND p1.Id.demographics.calculated_status = 'Alive' \ No newline at end of file +AND LOWER(p1.Id.demographics.calculated_status) = LOWER('Alive') \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/pathAssignmentData.sql b/onprc_ehr/resources/queries/study/pathAssignmentData.sql index 66f5c17c8..d3d192377 100644 --- a/onprc_ehr/resources/queries/study/pathAssignmentData.sql +++ b/onprc_ehr/resources/queries/study/pathAssignmentData.sql @@ -1,8 +1,8 @@ SELECT Id, -- Id.demographics.gender as Sex, CASE - WHEN Id.demographics.gender = 'F' THEN 'Female' - WHEN Id.demographics.gender = 'M' THEN 'Male' + WHEN LOWER(Id.demographics.gender) = LOWER('F') THEN 'Female' + WHEN LOWER(Id.demographics.gender) = LOWER('M') THEN 'Male' ELSE 'Unknown' END AS Sex, Id.Age.ageinyearsrounded as AgeInYearsRounded, diff --git a/onprc_ehr/resources/queries/study/pregnancyChecks.sql b/onprc_ehr/resources/queries/study/pregnancyChecks.sql index b6f01d331..5aa18b60d 100644 --- a/onprc_ehr/resources/queries/study/pregnancyChecks.sql +++ b/onprc_ehr/resources/queries/study/pregnancyChecks.sql @@ -47,9 +47,9 @@ SELECT d.Id.activepregnancies.estDeliveryDate, d.Id.historicAnimalGroups.daysSinceLastAssignment FROM study.demographics d -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') AND d.Id.age.ageInYears >= 2.5 --greater than 2.5years - AND d.gender = 'F' + AND LOWER(d.gender) = LOWER('F') AND d.Id.activepregnancies.estDeliveryDate IS NULL AND d.Id.curlocation.area NOT IN ('Corral', 'Shelters', 'ASB ESPF', 'Catch Area', 'Harem') AND d.Id.curlocation.cage IS NOT NULL diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 3c7a8dd19..6cc43c825 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -336,13 +336,13 @@ LEFT JOIN ( p.id, max(p.date) as lastDate FROM study.flags p - WHERE p.flag.category ='Assign Alias' And p.flag.value = 'Assignment pool' + WHERE p.flag.category ='Assign Alias' And LOWER(p.flag.value) = LOWER('Assignment pool') And p.enddate is null GROUP BY p.id ) nts ON (nts.id = d.id) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') ) t \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/researchAssigned.sql b/onprc_ehr/resources/queries/study/researchAssigned.sql index 89ed53a48..915f5c67e 100644 --- a/onprc_ehr/resources/queries/study/researchAssigned.sql +++ b/onprc_ehr/resources/queries/study/researchAssigned.sql @@ -23,5 +23,5 @@ assignment.project, --assignment.project.use_category, v.userId.displayName as vetAssigned FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.assignment left outer join Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.onprc_ehr.Vet_Assignment v on assignment.project = v.project -where assignment.project.use_category = 'research' and enddate is null +where LOWER(assignment.project.use_category) = LOWER('research') and enddate is null group by assignment.Id,assignment.project,v.userId.displayName diff --git a/onprc_ehr/resources/queries/study/resourceAssigned.sql b/onprc_ehr/resources/queries/study/resourceAssigned.sql index a654a1e9d..c4d3a8f6a 100644 --- a/onprc_ehr/resources/queries/study/resourceAssigned.sql +++ b/onprc_ehr/resources/queries/study/resourceAssigned.sql @@ -23,5 +23,5 @@ assignment.project, --assignment.project.use_category, v.userId.displayName as vetAssigned FROM Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.study.assignment left outer join Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.onprc_ehr.Vet_Assignment v on assignment.project = v.project -where assignment.project.use_category != 'research' and enddate is null +where LOWER(assignment.project.use_category) != LOWER('research') and enddate is null group by assignment.id, assignment.project,v.userId.displayName diff --git a/onprc_ehr/resources/queries/study/surgeryChecklist.sql b/onprc_ehr/resources/queries/study/surgeryChecklist.sql index 352e6e584..bb409e45a 100644 --- a/onprc_ehr/resources/queries/study/surgeryChecklist.sql +++ b/onprc_ehr/resources/queries/study/surgeryChecklist.sql @@ -43,6 +43,6 @@ LEFT JOIN ( ) t ON (t.id = d.id) LEFT JOIN study.hematologyResults hr1 ON (hr1.id = d.id AND hr1.date = t.lastDate AND (hr1.testid = 'PLT' OR hr1.testid = 'HCT')) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') GROUP BY d.Id ) t \ No newline at end of file diff --git a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql index 4c868e5f8..610e72d7c 100644 --- a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql +++ b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql @@ -88,7 +88,7 @@ FROM study.demographics h JOIN ( ) s ) s ON (s.animalid = h.id) -WHERE h.calculated_status = 'Alive' +WHERE LOWER(h.calculated_status) = LOWER('Alive') --account for date/time in schedule --and s.date >= s.startDate and s.date <= s.enddate --Added the enddate = null clause by Kollil, 10/25/24. Refer to ticket #11471 diff --git a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql b/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql index f79d2d220..d498046f2 100644 --- a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql +++ b/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql @@ -34,6 +34,6 @@ FROM Study.Demographics AS Demographics LEFT JOIN CasesData ON Demographics.Id = CasesData.Id LEFT JOIN Study.Housing AS Housing ON Demographics.Id = Housing.Id LEFT JOIN Study.VetAssignment_projects AS AssignedProject ON Demographics.Id = AssignedProject.Id -WHERE Demographics.Calculated_Status = 'Alive' +WHERE LOWER(Demographics.Calculated_Status) = LOWER('Alive') AND NOT (LOWER(LEFT(Demographics.Id,1)) BETWEEN 'a' AND 'z') AND Housing.Enddate IS NULL \ No newline at end of file diff --git a/onprc_reports/resources/queries/study/processingGeneticsBloodDraws.sql b/onprc_reports/resources/queries/study/processingGeneticsBloodDraws.sql index 4c5867b54..a272651e2 100644 --- a/onprc_reports/resources/queries/study/processingGeneticsBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingGeneticsBloodDraws.sql @@ -46,7 +46,7 @@ SELECT WHEN (f.flags LIKE '%MHC Blood Draw Needed%') THEN 1 WHEN (f.flags LIKE '%MHC Typing Not Needed%') THEN 0 WHEN (f.flags LIKE '%MHC Blood Draw Collected%') THEN 0 - WHEN (d.species = 'RHESUS MACAQUE' AND d.Id.age.ageInYears <= 5.0 AND d.geographic_origin = 'India' AND m.Id IS NULL AND (a.Id IS NOT NULL OR d.gender = 'm' ) and u.id is null ) THEN 1 + WHEN (LOWER(d.species) = LOWER('RHESUS MACAQUE') AND d.Id.age.ageInYears <= 5.0 AND d.geographic_origin = 'India' AND m.Id IS NULL AND (a.Id IS NOT NULL OR LOWER(d.gender) = LOWER('m') ) and u.id is null ) THEN 1 WHEN (u.id is not Null) then 1 ELSE 0 END as mhcBloodDrawVol, @@ -113,7 +113,7 @@ LEFT JOIN ( GROUP BY s.subjectId, s.sampleType HAVING ( - (s.sampletype = 'Buffy coat' AND sum(coalesce(s.quantity, 0)) >= 5.0) OR + (LOWER(s.sampletype) = LOWER('Buffy coat') AND sum(coalesce(s.quantity, 0)) >= 5.0) OR (s.sampletype = 'Whole Blood' AND sum(coalesce(s.quantity, 0)) >= 5.0) ) ) t @@ -163,6 +163,6 @@ LEFT JOIN ( ) nts ON (nts.id = d.id) -WHERE d.calculated_status = 'Alive' +WHERE LOWER(d.calculated_status) = LOWER('Alive') ) t From e4fd7896dcaf6c8e4b0e67b2bcd78c8d44f1b31e Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Thu, 20 Aug 2026 09:35:05 -0700 Subject: [PATCH 07/11] fixes for query validations --- .../LeaseFee_UnitCost_RateCalc.sql | 2 +- .../clinPathRun_ExemptCharges.sql | 2 +- .../queries/onprc_billing/labworkFeeRates.sql | 2 +- .../queries/onprc_billing/leaseFees.sql | 4 +- .../onprc_billing/leasefee_rateData.sql | 2 +- .../onprc_billing/miscChargesWithRates.sql | 2 +- .../queries/onprc_billing/ogasynchIR.sql | 2 +- .../queries/onprc_billing/slaPerDiemRates.sql | 2 +- .../table/ONPRC_BillingCustomizer.java | 4 +- .../study/AssignmentPoolUnderTheAge.sql | 2 +- .../queries/study/AssignmentsUnderTheAge.sql | 4 +- .../onprc_ehr/table/ONPRC_EHRCustomizer.java | 39 ++++++++++++------- 12 files changed, 40 insertions(+), 27 deletions(-) diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql index 7958e085b..56687ed55 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql @@ -51,7 +51,7 @@ select '' as BirthType, 'automatic_adjustment' as AssignmentTypeNA, '' as DayLease, - '' as DayLeaseLength, --integer + CAST(null AS INTEGER) as DayLeaseLength, --integer; empty string here breaks the UNION with the numeric column above '' as MultipleAssignments, a.date, a.enddate as projectedrelease, diff --git a/onprc_billing/resources/queries/onprc_billing/clinPathRun_ExemptCharges.sql b/onprc_billing/resources/queries/onprc_billing/clinPathRun_ExemptCharges.sql index c71079dd5..366f27373 100644 --- a/onprc_billing/resources/queries/onprc_billing/clinPathRun_ExemptCharges.sql +++ b/onprc_billing/resources/queries/onprc_billing/clinPathRun_ExemptCharges.sql @@ -21,5 +21,5 @@ c.enteredSinceVetReview, c.QCState, c.objectID as sourceRecord, c.datefinalized as billingDate -FROM study.clinpathRuns c left outer join Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.lists.Labfee_NoChargeProjects p on c.project.DisplayName = p.project +FROM study.clinpathRuns c left outer join Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.lists.Labfee_NoChargeProjects p on c.project = p.project where (p.dateDisabled is null and p.project is Null) \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql b/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql index a6d6a4427..e78df48af 100644 --- a/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/labworkFeeRates.sql @@ -181,7 +181,7 @@ SELECT mc.item, mc.category, case - When mc.project.displayName in (Select project from Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.lists.LabFee_NoChargeProjects where enddate is null) + When mc.project in (Select project from Site.{substitutePath moduleProperty('ONPRC_Billing','BillingContainer')}.lists.LabFee_NoChargeProjects where enddate is null) then 0 else mc.unitcost End as unitCost, diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql index 4c7bc569d..04f012a44 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFees.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFees.sql @@ -163,8 +163,8 @@ SELECT a.releaseCondition, a.assignCondition, a.releaseType, - a.ageAtTime.AgeAtTimeYearsRounded as ageAtTime, ' ' as ESPFAnimal, + a.ageAtTime.AgeAtTimeYearsRounded as ageAtTime, '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, @@ -209,8 +209,8 @@ a.projectedReleaseCondition, a.releaseCondition, a.assignCondition, a.releaseType, -a.ageAtTime.AgeAtTimeYearsRounded as ageAtTime, a5.id as ESPFAnimal, +a.ageAtTime.AgeAtTimeYearsRounded as ageAtTime, 'Lease Fees' as category, --////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, diff --git a/onprc_billing/resources/queries/onprc_billing/leasefee_rateData.sql b/onprc_billing/resources/queries/onprc_billing/leasefee_rateData.sql index f3422d8b6..e138d2698 100644 --- a/onprc_billing/resources/queries/onprc_billing/leasefee_rateData.sql +++ b/onprc_billing/resources/queries/onprc_billing/leasefee_rateData.sql @@ -44,7 +44,7 @@ Case Else Null End as chargeID, --lf.chargeId, -Null as RevisedChargeID, +CAST(Null as Integer) as RevisedChargeID, --typed so PostgreSQL can join it to chargeRates.chargeId 1 as quantity diff --git a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql index 16437161b..d1d13d664 100644 --- a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql @@ -61,7 +61,7 @@ SELECT coalesce(p.creditedaccount, cu.account, ce.account) as creditAccount, CASE WHEN (cu.account IS NOT NULL) THEN 'Charge Unit' ELSE 'Chargeable Item' END as creditAccountType, - null as creditAccountId, + CAST(null AS INTEGER) as creditAccountId, --typed so the *Rates queries can UNION this with a real rowid coalesce(alias.investigatorId, p.project.investigatorId) as investigatorId, CASE --dont flag adjustments/reversals as exceptions diff --git a/onprc_billing/resources/queries/onprc_billing/ogasynchIR.sql b/onprc_billing/resources/queries/onprc_billing/ogasynchIR.sql index 10e966589..7bbf353fc 100644 --- a/onprc_billing/resources/queries/onprc_billing/ogasynchIR.sql +++ b/onprc_billing/resources/queries/onprc_billing/ogasynchIR.sql @@ -8,7 +8,7 @@ SELECT ogasynch.lastIndexed, ogasynch."OGA AWARD NUMBER", ogasynch."OGA AWARD TYPE", ogasynch."OGA PROJECT NUMBER", - ogasynch.ALIAS, + CAST(ogasynch.ALIAS AS VARCHAR(200)) AS ALIAS, --ogasynch stores the alias as an integer; aliases.alias is a varchar, and PostgreSQL will not compare the two implicitly ogasynch."ALIAS ENABLED FLAG", ogasynch."ALIAS ENABLED FLAG_MVIndicator", ogasynch.faRate, diff --git a/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql b/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql index f9c4a98aa..d14c82962 100644 --- a/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/slaPerDiemRates.sql @@ -97,7 +97,7 @@ SELECT ELSE null END as isExpiredAccount, CASE WHEN (TIMESTAMPDIFF('SQL_TSI_DAY', p.date, curdate()) > 45) THEN 'Y' ELSE null END as isOldCharge, - p.project as currentActiveAlias + CAST(p.project AS VARCHAR(200)) as currentActiveAlias FROM onprc_billing.slaPerDiems p diff --git a/onprc_billing/src/org/labkey/onprc_billing/table/ONPRC_BillingCustomizer.java b/onprc_billing/src/org/labkey/onprc_billing/table/ONPRC_BillingCustomizer.java index 804757c78..6e618887f 100644 --- a/onprc_billing/src/org/labkey/onprc_billing/table/ONPRC_BillingCustomizer.java +++ b/onprc_billing/src/org/labkey/onprc_billing/table/ONPRC_BillingCustomizer.java @@ -181,8 +181,8 @@ private void addTotalCost(AbstractTableInfo ti) if (ti.getColumn("totalCost") == null && unitCost != null && ti.getColumn("quantity") != null) { SQLFragment sql = new SQLFragment( - "CAST(ROUND((" + ExprColumn.STR_TABLE_ALIAS + ".unitCost * " + - ExprColumn.STR_TABLE_ALIAS + ".quantity), 2) AS DECIMAL(18,2))"); + "CAST(ROUND(CAST((" + ExprColumn.STR_TABLE_ALIAS + ".unitCost * " + + ExprColumn.STR_TABLE_ALIAS + ".quantity) AS DECIMAL(18,4)), 2) AS DECIMAL(18,2))"); ExprColumn totalCost = new ExprColumn( ti, "totalCost", diff --git a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql index 0cb7044d1..ee529b763 100644 --- a/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentPoolUnderTheAge.sql @@ -33,7 +33,7 @@ SELECT AND h.roommateEnd IS NULL AND h.roommateId IS NOT NULL AND d.enddate IS NULL - AND d.isActive = 1 + AND d.isActive = true AND d.project.displayname NOT IN ('0492-02', '0492-03') ) AS Cagemate_Assignments diff --git a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql index e6f0bb5ba..7f84fb2d7 100644 --- a/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql +++ b/onprc_ehr/resources/queries/study/AssignmentsUnderTheAge.sql @@ -37,7 +37,7 @@ AND h.roommateEnd IS NULL AND h.roommateId IS NOT NULL AND d.enddate IS NULL - AND d.isActive = 1 + AND d.isActive = true AND d.project.displayname NOT IN ('0492-02', '0492-03') ) AS Cagemate_Assignments @@ -46,7 +46,7 @@ WHERE a.Id.Age.ageinyears <= 3 AND LOWER(a.Id.demographics.species) = LOWER('Rhesus Macaque') AND a.enddate IS NULL - AND a.isActive = 1 + AND a.isActive = true AND a.project.displayname NOT IN ('0492-02', '0492-03') diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java b/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java index 7f95381d7..4d8d58579 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java @@ -468,10 +468,21 @@ else if (project.getJdbcType().getJavaClass().equals(String.class)) private void addNaturalSort(AbstractTableInfo ti, String columnName) { var column = ti.getMutableColumn(columnName); - if (column != null) + if (column == null) + return; + + //applyNaturalSort() throws on anything that is not a string. A table whose underlying database table is + //missing resolves its columns without a type, so one such table would otherwise take down every caller + //that enumerates this schema. Warn and skip instead - the missing table is the problem to chase. + if (!String.class.equals(column.getJavaClass())) { - LDKService.get().applyNaturalSort(ti, columnName); + _log.warn("Skipping natural sort on " + ti.getPublicSchemaName() + "." + ti.getName() + "." + columnName + + ": expected a string column but was " + column.getJavaClass().getSimpleName() + + ". This usually means the underlying table is missing from the database."); + return; } + + LDKService.get().applyNaturalSort(ti, columnName); } private void customizeDateColumn(AbstractTableInfo ti) @@ -1061,20 +1072,26 @@ private void customizeClinpathRunsTable(AbstractTableInfo ti) } - private void customizeTreatmentOrdersTable(AbstractTableInfo ti) + //treatment_times.time and treatment_frequency_times.hourofday are integers like 800 or 1600. Both are rendered as a + //zero-padded 4-character string so they sort correctly once group_concat'd. + private String getZeroPaddedTimeSql(AbstractTableInfo ti, String column) { - //for now, sqlserver only - if (!ti.getSqlDialect().isSqlServer()) - return; + if (ti.getSqlDialect().isSqlServer()) + return "REPLICATE('0', 4 - LEN(" + column + ")) + cast(" + column + " as varchar(4))"; + return "LPAD(CAST(" + column + " AS VARCHAR(4)), 4, '0')"; + } + + private void customizeTreatmentOrdersTable(AbstractTableInfo ti) + { String name = "treatmentTimes"; if (null == ti.getColumn(name) && null != ti.getColumn("objectid")) { SQLFragment sql = new SQLFragment("COALESCE(" + - "(SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment("REPLICATE('0', 4 - LEN(tt.time)) + cast(tt.time as varchar(4))"), true, false, getNewlineSql(ti)).getSqlCharSequence() + " as _expr " + + "(SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment(getZeroPaddedTimeSql(ti, "tt.time")), true, false, getNewlineSql(ti)).getSqlCharSequence() + " as _expr " + " FROM ehr.treatment_times tt " + " WHERE tt.treatmentId = " + ExprColumn.STR_TABLE_ALIAS + ".objectid)" + - ", (SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment("REPLICATE('0', 4 - LEN(ft.hourofday)) + cast(ft.hourofday as varchar(4))"), true, false, getNewlineSql(ti)).getSqlCharSequence() + " as _expr " + + ", (SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment(getZeroPaddedTimeSql(ti, "ft.hourofday")), true, false, getNewlineSql(ti)).getSqlCharSequence() + " as _expr " + " FROM ehr_lookups.treatment_frequency f " + " JOIN ehr_lookups.treatment_frequency_times ft ON (f.meaning = ft.frequency) WHERE f.rowid = " + ExprColumn.STR_TABLE_ALIAS + ".frequency)" + ", 'Custom')" @@ -1103,15 +1120,11 @@ private void customizeTreatmentOrdersTable(AbstractTableInfo ti) private void customizeTreatmentFrequency(AbstractTableInfo ti) { - //for now, sqlserver only - if (!ti.getSqlDialect().isSqlServer()) - return; - String name = "times"; ColumnInfo existing = ti.getColumn(name); if (null == existing && null != ti.getColumn("meaning")) { - SQLFragment sql = new SQLFragment("(SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment("REPLICATE('0', 4 - LEN(t.hourofday)) + cast(t.hourofday as varchar(4))"), true, true, ",").getSqlCharSequence() + + SQLFragment sql = new SQLFragment("(SELECT " + ti.getSqlDialect().getGroupConcat(new SQLFragment(getZeroPaddedTimeSql(ti, "t.hourofday")), true, true, ",").getSqlCharSequence() + "FROM ehr_lookups.treatment_frequency_times t " + " WHERE t.frequency = " + ExprColumn.STR_TABLE_ALIAS + ".meaning " + " GROUP BY t.frequency " + From 024d9166689626616b5202611b4e1a2875895af9 Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Thu, 20 Aug 2026 10:49:49 -0700 Subject: [PATCH 08/11] fixes more query validations --- .../queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql | 4 ++-- .../queries/onprc_billing/leaseFeeRates_2020.sql | 8 ++++---- .../queries/onprc_billing/leasefee_rateFunction.sql | 2 +- .../queries/onprc_billing/miscChargesWithRates.sql | 4 ++-- onprc_ehr/resources/queries/study/CMU_P2Review.sql | 4 ++-- .../queries/study/TreatmentSchedulePostOpFasts.sql | 2 +- .../queries/study/demographicsVetReviewObservation.sql | 6 +++--- .../queries/study/mostRecentObservationsForCase.sql | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql b/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql index 56687ed55..2aa73aa51 100644 --- a/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql +++ b/onprc_billing/resources/queries/onprc_billing/LeaseFee_UnitCost_RateCalc.sql @@ -28,7 +28,7 @@ SELECT d.Id, d.removesubsidy, d.canRaiseFA, r.ChargeID, --integer - RateCalc(d.alias,r.chargeID,d.project,d.Date,d.farate) as CalculatedRate, + RateCalc(d.alias,r.chargeID,d.project, CAST(d.Date AS DATE),d.farate) as CalculatedRate, r.revisedChargeID FROM Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.onprc_billing.leasefee_rateData r join @@ -67,7 +67,7 @@ select a.removeSubsidy as removesubsidy, a.canRaiseFA as canRaiseFA, a.leaseCharge1, --integer - RateCalc(a.alias,a.leasecharge2,a.projectID, a.date,a.farate) as RevisedRate, + RateCalc(a.alias,a.leasecharge2,a.projectID, CAST(a.date AS DATE),a.farate) as RevisedRate, a.leaseCharge2 FROM Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.onprc_billing.LeaseFeeReleaseAdjustment a \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/leaseFeeRates_2020.sql b/onprc_billing/resources/queries/onprc_billing/leaseFeeRates_2020.sql index 5be75f69e..11f42795a 100644 --- a/onprc_billing/resources/queries/onprc_billing/leaseFeeRates_2020.sql +++ b/onprc_billing/resources/queries/onprc_billing/leaseFeeRates_2020.sql @@ -37,7 +37,7 @@ SELECT d.Id, r.exemptionRate, r.Multiplier, r.subsidy, - RateCalc(r.AliasAtTime,r.chargeID,d.project,d.Date,.4) as CalculatedRate, + RateCalc(r.AliasAtTime,r.chargeID,d.project, CAST(d.Date AS DATE),.4) as CalculatedRate, null as revisedRate, r.revisedChargeID, r.revisedSubsidy @@ -63,7 +63,7 @@ select '' as BirthType, 'automatic_adjustment' as AssignmentTypeNA, '' as DayLease, - '' as DayLeaseLength, --integer + CAST(null AS INTEGER) as DayLeaseLength, --integer; empty string here breaks the UNION with the numeric column above '' as MultipleAssignments, null as dualassignment, null as creditto, @@ -86,8 +86,8 @@ select null as exemptionRate, null as Multiplier, null as subsidy, - RateCalc(a.alias,a.leasecharge1,a.projectID, a.date,a.farate) as CalculatedRate, - RateCalc(a.alias,a.leasecharge2,a.projectID, a.date,a.farate) as RevisedRate, + RateCalc(a.alias,a.leasecharge1,a.projectID, CAST(a.date AS DATE),a.farate) as CalculatedRate, + RateCalc(a.alias,a.leasecharge2,a.projectID, CAST(a.date AS DATE),a.farate) as RevisedRate, a.leaseCharge2, null as RevisedSubsidy diff --git a/onprc_billing/resources/queries/onprc_billing/leasefee_rateFunction.sql b/onprc_billing/resources/queries/onprc_billing/leasefee_rateFunction.sql index af90ffd4b..f118bd3af 100644 --- a/onprc_billing/resources/queries/onprc_billing/leasefee_rateFunction.sql +++ b/onprc_billing/resources/queries/onprc_billing/leasefee_rateFunction.sql @@ -19,7 +19,7 @@ t.faRate, t.removesubsidy, t.canRaiseFA, -RateCalc(c.alias,c.chargeID,c.projectID,c.assignmentDate,t.farate) as CalculatedRate +RateCalc(c.alias,c.chargeID,c.projectID, CAST(c.assignmentDate AS DATE),t.farate) as CalculatedRate FROM Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.onprc_Billing.leasefee_RateData c left join Site.{substitutePath moduleProperty('onprc_billing','BillingContainer')}.onprc_Billing.chargeRates r diff --git a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql index d1d13d664..12635ffd0 100644 --- a/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql +++ b/onprc_billing/resources/queries/onprc_billing/miscChargesWithRates.sql @@ -14,12 +14,12 @@ SELECT p.unitCost as MCEnteredUnitCost, case WHen p.unitCost is NOT NULL then p.unitCost - When RateCalc(p.debitedaccount,p.chargeID,p.project,p.Date,alias.farate) Is Not Null then RateCalc(p.debitedaccount,p.chargeID,p.project,p.Date,alias.farate) + When RateCalc(p.debitedaccount,p.chargeID,p.project, CAST(p.Date AS DATE),alias.farate) Is Not Null then RateCalc(p.debitedaccount,p.chargeID,p.project, CAST(p.Date AS DATE),alias.farate) Else cr.unitcost ENd as RateCalc, case WHen p.unitCost is NOT NULL then 'Misc Rate Entered' - When RateCalc(p.debitedaccount,p.chargeID,p.project,p.Date,alias.farate) Is Not Null then 'Rate Calc Function' + When RateCalc(p.debitedaccount,p.chargeID,p.project, CAST(p.Date AS DATE),alias.farate) Is Not Null then 'Rate Calc Function' else 'Passed Thru to Cr UnitCost' ENd as RateMethod, round(CAST(CASE diff --git a/onprc_ehr/resources/queries/study/CMU_P2Review.sql b/onprc_ehr/resources/queries/study/CMU_P2Review.sql index 131617c35..4b9512c6f 100644 --- a/onprc_ehr/resources/queries/study/CMU_P2Review.sql +++ b/onprc_ehr/resources/queries/study/CMU_P2Review.sql @@ -2,10 +2,10 @@ SELECT c.Id, c.date, c.p2, - (select group_concat(c4.p2, char(10)) AS p2 from clinremarks c4 where c4.id = c.id and c4.date in (Select max(c3.date) AS MaxDate from Clinremarks c3 where c3.id = c.id + (select group_concat(c4.p2, chr(10)) AS p2 from clinremarks c4 where c4.id = c.id and c4.date in (Select max(c3.date) AS MaxDate from Clinremarks c3 where c3.id = c.id and c3.date <> c.date and c3.p2 <> '' group by c3.id, c3.date order by date desc limit 1) ) as secondp2, c.remark, - (select group_concat(f1.flag.value, char(10)) AS v from flags f1 where f1.id = c.id And f1.flag.category = 'Alert' And f1.enddate is null) as alertflag, + (select group_concat(f1.flag.value, chr(10)) AS v from flags f1 where f1.id = c.id And f1.flag.category = 'Alert' And f1.enddate is null) as alertflag, c.history FROM clinremarks c diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql index b993fd41e..4ca5a9b7e 100644 --- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql +++ b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOpFasts.sql @@ -36,7 +36,7 @@ From encounters e, ehr.requests r Where e.requestid = r.requestid And procedureid in (1804,1807,2440, 3089) -- get these procedures only -And (date < cast(TimeStampAdd('SQL_TSI_DAY',1,cast(cast(now() as date) as varchar(30)) || ' ' || '08:00') as TIMESTAMP) +And (date < cast(TimeStampAdd('SQL_TSI_DAY',1,cast(cast(cast(now() as date) as varchar(30)) || ' ' || '08:00' as TIMESTAMP)) as TIMESTAMP) And date > cast(cast(cast(now() as date) as varchar(30)) || ' ' || '16:00' as TIMESTAMP) ) ---Between 4pm thru 8am And instructions not in ('Lab staff will pull chow and wash caging') And LOWER(type) = LOWER('Procedure') diff --git a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql index 1f6693b5f..37f304ebc 100644 --- a/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql +++ b/onprc_ehr/resources/queries/study/demographicsVetReviewObservation.sql @@ -3,14 +3,14 @@ select dem.*, (select s.date from study.mostRecentClinicalObservationsForAnimal s where s.id = dem.id) as mostRecentClinicalObservationsdate, - ( select group_concat(DISTINCT 'BCS: ' || j.observation, chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and LOWER(j.category) = LOWER('BCS') and j.date >= (select max(k.date) AS MaxDate + ( select group_concat(DISTINCT ('BCS: ' || j.observation), chr(10)) AS c from "Clinical Observations" j where j.id = dem.id and LOWER(j.category) = LOWER('BCS') and j.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as mostRecentBCSScore, - ( select group_concat(DISTINCT q.procedureid.name || ' : ' || q.remark , chr(10)) AS c from "Clinical Encounters" q where q.id = dem.id and q.type.value = 'Procedure' + ( select group_concat(DISTINCT (q.procedureid.name || ' : ' || q.remark), chr(10)) AS c from "Clinical Encounters" q where q.id = dem.id and q.type.value = 'Procedure' and q.procedureid.name in ('Ultrasound','Ultrasound - Ovaries','Ultrasound - Pregnancy', 'Ultrasound - Uterus','Dental prophylaxis','Palpation, bimanual') and q.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as mostRecentProcedure, - ( select group_concat(DISTINCT 'Observations: ' || t.remark, chr(10)) AS c from "Clinical Observations" t where t.id = dem.id and t.category = 'Observations' and t.remark is not null and t.date >= (select max(k.date) AS MaxDate + ( select group_concat(DISTINCT ('Observations: ' || t.remark), chr(10)) AS c from "Clinical Observations" t where t.id = dem.id and t.category = 'Observations' and t.remark is not null and t.date >= (select max(k.date) AS MaxDate from "Clinical Observations" k where k.category = 'Vet Review' and dem.id = k.Id) ) as observationremarks, ( select group_concat(DISTINCT s.remark, chr(10)) AS c from "Clinical Remarks" s where s.id = dem.id and s.date >= (select max(k.date) AS MaxDate diff --git a/onprc_ehr/resources/queries/study/mostRecentObservationsForCase.sql b/onprc_ehr/resources/queries/study/mostRecentObservationsForCase.sql index 85e54ffbe..4255aaed8 100644 --- a/onprc_ehr/resources/queries/study/mostRecentObservationsForCase.sql +++ b/onprc_ehr/resources/queries/study/mostRecentObservationsForCase.sql @@ -70,7 +70,7 @@ SELECT MAX(date) AS latest_date, GROUP_CONCAT( CAST(observation_string AS VARCHAR(1000)), - CHAR(10) + CHR(10) ) AS observations FROM ObservationStrings GROUP BY Id, caseid \ No newline at end of file From e42f6de2accebc81f59521a0ee97e78df3afdddc Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Thu, 20 Aug 2026 14:28:41 -0700 Subject: [PATCH 09/11] fix date formatting issues --- .../resources/web/onprc_billing/window/ReverseChargeWindow.js | 2 +- .../resources/web/onprc_ehr/model/sources/ARTCore_Services.js | 2 +- .../resources/web/onprc_ehr/model/sources/PMIC_Services.js | 2 +- onprc_ehr/resources/web/onprc_ehr/panel/AnimalDetailsPanel.js | 2 +- onprc_ehr/resources/web/onprc_ehr/panel/SnapshotPanel.js | 4 ++-- onprc_ehr/resources/web/onprc_ehr/window/SedationWindow.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js b/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js index 5691d0a26..6481080b1 100644 --- a/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js +++ b/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js @@ -286,7 +286,7 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { displayField: 'account', valueField: 'account', listConfig: { - innerTpl: '{[LABKEY.Utils.encodeHtml(values["account"] + (values["account"] == "Other" ? "" : " (" + (values["startdate"] ? values["startdate"].format("Y-m-d") : "No Start") + " - " + (values["enddate"] ? values["enddate"].format("Y-m-d") : "No End") + ")"))]}', + innerTpl: '{[LABKEY.Utils.encodeHtml(values["account"] + (values["account"] == "Other" ? "" : " (" + (values["startdate"] ? Ext4.Date.format(values["startdate"], "Y-m-d") : "No Start") + " - " + (values["enddate"] ? Ext4.Date.format(values["enddate"], "Y-m-d") : "No End") + ")"))]}', getInnerTpl: function(){ return this.innerTpl; } diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/ARTCore_Services.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/ARTCore_Services.js index 5e63c0344..fae5795f5 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/ARTCore_Services.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/ARTCore_Services.js @@ -22,7 +22,7 @@ EHR.model.DataModelManager.registerMetadata('ARTCore_Services', { date: { xtype: 'xdatetime', extFormat: 'Y-m-d H:i', - defaultValue: (new Date()).format('Y-m-d 8:0') + defaultValue: Ext4.Date.format(new Date(), 'Y-m-d 8:0') }, type: { defaultValue: 'Procedure', diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_Services.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_Services.js index 6b09a5c99..c2d5ae9d9 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_Services.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/PMIC_Services.js @@ -16,7 +16,7 @@ EHR.model.DataModelManager.registerMetadata('PMIC_Services', { date: { xtype: 'xdatetime', extFormat: 'Y-m-d H:i', - defaultValue: (new Date()).format('Y-m-d 8:0') + defaultValue: Ext4.Date.format(new Date(), 'Y-m-d 8:0') }, type: { defaultValue: 'Procedure', diff --git a/onprc_ehr/resources/web/onprc_ehr/panel/AnimalDetailsPanel.js b/onprc_ehr/resources/web/onprc_ehr/panel/AnimalDetailsPanel.js index f4160ebf5..e8fdc88b2 100644 --- a/onprc_ehr/resources/web/onprc_ehr/panel/AnimalDetailsPanel.js +++ b/onprc_ehr/resources/web/onprc_ehr/panel/AnimalDetailsPanel.js @@ -269,7 +269,7 @@ Ext4.define('ONPRC_EHR.panel.AnimalDetailsPanel', { interval = interval + ' days ago'; } - text = row.weight + ' kg, ' + date.format(LABKEY.extDefaultDateFormat) + (!Ext4.isEmpty(interval) ? ' (' + interval + ')' : ''); + text = row.weight + ' kg, ' + Ext4.Date.format(date, LABKEY.extDefaultDateFormat) + (!Ext4.isEmpty(interval) ? ' (' + interval + ')' : ''); } toSet['weights'] = text; diff --git a/onprc_ehr/resources/web/onprc_ehr/panel/SnapshotPanel.js b/onprc_ehr/resources/web/onprc_ehr/panel/SnapshotPanel.js index 5037999bb..5cf83c62b 100644 --- a/onprc_ehr/resources/web/onprc_ehr/panel/SnapshotPanel.js +++ b/onprc_ehr/resources/web/onprc_ehr/panel/SnapshotPanel.js @@ -445,7 +445,7 @@ Ext4.define('onprc_ehr.panel.SnapshotPanel', { var score4 = results[0].duration; - var text = ' ' + score3 + ' / ' + score1.format('Y-m-d') + ' (' + score4 + ' days ago) at ' + score2 + ' kg' ; + var text = ' ' + score3 + ' / ' + Ext4.Date.format(score1, 'Y-m-d') + ' (' + score4 + ' days ago) at ' + score2 + ' kg' ; toSet['bcsScore'] = text; } @@ -685,7 +685,7 @@ Ext4.define('onprc_ehr.panel.SnapshotPanel', { if (this.showLocationDuration && housingRow.date){ var date = LDK.ConvertUtils.parseDate(housingRow.date); if (date) - location += ' (' + date.format(LABKEY.extDefaultDateFormat) + ')'; + location += ' (' + Ext4.Date.format(date, LABKEY.extDefaultDateFormat) + ')'; } } } diff --git a/onprc_ehr/resources/web/onprc_ehr/window/SedationWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/SedationWindow.js index 6afecefb4..771128c34 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/SedationWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/SedationWindow.js @@ -200,7 +200,7 @@ Ext4.define('EHR.window.SedationWindow', { if (!minDate || date < minDate) minDate = date; - dates.push(date.format(LABKEY.extDefaultDateTimeFormat)); + dates.push(Ext4.Date.format(date, LABKEY.extDefaultDateTimeFormat)); }, this); items.push({ From f42ec819ef39c2b17869eded3396ebb574669ecf Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Thu, 20 Aug 2026 17:17:44 -0700 Subject: [PATCH 10/11] skip jhu notification --- .../src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java index e8c58b0ef..a5e445209 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java @@ -1382,7 +1382,9 @@ public void testNotifications() //iterate all notifications and run them. log("running all notifications"); - List skippedNotifications = Arrays.asList("ETL Validation Notification", "Billing Validation Notification", "Pregnant NHPs Gestation Notification"); //Skip "Billing Validation Notification" - this is broken on the server and not been run successfully by the client. + //Skip "Billing Validation Notification" - this is broken on the server and not been run successfully by the client. + List skippedNotifications = Arrays.asList("ETL Validation Notification", "Billing Validation Notification", + "Pregnant NHPs Gestation Notification", "JHU Dog Cage Size Notification"); int count = Locator.tagContainingText("a", "Run Report In Browser").findElements(getDriver()).size(); for (int i = 0; i < count; i++) From a124c593dbb09aeeb9d4fe15bb52b278360ccc87 Mon Sep 17 00:00:00 2001 From: ankurjuneja Date: Fri, 21 Aug 2026 16:38:45 -0700 Subject: [PATCH 11/11] fix trigger script failure --- .../resources/scripts/onprc_ehr/onprc_triggers.js | 13 +++++++++++++ .../labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java | 3 +-- .../labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java | 13 +++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js index 51e4b53e8..152bc53d5 100644 --- a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js +++ b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js @@ -136,6 +136,19 @@ exports.init = function(EHR){ }); }); + //Set explicitly so a module-level allowDatesInDistantPast=true cannot downgrade this WARN to INFO. + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'departure', function(event, helper){ + helper.setScriptOptions({ + allowDatesInDistantPast: false + }); + }); + + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'housing', function(event, helper){ + helper.setScriptOptions({ + allowDatesInDistantPast: false + }); + }); + //Added: 8-1-2019 R.Blasa EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'birth', function(event, helper){ //NOTE: births are sometimes not entered until processing, meaning they could be significantly in the past diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java index a5e445209..0c9a14a9f 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest.java @@ -1383,8 +1383,7 @@ public void testNotifications() //iterate all notifications and run them. log("running all notifications"); //Skip "Billing Validation Notification" - this is broken on the server and not been run successfully by the client. - List skippedNotifications = Arrays.asList("ETL Validation Notification", "Billing Validation Notification", - "Pregnant NHPs Gestation Notification", "JHU Dog Cage Size Notification"); + List skippedNotifications = Arrays.asList("ETL Validation Notification", "Billing Validation Notification", "Pregnant NHPs Gestation Notification"); int count = Locator.tagContainingText("a", "Run Report In Browser").findElements(getDriver()).size(); for (int i = 0; i < count; i++) diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java index 7b0c7fffb..8c25e4b5b 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java @@ -65,6 +65,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -1076,12 +1077,12 @@ public void testFormTriggers() createAnimal(); markDead(deadAnimal); - Map> formsToTest = Map.of( - "Birth", Map.of("gridToTest", "Births", "allowDatesInDistantPast", "true", "allowDeadIds", "true", "allowAnyId", "true"), - "Death", Map.of("gridToTest", "Deaths", "allowDatesInDistantPast", "true", "allowDeadIds", "false", "allowAnyId", "false"), - "Arrival", Map.of("gridToTest", "Arrivals", "allowDatesInDistantPast", "true", "allowDeadIds", "true", "allowAnyId", "true"), - "Departure", Map.of("gridToTest", "Departures", "allowDatesInDistantPast", "false", "allowDeadIds", "false", "allowAnyId", "false"), - "Housing Transfers", Map.of("gridToTest", "Housing Transfers", "allowDatesInDistantPast", "false", "allowDeadIds", "false", "allowAnyId", "false")); + Map> formsToTest = new LinkedHashMap<>(); + formsToTest.put("Birth", Map.of("gridToTest", "Births", "allowDatesInDistantPast", "true", "allowDeadIds", "true", "allowAnyId", "true")); + formsToTest.put("Death", Map.of("gridToTest", "Deaths", "allowDatesInDistantPast", "true", "allowDeadIds", "false", "allowAnyId", "false")); + formsToTest.put("Arrival", Map.of("gridToTest", "Arrivals", "allowDatesInDistantPast", "true", "allowDeadIds", "true", "allowAnyId", "true")); + formsToTest.put("Departure", Map.of("gridToTest", "Departures", "allowDatesInDistantPast", "false", "allowDeadIds", "false", "allowAnyId", "false")); + formsToTest.put("Housing Transfers", Map.of("gridToTest", "Housing Transfers", "allowDatesInDistantPast", "false", "allowDeadIds", "false", "allowAnyId", "false")); goToEHRFolder(); clickAndWait(Locator.linkWithText("Enter Data / Task Review"));