From cb610f31e162f8196238d7dd4ca8a9479f6638e8 Mon Sep 17 00:00:00 2001 From: Chad Sebranek Date: Tue, 12 Nov 2024 14:40:32 -0600 Subject: [PATCH 1/3] group up the blood draws if they are done at the same time --- .../wnprc_billing/bloodDrawsAllTubesSPI.sql | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql index fb5d7bec8..ea4fed321 100644 --- a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql +++ b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql @@ -2,15 +2,17 @@ SELECT Id, date, project, - coalesce(account, project.account.alias) AS debitedAccount, + coalesce(account, project.account.alias) as debitedAccount, coalesce(a.tier_rate.tierRate, project.account.tier_rate.tierRate) as otherRate, - objectid AS sourceRecord, - ('Blood Draws ' || Id) AS comment, - CAST(1 as DOUBLE) AS quantity, - taskId, - performedby + group_concat(objectid,';') as objectids, + ('Blood Draws ' || Id || ' x' || COUNT(*)) as comment, + CAST(1 AS DOUBLE) AS quantity, + group_concat(taskid, ';') as taskids, + group_concat(performedby, ';') as performedby FROM studyLinked.BloodSchedule bloodSch LEFT JOIN ehr_billing.aliases a ON bloodSch.account = a.alias WHERE billedBy.value = 'c' AND - qcstate.publicdata = true \ No newline at end of file + qcstate.publicdata = true + +GROUP BY id, date, project, coalesce(account, project.account.alias), coalesce(a.tier_rate.tierRate, project.account.tier_rate.tierRate); From 18ec00da8c055254d9d20d54621db22ac3507427 Mon Sep 17 00:00:00 2001 From: Chad Sebranek Date: Wed, 4 Dec 2024 15:29:52 -0600 Subject: [PATCH 2/3] remove count from comment --- .../resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql index ea4fed321..8eb3d3dc6 100644 --- a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql +++ b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql @@ -5,7 +5,7 @@ SELECT coalesce(account, project.account.alias) as debitedAccount, coalesce(a.tier_rate.tierRate, project.account.tier_rate.tierRate) as otherRate, group_concat(objectid,';') as objectids, - ('Blood Draws ' || Id || ' x' || COUNT(*)) as comment, + ('Blood Draws ' || Id ) as comment, CAST(1 AS DOUBLE) AS quantity, group_concat(taskid, ';') as taskids, group_concat(performedby, ';') as performedby From 3ebe6db3687be2b15eb21ef334d5c8ff77dc599a Mon Sep 17 00:00:00 2001 From: Chad Sebranek Date: Tue, 10 Dec 2024 10:32:52 -0600 Subject: [PATCH 3/3] comment sql --- .../resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql index 8eb3d3dc6..c46de5b39 100644 --- a/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql +++ b/wnprc_billing/resources/queries/wnprc_billing/bloodDrawsAllTubesSPI.sql @@ -15,4 +15,5 @@ WHERE billedBy.value = 'c' AND qcstate.publicdata = true +--group blood draws drawn on the same date with same project GROUP BY id, date, project, coalesce(account, project.account.alias), coalesce(a.tier_rate.tierRate, project.account.tier_rate.tierRate);