Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GeneticsCore/resources/queries/study/dnaFlagSummary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion GeneticsCore/resources/queries/study/mhcFlagSummary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
select value from ehr_complianceDB.Compliance_Reference_Data
where columnName = 'employeeHost'
where LOWER(columnName) = LOWER('employeeHost')
And endDate is null
Original file line number Diff line number Diff line change
Expand Up @@ -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()) ))

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ SELECT a.alias,
a.FUndingSourceName,
a.Org
FROM aliases a
where aliasEnabled = 'y'
where LOWER(aliasEnabled) = LOWER('y')
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]%'
AND a2.id IS NULL and NOT (LOWER(LEFT(a.participantID,1)) BETWEEN 'a' AND 'z')
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]%'
and NOT (LOWER(LEFT(a.id,1)) BETWEEN 'a' AND 'z')
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 --------------------------------------------------------------------------------------------------------
Expand All @@ -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-------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions onprc_billing/resources/queries/onprc_billing/leaseFees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading