4 * Copyright (C) 2010-2013 Rod Roark <rod@sunsetsystems.com>
5 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.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 Brady Miller <brady.g.miller@gmail.com>
21 * @link http://www.open-emr.org
24 require_once("../globals.php");
25 require_once("$srcdir/patient.inc");
26 require_once("$srcdir/acl.inc");
27 require_once "$srcdir/options.inc.php";
29 function thisLineItem($row) {
30 $provname = $row['provider_lname'];
31 if (!empty($row['provider_fname'])) {
32 $provname .= ', ' . $row['provider_fname'];
33 if (!empty($row['provider_mname'])) {
34 $provname .= ' ' . $row['provider_mname'];
38 if ($_POST['form_csvexport']) {
39 echo '"' . addslashes($row['patient_name' ]) . '",';
40 echo '"' . addslashes($row['pubpid' ]) . '",';
41 echo '"' . addslashes(oeFormatShortDate($row['date_ordered' ])) . '",';
42 echo '"' . addslashes($row['organization' ]) . '",';
43 echo '"' . addslashes($provname ) . '",';
44 echo '"' . addslashes($row['priority_name' ]) . '",';
45 echo '"' . addslashes($row['status_name' ]) . '"' . "\n";
50 <td
class="detail"><?php
echo $row['patient_name' ]; ?
></td
>
51 <td
class="detail"><?php
echo $row['pubpid' ]; ?
></td
>
52 <td
class="detail"><?php
echo oeFormatShortDate($row['date_ordered' ]); ?
></td
>
53 <td
class="detail"><?php
echo $row['organization' ]; ?
></td
>
54 <td
class="detail"><?php
echo $provname; ?
></td
>
55 <td
class="detail"><?php
echo $row['priority_name' ]; ?
></td
>
56 <td
class="detail"><?php
echo $row['status_name' ]; ?
></td
>
59 } // End not csv export
62 if (! acl_check('acct', 'rep')) die(xl("Unauthorized access."));
64 $form_from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
65 $form_to_date = fixDate($_POST['form_to_date'] , date('Y-m-d'));
66 $form_facility = $_POST['form_facility'];
68 if ($_POST['form_csvexport']) {
69 header("Pragma: public");
71 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
72 header("Content-Type: application/force-download");
73 header("Content-Disposition: attachment; filename=pending_orders.csv");
74 header("Content-Description: File Transfer");
76 echo '"' . xl('Patient') . '",';
77 echo '"' . xl('ID') . '",';
78 echo '"' . xl('Ordered') . '",';
79 echo '"' . xl('From') . '",';
80 echo '"' . xl('Procedure') . '",';
81 echo '"' . xl('Provider') . '",';
82 echo '"' . xl('Priority') . '",';
83 echo '"' . xl('Status') . '"' . "\n";
89 <?php
html_header_show();?
>
91 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
93 <title
><?php
xl('Pending Orders','e') ?
></title
>
95 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
96 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
98 <script language
="JavaScript">
100 $
(document
).ready(function() {
101 var win
= top
.printLogSetup ? top
: opener
.top
;
102 win
.printLogSetup(document
.getElementById('printbutton'));
104 $
('.datepicker').datetimepicker({
105 <?php
$datetimepicker_timepicker = false; ?
>
106 <?php
$datetimepicker_showseconds = false; ?
>
107 <?php
$datetimepicker_formatInput = false; ?
>
108 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
109 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
117 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
120 <h2
><?php
xl('Pending Orders','e')?
></h2
>
122 <form method
='post' action
='pending_orders.php'>
124 <table border
='0' cellpadding
='3'>
128 <?php
dropdown_facility(strip_escape_custom($form_facility), 'form_facility', false); ?
>
129  
;<?
xl('From:','e')?
>
130 <input type
='text' class='datepicker' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
133 <input type
='text' class='datepicker' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
136 <input type
='submit' name
='form_refresh' value
="<?php xl('Refresh','e') ?>">
138 <input type
='submit' name
='form_csvexport' value
="<?php xl('Export to CSV','e') ?>">
140 <input type
='button' value
='<?php echo xla('Print'); ?>' id
='printbutton' />
151 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
152 <tr bgcolor
="#dddddd">
153 <td
class="dehead"><?php
xl('Patient','e' ) ?
></td
>
154 <td
class="dehead"><?php
xl('ID','e' ) ?
></td
>
155 <td
class="dehead"><?php
xl('Ordered','e' ) ?
></td
>
156 <td
class="dehead"><?php
xl('From','e' ) ?
></td
>
157 <td
class="dehead"><?php
xl('Provider','e' ) ?
></td
>
158 <td
class="dehead"><?php
xl('Priority','e' ) ?
></td
>
159 <td
class="dehead"><?php
xl('Status','e' ) ?
></td
>
164 // If generating a report.
166 if ($_POST['form_refresh'] ||
$_POST['form_csvexport']) {
167 $from_date = $form_from_date;
168 $to_date = $form_to_date;
170 $query = "SELECT po.patient_id, po.date_ordered, " .
172 "CONCAT(pd.lname, ', ', pd.fname, ' ', pd.mname) AS patient_name, " .
173 "u1.lname AS provider_lname, u1.fname AS provider_fname, u1.mname AS provider_mname, " .
174 "pp.name AS organization, " .
175 "lop.title AS priority_name, " .
176 "los.title AS status_name, " .
177 "pr.procedure_report_id, pr.date_report, pr.report_status " .
178 "FROM procedure_order AS po " .
179 "JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " .
180 "JOIN patient_data AS pd ON pd.pid = po.patient_id " .
181 "LEFT JOIN users AS u1 ON u1.id = po.provider_id " .
182 "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " .
183 "LEFT JOIN list_options AS lop ON lop.list_id = 'ord_priority' AND lop.option_id = po.order_priority AND lop.activity = 1 " .
184 "LEFT JOIN list_options AS los ON los.list_id = 'ord_status' AND los.option_id = po.order_status AND los.activity = 1 " .
185 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " .
187 "po.date_ordered >= '$from_date' AND po.date_ordered <= '$to_date' AND " .
188 "( pr.report_status IS NULL OR pr.report_status = 'prelim' )";
190 // TBD: What if preliminary and final reports for the same order?
192 if ($form_facility) {
193 $query .= " AND fe.facility_id = '$form_facility'";
195 $query .= " ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, " .
196 "po.date_ordered, po.procedure_order_id";
198 $res = sqlStatement($query);
199 while ($row = sqlFetchArray($res)) {
203 } // end report generation
205 if (! $_POST['form_csvexport']) {
215 } // End not csv export