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>;.
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 $fake_register_globals=false;
28 $sanitize_all_escapes=true;
30 require_once("../globals.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/formatting.inc.php");
33 require_once "$srcdir/options.inc.php";
35 $from_date = (isset($_POST['form_from_date'])) ?
fixDate($_POST['form_from_date'], date('Y-m-d')) : '';
36 $form_from_date = $from_date;
37 $to_date = (isset($_POST['form_to_date'])) ?
fixDate($_POST['form_to_date'], date('Y-m-d')) : '';;
38 $form_to_date = $to_date;
39 $form_facility = isset($_POST['form_facility']) ?
$_POST['form_facility'] : '';
43 <?php
html_header_show();?
>
44 <title
><?php
echo xlt('Referrals'); ?
></title
>
46 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
47 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
48 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
49 <script type
="text/javascript" src
="../../library/js/report_helper.js?v=<?php echo $v_js_includes; ?>"></script
>
50 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
51 <script language
="JavaScript">
53 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
55 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
57 $
(document
).ready(function() {
58 oeFixedHeaderSetup(document
.getElementById('mymaintable'));
59 var win
= top
.printLogSetup ? top
: opener
.top
;
60 win
.printLogSetup(document
.getElementById('printbutton'));
62 $
('.datepicker').datetimepicker({
63 <?php
$datetimepicker_timepicker = false; ?
>
64 <?php
$datetimepicker_formatInput = false; ?
>
65 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
66 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
70 // The OnClick handler for referral display.
72 function show_referral(transid
) {
73 dlgopen('../patient_file/transaction/print_referral.php?transid=' + transid
,
74 '_blank', 550, 400,true); // Force new window rather than iframe because of the dynamic generation of the content in print_referral.php
80 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
81 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
82 <style type
="text/css">
84 /* specifically include & exclude from printing */
90 #report_parameters_daterange {
94 #report_results table {
99 /* specifically exclude some from the screen */
101 #report_parameters_daterange {
109 <script language
="JavaScript">
115 <body
class="body_top">
117 <span
class='title'><?php
echo xlt('Report'); ?
> - <?php
echo xlt('Referrals'); ?
></span
>
119 <div id
="report_parameters_daterange">
120 <?php
echo text(date("d F Y", strtotime($form_from_date))) ." to ". text(date("d F Y", strtotime($form_to_date))); ?
>
123 <form name
='theform' id
='theform' method
='post' action
='referrals_report.php'>
125 <div id
="report_parameters">
126 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
130 <div style
='float:left'>
135 <?php
echo xlt('Facility'); ?
>:
138 <?php
dropdown_facility(($form_facility), 'form_facility', true); ?
>
141 <?php
echo xlt('From'); ?
>:
144 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo attr($form_from_date) ?>'
146 title
='<?php echo xla('yyyy
-mm
-dd
') ?>'>
149 <?php
echo xlt('To'); ?
>:
152 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo attr($form_to_date) ?>'
154 title
='<?php echo xla('yyyy
-mm
-dd
') ?>'>
162 <td align
='left' valign
='middle' height
="100%">
163 <table style
='border-left:1px solid; width:100%; height:100%' >
166 <div style
='margin-left:15px'>
167 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
169 <?php
echo xlt('Submit'); ?
>
173 <?php
if ($_POST['form_refresh']) { ?
>
174 <a href
='#' class='css_button' id
='printbutton'>
176 <?php
echo xlt('Print'); ?
>
187 </div
> <!-- end of parameters
-->
190 if ($_POST['form_refresh']) {
192 <div id
="report_results">
193 <table width
='98%' id
='mymaintable'>
195 <th
> <?php
echo xlt('Refer To'); ?
> </th
>
196 <th
> <?php
echo xlt('Refer Date'); ?
> </th
>
197 <th
> <?php
echo xlt('Reply Date'); ?
> </th
>
198 <th
> <?php
echo xlt('Patient'); ?
> </th
>
199 <th
> <?php
echo xlt('ID'); ?
> </th
>
200 <th
> <?php
echo xlt('Reason'); ?
> </th
>
204 if ($_POST['form_refresh']) {
205 $query = "SELECT t.id, t.pid, " .
206 "d1.field_value AS refer_date, " .
207 "d3.field_value AS reply_date, " .
208 "d4.field_value AS body, " .
209 "ut.organization, uf.facility_id, p.pubpid, " .
210 "CONCAT(uf.fname,' ', uf.lname) AS referer_name, " .
211 "CONCAT(ut.fname,' ', ut.lname) AS referer_to, " .
212 "CONCAT(p.fname,' ', p.lname) AS patient_name " .
213 "FROM transactions AS t " .
214 "LEFT JOIN patient_data AS p ON p.pid = t.pid " .
215 "JOIN lbt_data AS d1 ON d1.form_id = t.id AND d1.field_id = 'refer_date' " .
216 "LEFT JOIN lbt_data AS d3 ON d3.form_id = t.id AND d3.field_id = 'reply_date' " .
217 "LEFT JOIN lbt_data AS d4 ON d4.form_id = t.id AND d4.field_id = 'body' " .
218 "LEFT JOIN lbt_data AS d7 ON d7.form_id = t.id AND d7.field_id = 'refer_to' " .
219 "LEFT JOIN lbt_data AS d8 ON d8.form_id = t.id AND d8.field_id = 'refer_from' " .
220 "LEFT JOIN users AS ut ON ut.id = d7.field_value " .
221 "LEFT JOIN users AS uf ON uf.id = d8.field_value " .
222 "WHERE t.title = 'LBTref' AND " .
223 "d1.field_value >= ? AND d1.field_value <= ? " .
224 "ORDER BY ut.organization, d1.field_value, t.id";
225 $res = sqlStatement($query, array($from_date, $to_date));
227 while ($row = sqlFetchArray($res)) {
228 // If a facility is specified, ignore rows that do not match.
229 if ($form_facility !== '') {
230 if ($form_facility) {
231 if ($row['facility_id'] != $form_facility) continue;
234 if (!empty($row['facility_id'])) continue;
241 <?php
if($row['organization']!=NULL ||
$row['organization']!='') {
242 echo text($row['organization']);
245 echo text($row['referer_to']);
251 <a href
='#' onclick
="return show_referral(<?php echo attr($row['id']); ?>)">
252 <?php
echo text(oeFormatShortDate($row['refer_date'])); ?
> 
;
256 <?php
echo text(oeFormatShortDate($row['reply_date'])) ?
>
259 <?php
echo text($row['patient_name']) ?
>
262 <?php
echo text($row['pubpid']) ?
>
265 <?php
echo text($row['body']) ?
>
274 </div
> <!-- end of results
-->
277 <?php
echo xlt('Please input search criteria above, and click Submit to view results.'); ?
>