From 83591ab8883722313719d93bd1f1560657a7bebc Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Tue, 14 Dec 2010 16:35:28 -0800 Subject: [PATCH] A couple of ippf export fixes. --- interface/main/ippf_export.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/interface/main/ippf_export.php b/interface/main/ippf_export.php index a8ddb783c..836744a3a 100644 --- a/interface/main/ippf_export.php +++ b/interface/main/ippf_export.php @@ -211,6 +211,15 @@ function exportEncounter($pid, $encounter, $date) { foreach ($relcodes as $codestring) { if ($codestring === '') continue; list($codetype, $code) = explode(':', $codestring); + if ($codetype == 'REF') { + // This is the expected case; a direct IPPF code is obsolete. + $rrow = sqlQuery("SELECT related_code FROM codes WHERE " . + "code_type = '16' AND code = '$code' AND active = 1 " . + "ORDER BY id LIMIT 1"); + if (!empty($rrow['related_code'])) { + list($codetype, $code) = explode(':', $rrow['related_code']); + } + } if ($codetype !== 'IPPF') continue; OpenTag('IMS_eMRUpload_Service'); Add('IppfServiceProductId', $code); @@ -522,13 +531,20 @@ if (!empty($form_submit)) { AddIfPresent('UserText19', $row['usertext19']); AddIfPresent('UserText20', $row['usertext20']); - // Dump all visits for this patient at this facility. + // Dump the visits for this patient. $query = "SELECT " . "encounter, date " . "FROM form_encounter WHERE " . // "pid = '$last_pid' AND facility_id = '$last_facility' " . - "pid = '$last_pid' " . - "ORDER BY encounter"; + "pid = '$last_pid' "; + if (true) { + // The new logic here is to restrict to the given date range. + // Set the above to false if all visits are wanted. + $query .= "AND " . + sprintf("date >= '%04u-%02u-01 00:00:00' AND ", $beg_year, $beg_month) . + sprintf("date < '%04u-%02u-01 00:00:00' ", $end_year, $end_month); + } + $query .= "ORDER BY encounter"; // Add('Debug', $query); // debugging -- 2.11.4.GIT