2 // Copyright (C) 2010-2013 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 require_once("../globals.php");
10 require_once("$srcdir/patient.inc");
11 require_once("$srcdir/acl.inc");
12 require_once("$srcdir/formatting.inc.php");
13 require_once "$srcdir/options.inc.php";
14 require_once "$srcdir/formdata.inc.php";
16 function thisLineItem($row) {
17 $provname = $row['provider_lname'];
18 if (!empty($row['provider_fname'])) {
19 $provname .= ', ' . $row['provider_fname'];
20 if (!empty($row['provider_mname'])) {
21 $provname .= ' ' . $row['provider_mname'];
25 if ($_POST['form_csvexport']) {
26 echo '"' . addslashes($row['patient_name' ]) . '",';
27 echo '"' . addslashes($row['pubpid' ]) . '",';
28 echo '"' . addslashes(oeFormatShortDate($row['date_ordered' ])) . '",';
29 echo '"' . addslashes($row['organization' ]) . '",';
30 echo '"' . addslashes($provname ) . '",';
31 echo '"' . addslashes($row['priority_name' ]) . '",';
32 echo '"' . addslashes($row['status_name' ]) . '"' . "\n";
37 <td
class="detail"><?php
echo $row['patient_name' ]; ?
></td
>
38 <td
class="detail"><?php
echo $row['pubpid' ]; ?
></td
>
39 <td
class="detail"><?php
echo oeFormatShortDate($row['date_ordered' ]); ?
></td
>
40 <td
class="detail"><?php
echo $row['organization' ]; ?
></td
>
41 <td
class="detail"><?php
echo $provname; ?
></td
>
42 <td
class="detail"><?php
echo $row['priority_name' ]; ?
></td
>
43 <td
class="detail"><?php
echo $row['status_name' ]; ?
></td
>
46 } // End not csv export
49 if (! acl_check('acct', 'rep')) die(xl("Unauthorized access."));
51 $form_from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
52 $form_to_date = fixDate($_POST['form_to_date'] , date('Y-m-d'));
53 $form_facility = $_POST['form_facility'];
55 if ($_POST['form_csvexport']) {
56 header("Pragma: public");
58 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
59 header("Content-Type: application/force-download");
60 header("Content-Disposition: attachment; filename=pending_orders.csv");
61 header("Content-Description: File Transfer");
63 echo '"' . xl('Patient') . '",';
64 echo '"' . xl('ID') . '",';
65 echo '"' . xl('Ordered') . '",';
66 echo '"' . xl('From') . '",';
67 echo '"' . xl('Procedure') . '",';
68 echo '"' . xl('Provider') . '",';
69 echo '"' . xl('Priority') . '",';
70 echo '"' . xl('Status') . '"' . "\n";
76 <?php
html_header_show();?
>
77 <title
><?php
xl('Pending Orders','e') ?
></title
>
79 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.9.1.min.js"></script
>
80 <script language
="JavaScript">
82 $
(document
).ready(function() {
83 var win
= top
.printLogSetup ? top
: opener
.top
;
84 win
.printLogSetup(document
.getElementById('printbutton'));
91 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
94 <h2
><?php
xl('Pending Orders','e')?
></h2
>
96 <form method
='post' action
='pending_orders.php'>
98 <table border
='0' cellpadding
='3'>
102 <?php
dropdown_facility(strip_escape_custom($form_facility), 'form_facility', false); ?
>
103  
;<?
xl('From:','e')?
>
104 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
105 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
106 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
107 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
108 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
110 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
111 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
112 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
113 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
114 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
116 <input type
='submit' name
='form_refresh' value
="<?php xl('Refresh','e') ?>">
118 <input type
='submit' name
='form_csvexport' value
="<?php xl('Export to CSV','e') ?>">
120 <input type
='button' value
='<?php echo xla('Print'); ?>' id
='printbutton' />
131 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
132 <tr bgcolor
="#dddddd">
133 <td
class="dehead"><?php
xl('Patient','e' ) ?
></td
>
134 <td
class="dehead"><?php
xl('ID','e' ) ?
></td
>
135 <td
class="dehead"><?php
xl('Ordered','e' ) ?
></td
>
136 <td
class="dehead"><?php
xl('From','e' ) ?
></td
>
137 <td
class="dehead"><?php
xl('Provider','e' ) ?
></td
>
138 <td
class="dehead"><?php
xl('Priority','e' ) ?
></td
>
139 <td
class="dehead"><?php
xl('Status','e' ) ?
></td
>
144 // If generating a report.
146 if ($_POST['form_refresh'] ||
$_POST['form_csvexport']) {
147 $from_date = $form_from_date;
148 $to_date = $form_to_date;
150 $query = "SELECT po.patient_id, po.date_ordered, " .
152 "CONCAT(pd.lname, ', ', pd.fname, ' ', pd.mname) AS patient_name, " .
153 "u1.lname AS provider_lname, u1.fname AS provider_fname, u1.mname AS provider_mname, " .
154 "pp.name AS organization, " .
155 "lop.title AS priority_name, " .
156 "los.title AS status_name, " .
157 "pr.procedure_report_id, pr.date_report, pr.report_status " .
158 "FROM procedure_order AS po " .
159 "JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " .
160 "JOIN patient_data AS pd ON pd.pid = po.patient_id " .
161 "LEFT JOIN users AS u1 ON u1.id = po.provider_id " .
162 "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " .
163 "LEFT JOIN list_options AS lop ON lop.list_id = 'ord_priority' AND lop.option_id = po.order_priority " .
164 "LEFT JOIN list_options AS los ON los.list_id = 'ord_status' AND los.option_id = po.order_status " .
165 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " .
167 "po.date_ordered >= '$from_date' AND po.date_ordered <= '$to_date' AND " .
168 "( pr.report_status IS NULL OR pr.report_status = 'prelim' )";
170 // TBD: What if preliminary and final reports for the same order?
172 if ($form_facility) {
173 $query .= " AND fe.facility_id = '$form_facility'";
175 $query .= " ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, " .
176 "po.date_ordered, po.procedure_order_id";
178 $res = sqlStatement($query);
179 while ($row = sqlFetchArray($res)) {
183 } // end report generation
185 if (! $_POST['form_csvexport']) {
193 <!-- stuff
for the popup calendar
-->
194 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
195 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
196 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
197 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
198 <script language
="Javascript">
199 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
200 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});
205 } // End not csv export