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>;.
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";
48 $title_tooltip = "YYYY-MM-DD";
51 $display_div = "style='display:block;'";
52 $display_expand_msg = "display:none;";
53 $display_collapse_msg = "display:inline;";
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() {
80 content
: '<iframe class="qtip-box" src="' + $
(this
).attr('title') +
'" />',
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'); ?>");
106 document
.location
='<?php echo $GLOBALS['webroot
']; ?>/interface/main/display_documents.php?' + fromDate +
'='+frmdate+
'&' + toDate +
'='+todate
;
109 function expandOrCollapse(type
,prefixString
) {
111 $
("#" + prefixString +
"filterdiv").show();
112 $
("#" + prefixString +
"div").show();
113 $
("#" + prefixString +
"collapse").show();
114 $
("#" + prefixString +
"expand").hide();
116 $
("#" + prefixString +
"filterdiv").hide();
117 $
("#" + prefixString +
"div").hide();
118 $
("#" + prefixString +
"collapse").hide();
119 $
("#" + prefixString +
"expand").show();
125 <style type
="text/css">
143 text
-overflow
: ellipsis
;
151 <body
class="body_top">
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
>
158 <div id
='docfilterdiv'<?php
echo $display_div; ?
>>
159 <table style
="margin-left:10px; " width
='40%'>
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
>
167 Calendar
.setup({inputField
:"form_from_doc_date", ifFormat
:global_date_format
, button
:"img_from_doc_date"});
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
>
175 Calendar
.setup({inputField
:"form_to_doc_date", ifFormat
:global_date_format
, button
:"img_to_doc_date"});
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
>
187 <div id
='docdiv' <?php
echo $display_div; ?
>>
189 $current_user = $_SESSION["authId"];
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
>
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.
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 />";
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
>
244 <td
><?php
echo text($row['pname']); ?
> </td
>
245 <td
><?php
echo $note; ?
>  
;</td
>
246 <td align
="center"><?php
echo ( $row['encounter_id'] ) ?
text($row['encounter_id']) : ''; ?
> </td
>