removal of overlib_mini.js and calendar.js (#640)
[openemr.git] / interface / reports / patient_list_creation.php
blobdb24db2658afa605f1aa9da3fbde717d6bbbd53b
1 <?php
2 /**
3 * This report lists all the demographics allergies,problems,drugs and lab results
5 * Copyright (C) 2014 Ensoftek, Inc
6 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
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 Brady Miller <brady.g.miller@gmail.com>
21 * @link http://www.open-emr.org
24 //SANITIZE ALL ESCAPES
25 $sanitize_all_escapes=true;
28 //STOP FAKE REGISTER GLOBALS
29 $fake_register_globals=false;
31 require_once("../globals.php");
32 require_once("$srcdir/patient.inc");
33 require_once("$srcdir/options.inc.php");
34 require_once("../drugs/drugs.inc.php");
35 require_once("$srcdir/payment_jav.inc.php");
37 $search_options = array("Demographics"=>xl("Demographics"),"Problems"=>xl("Problems"),"Medications"=>xl("Medications"),"Allergies"=>xl("Allergies"),"Lab results"=>xl("Lab Results"),"Communication"=>xl("Communication"));
38 $comarr = array("allow_sms"=>xl("Allow SMS"),"allow_voice"=>xl("Allow Voice Message"),"allow_mail"=>xl("Allow Mail Message"),"allow_email"=>xl("Allow Email"));
39 $_POST['form_details'] = true;
40 function add_date($givendate,$day=0,$mth=0,$yr=0) {
41 $cd = strtotime($givendate);
42 $newdate = date('Y-m-d H:i:s', mktime(date('h',$cd),
43 date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
44 date('d',$cd)+$day, date('Y',$cd)+$yr));
45 return $newdate;
47 if($_POST['date_from'] != "")
48 $sql_date_from = $_POST['date_from'];
49 else
50 $sql_date_from = fixDate($_POST['date_from'], date('Y-01-01 H:i:s'));
52 if($_POST['date_to'] != "")
53 $sql_date_to = $_POST['date_to'];
54 else
55 $sql_date_to = fixDate($_POST['date_to'] , add_date(date('Y-m-d H:i:s')));
57 //echo "<pre>";print_r($_POST);
58 $patient_id = trim($_POST["patient_id"]);
59 $age_from = $_POST["age_from"];
60 $age_to = $_POST["age_to"];
61 $sql_gender = $_POST["gender"];
62 $sql_ethnicity = $_POST["cpms_ethnicity"];
63 $sql_race=$_POST["race"];
64 $form_drug_name = trim($_POST["form_drug_name"]);
65 $form_diagnosis = trim($_POST["form_diagnosis"]);
66 $form_lab_results = trim($_POST["form_lab_results"]);
67 $form_service_codes = trim($_POST["form_service_codes"]);
68 $form_immunization = trim($_POST["form_immunization"]);
69 $communication = trim($_POST["communication"]);
71 <html>
72 <head>
73 <?php html_header_show();?>
74 <title>
75 <?php echo xlt('Patient List Creation'); ?>
76 </title>
77 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
78 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
79 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
80 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.min.js"></script>
81 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.patched.js"></script>
82 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
83 <script language="JavaScript">
84 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
85 var global_date_format = '%Y-%m-%d';
87 function Form_Validate() {
88 var d = document.forms[0];
89 FromDate = d.date_from.value;
90 ToDate = d.date_to.value;
91 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
92 if ( FromDate > ToDate ){
93 alert("<?php echo xls('To date must be later than From date!'); ?>");
94 return false;
97 $("#processing").show();
98 return true;
101 </script>
102 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
103 <link rel="stylesheet" href="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.css" type="text/css" />
104 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media="screen" />
105 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
106 <style type="text/css">
107 /* specifically include & exclude from printing */
108 @media print {
109 #report_parameters {
110 visibility: hidden;
111 display: none;
113 #report_parameters_daterange {
114 visibility: visible;
115 display: inline;
117 #report_results table {
118 margin-top: 0px;
120 #report_image {
121 visibility: hidden;
122 display: none;
126 /* specifically exclude some from the screen */
127 @media screen {
128 #report_parameters_daterange {
129 visibility: hidden;
130 display: none;
134 </style>
135 <script language="javascript" type="text/javascript">
137 function submitForm() {
138 var d_from = new String($('#date_from').val());
139 var d_to = new String($('#date_to').val());
141 var d_from_arr = d_from.split('-');
142 var d_to_arr = d_to.split('-');
144 var dt_from = new Date(d_from_arr[0], d_from_arr[1], d_from_arr[2]);
145 var dt_to = new Date(d_to_arr[0], d_to_arr[1], d_to_arr[2]);
147 var mili_from = dt_from.getTime();
148 var mili_to = dt_to.getTime();
149 var diff = mili_to - mili_from;
151 $('#date_error').css("display", "none");
153 if(diff < 0) //negative
155 $('#date_error').css("display", "inline");
157 else
159 $("#form_refresh").attr("value","true");
160 top.restoreSession();
161 $("#theform").submit();
165 //sorting changes
166 function sortingCols(sort_by,sort_order)
168 $("#sortby").val(sort_by);
169 $("#sortorder").val(sort_order);
170 $("#form_refresh").attr("value","true");
171 $("#theform").submit();
174 $(document).ready(function() {
175 $(".numeric_only").keydown(function(event) {
176 //alert(event.keyCode);
177 // Allow only backspace and delete
178 if ( event.keyCode == 46 || event.keyCode == 8 ) {
179 // let it happen, don't do anything
181 else {
182 if(!((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57)))
184 event.preventDefault();
188 <?php if($_POST['srch_option'] == "Communication"){ ?>
189 $('#com_pref').show();
190 <?php } ?>
192 $('.datetimepicker').datetimepicker({
193 <?php $datetimepicker_timepicker = true; ?>
194 <?php $datetimepicker_showseconds = true; ?>
195 <?php $datetimepicker_formatInput = false; ?>
196 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
197 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
201 function printForm(){
202 var win = top.printLogPrint ? top : opener.top;
203 win.printLogPrint(window);
205 </script>
206 </head>
208 <body class="body_top">
209 <!-- Required for the popup date selectors -->
210 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
211 <span class='title'>
212 <?php echo xlt('Report - Patient List Creation');?>
213 </span>
214 <!-- Search can be done using age range, gender, and ethnicity filters.
215 Search options include diagnosis, procedure, prescription, medical history, and lab results.
218 <div id="report_parameters_daterange">
220 <?php echo "<span style='margin-left:5px;'><b>".xlt('Date Range').":</b>&nbsp;".text(date($sql_date_from, strtotime($sql_date_from))) .
221 " &nbsp; to &nbsp; ". text(date($sql_date_to, strtotime($sql_date_to)))."</span>"; ?>
222 <span style="margin-left:5px; " ><b><?php echo xlt('Option'); ?>:</b>&nbsp;<?php echo text($_POST['srch_option']);
223 if($_POST['srch_option'] == "Communication" && $_POST['communication'] != ""){
224 if(isset($comarr[$_POST['communication']]))
225 echo "(".text($comarr[$_POST['communication']]).")";
226 else
227 echo "(".xlt('All').")";
228 } ?></span>
229 </p>
230 </div>
231 <form name='theform' id='theform' method='post' action='patient_list_creation.php' onSubmit="return Form_Validate();">
232 <div id="report_parameters">
233 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
234 <table>
235 <tr>
236 <td width='900px'>
237 <div class="cancel-float" style='float:left'>
238 <table class='text'>
239 <tr>
240 <td class='label_custom' ><?php echo xlt('From'); ?>: </td>
241 <td><input type='text' class='datetimepicker' name='date_from' id="date_from" size='18' value='<?php echo attr($sql_date_from); ?>' title='<?php echo attr($title_tooltip) ?>'>
242 </td>
243 <td class='label_custom'><?php echo xlt('To{{range}}'); ?>: </td>
244 <td><input type='text' class='datetimepicker' name='date_to' id="date_to" size='18' value='<?php echo attr($sql_date_to); ?>' title='<?php echo attr($title_tooltip) ?>'>
245 </td>
246 <td class='label_custom'><?php echo xlt('Option'); ?>: </td>
247 <td class='label_custom'>
248 <select name="srch_option" id="srch_option" onchange="javascript:$('#sortby').val('');$('#sortorder').val('');if(this.value == 'Communication'){ $('#communication').val('');$('#com_pref').show();}else{ $('#communication').val('');$('#com_pref').hide();}">
249 <?php foreach($search_options as $skey => $svalue){ ?>
250 <option <?php if($_POST['srch_option'] == $skey) echo 'selected'; ?> value="<?php echo attr($skey); ?>"><?php echo text($svalue); ?></option>
251 <?php } ?>
252 </select>
253 <?php ?>
254 </td>
256 <td >
257 <span id="com_pref" style="display:none">
258 <select name="communication" id="communication" title="<?php echo xlt('Select Communication Preferences'); ?>">
259 <option> <?php echo xlt('All'); ?></option>
260 <option value="allow_sms" <?php if($communication == "allow_sms"){ echo "selected";}?>><?php echo xlt('Allow SMS'); ?></option>
261 <option value="allow_voice" <?php if($communication == "allow_voice"){ echo "selected";}?>><?php echo xlt('Allow Voice Message'); ?></option>
262 <option value="allow_mail" <?php if($communication == "allow_mail"){ echo "selected";}?>><?php echo xlt('Allow Mail Message'); ?></option>
263 <option value="allow_email" <?php if($communication == "allow_email"){ echo "selected";}?>><?php echo xlt('Allow Email'); ?></option>
264 </select>
265 </span>
266 </td>
268 </tr>
269 <tr>
270 <td class='label_custom'><?php echo xlt('Patient ID'); ?>:</td>
271 <td><input name='patient_id' class="numeric_only" type='text' id="patient_id" title='<?php echo xla('Optional numeric patient ID'); ?>' value='<?php echo attr($patient_id); ?>' size='10' maxlength='20' /></td>
272 <td class='label_custom'><?php echo xlt('Age Range'); ?>:</td>
273 <td><?php echo xlt('From'); ?>
274 <input name='age_from' class="numeric_only" type='text' id="age_from" value="<?php echo attr($age_from); ?>" size='3' maxlength='3' /> <?php echo xlt('To{{range}}'); ?>
275 <input name='age_to' class="numeric_only" type='text' id="age_to" value="<?php echo attr($age_to); ?>" size='3' maxlength='3' /></td>
276 <td class='label_custom'><?php echo xlt('Gender'); ?>:</td>
277 <td colspan="2"><?php echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?></td>
278 </tr>
280 </table>
282 </div></td>
283 <td height="100%" valign='middle' width="175"><table style='border-left:1px solid; width:100%; height:100%'>
284 <tr>
285 <td width="130px"><div style='margin-left:15px'> <a href='#' class='css_button' onclick='submitForm();'> <span>
286 <?php echo xlt('Submit'); ?>
287 </span> </a>
288 </div>
289 </td>
290 <?php if(isset($_POST['form_refresh'])){?>
291 <td width="130px"><div style='margin-left:15px'> <a href='#' class='css_button' onclick="printForm()"> <span>
292 <?php echo xlt('Print'); ?>
293 </span> </a>
294 </div>
295 </td>
296 <?php }?>
297 <td>
298 <div id='processing' style='display:none;' ><img src='../pic/ajax-loader.gif'/></div>
299 </td>
301 </tr>
302 </table></td>
303 </tr>
304 </table>
305 </div>
306 <!-- end of parameters -->
307 <?php
309 // SQL scripts for the various searches
310 $sqlBindArray = array();
311 if ($_POST['form_refresh']){
313 $sqlstmt = "select
314 pd.date as patient_date,
315 concat(pd.lname, ', ', pd.fname) AS patient_name,
316 pd.pid AS patient_id,
317 DATE_FORMAT(FROM_DAYS(DATEDIFF('".date('Y-m-d H:i:s')."',pd.dob)), '%Y')+0 AS patient_age,
318 pd.sex AS patient_sex,
319 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
320 concat(u.lname, ', ', u.fname) AS users_provider";
322 $srch_option = $_POST['srch_option'];
323 switch ($srch_option) {
324 case "Medications":
325 case "Allergies":
326 case "Problems":
327 $sqlstmt=$sqlstmt.",li.date AS lists_date,
328 li.diagnosis AS lists_diagnosis,
329 li.title AS lists_title";
330 break;
331 case "Lab results":
332 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
333 pr.facility AS procedure_result_facility,
334 pr.units AS procedure_result_units,
335 pr.result AS procedure_result_result,
336 pr.range AS procedure_result_range,
337 pr.abnormal AS procedure_result_abnormal,
338 pr.comments AS procedure_result_comments,
339 pr.document_id AS procedure_result_document_id";
340 break;
341 case "Communication":
342 $sqlstmt = $sqlstmt.",REPLACE(REPLACE(concat_ws(',',IF(pd.hipaa_allowemail = 'YES', 'Allow Email','NO'),IF(pd.hipaa_allowsms = 'YES', 'Allow SMS','NO') , IF(pd.hipaa_mail = 'YES', 'Allow Mail Message','NO') , IF(pd.hipaa_voice = 'YES', 'Allow Voice Message','NO') ), ',NO',''), 'NO,','') as communications";
343 break;
346 //from
347 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid";
348 //JOINS
349 switch ($srch_option) {
350 case "Problems":
351 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND li.type='medical_problem')";
352 break;
353 case "Medications":
354 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medication')) ";
355 break;
356 case "Allergies":
357 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
358 break;
359 case "Lab results":
361 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
362 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
363 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
364 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id
365 left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id";
366 break;
369 //WHERE Conditions started
370 $whr_stmt="where 1=1";
371 switch ($srch_option) {
372 case "Medications":
373 case "Allergies":
374 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
375 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
376 break;
377 case "Problems":
378 $whr_stmt = $whr_stmt." AND li.title != '' ";
379 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
380 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
381 break;
382 case "Lab results":
383 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND pr.date <= ?";
384 $whr_stmt= $whr_stmt." AND (pr.result != '') ";
385 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
386 break;
387 case "Communication":
388 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
389 break;
392 if(strlen($patient_id) != 0) {
393 $whr_stmt = $whr_stmt." and pd.pid = ?";
394 array_push($sqlBindArray, $patient_id);
397 if(strlen($age_from) != 0) {
398 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
399 array_push($sqlBindArray, $age_from);
402 if(strlen($age_to) != 0) {
403 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
404 array_push($sqlBindArray, $age_to);
407 if(strlen($sql_gender) != 0) {
408 $whr_stmt = $whr_stmt." and pd.sex = ?";
409 array_push($sqlBindArray, $sql_gender);
412 if($srch_option == "Communication" && strlen($communication) > 0){
413 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
414 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
415 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
416 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
419 //Sorting By filter fields
420 $sortby = $_REQUEST['sortby'];
421 $sortorder = $_REQUEST['sortorder'];
423 // This is for sorting the records.
424 switch ($srch_option) {
425 case "Medications":
426 case "Allergies":
427 case "Problems":
428 $sort = array("lists_date","lists_diagnosis","lists_title");
429 if($sortby == "")$sortby = $sort[1];
430 break;
431 case "Lab results":
432 $sort = array("procedure_result_date","procedure_result_facility","procedure_result_units","procedure_result_result","procedure_result_range","procedure_result_abnormal");
433 //$odrstmt = " procedure_result_result";
434 break;
435 case "Communication":
436 //$commsort = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(','))";
437 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","users_provider", "communications");
438 if($sortby == "")$sortby = $sort[6];
439 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
440 break;
441 case "Demographics":
442 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","patient_race","patient_ethinic","users_provider");
443 break;
445 if($sortby == "") {
446 $sortby = $sort[0];
448 if($sortorder == "") {
449 $sortorder = "asc";
451 for($i = 0; $i < count($sort); $i++) {
452 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sort[$i]','asc');\" ><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Up')."\"></a>";
454 for($i = 0; $i < count($sort); $i++) {
455 if($sortby == $sort[$i]) {
456 switch($sortorder) {
457 case "asc" : $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','desc');\" ><img src=\"../../images/sortup.gif\" border=0 alt=\"".htmlspecialchars( xl('Sort Up'), ENT_QUOTES)."\"></a>"; break;
458 case "desc" : $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','asc');\" onclick=\"top.restoreSession()\"><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Down')."\"></a>"; break;
459 } break;
463 switch ($srch_option) {
464 case "Medications":
465 case "Allergies":
466 case "Problems":
467 $odrstmt = " ORDER BY lists_date asc";
468 break;
469 case "Lab results":
470 $odrstmt = " ORDER BY procedure_result_date asc";
471 break;
472 case "Communication":
473 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) asc, communications asc";
474 break;
475 case "Demographics":
476 $odrstmt = " ORDER BY patient_date asc";
477 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
478 break;
480 if(!empty($_REQUEST['sortby']) && !empty($_REQUEST['sortorder'])){
481 if($_REQUEST['sortby'] =="communications"){
482 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) ".escape_sort_order($_REQUEST['sortorder']).", communications ".escape_sort_order($_REQUEST['sortorder']);
483 }else{
484 $odrstmt = "ORDER BY ".escape_identifier($_REQUEST['sortby'],$sort,TRUE)." ".escape_sort_order($_REQUEST['sortorder']);
488 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
489 //echo $sqlstmt."<hr>";
490 $result = sqlStatement($sqlstmt,$sqlBindArray);
491 //print_r($result);
492 $row_id = 1.1;//given to each row to identify and toggle
493 $img_id = 1.2;
494 $k=1.3;
496 if(sqlNumRows($result) > 0){
497 $patArr = array();
499 $patDataArr = array();
500 $smoke_codes_arr = getSmokeCodes();
501 while ($row = sqlFetchArray($result)) {
503 $patArr[] = $row['patient_id'];
504 $patInfoArr = array();
505 $patInfoArr['patient_id'] = $row['patient_id'];
506 //Diagnosis Check
507 if($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems"){
508 $patInfoArr['lists_date'] = $row['lists_date'];
509 $patInfoArr['lists_diagnosis'] = $row['lists_diagnosis'];
510 $patInfoArr['lists_title'] = $row['lists_title'];
511 $patInfoArr['patient_name'] = $row['patient_name'];
512 $patInfoArr['patient_age'] = $row['patient_age'];
513 $patInfoArr['patient_sex'] = $row['patient_sex'];
514 $patInfoArr['patient_race'] = $row['patient_race'];
515 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
516 $patInfoArr['users_provider'] = $row['users_provider'];
517 }elseif($srch_option == "Lab results"){
518 $patInfoArr['procedure_result_date'] = $row['procedure_result_date'];
519 $patInfoArr['procedure_result_facility'] = $row['procedure_result_facility'];
520 $patInfoArr['procedure_result_units'] = $row['procedure_result_units'];
521 $patInfoArr['procedure_result_result'] = $row['procedure_result_result'];
522 $patInfoArr['procedure_result_range'] = $row['procedure_result_range'];
523 $patInfoArr['procedure_result_abnormal'] = $row['procedure_result_abnormal'];
524 $patInfoArr['procedure_result_comments'] = $row['procedure_result_comments'];
525 $patInfoArr['procedure_result_document_id'] = $row['procedure_result_document_id'];
526 }elseif($srch_option == "Communication"){
527 $patInfoArr['patient_date'] = $row['patient_date'];
528 $patInfoArr['patient_name'] = $row['patient_name'];
529 $patInfoArr['patient_age'] = $row['patient_age'];
530 $patInfoArr['patient_sex'] = $row['patient_sex'];
531 $patInfoArr['users_provider'] = $row['users_provider'];
532 $patInfoArr['communications'] = $row['communications'];
533 }elseif($srch_option == "Demographics"){
534 $patInfoArr['patient_date'] = $row['patient_date'];
535 $patInfoArr['patient_name'] = $row['patient_name'];
536 $patInfoArr['patient_age'] = $row['patient_age'];
537 $patInfoArr['patient_sex'] = $row['patient_sex'];
538 $patInfoArr['patient_race'] = $row['patient_race'];
539 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
540 $patInfoArr['users_provider'] = $row['users_provider'];
543 $patFinalDataArr[] = $patInfoArr;
550 <br>
552 <input type="hidden" name="sortby" id="sortby" value="<?php echo attr($sortby); ?>" />
553 <input type="hidden" name="sortorder" id="sortorder" value="<?php echo attr($sortorder); ?>" />
554 <div id = "report_results">
555 <table>
556 <tr>
557 <td class="text"><strong><?php echo xlt('Total Number of Patients')?>:</strong>&nbsp;<span id="total_patients"><?php echo attr(count(array_unique($patArr)));?></span></td>
558 </tr>
559 </table>
561 <table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0">
563 <?php if($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems"){ ?>
564 <tr style="font-size:15px;">
565 <td width="15%"><b><?php echo xlt('Diagnosis Date'); ?><?php echo $sortlink[0]; ?></b></td>
566 <td width="15%"><b><?php echo xlt('Diagnosis'); ?><?php echo $sortlink[1]; ?></b></td>
567 <td width="15%"><b><?php echo xlt('Diagnosis Name');?><?php echo $sortlink[2]; ?></b></td>
568 <td width="15%"><b><?php echo xlt('Patient Name'); ?></b></td>
569 <td width="5%"><b><?php echo xlt('PID');?></b></td>
570 <td width="5%"><b><?php echo xlt('Age');?></b></td>
571 <td width="10%"><b><?php echo xlt('Gender');?></b></td>
572 <td colspan=4><b><?php echo xlt('Provider');?></b></td>
573 </tr>
574 <?php foreach($patFinalDataArr as $patKey => $patDetailVal){ ?>
575 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
576 <td ><?php echo text($patDetailVal['lists_date']); ?></td>
577 <td ><?php echo text($patDetailVal['lists_diagnosis']); ?></td>
578 <td ><?php echo text($patDetailVal['lists_title']); ?></td>
579 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
580 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
581 <td ><?php echo text($patDetailVal['patient_age']);?></td>
582 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
583 <td colspan=4><?php echo text($patDetailVal['users_provider']);?></td>
584 </tr>
585 <?php }
586 }elseif($srch_option == "Lab results"){ ?>
587 <tr bgcolor="#C3FDB8" align= "left" >
588 <td width="15%"><b><?php echo xlt('Date'); ?><?php echo $sortlink[0]; ?></b></td>
589 <td width="15%"><b><?php echo xlt('Facility');?><?php echo $sortlink[1]; ?></b></td>
590 <td width="10%"><b><?php echo xlt('Unit');?></b><?php echo $sortlink[2]; ?></td>
591 <td width="10%"><b><?php echo xlt('Result');?></b><?php echo $sortlink[3]; ?></td>
592 <td width="10%"><b><?php echo xlt('Range');?></b><?php echo $sortlink[4]; ?></td>
593 <td width="10%"><b><?php echo xlt('Abnormal');?><?php echo $sortlink[5]; ?></b></td>
594 <td><b><?php echo xlt('Comments');?></b></td>
595 <td width="5%"><b><?php echo xlt('Document ID');?></b></td>
596 <td width="5%"><b><?php echo xlt('PID');?></b></td>
597 </tr>
598 <?php
599 foreach($patFinalDataArr as $patKey => $labResInsideArr){?>
600 <tr bgcolor = "#CCCCCC" >
601 <td> <?php echo text($labResInsideArr['procedure_result_date']);?>&nbsp;</td>
602 <td> <?php echo text($labResInsideArr['procedure_result_facility'],ENT_NOQUOTES); ?>&nbsp;</td>
603 <td> <?php echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$labResInsideArr['procedure_result_units']); ?>&nbsp;</td>
604 <td> <?php echo text($labResInsideArr['procedure_result_result']); ?>&nbsp;</td>
605 <td> <?php echo text($labResInsideArr['procedure_result_range']); ?>&nbsp;</td>
606 <td> <?php echo text($labResInsideArr['procedure_result_abnormal']); ?>&nbsp;</td>
607 <td> <?php echo text($labResInsideArr['procedure_result_comments']); ?>&nbsp;</td>
608 <td> <?php echo text($labResInsideArr['procedure_result_document_id']); ?>&nbsp;</td>
609 <td colspan="3"> <?php echo text($labResInsideArr['patient_id']); ?>&nbsp;</td>
610 </tr>
611 <?php
613 }elseif($srch_option == "Communication"){ ?>
614 <tr style="font-size:15px;">
615 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
616 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
617 <td width="5%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
618 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
619 <td width="10%"><b><?php echo xlt('Gender');?></b><?php echo $sortlink[4]; ?></td>
620 <td width="15%"><b><?php echo xlt('Provider');?></b><?php echo $sortlink[5]; ?></td>
621 <td ><b><?php echo xlt('Communication');?></b><?php echo $sortlink[6]; ?></td>
622 </tr>
623 <?php foreach($patFinalDataArr as $patKey => $patDetailVal){ ?>
624 <tr bgcolor = "#CCCCCC" >
625 <td ><?php if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; }; ?></td>
626 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
627 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
628 <td ><?php echo text($patDetailVal['patient_age']);?></td>
629 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
630 <td ><?php echo text($patDetailVal['users_provider']);?></td>
631 <td ><?php echo text($patDetailVal['communications']);?></td>
632 </tr>
633 <?php
635 }elseif($srch_option == "Demographics"){ ?>
636 <tr style="font-size:15px;">
637 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
638 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
639 <td width="15%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
640 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
641 <td width="10%"><b><?php echo xlt('Gender'); ?></b><?php echo $sortlink[4]; ?></td>
642 <td width="20%"><b><?php echo xlt('Race');?></b><?php echo $sortlink[5]; ?></td>
643 <td colspan=5><b><?php echo xlt('Provider');?></b><?php echo $sortlink[7]; ?></td>
644 </tr>
645 <?php foreach($patFinalDataArr as $patKey => $patDetailVal){ ?>
646 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
647 <td ><?php if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; };?></td>
648 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
649 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
650 <td ><?php echo text($patDetailVal['patient_age']);?></td>
651 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
652 <td ><?php echo generate_display_field(array('data_type'=>'36','list_id'=>'race'), $patDetailVal['patient_race']); ?></td>
653 <td colspan=5><?php echo text($patDetailVal['users_provider']);?></td>
654 </tr>
655 <?php }
656 } ?>
658 </table>
659 <!-- Main table ends -->
660 <?php
661 }else{//End if $result?>
662 <table>
663 <tr>
664 <td class="text">&nbsp;&nbsp;<?php echo xlt('No records found.')?></td>
665 </tr>
666 </table>
667 <?php
670 </div>
672 <?php
673 }else{//End if form_refresh
674 ?><div class='text'> <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?> </div><?php
677 </form>
679 </body>
680 </html>