Revert "1. add edit event fails when save edited single provider recurring events...
[openemr.git] / interface / main / display_documents.php
blob8c8fe4e97e63974a8b68bd1eed3628984c2954d1
1 <?php
2 /**
3 * Displays the documents
4 * Only Lab documents for now.
6 * Copyright (C) 2014 Ensoftek
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 3
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 Hema Bandaru <hemab@drcloudemr.com>
22 * @author Brady Miller <brady.g.miller@gmail.com>
23 * @link http://www.open-emr.org
28 require_once('../globals.php');
29 require_once("$srcdir/patient.inc");
30 require_once("$srcdir/payment_jav.inc.php");
32 $curdate = date_create(date("Y-m-d"));
33 date_sub($curdate, date_interval_create_from_date_string("7 days"));
34 $sub_date = date_format($curdate, 'Y-m-d');
36 // Set the default dates for Lab document search
37 $form_from_doc_date = ( $_GET['form_from_doc_date'] ) ? $_GET['form_from_doc_date'] : oeFormatShortDate($sub_date);
38 $form_to_doc_date = ( $_GET['form_to_doc_date'] ) ? $_GET['form_to_doc_date'] : oeFormatShortDate(date("Y-m-d"));
40 if ($GLOBALS['date_display_format'] == 1) {
41 $title_tooltip = "MM/DD/YYYY";
42 } elseif ($GLOBALS['date_display_format'] == 2) {
43 $title_tooltip = "DD/MM/YYYY";
44 } else {
45 $title_tooltip = "YYYY-MM-DD";
48 $display_div = "style='display:block;'";
49 $display_expand_msg = "display:none;";
50 $display_collapse_msg = "display:inline;";
54 <html>
55 <head>
57 <?php html_header_show();?>
58 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
59 <link rel="stylesheet" href='<?php echo $GLOBALS['assets_static_relative'] ?>/qtip2-2-2-1/jquery.qtip.min.css' type='text/css'>
60 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
63 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
64 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
65 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
66 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
67 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.6.custom.min.js"></script>
68 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/qtip2-2-2-1/jquery.qtip.js"></script>
69 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
71 <script type="text/javascript">
72 var global_date_format = '<?php echo DateFormatRead(); ?>';
73 $(document).ready(function() {
74 $("#docdiv a").each(function() {
75 $(this).qtip({
76 content : '<iframe class="qtip-box" src="' + $(this).attr('title') + '" />',
77 hide : {
78 delay : 20,
79 fixed : true
81 position : {
82 at : 'bottom left',
83 viewport : $(window),
84 adjust: {
85 x: 20
88 style: 'qtip-style'
92 $('.datepicker').datetimepicker({
93 <?php $datetimepicker_timepicker = false; ?>
94 <?php $datetimepicker_showseconds = false; ?>
95 <?php $datetimepicker_formatInput = true; ?>
96 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
97 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
98 });
99 });
101 function validateDate(fromDate,toDate){
102 var frmdate = $("#" + fromDate).val();
103 var todate = $("#" + toDate).val();
104 if ( (frmdate.length > 0) && (todate.length > 0) ) {
105 if ( DateCheckGreater(frmdate, todate, global_date_format) == false ){
106 alert("<?php xl('To date must be later than From date!', 'e'); ?>");
107 return false;
110 document.location='<?php echo $GLOBALS['webroot']; ?>/interface/main/display_documents.php?' + fromDate + '='+frmdate+'&' + toDate + '='+todate;
113 function expandOrCollapse(type,prefixString) {
114 if(type == 1 ) {
115 $("#" + prefixString + "filterdiv").show();
116 $("#" + prefixString + "div").show();
117 $("#" + prefixString + "collapse").show();
118 $("#" + prefixString + "expand").hide();
119 } else {
120 $("#" + prefixString + "filterdiv").hide();
121 $("#" + prefixString + "div").hide();
122 $("#" + prefixString + "collapse").hide();
123 $("#" + prefixString + "expand").show();
127 </script>
129 <style type="text/css">
130 .qtip-box{
131 width : 100%;
132 height : 95%;
135 .qtip-style {
136 width: 75%;
137 max-width: 75%;
138 height: 50%;
139 max-height: 50%;
141 .qtip {
142 max-width : 100%;
145 .linkcell {
146 max-width: 250px ;
147 text-overflow: ellipsis;
148 overflow: hidden;
149 valign : absbottom;
152 </style>
153 </head>
155 <body class="body_top">
157 <div>
158 <span class='title'><?php echo xlt('Lab Documents'); ?></span>
159 <span id='docexpand' onclick='expandOrCollapse(1,"doc")' style='cursor:pointer;<?php echo $display_expand_msg ?>'>(expand)</span>
160 <span id='doccollapse' onclick='expandOrCollapse(2,"doc")' style='cursor:pointer;<?php echo $display_collapse_msg ?>'>(collapse)</span>
161 <br><br>
162 <div id='docfilterdiv'<?php echo $display_div; ?>>
163 <table style="margin-left:10px; " width='40%'>
164 <tr>
165 <td scope="row" class='label_custom'><?php echo xlt('From'); ?>:</td>
166 <td><input type='text' class='datepicker' name='form_from_doc_date' id="form_from_doc_date"
167 size='10' value='<?php echo attr($form_from_doc_date) ?>' title='<?php echo attr($title_tooltip) ?>'>
168 </td>
169 <td class='label_custom'><?php echo xlt('To'); ?>:</td>
170 <td><input type='text' class='datepicker' name='form_to_doc_date' id="form_to_doc_date"
171 size='10' value='<?php echo attr($form_to_doc_date) ?>' title='<?php echo attr($title_tooltip) ?>'>
172 </td>
173 <td>
174 <span style='float: left;' id="docrefresh">
175 <a href='#' class='css_button' onclick='return validateDate("form_from_doc_date","form_to_doc_date")'> <span><?php echo xlt('Refresh'); ?> </span></a>
176 </span>
177 </td>
178 </tr>
179 </table>
180 </div>
181 </div>
183 <div id='docdiv' <?php echo $display_div; ?>>
184 <?php
185 $current_user = $_SESSION["authId"];
186 $date_filter = '';
187 $query_array = array();
188 if ($form_from_doc_date) {
189 $form_from_doc_date = DateToYYYYMMDD($form_from_doc_date);
190 $date_filter = " DATE(d.date) >= ? ";
191 array_push($query_array, $form_from_doc_date);
194 if ($form_to_doc_date) {
195 $form_to_doc_date = DateToYYYYMMDD($form_to_doc_date);
196 $date_filter .= " AND DATE(d.date) <= ? ";
197 array_push($query_array, $form_to_doc_date);
200 // Get the category ID for lab reports.
201 $query = "SELECT rght FROM categories WHERE name = ?";
202 $catIDRs = sqlQuery($query, array($GLOBALS['lab_results_category_name']));
203 $catID = $catIDRs['rght'];
205 $query = "SELECT d.*,CONCAT(pd.fname,' ',pd.lname) AS pname,GROUP_CONCAT(n.note ORDER BY n.date DESC SEPARATOR '|') AS docNotes,
206 GROUP_CONCAT(n.date ORDER BY n.date DESC SEPARATOR '|') AS docDates FROM documents d
207 INNER JOIN patient_data pd ON d.foreign_id = pd.pid
208 INNER JOIN categories_to_documents ctd ON d.id = ctd.document_id AND ctd.category_id = ?
209 LEFT JOIN notes n ON d.id = n.foreign_id
210 WHERE " . $date_filter . " GROUP BY d.id ORDER BY date DESC";
211 array_unshift($query_array, $catID);
212 $resultSet = sqlStatement($query, $query_array);
215 <table border="1" cellpadding=3 cellspacing=0>
216 <tr class='text bold'>
217 <th align="left" width="10%"><?php echo xlt('Date'); ?></th>
218 <th align="left" class="linkcell" width="20%" ><?php echo xlt('Name'); ?></th>
219 <th align="left" width="20%"><?php echo xlt('Patient'); ?></th>
220 <th align="left" width="30%"><?php echo xlt('Note'); ?></th>
221 <th width="10%"><?php echo xlt('Encounter ID'); ?></th>
222 </tr>
223 <?php
224 if (sqlNumRows($resultSet)) {
225 while ($row = sqlFetchArray($resultSet)) {
226 $url = $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=" . attr($row["foreign_id"]) . "&document_id=" . attr($row["id"]) . '&as_file=false';
227 // Get the notes for this document.
228 $notes = array();
229 $note = '';
230 if ($row['docNotes']) {
231 $notes = explode("|", $row['docNotes']);
232 $dates = explode("|", $row['docDates']);
235 for ($i = 0; $i < count($notes); $i++) {
236 $note .= text(oeFormatShortDate(date('Y-m-d', strtotime($dates[$i])))) . " : " . text($notes[$i]) . "<br />";
239 <tr class="text">
240 <td><?php echo text(oeFormatShortDate(date('Y-m-d', strtotime($row['date'])))); ?> </td>
241 <td class="linkcell">
242 <a id="<?php echo attr($row['id']); ?>" title='<?php echo $url; ?>' onclick='top.restoreSession()'><?php echo text(basename($row['url'])); ?></a>
243 </td>
244 <td><?php echo text($row['pname']); ?> </td>
245 <td><?php echo $note; ?> &nbsp;</td>
246 <td align="center"><?php echo ( $row['encounter_id'] ) ? text($row['encounter_id']) : ''; ?> </td>
247 </tr>
248 <?php
249 } ?>
250 <?php
251 } ?>
252 </table>
253 </div>
254 </body>
255 </html>