From 3fa66713beb2ea054ee27556045b169b91e05476 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Fri, 6 Mar 2026 23:28:05 -0800 Subject: [PATCH 01/18] Modified Blood Processing with latest most recent criteria for drawing blood. --- .../queries/study/processingSerology.sql | 27 +++++++++++++++++++ .../study/processingBloodDraws.query.xml | 3 +++ .../queries/study/processingBloodDraws.sql | 5 ++++ 3 files changed, 35 insertions(+) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 20ebcb2e7..980ffbe05 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -36,6 +36,11 @@ SELECT ELSE 0 END as PCRbloodVol, + CASE + WHEN (t.isESPFRequired = true AND t.isESPFCurrent = false AND ) THEN 4 + ELSE 0 + END as ESPFbloodVol, + FROM ( @@ -66,6 +71,18 @@ SELECT ELSE false END as isPCRRequired + espf.lastDate as lastESPF, + timestampdiff('SQL_TSI_DAY', espf.lastDate, now()) as daysSinceESPF, + CASE + WHEN (year(now()) = year(espf.lastDate) AND daysSinceESPF < 180) THEN true + ELSE false + END as isESPFCurrent, + + CASE + WHEN (d.Id.age.ageInDays > 180 ) THEN true + ELSE false + END as isESPFRequired + FROM study.demographics d LEFT JOIN ( @@ -78,6 +95,16 @@ LEFT JOIN ( ) srv ON (srv.id = d.id) +LEFT JOIN ( + SELECT + k.id, + max(k.date) as lastDate + FROM study.blood k + WHERE (k.additionalservices = 'ESPF Surveillance - Semiannual') + GROUP BY k.id + +) espf ON (espf.id = d.id) + LEFT JOIN ( SELECT b.id, diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml index 32b18373b..4cf1cc926 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml +++ b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml @@ -28,6 +28,9 @@ Serology RTT (mL) + + Serology RTT (mL) + Genetics Blood Vol (mL) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 68eedb48e..a67fc0762 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -9,6 +9,11 @@ SELECT 0 End as PCRBloodVolume, + Case when (a.Id IS NOT NULL) And (s.ESPFBloodVol > 0 ) then 2 + ELSE + 0 + End as PCRBloodVolume, + s.srvBloodVol as serologyBloodVol, g.parentageBloodDrawVol, g.mhcBloodDrawVol, From 17c47964e8208a14cb143b08703b76783496c4ff Mon Sep 17 00:00:00 2001 From: ohsudev Date: Fri, 6 Mar 2026 23:31:56 -0800 Subject: [PATCH 02/18] Modified Blood Processing with latest most recent criteria for drawing blood. --- onprc_reports/resources/queries/study/processingBloodDraws.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index a67fc0762..0a1e3abff 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -12,7 +12,7 @@ SELECT Case when (a.Id IS NOT NULL) And (s.ESPFBloodVol > 0 ) then 2 ELSE 0 - End as PCRBloodVolume, + End as ESPFloodVolume, s.srvBloodVol as serologyBloodVol, g.parentageBloodDrawVol, From 326b5bd29da77f168a28be87922160c4b205bb6d Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 9 Mar 2026 09:18:40 -0700 Subject: [PATCH 03/18] Modified Blood Processing with latest most recent criteria for drawing blood. --- .../queries/study/processingSerology.sql | 45 ++++++++++++++++++- .../queries/study/processingBloodDraws.sql | 5 +-- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 980ffbe05..4b6a372f2 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -41,7 +41,6 @@ SELECT ELSE 0 END as ESPFbloodVol, - FROM ( SELECT @@ -74,7 +73,7 @@ SELECT espf.lastDate as lastESPF, timestampdiff('SQL_TSI_DAY', espf.lastDate, now()) as daysSinceESPF, CASE - WHEN (year(now()) = year(espf.lastDate) AND daysSinceESPF < 180) THEN true + WHEN (year(now()) = year(espf.lastDate) AND daysSinceESPF > 180) THEN true ELSE false END as isESPFCurrent, @@ -83,6 +82,18 @@ SELECT ELSE false END as isESPFRequired + cbc.lastDate as lastESPF, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSincCBC, + CASE + WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC > 165) THEN true + ELSE false + END as isCBCCurrent, + + CASE + WHEN (d.Id.age.ageInDays > 180 ) THEN true + ELSE false + END as isCBCRequired + FROM study.demographics d LEFT JOIN ( @@ -115,6 +126,36 @@ LEFT JOIN ( ) pcr ON (pcr.id = d.id) +LEFT JOIN ( + SELECT + j.id, + max(j.date) as lastDate + FROM study.blood j + WHERE j.additionalservices like 'CBC with automated differential' + GROUP BY j.id + +) cbc ON (cbc.id = d.id) + +LEFT JOIN ( + SELECT + m.id, + max(m.date) as lastDate + FROM study.blood m + WHERE j.additionalservices like 'Comprehensive Chemistry panel in-house' + GROUP BY m.id + +) chem ON (chem.id = d.id) + +LEFT JOIN ( + SELECT + n.id, + max(n.date) as lastDate + FROM study.flags n + WHERE n.category ='Behavior Flag' And n.value = 'Socially important' + GROUP BY n.id + +) flg ON (flg.id = d.id) + WHERE d.calculated_status = 'Alive' diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 0a1e3abff..422c53150 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -9,12 +9,9 @@ SELECT 0 End as PCRBloodVolume, - Case when (a.Id IS NOT NULL) And (s.ESPFBloodVol > 0 ) then 2 - ELSE - 0 - End as ESPFloodVolume, s.srvBloodVol as serologyBloodVol, + s.ESPFBloodVol as ESPFBloodVol, g.parentageBloodDrawVol, g.mhcBloodDrawVol, g.dnaBloodDrawVol, From f53ea8ac4ea06f8d1edb7cec129551d94aa41114 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 14:31:14 -0700 Subject: [PATCH 04/18] Modified blood Processing program. --- .../queries/study/processingSerology.sql | 112 ++++++++++++++++-- 1 file changed, 103 insertions(+), 9 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 4b6a372f2..3aaa419e1 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -72,27 +72,97 @@ SELECT espf.lastDate as lastESPF, timestampdiff('SQL_TSI_DAY', espf.lastDate, now()) as daysSinceESPF, - CASE + CASE WHEN (year(now()) = year(espf.lastDate) AND daysSinceESPF > 180) THEN true ELSE false END as isESPFCurrent, - CASE + CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false END as isESPFRequired - cbc.lastDate as lastESPF, - timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSincCBC, + + ------ All CBC Sections + + cbc.lastDate as lastCBC1, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC1, + CASE + WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC1 > 165 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + ELSE false + END as isCBCCurrent1, + CASE - WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC > 165) THEN true + WHEN (d.Id.age.ageInDays > 20 ) THEN true + ELSE false + END as isCBCRequired1 + + cbc.lastDate as lastCBC2, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC2, + CASE + WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC2 > 340 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true + ELSE false + END as isCBCCurrent2, + + CASE + WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isCBCCurrent, + END as isCBCRequired2 + + cbc.lastDate as lastCBC3, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC3, + CASE + WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC3 > 340 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + ELSE false + END as isCBCCurrent3, + + CASE + WHEN (d.Id.age.ageInDays > 12 ) THEN true + ELSE false + END as isCBCRequired3 + + + cbc.lastDate as lastCBC4, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC4, + CASE + WHEN (year(cbc.lastDate) is null AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + ELSE false + END as isCBCCurrent4, + + CASE + WHEN (d.Id.age.ageInDays > 6 ) THEN true + ELSE false + END as isCBCRequired4 + + + cbc.lastDate as lastCBC5,, + timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC5, + CASE + WHEN (year(now()) = year(cbc5.lastDate) AND daysSinceCBC5 > 180 AND (nts.Id is not null) ) THEN true + ELSE false + END as isCBCCurrent5, + + CASE + WHEN (d.Id.age.ageInDays > 180 ) THEN true + ELSE false + END as isCBCRequired5 + + + + ----- All Chemistry sections + + + cchem.lastDate as lastCChem1, + timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem1, + CASE + WHEN (year(now()) = year(cchem.lastDate) AND daysSincCChem1 > 165 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) THEN true + ELSE false + END as isCChemCurrent1, CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isCBCRequired + END as isCChemRequired1 FROM study.demographics d @@ -141,10 +211,21 @@ LEFT JOIN ( m.id, max(m.date) as lastDate FROM study.blood m - WHERE j.additionalservices like 'Comprehensive Chemistry panel in-house' + WHERE m.additionalservices like 'Comprehensive Chemistry panel in-house' GROUP BY m.id -) chem ON (chem.id = d.id) +) cchem ON (cchem.id = d.id) + + +LEFT JOIN ( + SELECT + t.id, + max(t.date) as lastDate + FROM study.blood t + WHERE t.additionalservices like 'Basic Chemistry Panel' + GROUP BY t.id + +) bchem ON (bchem.id = d.id) LEFT JOIN ( SELECT @@ -152,11 +233,24 @@ LEFT JOIN ( max(n.date) as lastDate FROM study.flags n WHERE n.category ='Behavior Flag' And n.value = 'Socially important' + And n.enddate is null GROUP BY n.id ) flg ON (flg.id = d.id) +LEFT JOIN ( + SELECT + p.id, + max(p.date) as lastDate + FROM study.flags p + WHERE p.category ='Notes Pertaining to DAR' And n.value = 'Assignment pool' + And p.enddate is null + GROUP BY p.id + +) nts ON (nts.id = d.id) + + WHERE d.calculated_status = 'Alive' ) t \ No newline at end of file From 47462155e6bec0d1ce800198dc72781831b0fa1a Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 14:58:20 -0700 Subject: [PATCH 05/18] Modified blood Processing program. --- .../queries/study/processingSerology.sql | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 3aaa419e1..fa30b5ffc 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -138,7 +138,7 @@ SELECT cbc.lastDate as lastCBC5,, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC5, CASE - WHEN (year(now()) = year(cbc5.lastDate) AND daysSinceCBC5 > 180 AND (nts.Id is not null) ) THEN true + WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC5 > 180 AND (nts.Id is not null) ) THEN true ELSE false END as isCBCCurrent5, @@ -149,21 +149,51 @@ SELECT - ----- All Chemistry sections + ----- All Comp Chemistry sections cchem.lastDate as lastCChem1, timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem1, CASE - WHEN (year(now()) = year(cchem.lastDate) AND daysSincCChem1 > 165 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) THEN true + WHEN ( ( (year(now()) = year(cchem.lastDate) AND daysSinceCChem1 > 165) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCChemCurrent1, CASE - WHEN (d.Id.age.ageInDays > 180 ) THEN true + WHEN (d.Id.age.ageInDays > 20 ) THEN true ELSE false END as isCChemRequired1 + + cchem.lastDate as lastCChem2, + timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem2, + CASE + WHEN ( ( (year(now()) = year(cchem.lastDate) AND daysSinceCChem2 > 340) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true + ELSE false + END as isCChemCurrent2, + + CASE + WHEN (d.Id.age.ageInDays > 180 ) THEN true + ELSE false + END as isCChemRequired2 + + cchem.lastDate as lastCChem3, + timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem3, + CASE + WHEN ( year(now()) = year(cchem.lastDate) AND daysSinceCChem3 > 180 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + ELSE false + END as isCChemCurrent3, + + CASE + WHEN (d.Id.age.ageInDays >= 18 ) THEN true + ELSE false + END as isCChemRequired3 + + + + + + FROM study.demographics d LEFT JOIN ( From 102601b9f4836eeb404a6bd935ed5be1ba2b429c Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 16:57:29 -0700 Subject: [PATCH 06/18] Modified blood Processing program. --- .../queries/study/processingSerology.sql | 88 +++++++++++++++++++ .../queries/study/processingBloodDraws.sql | 5 ++ 2 files changed, 93 insertions(+) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index fa30b5ffc..8d53820d4 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -26,6 +26,12 @@ SELECT t.isPCRRequired, t.isPCRCurrent, + t.lastBchem, + t.daysSinceBchem, + t.isBchemRequired, + t.isBchemCurrent, + + CASE WHEN (t.isSRVRequired = true AND t.isSRVCurrent = false) THEN 4 ELSE 0 @@ -41,6 +47,61 @@ SELECT ELSE 0 END as ESPFbloodVol, + -----CBC + CASE + WHEN (t.isCBCRequired1 = true AND t.isCBCCurrent1 = false AND ) THEN 1 + ELSE 0 + END as CBCbloodVol1, + + CASE + WHEN (t.isCBCRequired2 = true AND t.isCBCCurrent2 = false AND ) THEN 1 + ELSE 0 + END as CBCbloodVol2, + + CASE + WHEN (t.isCBCRequired3 = true AND t.isCBCCurrent3 = false AND ) THEN 1 + ELSE 0 + END as CBCbloodVol3, + + CASE + WHEN (t.isCBCRequired4 = true AND t.isCBCCurrent4 = false AND ) THEN 1 + ELSE 0 + END as CBCbloodVol4, + + CASE + WHEN (t.isCBCRequired5 = true AND t.isCBCCurrent5 = false AND ) THEN 1 + ELSE 0 + END as CBCbloodVol5, + + + + -----Comprehensive Chemistry + CASE + WHEN (t.isCChemRequired1 = true AND t.isCChemCurrent1 = false AND ) THEN 2 + ELSE 0 + END as CChembloodVol1, + + CASE + WHEN (t.isCChemRequired2 = true AND t.isCChemCurrent2 = false AND ) THEN 2 + ELSE 0 + END as CChembloodVol2, + + CASE + WHEN (t.isCChemRequired3 = true AND t.isCChemCurrent3 = false AND ) THEN 2 + ELSE 0 + END as CChembloodVol3, + + CASE + WHEN (t.isCChemRequired4 = true AND t.isCChemCurrent4 = false AND ) THEN 2 + ELSE 0 + END as CChembloodVol4, + + -----Basic Chemistry + CASE + WHEN (t.isBChemRequired = true AND t.isBChemCurrent = false AND ) THEN 2 + ELSE 0 + END as BchembloodVol, + FROM ( SELECT @@ -189,6 +250,33 @@ SELECT ELSE false END as isCChemRequired3 + cchem.lastDate as lastCChem4, + timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem4, + CASE + WHEN ( ( year(now()) = year(cchem.lastDate) AND daysSinceCChem4 > 180 ) AND (nts.Id is not null ) ) THEN true + ELSE false + END as isCChemCurrent4, + + CASE + WHEN (d.Id.age.ageInDays >= 18 ) THEN true + ELSE false + END as isCChemRequired4 + + + ------------- Basic Chemistry + + + bchem.lastDate as lastBChem, + timestampdiff('SQL_TSI_DAY', bchem.lastDate, now()) as daysSinceBChem, + CASE + WHEN ( ( year(now()) = year(bchem.lastDate) AND daysSinceBChem > 340 ) AND (d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) ) THEN true + ELSE false + END as isBChemCurrent, + + CASE + WHEN (d.Id.age.ageInDays >= 6 AND d.Id.age.ageInDays < 18 ) THEN true + ELSE false + END as isBChemRequired diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 422c53150..cda4008ac 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -12,6 +12,11 @@ SELECT s.srvBloodVol as serologyBloodVol, s.ESPFBloodVol as ESPFBloodVol, + + ( coalesce(s.CBCbloodVol1,0) + coalesce((s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, + (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as CompChemBloodVol, + (coalesce(s.BChembloodVol1,0) ) as BasicChemBloodVol, + g.parentageBloodDrawVol, g.mhcBloodDrawVol, g.dnaBloodDrawVol, From c6d7888d087a663c5a6fa69b4675e0723641b1c0 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 19:16:31 -0700 Subject: [PATCH 07/18] Modified blood Processing program. --- .../queries/study/processingSerology.sql | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index 8d53820d4..e0e6bcef0 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -43,33 +43,33 @@ SELECT END as PCRbloodVol, CASE - WHEN (t.isESPFRequired = true AND t.isESPFCurrent = false AND ) THEN 4 + WHEN (t.isESPFRequired = true AND t.isESPFCurrent = false ) THEN 4 ELSE 0 END as ESPFbloodVol, -----CBC CASE - WHEN (t.isCBCRequired1 = true AND t.isCBCCurrent1 = false AND ) THEN 1 + WHEN (t.isCBCRequired1 = true AND t.isCBCCurrent1 = false ) THEN 1 ELSE 0 END as CBCbloodVol1, CASE - WHEN (t.isCBCRequired2 = true AND t.isCBCCurrent2 = false AND ) THEN 1 + WHEN (t.isCBCRequired2 = true AND t.isCBCCurrent2 = false ) THEN 1 ELSE 0 END as CBCbloodVol2, CASE - WHEN (t.isCBCRequired3 = true AND t.isCBCCurrent3 = false AND ) THEN 1 + WHEN (t.isCBCRequired3 = true AND t.isCBCCurrent3 = false ) THEN 1 ELSE 0 END as CBCbloodVol3, CASE - WHEN (t.isCBCRequired4 = true AND t.isCBCCurrent4 = false AND ) THEN 1 + WHEN (t.isCBCRequired4 = true AND t.isCBCCurrent4 = false ) THEN 1 ELSE 0 END as CBCbloodVol4, CASE - WHEN (t.isCBCRequired5 = true AND t.isCBCCurrent5 = false AND ) THEN 1 + WHEN (t.isCBCRequired5 = true AND t.isCBCCurrent5 = false ) THEN 1 ELSE 0 END as CBCbloodVol5, @@ -77,28 +77,28 @@ SELECT -----Comprehensive Chemistry CASE - WHEN (t.isCChemRequired1 = true AND t.isCChemCurrent1 = false AND ) THEN 2 + WHEN (t.isCChemRequired1 = true AND t.isCChemCurrent1 = false ) THEN 2 ELSE 0 END as CChembloodVol1, CASE - WHEN (t.isCChemRequired2 = true AND t.isCChemCurrent2 = false AND ) THEN 2 + WHEN (t.isCChemRequired2 = true AND t.isCChemCurrent2 = false ) THEN 2 ELSE 0 END as CChembloodVol2, CASE - WHEN (t.isCChemRequired3 = true AND t.isCChemCurrent3 = false AND ) THEN 2 + WHEN (t.isCChemRequired3 = true AND t.isCChemCurrent3 = false ) THEN 2 ELSE 0 END as CChembloodVol3, CASE - WHEN (t.isCChemRequired4 = true AND t.isCChemCurrent4 = false AND ) THEN 2 + WHEN (t.isCChemRequired4 = true AND t.isCChemCurrent4 = false ) THEN 2 ELSE 0 END as CChembloodVol4, -----Basic Chemistry CASE - WHEN (t.isBChemRequired = true AND t.isBChemCurrent = false AND ) THEN 2 + WHEN (t.isBChemRequired = true AND t.isBChemCurrent = false ) THEN 2 ELSE 0 END as BchembloodVol, From 4a33abff2cd49fa45ceddc4d21a5d49fc323e83f Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 19:32:55 -0700 Subject: [PATCH 08/18] Modified blood Processing program. --- .../queries/study/processingSerology.sql | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index e0e6bcef0..de4510226 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -129,19 +129,19 @@ SELECT CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isPCRRequired + END as isPCRRequired, espf.lastDate as lastESPF, timestampdiff('SQL_TSI_DAY', espf.lastDate, now()) as daysSinceESPF, CASE - WHEN (year(now()) = year(espf.lastDate) AND daysSinceESPF > 180) THEN true + WHEN (year(now()) = year(espf.lastDate) AND (timestampdiff('SQL_TSI_DAY', espf.lastDate, now()) > 180) ) THEN true ELSE false END as isESPFCurrent, CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isESPFRequired + END as isESPFRequired, ------ All CBC Sections @@ -149,38 +149,38 @@ SELECT cbc.lastDate as lastCBC1, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC1, CASE - WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC1 > 165 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + WHEN (year(now()) = year(cbc.lastDate) AND (timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) > 165 )AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCBCCurrent1, CASE WHEN (d.Id.age.ageInDays > 20 ) THEN true ELSE false - END as isCBCRequired1 + END as isCBCRequired1, cbc.lastDate as lastCBC2, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC2, CASE - WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC2 > 340 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true + WHEN (year(now()) = year(cbc.lastDate) AND (timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) > 340) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true ELSE false END as isCBCCurrent2, CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isCBCRequired2 + END as isCBCRequired2, cbc.lastDate as lastCBC3, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC3, CASE - WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC3 > 340 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + WHEN (year(now()) = year(cbc.lastDate) AND (timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) > 340) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCBCCurrent3, CASE WHEN (d.Id.age.ageInDays > 12 ) THEN true ELSE false - END as isCBCRequired3 + END as isCBCRequired3, cbc.lastDate as lastCBC4, @@ -193,20 +193,20 @@ SELECT CASE WHEN (d.Id.age.ageInDays > 6 ) THEN true ELSE false - END as isCBCRequired4 + END as isCBCRequired4, - cbc.lastDate as lastCBC5,, + cbc.lastDate as lastCBC5, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC5, CASE - WHEN (year(now()) = year(cbc.lastDate) AND daysSinceCBC5 > 180 AND (nts.Id is not null) ) THEN true + WHEN (year(now()) = year(cbc.lastDate) AND (timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) > 180) AND (nts.Id is not null) ) THEN true ELSE false END as isCBCCurrent5, CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isCBCRequired5 + END as isCBCRequired5, @@ -216,51 +216,51 @@ SELECT cchem.lastDate as lastCChem1, timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem1, CASE - WHEN ( ( (year(now()) = year(cchem.lastDate) AND daysSinceCChem1 > 165) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + WHEN ( ( (year(now()) = year(cchem.lastDate) AND (timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) > 165)) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCChemCurrent1, CASE WHEN (d.Id.age.ageInDays > 20 ) THEN true ELSE false - END as isCChemRequired1 + END as isCChemRequired1, cchem.lastDate as lastCChem2, timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem2, CASE - WHEN ( ( (year(now()) = year(cchem.lastDate) AND daysSinceCChem2 > 340) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true + WHEN ( ( (year(now()) = year(cchem.lastDate) AND (timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) > 340) ) OR cchem.lastDate is null ) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) AND (flg.Id is not null) ) THEN true ELSE false END as isCChemCurrent2, CASE WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false - END as isCChemRequired2 + END as isCChemRequired2, cchem.lastDate as lastCChem3, timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem3, CASE - WHEN ( year(now()) = year(cchem.lastDate) AND daysSinceCChem3 > 180 AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + WHEN ( year(now()) = year(cchem.lastDate) AND (timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) > 180) AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCChemCurrent3, CASE WHEN (d.Id.age.ageInDays >= 18 ) THEN true ELSE false - END as isCChemRequired3 + END as isCChemRequired3, cchem.lastDate as lastCChem4, timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) as daysSinceCChem4, CASE - WHEN ( ( year(now()) = year(cchem.lastDate) AND daysSinceCChem4 > 180 ) AND (nts.Id is not null ) ) THEN true + WHEN ( ( year(now()) = year(cchem.lastDate) AND (timestampdiff('SQL_TSI_DAY', cchem.lastDate, now()) > 180 )) AND (nts.Id is not null ) ) THEN true ELSE false END as isCChemCurrent4, CASE WHEN (d.Id.age.ageInDays >= 18 ) THEN true ELSE false - END as isCChemRequired4 + END as isCChemRequired4, ------------- Basic Chemistry @@ -269,7 +269,7 @@ SELECT bchem.lastDate as lastBChem, timestampdiff('SQL_TSI_DAY', bchem.lastDate, now()) as daysSinceBChem, CASE - WHEN ( ( year(now()) = year(bchem.lastDate) AND daysSinceBChem > 340 ) AND (d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) ) THEN true + WHEN ( ( year(now()) = year(bchem.lastDate) AND (timestampdiff('SQL_TSI_DAY', bchem.lastDate, now()) > 340 ) ) AND (d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) ) THEN true ELSE false END as isBChemCurrent, @@ -362,7 +362,7 @@ LEFT JOIN ( p.id, max(p.date) as lastDate FROM study.flags p - WHERE p.category ='Notes Pertaining to DAR' And n.value = 'Assignment pool' + WHERE p.category ='Notes Pertaining to DAR' And p.value = 'Assignment pool' And p.enddate is null GROUP BY p.id From f1e93fd440f269ec080379092eb8bf2d19786276 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 19:44:07 -0700 Subject: [PATCH 09/18] Modified blood Processing program. --- .../queries/study/processingBloodDraws.query.xml | 10 ++++++++-- .../resources/queries/study/processingBloodDraws.sql | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml index 4cf1cc926..bb90eb34d 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml +++ b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml @@ -28,8 +28,14 @@ Serology RTT (mL) - - Serology RTT (mL) + + CBC PTT (mL) + + + COMP Chem RTT (mL) + + + BASIC Chem RTT (mL) Genetics Blood Vol (mL) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index cda4008ac..425fb81f7 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -13,8 +13,8 @@ SELECT s.srvBloodVol as serologyBloodVol, s.ESPFBloodVol as ESPFBloodVol, - ( coalesce(s.CBCbloodVol1,0) + coalesce((s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, - (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as CompChemBloodVol, + ( coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, + (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as totalCompChemBloodVol, (coalesce(s.BChembloodVol1,0) ) as BasicChemBloodVol, g.parentageBloodDrawVol, From d9a152c61d2515b42126a32fa9fa414be6e63344 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 22:40:55 -0700 Subject: [PATCH 10/18] Modified blood Processing program. --- onprc_reports/resources/queries/study/processingBloodDraws.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 425fb81f7..b4fe6fbf5 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -15,7 +15,7 @@ SELECT ( coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as totalCompChemBloodVol, - (coalesce(s.BChembloodVol1,0) ) as BasicChemBloodVol, + (coalesce(s.BChembloodVol,0) ) as BasicChemBloodVol, g.parentageBloodDrawVol, g.mhcBloodDrawVol, From 7a7ac2aef79c3010dec47f0a1dd81eaa028b64fb Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 23:07:46 -0700 Subject: [PATCH 11/18] Modified blood Processing program. --- .../queries/study/processingBloodDraws.query.xml | 3 +++ .../resources/queries/study/processingBloodDraws.sql | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml index bb90eb34d..2a5774c3e 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.query.xml +++ b/onprc_reports/resources/queries/study/processingBloodDraws.query.xml @@ -22,6 +22,9 @@ PCR PTT (mL) + + ESPF PTT (mL) + DNA Pink/PTT (mL) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index b4fe6fbf5..4bb6be21c 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -9,9 +9,13 @@ SELECT 0 End as PCRBloodVolume, - s.srvBloodVol as serologyBloodVol, - s.ESPFBloodVol as ESPFBloodVol, + + Case when (a.Id IS NOT NULL) And (s.ESPFBloodVol > 0 ) then 4 + ELSE + 0 + End as ESPFBloodVol, + ( coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as totalCompChemBloodVol, From aa193224a10ce1a88ffa1b6cd6d9af7d2248953a Mon Sep 17 00:00:00 2001 From: ohsudev Date: Fri, 13 Mar 2026 10:19:09 -0700 Subject: [PATCH 12/18] Modified blood Processing program. --- .../resources/queries/study/processingBloodDraws/.qview.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws/.qview.xml b/onprc_reports/resources/queries/study/processingBloodDraws/.qview.xml index 7921a2716..0bc0ab9e9 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws/.qview.xml +++ b/onprc_reports/resources/queries/study/processingBloodDraws/.qview.xml @@ -8,6 +8,10 @@ + + + + From d78fa5dddfb7cd5f3c139f63343a2575bf197c69 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Fri, 13 Mar 2026 10:35:37 -0700 Subject: [PATCH 13/18] Modified blood Processing program. --- .../resources/queries/study/processingBloodDraws.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 4bb6be21c..9791c0332 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -29,7 +29,11 @@ SELECT coalesce(s.srvBloodVol, 0) + Case when (a.Id IS NOT NULL) And (s.pcrbloodVol > 0 ) then 2 ELSE 0 - End + coalesce(g.totalBloodDrawVol, 0) as totalBloodDrawVol, + End + coalesce(s.ESPFBloodVol, 0) + + coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) + + coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) + + coalesce(s.BChembloodVol,0) + + coalesce(g.totalBloodDrawVol, 0) as totalBloodDrawVol, (select k.room from study.housing k where k.Id =d.Id And k.enddate is null) as currentlocationroom, (select coalesce(k.cage, ' ') from study.housing k where k.Id =d.Id And k.enddate is null) as currentlocationcage, From 25af089e757ad3927dbf25fb1ecc8cb43417047f Mon Sep 17 00:00:00 2001 From: ohsudev Date: Fri, 13 Mar 2026 16:01:56 -0700 Subject: [PATCH 14/18] Modified blood Processing program. --- .../resources/queries/study/processingSerology.sql | 10 +++------- .../resources/queries/study/processingBloodDraws.sql | 11 ++++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/onprc_ehr/resources/queries/study/processingSerology.sql b/onprc_ehr/resources/queries/study/processingSerology.sql index de4510226..eb5f91b43 100644 --- a/onprc_ehr/resources/queries/study/processingSerology.sql +++ b/onprc_ehr/resources/queries/study/processingSerology.sql @@ -49,14 +49,10 @@ SELECT -----CBC CASE - WHEN (t.isCBCRequired1 = true AND t.isCBCCurrent1 = false ) THEN 1 + WHEN (t.isCBCRequired1 = true AND t.isCBCCurrent1 = false ) OR (t.isCBCRequired2 = true AND t.isCBCCurrent2 = false ) THEN 1 ELSE 0 END as CBCbloodVol1, - CASE - WHEN (t.isCBCRequired2 = true AND t.isCBCCurrent2 = false ) THEN 1 - ELSE 0 - END as CBCbloodVol2, CASE WHEN (t.isCBCRequired3 = true AND t.isCBCCurrent3 = false ) THEN 1 @@ -186,7 +182,7 @@ SELECT cbc.lastDate as lastCBC4, timestampdiff('SQL_TSI_DAY', cbc.lastDate, now()) as daysSinceCBC4, CASE - WHEN (year(cbc.lastDate) is null AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true + WHEN ( cbc.lastDate is null AND d.Id.curLocation.area in ('Corrals', 'Shelters', 'PENS' ) ) THEN true ELSE false END as isCBCCurrent4, @@ -258,7 +254,7 @@ SELECT END as isCChemCurrent4, CASE - WHEN (d.Id.age.ageInDays >= 18 ) THEN true + WHEN (d.Id.age.ageInDays > 180 ) THEN true ELSE false END as isCChemRequired4, diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 9791c0332..8a5259f98 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -26,11 +26,16 @@ SELECT g.dnaBloodDrawVol, g.totalBloodDrawVol as geneticsBloodVol, - coalesce(s.srvBloodVol, 0) + Case when (a.Id IS NOT NULL) And (s.pcrbloodVol > 0 ) then 2 + coalesce(s.srvBloodVol, 0) + + Case when (a.Id IS NOT NULL) And (s.pcrbloodVol > 0 ) then 2 ELSE 0 - End + coalesce(s.ESPFBloodVol, 0) + - coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) + + End + + Case when (a.Id IS NOT NULL) And (s.ESPFBloodVol > 0 ) then 4 + ELSE + 0 + End + + coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) + coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) + coalesce(s.BChembloodVol,0) + coalesce(g.totalBloodDrawVol, 0) as totalBloodDrawVol, From 1e06707aec31f2c5d7a39f7c5d2640065fa2dd00 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 16 Mar 2026 11:47:24 -0700 Subject: [PATCH 15/18] Modified blood Processing program. --- .../queries/study/processingBloodDraws.sql | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 8a5259f98..77fc8c60f 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -24,7 +24,12 @@ SELECT g.parentageBloodDrawVol, g.mhcBloodDrawVol, g.dnaBloodDrawVol, - g.totalBloodDrawVol as geneticsBloodVol, + ---- g.totalBloodDrawVol as geneticsBloodVol, + + Case when (nts.Id is not null) then 0 + ELSE + g.totalBloodDrawVol + END as as geneticsBloodVol, coalesce(s.srvBloodVol, 0) + Case when (a.Id IS NOT NULL) And (s.pcrbloodVol > 0 ) then 2 @@ -54,3 +59,14 @@ FROM study.assignment a WHERE a.isActive = true and a.project.name = javaConstant('org.labkey.onprc_ehr.ONPRC_EHRManager.U42_PROJECT') GROUP BY a.Id ) a ON (a.Id = d.Id) + +LEFT JOIN ( + SELECT + p.id, + max(p.date) as lastDate + FROM study.flags p + WHERE p.category ='Genetics' And p.value = 'DNA Bank Blood Draw Not Needed' + And p.enddate is null + GROUP BY p.id + +) nts ON (nts.id = d.id) From 00786926f164d98771e7859397e8b04459f0cf1a Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:19:56 -0700 Subject: [PATCH 16/18] Modified blood Processing program. --- onprc_reports/resources/queries/study/processingBloodDraws.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 77fc8c60f..6491f7de2 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -28,7 +28,7 @@ SELECT Case when (nts.Id is not null) then 0 ELSE - g.totalBloodDrawVol + coalesce(g.totalBloodDrawVol,0) END as as geneticsBloodVol, coalesce(s.srvBloodVol, 0) + From be7cb801ba4ef7f4a035ea5287f8845e940f0bcb Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:53:23 -0700 Subject: [PATCH 17/18] Modified blood Processing program. --- onprc_reports/resources/queries/study/processingBloodDraws.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 6491f7de2..7e1195424 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -29,7 +29,7 @@ SELECT Case when (nts.Id is not null) then 0 ELSE coalesce(g.totalBloodDrawVol,0) - END as as geneticsBloodVol, + END as geneticsBloodVol, coalesce(s.srvBloodVol, 0) + Case when (a.Id IS NOT NULL) And (s.pcrbloodVol > 0 ) then 2 From 268126b338689375d5a0ef167446033afeee0f60 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Mon, 16 Mar 2026 14:30:14 -0700 Subject: [PATCH 18/18] Modified blood Processing program. --- onprc_reports/resources/queries/study/processingBloodDraws.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_reports/resources/queries/study/processingBloodDraws.sql b/onprc_reports/resources/queries/study/processingBloodDraws.sql index 7e1195424..cbb77c4cd 100644 --- a/onprc_reports/resources/queries/study/processingBloodDraws.sql +++ b/onprc_reports/resources/queries/study/processingBloodDraws.sql @@ -17,7 +17,7 @@ SELECT End as ESPFBloodVol, - ( coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol2,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, + ( coalesce(s.CBCbloodVol1,0) + coalesce(s.CBCbloodVol3,0) + coalesce(s.CBCbloodVol4,0) + coalesce(s.CBCbloodVol5,0) ) as totalCBCVol, (coalesce(s.CChembloodVol1,0) + coalesce(s.CChembloodVol2,0) + coalesce(s.CChembloodVol3,0) + coalesce(s.CChembloodVol4,0) ) as totalCompChemBloodVol, (coalesce(s.BChembloodVol,0) ) as BasicChemBloodVol,