ongoing internationalization of date widget
[openemr.git] / interface / reports / referrals_report.php
blob1f30486034f648ff873e3194e3b8da9d6425f890
1 <?php
2 /**
3 * This report lists referrals for a given date range.
5 * Copyright (C) 2008-2016 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2016 Roberto Vasquez <robertogagliotta@gmail.com>
7 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author Rod Roark <rod@sunsetsystems.com>
22 * @author Roberto Vasquez <robertogagliotta@gmail.com>
23 * @author Brady Miller <brady.g.miller@gmail.com>
24 * @link http://www.open-emr.org
27 use OpenEMR\Core\Header;
29 require_once("../globals.php");
30 require_once("$srcdir/patient.inc");
31 require_once "$srcdir/options.inc.php";
33 $from_date = (isset($_POST['form_from_date'])) ? fixDate($_POST['form_from_date'], date('Y-m-d')) : '';
34 $form_from_date = $from_date;
35 $to_date = (isset($_POST['form_to_date'])) ? fixDate($_POST['form_to_date'], date('Y-m-d')) : '';
37 $form_to_date = $to_date;
38 $form_facility = isset($_POST['form_facility']) ? $_POST['form_facility'] : '';
40 <html>
41 <head>
43 <title><?php echo xlt('Referrals'); ?></title>
45 <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
47 <script language="JavaScript">
49 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
51 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
53 $(document).ready(function() {
54 oeFixedHeaderSetup(document.getElementById('mymaintable'));
55 var win = top.printLogSetup ? top : opener.top;
56 win.printLogSetup(document.getElementById('printbutton'));
58 $('.datepicker').datetimepicker({
59 <?php $datetimepicker_timepicker = false; ?>
60 <?php $datetimepicker_showseconds = false; ?>
61 <?php $datetimepicker_formatInput = false; ?>
62 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
63 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
64 });
65 });
67 // The OnClick handler for referral display.
69 function show_referral(transid) {
70 dlgopen('../patient_file/transaction/print_referral.php?transid=' + transid,
71 '_blank', 550, 400,true); // Force new window rather than iframe because of the dynamic generation of the content in print_referral.php
72 return false;
75 </script>
77 <style type="text/css">
79 /* specifically include & exclude from printing */
80 @media print {
81 #report_parameters {
82 visibility: hidden;
83 display: none;
85 #report_parameters_daterange {
86 visibility: visible;
87 display: inline;
89 #report_results table {
90 margin-top: 0px;
94 /* specifically exclude some from the screen */
95 @media screen {
96 #report_parameters_daterange {
97 visibility: hidden;
98 display: none;
102 </style>
104 <script language="JavaScript">
106 </script>
108 </head>
110 <body class="body_top">
112 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Referrals'); ?></span>
114 <div id="report_parameters_daterange">
115 <?php echo text(date("d F Y", strtotime($form_from_date))) ." &nbsp; to &nbsp; ". text(date("d F Y", strtotime($form_to_date))); ?>
116 </div>
118 <form name='theform' id='theform' method='post' action='referrals_report.php' onsubmit='return top.restoreSession()'>
120 <div id="report_parameters">
121 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
122 <table>
123 <tr>
124 <td width='640px'>
125 <div style='float:left'>
127 <table class='text'>
128 <tr>
129 <td class='control-label'>
130 <?php echo xlt('Facility'); ?>:
131 </td>
132 <td>
133 <?php dropdown_facility(($form_facility), 'form_facility', true); ?>
134 </td>
135 <td class='control-label'>
136 <?php echo xlt('From'); ?>:
137 </td>
138 <td>
139 <input type='text' name='form_from_date' id="form_from_date" size='10' value='<?php echo attr($form_from_date) ?>'
140 class='datepicker form-control'
141 title='<?php echo xla('yyyy-mm-dd') ?>'>
142 </td>
143 <td class='control-label'>
144 <?php echo xlt('To'); ?>:
145 </td>
146 <td>
147 <input type='text' name='form_to_date' id="form_to_date" size='10' value='<?php echo attr($form_to_date) ?>'
148 class='datepicker form-control'
149 title='<?php echo xla('yyyy-mm-dd') ?>'>
150 </td>
151 </tr>
152 </table>
154 </div>
156 </td>
157 <td align='left' valign='middle' height="100%">
158 <table style='border-left:1px solid; width:100%; height:100%' >
159 <tr>
160 <td>
161 <div class="text-center">
162 <div class="btn-group" role="group">
163 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
164 <?php echo xlt('Submit'); ?>
165 </a>
166 <?php if ($_POST['form_refresh']) { ?>
167 <a href='#' class='btn btn-default btn-print' id='printbutton'>
168 <?php echo xlt('Print'); ?>
169 </a>
170 <?php } ?>
171 </div>
172 </div>
173 </td>
174 </tr>
175 </table>
176 </td>
177 </tr>
178 </table>
179 </div> <!-- end of parameters -->
181 <?php
182 if ($_POST['form_refresh']) {
184 <div id="report_results">
185 <table width='98%' id='mymaintable'>
186 <thead>
187 <th> <?php echo xlt('Refer To'); ?> </th>
188 <th> <?php echo xlt('Refer Date'); ?> </th>
189 <th> <?php echo xlt('Reply Date'); ?> </th>
190 <th> <?php echo xlt('Patient'); ?> </th>
191 <th> <?php echo xlt('ID'); ?> </th>
192 <th> <?php echo xlt('Reason'); ?> </th>
193 </thead>
194 <tbody>
195 <?php
196 if ($_POST['form_refresh']) {
197 $query = "SELECT t.id, t.pid, " .
198 "d1.field_value AS refer_date, " .
199 "d3.field_value AS reply_date, " .
200 "d4.field_value AS body, " .
201 "ut.organization, uf.facility_id, p.pubpid, " .
202 "CONCAT(uf.fname,' ', uf.lname) AS referer_name, " .
203 "CONCAT(ut.fname,' ', ut.lname) AS referer_to, " .
204 "CONCAT(p.fname,' ', p.lname) AS patient_name " .
205 "FROM transactions AS t " .
206 "LEFT JOIN patient_data AS p ON p.pid = t.pid " .
207 "JOIN lbt_data AS d1 ON d1.form_id = t.id AND d1.field_id = 'refer_date' " .
208 "LEFT JOIN lbt_data AS d3 ON d3.form_id = t.id AND d3.field_id = 'reply_date' " .
209 "LEFT JOIN lbt_data AS d4 ON d4.form_id = t.id AND d4.field_id = 'body' " .
210 "LEFT JOIN lbt_data AS d7 ON d7.form_id = t.id AND d7.field_id = 'refer_to' " .
211 "LEFT JOIN lbt_data AS d8 ON d8.form_id = t.id AND d8.field_id = 'refer_from' " .
212 "LEFT JOIN users AS ut ON ut.id = d7.field_value " .
213 "LEFT JOIN users AS uf ON uf.id = d8.field_value " .
214 "WHERE t.title = 'LBTref' AND " .
215 "d1.field_value >= ? AND d1.field_value <= ? " .
216 "ORDER BY ut.organization, d1.field_value, t.id";
217 $res = sqlStatement($query, array($from_date, $to_date));
219 while ($row = sqlFetchArray($res)) {
220 // If a facility is specified, ignore rows that do not match.
221 if ($form_facility !== '') {
222 if ($form_facility) {
223 if ($row['facility_id'] != $form_facility) {
224 continue;
226 } else {
227 if (!empty($row['facility_id'])) {
228 continue;
234 <tr>
235 <td>
236 <?php if ($row['organization']!=null || $row['organization']!='') {
237 echo text($row['organization']);
238 } else {
239 echo text($row['referer_to']);
243 </td>
244 <td>
245 <a href='#' onclick="return show_referral(<?php echo attr($row['id']); ?>)">
246 <?php echo text(oeFormatShortDate($row['refer_date'])); ?>&nbsp;
247 </a>
248 </td>
249 <td>
250 <?php echo text(oeFormatShortDate($row['reply_date'])) ?>
251 </td>
252 <td>
253 <?php echo text($row['patient_name']) ?>
254 </td>
255 <td>
256 <?php echo text($row['pubpid']) ?>
257 </td>
258 <td>
259 <?php echo text($row['body']) ?>
260 </td>
261 </tr>
262 <?php
266 </tbody>
267 </table>
268 </div> <!-- end of results -->
269 <?php } else { ?>
270 <div class='text'>
271 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
272 </div>
273 <?php } ?>
274 </form>
276 </body>
277 </html>