From 22447ee3e74e0f2d7beff628f73338dc3b82fc10 Mon Sep 17 00:00:00 2001 From: markleeds Date: Sun, 13 Jan 2008 17:24:37 +0000 Subject: [PATCH] Changed query that gets the date of the last encounter for date calculations. It is still the date of the last encounter with a cpt4 associated with it, but it gets the date from the form_encounter table (with a join to billing) rather than just getting the date from billing. This accounts for users that might enter their billing codes at a later date. The reason for checking for a cpt4 entry at all is to account for users who put notes in form_encounter for events that are not billable (phone calls, pharmacy call-ins etc...) If you do not enter cpt4 codes at all for an encounter, then you will have to modify this query yourself. --- interface/main/finder/patient_select.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/main/finder/patient_select.php b/interface/main/finder/patient_select.php index 8826b9a2a..54ddd6937 100644 --- a/interface/main/finder/patient_select.php +++ b/interface/main/finder/patient_select.php @@ -113,12 +113,12 @@ if ($result) { $next_appt_date= ''; $pid = ''; //calculate date differences based on date of last cpt4 entry - $query = "select DATE_FORMAT(date(max(date)),'%m/%d/%y') as mydate," . - " (to_days(current_date())-to_days(max(date))) as day_diff," . - " DATE_FORMAT(date(max(date)) + interval " . $add_days . - " day,'%m/%d/%y') as next_appt, dayname(max(date) + interval " . - $add_days." day) as next_appt_day from billing where code_type". - " like 'CPT4' and pid=" . $iter{"pid"}; + $query = "select DATE_FORMAT(date(max(form_encounter.date)),'%m/%d/%y') as mydate," . + " (to_days(current_date())-to_days(max(form_encounter.date))) as day_diff," . + " DATE_FORMAT(date(max(form_encounter.date)) + interval " . $add_days . + " day,'%m/%d/%y') as next_appt, dayname(max(form_encounter.date) + interval " . + $add_days." day) as next_appt_day from form_encounter join billing on (billing.encounter = form_encounter.encounter) where billing.code_type". + " like 'CPT4' and form_encounter.pid=" . $iter{"pid"}; $statement= sqlStatement($query); if ($results = mysql_fetch_array($statement, MYSQL_ASSOC)) { $last_date_seen = $results['mydate']; -- 2.11.4.GIT