3 * This report lists referrals for a given date range.
5 * Copyright (C) 2008, 2010 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author Rod Roark <rod@sunsetsystems.com>
20 * @author Roberto Vasquez <robertogagliotta@gmail.com>
21 * @link http://www.open-emr.org
24 require_once("../globals.php");
25 require_once("$srcdir/patient.inc");
26 require_once("$srcdir/formatting.inc.php");
27 require_once "$srcdir/options.inc.php";
28 require_once "$srcdir/formdata.inc.php";
30 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
31 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
32 $form_facility = isset($_POST['form_facility']) ?
$_POST['form_facility'] : '';
36 <?php
html_header_show();?
>
37 <title
><?php
xl('Referrals','e'); ?
></title
>
39 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
41 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
42 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
43 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
44 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
45 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
46 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
48 <script language
="JavaScript">
50 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
52 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
54 $
(document
).ready(function() {
55 var win
= top
.printLogSetup ? top
: opener
.top
;
56 win
.printLogSetup(document
.getElementById('printbutton'));
59 // The OnClick handler for referral display.
60 function show_referral(transid
) {
61 dlgopen('../patient_file/transaction/print_referral.php?transid=' + transid
,
68 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
69 <style type
="text/css">
71 /* specifically include & exclude from printing */
77 #report_parameters_daterange {
81 #report_results table {
86 /* specifically exclude some from the screen */
88 #report_parameters_daterange {
97 <body
class="body_top">
99 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Referrals','e'); ?
></span
>
101 <div id
="report_parameters_daterange">
102 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
105 <form name
='theform' id
='theform' method
='post' action
='referrals_report.php'>
107 <div id
="report_parameters">
108 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
112 <div style
='float:left'>
117 <?php
xl('Facility','e'); ?
>:
120 <?php
dropdown_facility(strip_escape_custom($form_facility), 'form_facility', true); ?
>
123 <?php
xl('From','e'); ?
>:
126 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
127 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
128 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
129 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
130 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
133 <?php
xl('To','e'); ?
>:
136 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
137 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
138 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
139 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
140 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
148 <td align
='left' valign
='middle' height
="100%">
149 <table style
='border-left:1px solid; width:100%; height:100%' >
152 <div style
='margin-left:15px'>
153 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
155 <?php
xl('Submit','e'); ?
>
159 <?php
if ($_POST['form_refresh']) { ?
>
160 <a href
='#' class='css_button' id
='printbutton'>
162 <?php
xl('Print','e'); ?
>
173 </div
> <!-- end of parameters
-->
177 if ($_POST['form_refresh']) {
179 <div id
="report_results">
182 <th
> <?php
xl('Refer To','e'); ?
> </th
>
183 <th
> <?php
xl('Refer Date','e'); ?
> </th
>
184 <th
> <?php
xl('Reply Date','e'); ?
> </th
>
185 <th
> <?php
xl('Patient','e'); ?
> </th
>
186 <th
> <?php
xl('ID','e'); ?
> </th
>
187 <th
> <?php
xl('Reason','e'); ?
> </th
>
191 if ($_POST['form_refresh']) {
192 $query = "SELECT t.id, t.refer_date, t.reply_date, t.body, " .
193 "ut.organization, uf.facility_id, p.pubpid, " .
194 "CONCAT(uf.fname,' ', uf.lname) AS referer_name, " .
195 "CONCAT(ut.fname,' ', ut.lname) AS referer_to, " .
196 "CONCAT(p.fname,' ', p.lname) AS patient_name " .
197 "FROM transactions AS t " .
198 "LEFT OUTER JOIN patient_data AS p ON p.pid = t.pid " .
199 "LEFT OUTER JOIN users AS ut ON ut.id = t.refer_to " .
200 "LEFT OUTER JOIN users AS uf ON uf.id = t.refer_from " .
201 "WHERE t.title = 'Referral' AND " .
202 "t.refer_date >= '$from_date' AND t.refer_date <= '$to_date' " .
203 "ORDER BY ut.organization, t.refer_date, t.id";
205 // echo "<!-- $query -->\n"; // debugging
206 $res = sqlStatement($query);
208 while ($row = sqlFetchArray($res)) {
209 // If a facility is specified, ignore rows that do not match.
210 if ($form_facility !== '') {
211 if ($form_facility) {
212 if ($row['facility_id'] != $form_facility) continue;
215 if (!empty($row['facility_id'])) continue;
222 <?php
if($row['organization']!=NULL ||
$row['organization']!='') {
223 echo $row['organization'];
226 echo text($row['referer_to']);
232 <a href
='#' onclick
="return show_referral(<?php echo $row['id']; ?>)">
233 <?php
echo oeFormatShortDate($row['refer_date']); ?
> 
;
237 <?php
echo oeFormatShortDate($row['reply_date']) ?
>
240 <?php
echo $row['patient_name'] ?
>
243 <?php
echo $row['pubpid'] ?
>
246 <?php
echo text($row['body']) ?
>
255 </div
> <!-- end of results
-->
258 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
263 <script language
='JavaScript'>
264 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
265 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});