From 4d0e12f577d26ca0ed23bcf0b04364171475aab2 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Sat, 14 Mar 2009 00:18:03 +0000 Subject: [PATCH] added function for testing if an encounter is billed --- library/billing.inc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/library/billing.inc b/library/billing.inc index 9dd62e049..aac4b4d59 100644 --- a/library/billing.inc +++ b/library/billing.inc @@ -199,4 +199,19 @@ function updateClaim($newversion, $patient_id, $encounter_id, $payer_id=-1, $pay return 1; } -?> + +// Determine if anything in a visit has been billed. +// +function isEncounterBilled($pid, $encounter) { + $row = sqlQuery("SELECT count(*) AS count FROM billing WHERE " . + "pid = '$pid' AND encounter = '$encounter' AND activity = 1 AND " . + "billed = 1"); + $count = $row['count']; + if (!$count) { + $row = sqlQuery("SELECT count(*) AS count FROM drug_sales WHERE " . + "pid = '$pid' AND encounter = '$encounter' AND billed = 1"); + $count = $row['count']; + } + return $count ? true : false; +} +?> \ No newline at end of file -- 2.11.4.GIT