2 // Copyright (C) 2008, 2010 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This report lists referrals for a given date range.
11 require_once("../globals.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/formatting.inc.php");
14 require_once "$srcdir/options.inc.php";
15 require_once "$srcdir/formdata.inc.php";
17 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
18 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
19 $form_facility = isset($_POST['form_facility']) ?
$_POST['form_facility'] : '';
23 <?php
html_header_show();?
>
24 <title
><?php
xl('Referrals','e'); ?
></title
>
26 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
28 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
29 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
30 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
31 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
32 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
33 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
35 <script language
="JavaScript">
37 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
39 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
41 // The OnClick handler for referral display.
42 function show_referral(transid
) {
43 dlgopen('../patient_file/transaction/print_referral.php?transid=' + transid
,
50 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
51 <style type
="text/css">
53 /* specifically include & exclude from printing */
59 #report_parameters_daterange {
63 #report_results table {
68 /* specifically exclude some from the screen */
70 #report_parameters_daterange {
79 <body
class="body_top">
81 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Referrals','e'); ?
></span
>
83 <div id
="report_parameters_daterange">
84 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
87 <form name
='theform' id
='theform' method
='post' action
='referrals_report.php'>
89 <div id
="report_parameters">
90 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
94 <div style
='float:left'>
99 <?php
xl('Facility','e'); ?
>:
102 <?php
dropdown_facility(strip_escape_custom($form_facility), 'form_facility', true); ?
>
105 <?php
xl('From','e'); ?
>:
108 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
109 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
110 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
111 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
112 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
115 <?php
xl('To','e'); ?
>:
118 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
119 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
120 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
121 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
122 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
130 <td align
='left' valign
='middle' height
="100%">
131 <table style
='border-left:1px solid; width:100%; height:100%' >
134 <div style
='margin-left:15px'>
135 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
137 <?php
xl('Submit','e'); ?
>
141 <?php
if ($_POST['form_refresh']) { ?
>
142 <a href
='#' class='css_button' onclick
='window.print()'>
144 <?php
xl('Print','e'); ?
>
155 </div
> <!-- end of parameters
-->
159 if ($_POST['form_refresh']) {
161 <div id
="report_results">
164 <th
> <?php
xl('Refer To','e'); ?
> </th
>
165 <th
> <?php
xl('Refer Date','e'); ?
> </th
>
166 <th
> <?php
xl('Reply Date','e'); ?
> </th
>
167 <th
> <?php
xl('Patient','e'); ?
> </th
>
168 <th
> <?php
xl('ID','e'); ?
> </th
>
169 <th
> <?php
xl('Reason','e'); ?
> </th
>
173 if ($_POST['form_refresh']) {
174 $query = "SELECT t.id, t.refer_date, t.reply_date, t.body, " .
175 "ut.organization, uf.facility_id, p.pubpid, " .
176 "CONCAT(uf.fname,' ', uf.lname) AS referer_name, " .
177 "CONCAT(ut.fname,' ', ut.lname) AS referer_to, " .
178 "CONCAT(p.fname,' ', p.lname) AS patient_name " .
179 "FROM transactions AS t " .
180 "LEFT OUTER JOIN patient_data AS p ON p.pid = t.pid " .
181 "LEFT OUTER JOIN users AS ut ON ut.id = t.refer_to " .
182 "LEFT OUTER JOIN users AS uf ON uf.id = t.refer_from " .
183 "WHERE t.title = 'Referral' AND " .
184 "t.refer_date >= '$from_date' AND t.refer_date <= '$to_date' " .
185 "ORDER BY ut.organization, t.refer_date, t.id";
187 // echo "<!-- $query -->\n"; // debugging
188 $res = sqlStatement($query);
190 while ($row = sqlFetchArray($res)) {
191 // If a facility is specified, ignore rows that do not match.
192 if ($form_facility !== '') {
193 if ($form_facility) {
194 if ($row['facility_id'] != $form_facility) continue;
197 if (!empty($row['facility_id'])) continue;
204 <?php
if($row['organization']!=NULL ||
$row['organization']!='') {
205 echo $row['organization'];
208 echo $row['referer_to'];
214 <a href
='#' onclick
="return show_referral(<?php echo $row['id']; ?>)">
215 <?php
echo oeFormatShortDate($row['refer_date']); ?
> 
;
219 <?php
echo oeFormatShortDate($row['reply_date']) ?
>
222 <?php
echo $row['patient_name'] ?
>
225 <?php
echo $row['pubpid'] ?
>
228 <?php
echo $row['body'] ?
>
237 </div
> <!-- end of results
-->
240 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
245 <script language
='JavaScript'>
246 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
247 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});