Removes frames from login gui and condense login gui into a single file.
[openemr.git] / interface / main / display_documents.php
blob4cf79226ce568feb21cdde41ea92cc843b875887
1 <?php
2 /**
3 * Displays the documents
4 * Only Lab documents for now.
6 * Copyright (C) 2014 Ensoftek
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Hema Bandaru <hemab@drcloudemr.com>
21 * @link http://www.open-emr.org
24 //SANITIZE ALL ESCAPES
25 $sanitize_all_escapes=true;
26 //STOP FAKE REGISTER GLOBALS
27 $fake_register_globals=false;
29 require_once('../globals.php');
30 require_once("$srcdir/formatting.inc.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/payment_jav.inc.php");
34 $DateFormat = DateFormatRead();
35 $curdate = date_create(date("Y-m-d"));
36 date_sub($curdate, date_interval_create_from_date_string("7 days"));
37 $sub_date = date_format($curdate, 'Y-m-d');
39 // Set the default dates for Lab document search
40 $form_from_doc_date = ( $_GET['form_from_doc_date'] ) ? $_GET['form_from_doc_date'] : oeFormatShortDate(fixDate($_GET['form_from_doc_date'],$sub_date));
41 $form_to_doc_date = ( $_GET['form_to_doc_date'] ) ? $_GET['form_to_doc_date'] : oeFormatShortDate(fixDate($_GET['form_to_doc_date'],date("Y-m-d")));
43 if($GLOBALS['date_display_format'] == 1) {
44 $title_tooltip = "MM/DD/YYYY";
45 } elseif($GLOBALS['date_display_format'] == 2) {
46 $title_tooltip = "DD/MM/YYYY";
47 } else {
48 $title_tooltip = "YYYY-MM-DD";
51 $display_div = "style='display:block;'";
52 $display_expand_msg = "display:none;";
53 $display_collapse_msg = "display:inline;";
57 <html>
58 <head>
60 <?php html_header_show();?>
61 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
62 <link rel="stylesheet" href='<?php echo $GLOBALS['webroot'] ?>/library/js/qtip/jquery.qtip.min.css' type='text/css'>
63 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
64 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
65 <!-- stuff for the popup calendar -->
66 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
67 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
68 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
69 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
70 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
71 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.7.2.min.js"></script>
72 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.6.custom.min.js"></script>
73 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/qtip/jquery.qtip.js"></script>
75 <script type="text/javascript">
76 var global_date_format = '<?php echo $DateFormat; ?>';
77 $(document).ready(function() {
78 $("#docdiv a").each(function() {
79 $(this).qtip({
80 content : '<iframe class="qtip-box" src="' + $(this).attr('title') + '" />',
81 hide : {
82 delay : 20,
83 fixed : true
85 position : {
86 at : 'bottom left',
87 viewport : $(window),
88 adjust: {
89 x: 20
92 style: 'qtip-style'
95 });
97 function validateDate(fromDate,toDate){
98 var frmdate = $("#" + fromDate).val();
99 var todate = $("#" + toDate).val();
100 if ( (frmdate.length > 0) && (todate.length > 0) ) {
101 if ( DateCheckGreater(frmdate, todate, global_date_format) == false ){
102 alert("<?php xl('To date must be later than From date!','e'); ?>");
103 return false;
106 document.location='<?php echo $GLOBALS['webroot']; ?>/interface/main/display_documents.php?' + fromDate + '='+frmdate+'&' + toDate + '='+todate;
109 function expandOrCollapse(type,prefixString) {
110 if(type == 1 ) {
111 $("#" + prefixString + "filterdiv").show();
112 $("#" + prefixString + "div").show();
113 $("#" + prefixString + "collapse").show();
114 $("#" + prefixString + "expand").hide();
115 } else {
116 $("#" + prefixString + "filterdiv").hide();
117 $("#" + prefixString + "div").hide();
118 $("#" + prefixString + "collapse").hide();
119 $("#" + prefixString + "expand").show();
123 </script>
125 <style type="text/css">
126 .qtip-box{
127 width : 100%;
128 height : 95%;
131 .qtip-style {
132 width: 75%;
133 max-width: 75%;
134 height: 50%;
135 max-height: 50%;
137 .qtip {
138 max-width : 100%;
141 .linkcell {
142 max-width: 250px ;
143 text-overflow: ellipsis;
144 overflow: hidden;
145 valign : absbottom;
148 </style>
149 </head>
151 <body class="body_top">
153 <div>
154 <span class='title'><?php echo text('Lab Documents'); ?></span>
155 <span id='docexpand' onclick='expandOrCollapse(1,"doc")' style='cursor:pointer;<?php echo $display_expand_msg ?>'>(expand)</span>
156 <span id='doccollapse' onclick='expandOrCollapse(2,"doc")' style='cursor:pointer;<?php echo $display_collapse_msg ?>'>(collapse)</span>
157 <br><br>
158 <div id='docfilterdiv'<?php echo $display_div; ?>>
159 <table style="margin-left:10px; " width='40%'>
160 <tr>
161 <td scope="row" class='label'><?php echo xlt('From'); ?>:</td>
162 <td><input type='text' name='form_from_doc_date' id="form_from_doc_date"
163 size='10' value='<?php echo attr($form_from_doc_date) ?>' readonly="readonly" title='<?php echo attr($title_tooltip) ?>'>
164 <img alt="<?php echo xla("Date Selector"); ?>" src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_from_doc_date'
165 border='0' alt='[?]' style='cursor: pointer' title='<?php echo xla('Click here to choose a date'); ?>'></td>
166 <script>
167 Calendar.setup({inputField:"form_from_doc_date", ifFormat:global_date_format, button:"img_from_doc_date"});
168 </script>
169 <td class='label'><?php echo xlt('To'); ?>:</td>
170 <td><input type='text' name='form_to_doc_date' id="form_to_doc_date"
171 size='10' value='<?php echo attr($form_to_doc_date) ?>' readonly="readonly" title='<?php echo attr($title_tooltip) ?>'>
172 <img alt="<?php xla("Date Selector"); ?>" src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_to_doc_date'
173 border='0' alt='[?]' style='cursor: pointer' title='<?php echo xla('Click here to choose a date'); ?>'></td>
174 <script>
175 Calendar.setup({inputField:"form_to_doc_date", ifFormat:global_date_format, button:"img_to_doc_date"});
176 </script>
177 <td>
178 <span style='float: left;' id="docrefresh">
179 <a href='#' class='css_button' onclick='return validateDate("form_from_doc_date","form_to_doc_date")'> <span><?php echo xlt('Refresh'); ?> </span></a>
180 </span>
181 </td>
182 </tr>
183 </table>
184 </div>
185 </div>
187 <div id='docdiv' <?php echo $display_div; ?>>
188 <?php
189 $current_user = $_SESSION["authId"];
190 $date_filter = '';
191 $query_array = array();
192 if ($form_from_doc_date) {
193 $form_from_doc_date = DateToYYYYMMDD($form_from_doc_date);
194 $date_filter = " DATE(d.date) >= ? ";
195 array_push($query_array,$form_from_doc_date);
197 if ($form_to_doc_date) {
198 $form_to_doc_date = DateToYYYYMMDD($form_to_doc_date);
199 $date_filter .= " AND DATE(d.date) <= ? ";
200 array_push($query_array,$form_to_doc_date);
202 // Get the category ID for lab reports.
203 $query = "SELECT rght FROM categories WHERE name = ?";
204 $catIDRs = sqlQuery($query,array($GLOBALS['lab_results_category_name']));
205 $catID = $catIDRs['rght'];
207 $query = "SELECT d.*,CONCAT(pd.fname,' ',pd.lname) AS pname,GROUP_CONCAT(n.note ORDER BY n.date DESC SEPARATOR '|') AS docNotes,
208 GROUP_CONCAT(n.date ORDER BY n.date DESC SEPARATOR '|') AS docDates FROM documents d
209 INNER JOIN patient_data pd ON d.foreign_id = pd.pid
210 INNER JOIN categories_to_documents ctd ON d.id = ctd.document_id AND ctd.category_id = ?
211 LEFT JOIN notes n ON d.id = n.foreign_id
212 WHERE " . $date_filter . " GROUP BY d.id ORDER BY date DESC";
213 array_unshift($query_array,$catID);
214 $resultSet = sqlStatement($query,$query_array);
217 <table border="1" cellpadding=3 cellspacing=0>
218 <tr class='text bold'>
219 <th align="left" width="10%"><?php echo xlt('Date'); ?></th>
220 <th align="left" class="linkcell" width="20%" ><?php echo xlt('Name'); ?></th>
221 <th align="left" width="20%"><?php echo xlt('Patient'); ?></th>
222 <th align="left" width="30%"><?php echo xlt('Note'); ?></th>
223 <th width="10%"><?php echo xlt('Encounter ID'); ?></th>
224 </tr>
225 <?php
226 if (sqlNumRows($resultSet)) {
227 while ( $row = sqlFetchArray($resultSet) ) {
228 $url = $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=" . attr($row["foreign_id"]) . "&document_id=" . attr($row["id"]) . '&as_file=false';
229 // Get the notes for this document.
230 $notes = array();
231 $note = '';
232 if ( $row['docNotes'] ) {
233 $notes = explode("|",$row['docNotes']);
234 $dates = explode("|", $row['docDates']);
236 for ( $i = 0 ; $i < count($notes) ; $i++ )
237 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . text($notes[$i]) . "<br />";
239 <tr class="text">
240 <td><?php echo 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 <?php } ?>
250 </table>
251 </div>
252 </body>
253 </html>