From 5b44497c90667537d290fffbb4353e93ed9d2e0f Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 10 Apr 2026 14:44:10 -0700 Subject: [PATCH 1/5] New query to resolve rerqeust for Discrepancy Report for R&L when Procedures are carged against an incorrect Alias --- .../onprc_ehr/GJ_BillingDescrepenciesR&.sql | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql diff --git a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql new file mode 100644 index 000000000..854494058 --- /dev/null +++ b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql @@ -0,0 +1,57 @@ +/* +===================================================================== + Query Name : GJ_BillingDescrepenciesR&L + Schema : onprc_ehr + Purpose : To provide the R&L team with a tool to idetofy when a procedure charges will be generated + Point to a alias that is not associcated witht eh Aniomals assigned project + Issue / Ticket : EHR Issue 11870 + Feature Branch: + Pull Request: + Development Status: In development FB posted to Test E + Business Context: + Resolution Logic: + Parameters : Non Defined + Output : Query Grid + Validation Notes: Thi + Author : jonesga + Created : 2026-04-10 + Last Modified : 2026-04-10 +===================================================================== +*/ + + +With procedureFees as ( + Select + pfr.id, + pfr.date, + pfr.project, + pfr.account, + pfr.chargetype, + pfr.assistingStaff, + pfr.procedureid, + pfr.chargeID, + pfr.serviceCenter, + pfr.item, + pfr.category, + pfr.sourceRecord, + pfr.unitcost, + pfr.NIHRate, + pfr.creditAccount, + pfr.matchesProject, + pfr.isAdjustment, + pfr.IsAcceptingCharges, + pfr.isExpiredAccount, + pfr.currentActiveAlias + from onprc_billing.procedurefeeRates pfr ) + +Select pf.* from procedureFees pf + +/*I want to add these are parameters on a webpart after we validate the query + +WHERE + (?matchesProject IS NULL OR pfr.matchesProject = ?matchesProject) + AND (?isAdjustment IS NULL OR pfr.isAdjustment = ?isAdjustment) + AND (?isAcceptingCharges IS NULL OR pfr.isAcceptingCharges = ?isAcceptingCharges) + AND (?isExpiredAccount IS NULL OR pfr.isExpiredAccount = ?isExpiredAccount) + AND (?currentActiveAlias IS NULL OR pfr.currentActiveAlias = ?currentActiveAlias) +*/ \ No newline at end of file From 68ea8712a884ec40befdc50bb77f8b124ab26823 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 10 Apr 2026 14:52:18 -0700 Subject: [PATCH 2/5] New query to resolve rerqeust for Discrepancy Report for R&L when Procedures are carged against an incorrect Alias --- .../resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql index 854494058..919858c7f 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql @@ -17,6 +17,7 @@ Created : 2026-04-10 Last Modified : 2026-04-10 ===================================================================== +2nd Try bad Github token */ From cc29d536d07055b4ea3ae5f66e995c746ca5fdb5 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sat, 11 Apr 2026 05:11:51 -0700 Subject: [PATCH 3/5] New query to resolve rerqeust for Discrepancy Report for R&L when Procedures are carged against an incorrect Alias --- ...ngDescrepenciesR&.sql => GJ_BillingDescrepenciesRl.sql} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename onprc_ehr/resources/queries/onprc_ehr/{GJ_BillingDescrepenciesR&.sql => GJ_BillingDescrepenciesRl.sql} (95%) diff --git a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql similarity index 95% rename from onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql rename to onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql index 919858c7f..4af8cbc29 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesR&.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql @@ -1,6 +1,6 @@ /* ===================================================================== - Query Name : GJ_BillingDescrepenciesR&L + Query Name : GJ_BillingDescrepenciesRL Schema : onprc_ehr Purpose : To provide the R&L team with a tool to idetofy when a procedure charges will be generated Point to a alias that is not associcated witht eh Aniomals assigned project @@ -16,11 +16,8 @@ Author : jonesga Created : 2026-04-10 Last Modified : 2026-04-10 -===================================================================== -2nd Try bad Github token +=====================================================================\ */ - - With procedureFees as ( Select pfr.id, From cf6bed4a22dfec4659486f06b10262738fb0350b Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Mon, 13 Apr 2026 14:26:18 -0700 Subject: [PATCH 4/5] Updared the CTGE adding a check of the Current Alis for the assigned Project --- .../onprc_ehr/GJ_BillingDescrepenciesRl.sql | 79 +++++++++++-------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql index 4af8cbc29..b0b4326c1 100644 --- a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql +++ b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl.sql @@ -15,41 +15,56 @@ Validation Notes: Thi Author : jonesga Created : 2026-04-10 - Last Modified : 2026-04-10 -=====================================================================\ + Last Modified : 2026-04-13 +===================================================================== */ -With procedureFees as ( - Select +WITH procedureFees AS ( + SELECT pfr.id, pfr.date, pfr.project, - pfr.account, - pfr.chargetype, - pfr.assistingStaff, - pfr.procedureid, - pfr.chargeID, - pfr.serviceCenter, - pfr.item, - pfr.category, - pfr.sourceRecord, - pfr.unitcost, - pfr.NIHRate, - pfr.creditAccount, - pfr.matchesProject, - pfr.isAdjustment, - pfr.IsAcceptingCharges, - pfr.isExpiredAccount, - pfr.currentActiveAlias - from onprc_billing.procedurefeeRates pfr ) - -Select pf.* from procedureFees pf + pfr.account, + pfr.chargetype AS chargeType, + pfr.assistingStaff, + pfr.procedureid, + pfr.chargeID, + pfr.serviceCenter, + pfr.item, + pfr.category, + pfr.sourceRecord, + pfr.unitcost, + pfr.NIHRate, + pfr.creditAccount, + pfr.matchesProject, + pfr.isAdjustment, + pfr.IsAcceptingCharges, + pfr.isExpiredAccount, + pfr.currentActiveAlias + FROM onprc_billing.procedurefeeRates pfr +), -/*I want to add these are parameters on a webpart after we validate the query + ProjectAlias AS (SELECT pa.name, + pa.account + FROM ehr.project pa + where (pa.enddate > CurDate() + or pa.enddate is null) ) -WHERE - (?matchesProject IS NULL OR pfr.matchesProject = ?matchesProject) - AND (?isAdjustment IS NULL OR pfr.isAdjustment = ?isAdjustment) - AND (?isAcceptingCharges IS NULL OR pfr.isAcceptingCharges = ?isAcceptingCharges) - AND (?isExpiredAccount IS NULL OR pfr.isExpiredAccount = ?isExpiredAccount) - AND (?currentActiveAlias IS NULL OR pfr.currentActiveAlias = ?currentActiveAlias) -*/ \ No newline at end of file +SELECT + pf.id, + pf.date, + pf.project, + pf.account AS chargeToAlias, + pa.account AS projectAlias, + CASE When pf.account = pa.account then 'Billing is Correct' + ELSE 'Billing Needs Review' + end as ChargeReview, + pf.chargeType, + pf.procedureID, + pf.chargeID, + pf.unitcost, + pf.matchesProject +FROM procedureFees pf + LEFT JOIN ProjectAlias pa + ON pf.project.displayName = pa.name +/*WHERE + pf.account != pa.account*/ \ No newline at end of file From f145fce8175db9080dd76cba5380bc968298cf03 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 14 Apr 2026 19:57:00 -0700 Subject: [PATCH 5/5] This is an update of the original query with Enhancement that ned adjustment but wanted them in the Repository, Not available to the user yet as not added to the menu --- .../GJ_BillingDescrepenciesRl_enhanced.sql | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl_enhanced.sql diff --git a/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl_enhanced.sql b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl_enhanced.sql new file mode 100644 index 000000000..30064e143 --- /dev/null +++ b/onprc_ehr/resources/queries/onprc_ehr/GJ_BillingDescrepenciesRl_enhanced.sql @@ -0,0 +1,114 @@ +/* +===================================================================== + Query Name : GJ_BillingDescrepenciesRL + Schema : onprc_ehr + Purpose : To provide the R&L team with a tool to identify when + procedure charges will be generated pointing to an + alias not associated with the animal's project + Issue / Ticket : EHR Issue 11870 + Development Status: In development FB posted to Test E + Author : jonesga + Created : 2026-04-10 + Last Modified : 2026-04-14 +Latest Changes: Added logic requested relating to date run but requires more review + Also added functionality to add a Red X where ther is a problem + THis is a new query based on the original with the enahncements +===================================================================== +*/ + +WITH RunContext AS ( + SELECT + CURDATE() AS runDate, + DAYOFWEEK(CURDATE()) AS runDayOfWeekNum, + CASE DAYOFWEEK(CURDATE()) + WHEN 1 THEN 'Sunday' + WHEN 2 THEN 'Monday' + WHEN 3 THEN 'Tuesday' + WHEN 4 THEN 'Wednesday' + WHEN 5 THEN 'Thursday' + WHEN 6 THEN 'Friday' + WHEN 7 THEN 'Saturday' + END AS runDayOfWeekName, + + -- If run on Monday, include Friday–Sunday; otherwise include yesterday + CASE + WHEN DAYOFWEEK(CURDATE()) = 2 THEN timestampadd('SQL_TSI_DAY', -3, CURDATE()) + ELSE timestampadd('SQL_TSI_DAY', -1, CURDATE()) + END AS changeStartDate, + + CURDATE() AS changeEndDate, + + CASE + WHEN DAYOFWEEK(CURDATE()) = 2 + THEN 'Monday run – includes Friday, Saturday, and Sunday changes' + ELSE 'Daily run – includes previous day changes' + END AS runLogicNote +), + + procedureFees AS ( + SELECT + pfr.id, + pfr.date, + pfr.project, + pfr.account, + pfr.chargetype AS chargeType, + pfr.assistingStaff, + pfr.procedureid, + pfr.chargeID, + pfr.serviceCenter, + pfr.item, + pfr.category, + pfr.sourceRecord, + pfr.unitcost, + pfr.NIHRate, + pfr.creditAccount, + pfr.matchesProject, + pfr.isAdjustment, + pfr.IsAcceptingCharges, + pfr.isExpiredAccount, + pfr.currentActiveAlias + FROM onprc_billing.procedurefeeRates pfr + ), + + ProjectAlias AS ( + SELECT + pa.name, + pa.account + FROM ehr.project pa + WHERE pa.enddate > CURDATE() + OR pa.enddate IS NULL + ) + +SELECT + pf.id, + pf.date, + pf.project, + pf.account AS chargeToAlias, + pa.account AS projectAlias, + + -- ✅ Status with symbols for conditional formatting + CASE + WHEN pf.account = pa.account + THEN '✅ Billing is Correct' + ELSE '❌ Billing Needs Review' + END AS ChargeReview, + + pf.chargeType, + pf.procedureID, + pf.chargeID, + pf.unitcost, + pf.matchesProject, + + -- ✅ Run context for transparency and auditability + --rc.runDate, + --rc.runDayOfWeekName, + --rc.runLogicNote + +FROM procedureFees pf + -- CROSS JOIN RunContext rc + LEFT JOIN ProjectAlias pa + ON pf.project.displayName = pa.name + +WHERE pf.project.displayName NOT LIKE '0492-%' + --AND pf.date >= rc.changeStartDate + --AND pf.date < rc.changeEndDate; \ No newline at end of file