ongoing internationalization of date widget
[openemr.git] / interface / reports / patient_list_creation.php
blobd9a638cef4e34cfa751505d282b25ea20d9dafc7
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 use OpenEMR\Core\Header;
26 require_once("../globals.php");
27 require_once("$srcdir/patient.inc");
28 require_once("$srcdir/options.inc.php");
29 require_once("../drugs/drugs.inc.php");
30 require_once("$srcdir/payment_jav.inc.php");
32 $search_options = array("Demographics"=>xl("Demographics"),"Problems"=>xl("Problems"),"Medications"=>xl("Medications"),"Allergies"=>xl("Allergies"),"Lab results"=>xl("Lab Results"),"Communication"=>xl("Communication"));
33 $comarr = array("allow_sms"=>xl("Allow SMS"),"allow_voice"=>xl("Allow Voice Message"),"allow_mail"=>xl("Allow Mail Message"),"allow_email"=>xl("Allow Email"));
34 $_POST['form_details'] = true;
35 function add_date($givendate, $day = 0, $mth = 0, $yr = 0)
37 $cd = strtotime($givendate);
38 $newdate = date('Y-m-d H:i:s', mktime(
39 date('h', $cd),
40 date('i', $cd),
41 date('s', $cd),
42 date('m', $cd)+$mth,
43 date('d', $cd)+$day,
44 date('Y', $cd)+$yr
45 ));
46 return $newdate;
48 if ($_POST['date_from'] != "") {
49 $sql_date_from = $_POST['date_from'];
50 } else {
51 $sql_date_from = fixDate($_POST['date_from'], date('Y-01-01 H:i:s'));
54 if ($_POST['date_to'] != "") {
55 $sql_date_to = $_POST['date_to'];
56 } else {
57 $sql_date_to = fixDate($_POST['date_to'], add_date(date('Y-m-d H:i:s')));
60 //echo "<pre>";print_r($_POST);
61 $patient_id = trim($_POST["patient_id"]);
62 $age_from = $_POST["age_from"];
63 $age_to = $_POST["age_to"];
64 $sql_gender = $_POST["gender"];
65 $sql_ethnicity = $_POST["cpms_ethnicity"];
66 $sql_race=$_POST["race"];
67 $form_drug_name = trim($_POST["form_drug_name"]);
68 $form_diagnosis = trim($_POST["form_diagnosis"]);
69 $form_lab_results = trim($_POST["form_lab_results"]);
70 $form_service_codes = trim($_POST["form_service_codes"]);
71 $form_immunization = trim($_POST["form_immunization"]);
72 $communication = trim($_POST["communication"]);
74 <html>
75 <head>
77 <title>
78 <?php echo xlt('Patient List Creation'); ?>
79 </title>
81 <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
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>
103 <style type="text/css">
104 /* specifically include & exclude from printing */
105 @media print {
106 #report_parameters {
107 visibility: hidden;
108 display: none;
110 #report_parameters_daterange {
111 visibility: visible;
112 display: inline;
114 #report_results table {
115 margin-top: 0px;
117 #report_image {
118 visibility: hidden;
119 display: none;
123 /* specifically exclude some from the screen */
124 @media screen {
125 #report_parameters_daterange {
126 visibility: hidden;
127 display: none;
131 </style>
132 <script language="javascript" type="text/javascript">
134 function submitForm() {
135 var d_from = new String($('#date_from').val());
136 var d_to = new String($('#date_to').val());
138 var d_from_arr = d_from.split('-');
139 var d_to_arr = d_to.split('-');
141 var dt_from = new Date(d_from_arr[0], d_from_arr[1], d_from_arr[2]);
142 var dt_to = new Date(d_to_arr[0], d_to_arr[1], d_to_arr[2]);
144 var mili_from = dt_from.getTime();
145 var mili_to = dt_to.getTime();
146 var diff = mili_to - mili_from;
148 $('#date_error').css("display", "none");
150 if(diff < 0) //negative
152 $('#date_error').css("display", "inline");
154 else
156 $("#form_refresh").attr("value","true");
157 top.restoreSession();
158 $("#theform").submit();
162 //sorting changes
163 function sortingCols(sort_by,sort_order)
165 $("#sortby").val(sort_by);
166 $("#sortorder").val(sort_order);
167 $("#form_refresh").attr("value","true");
168 $("#theform").submit();
171 $(document).ready(function() {
172 $(".numeric_only").keydown(function(event) {
173 //alert(event.keyCode);
174 // Allow only backspace and delete
175 if ( event.keyCode == 46 || event.keyCode == 8 ) {
176 // let it happen, don't do anything
178 else {
179 if(!((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57)))
181 event.preventDefault();
185 <?php if ($_POST['srch_option'] == "Communication") { ?>
186 $('#com_pref').show();
187 <?php } ?>
189 $('.datetimepicker').datetimepicker({
190 <?php $datetimepicker_timepicker = true; ?>
191 <?php $datetimepicker_showseconds = true; ?>
192 <?php $datetimepicker_formatInput = false; ?>
193 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
194 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
198 function printForm(){
199 var win = top.printLogPrint ? top : opener.top;
200 win.printLogPrint(window);
202 </script>
203 </head>
205 <body class="body_top">
206 <!-- Required for the popup date selectors -->
207 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
208 <span class='title'>
209 <?php echo xlt('Report - Patient List Creation');?>
210 </span>
211 <!-- Search can be done using age range, gender, and ethnicity filters.
212 Search options include diagnosis, procedure, prescription, medical history, and lab results.
215 <div id="report_parameters_daterange">
217 <?php echo "<span style='margin-left:5px;'><b>".xlt('Date Range').":</b>&nbsp;".text(date($sql_date_from, strtotime($sql_date_from))) .
218 " &nbsp; to &nbsp; ". text(date($sql_date_to, strtotime($sql_date_to)))."</span>"; ?>
219 <span style="margin-left:5px; " ><b><?php echo xlt('Option'); ?>:</b>&nbsp;<?php echo text($_POST['srch_option']);
220 if ($_POST['srch_option'] == "Communication" && $_POST['communication'] != "") {
221 if (isset($comarr[$_POST['communication']])) {
222 echo "(".text($comarr[$_POST['communication']]).")";
223 } else {
224 echo "(".xlt('All').")";
226 } ?></span>
227 </p>
228 </div>
229 <form name='theform' id='theform' method='post' action='patient_list_creation.php' onSubmit="return Form_Validate();">
230 <div id="report_parameters">
231 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
232 <table>
233 <tr>
234 <td width='640px'>
235 <div class="cancel-float" style='float:left'>
236 <table class='text'>
237 <tr>
238 <td class='control-label' ><?php echo xlt('From'); ?>: </td>
239 <td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr($sql_date_from); ?>' title='<?php echo attr($title_tooltip) ?>'>
240 </td>
241 <td class='control-label'><?php echo xlt('To{{range}}'); ?>: </td>
242 <td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr($sql_date_to); ?>' title='<?php echo attr($title_tooltip) ?>'>
243 </td>
244 <td class='control-label'><?php echo xlt('Option'); ?>: </td>
245 <td class='control-label'>
246 <select class="form-control" 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();}">
247 <?php foreach ($search_options as $skey => $svalue) { ?>
248 <option <?php if ($_POST['srch_option'] == $skey) {
249 echo 'selected';
250 } ?> 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 class="form-control" 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") {
261 echo "selected";
262 }?>><?php echo xlt('Allow SMS'); ?></option>
263 <option value="allow_voice" <?php if ($communication == "allow_voice") {
264 echo "selected";
265 }?>><?php echo xlt('Allow Voice Message'); ?></option>
266 <option value="allow_mail" <?php if ($communication == "allow_mail") {
267 echo "selected";
268 }?>><?php echo xlt('Allow Mail Message'); ?></option>
269 <option value="allow_email" <?php if ($communication == "allow_email") {
270 echo "selected";
271 }?>><?php echo xlt('Allow Email'); ?></option>
272 </select>
273 </span>
274 </td>
276 </tr>
277 <tr>
278 <td class='control-label'><?php echo xlt('Patient ID'); ?>:</td>
279 <td><input name='patient_id' class="numeric_only form-control" type='text' id="patient_id" title='<?php echo xla('Optional numeric patient ID'); ?>' value='<?php echo attr($patient_id); ?>' size='10' maxlength='20' /></td>
280 <td class='control-label'><?php echo xlt('Age Range'); ?>:</td>
282 <td>
283 <table>
284 <tr>
285 <td class='control-label'>
286 <?php echo xlt('From'); ?>:
287 </td>
288 <td>
289 <input name='age_from' class="numeric_only form-control" type='text' id="age_from" value="<?php echo attr($age_from); ?>" size='3' maxlength='3' />
290 </td>
291 <td class='control-label'>
292 <?php echo xlt('To{{range}}'); ?>:
293 </td>
294 <td>
295 <input name='age_to' class="numeric_only form-control" type='text' id="age_to" value="<?php echo attr($age_to); ?>" size='3' maxlength='3' />
296 </td>
297 </tr>
298 </table>
299 </td>
301 <td class='control-label'><?php echo xlt('Gender'); ?>:</td>
302 <td colspan="2"><?php echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?></td>
303 </tr>
305 </table>
307 </div></td>
308 <td height="100%" valign='middle' width="175"><table style='border-left:1px solid; width:100%; height:100%'>
309 <tr>
310 <td>
311 <div class="text-center">
312 <div class="btn-group" role="group">
313 <a href='#' class='btn btn-default btn-save' onclick='submitForm();'>
314 <?php echo xlt('Submit'); ?>
315 </a>
316 <?php if (isset($_POST['form_refresh'])) {?>
317 <a href='#' class='btn btn-default btn-print' onclick="printForm()">
318 <?php echo xlt('Print'); ?>
319 </a>
320 <?php }?>
321 </div>
322 </div>
323 </td>
324 <td>
325 <div id='processing' style='display:none;' ><img src='../pic/ajax-loader.gif'/></div>
326 </td>
328 </tr>
329 </table></td>
330 </tr>
331 </table>
332 </div>
333 <!-- end of parameters -->
334 <?php
336 // SQL scripts for the various searches
337 $sqlBindArray = array();
338 if ($_POST['form_refresh']) {
339 $sqlstmt = "select
340 pd.date as patient_date,
341 concat(pd.lname, ', ', pd.fname) AS patient_name,
342 pd.pid AS patient_id,
343 DATE_FORMAT(FROM_DAYS(DATEDIFF('".date('Y-m-d H:i:s')."',pd.dob)), '%Y')+0 AS patient_age,
344 pd.sex AS patient_sex,
345 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
346 concat(u.lname, ', ', u.fname) AS users_provider";
348 $srch_option = $_POST['srch_option'];
349 switch ($srch_option) {
350 case "Medications":
351 case "Allergies":
352 case "Problems":
353 $sqlstmt=$sqlstmt.",li.date AS lists_date,
354 li.diagnosis AS lists_diagnosis,
355 li.title AS lists_title";
356 break;
357 case "Lab results":
358 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
359 pr.facility AS procedure_result_facility,
360 pr.units AS procedure_result_units,
361 pr.result AS procedure_result_result,
362 pr.range AS procedure_result_range,
363 pr.abnormal AS procedure_result_abnormal,
364 pr.comments AS procedure_result_comments,
365 pr.document_id AS procedure_result_document_id";
366 break;
367 case "Communication":
368 $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";
369 break;
372 //from
373 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid";
374 //JOINS
375 switch ($srch_option) {
376 case "Problems":
377 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND li.type='medical_problem')";
378 break;
379 case "Medications":
380 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medication')) ";
381 break;
382 case "Allergies":
383 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
384 break;
385 case "Lab results":
386 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
387 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
388 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
389 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id
390 left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id";
391 break;
394 //WHERE Conditions started
395 $whr_stmt="where 1=1";
396 switch ($srch_option) {
397 case "Medications":
398 case "Allergies":
399 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
400 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
401 break;
402 case "Problems":
403 $whr_stmt = $whr_stmt." AND li.title != '' ";
404 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
405 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
406 break;
407 case "Lab results":
408 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND pr.date <= ?";
409 $whr_stmt= $whr_stmt." AND (pr.result != '') ";
410 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
411 break;
412 case "Communication":
413 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
414 break;
417 if (strlen($patient_id) != 0) {
418 $whr_stmt = $whr_stmt." and pd.pid = ?";
419 array_push($sqlBindArray, $patient_id);
422 if (strlen($age_from) != 0) {
423 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
424 array_push($sqlBindArray, $age_from);
427 if (strlen($age_to) != 0) {
428 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
429 array_push($sqlBindArray, $age_to);
432 if (strlen($sql_gender) != 0) {
433 $whr_stmt = $whr_stmt." and pd.sex = ?";
434 array_push($sqlBindArray, $sql_gender);
437 if ($srch_option == "Communication" && strlen($communication) > 0) {
438 if ($communication == "allow_sms") {
439 $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
440 } else if ($communication == "allow_voice") {
441 $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
442 } else if ($communication == "allow_mail") {
443 $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
444 } else if ($communication == "allow_email") {
445 $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
449 //Sorting By filter fields
450 $sortby = $_REQUEST['sortby'];
451 $sortorder = $_REQUEST['sortorder'];
453 // This is for sorting the records.
454 switch ($srch_option) {
455 case "Medications":
456 case "Allergies":
457 case "Problems":
458 $sort = array("lists_date","lists_diagnosis","lists_title");
459 if ($sortby == "") {
460 $sortby = $sort[1];
462 break;
463 case "Lab results":
464 $sort = array("procedure_result_date","procedure_result_facility","procedure_result_units","procedure_result_result","procedure_result_range","procedure_result_abnormal");
465 //$odrstmt = " procedure_result_result";
466 break;
467 case "Communication":
468 //$commsort = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(','))";
469 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","users_provider", "communications");
470 if ($sortby == "") {
471 $sortby = $sort[6];
474 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
475 break;
476 case "Demographics":
477 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","patient_race","patient_ethinic","users_provider");
478 break;
481 if ($sortby == "") {
482 $sortby = $sort[0];
485 if ($sortorder == "") {
486 $sortorder = "asc";
489 for ($i = 0; $i < count($sort); $i++) {
490 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sort[$i]','asc');\" ><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Up')."\"></a>";
493 for ($i = 0; $i < count($sort); $i++) {
494 if ($sortby == $sort[$i]) {
495 switch ($sortorder) {
496 case "asc":
497 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','desc');\" ><img src=\"../../images/sortup.gif\" border=0 alt=\"".htmlspecialchars(xl('Sort Up'), ENT_QUOTES)."\"></a>";
498 break;
499 case "desc":
500 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','asc');\" onclick=\"top.restoreSession()\"><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Down')."\"></a>";
501 break;
502 } break;
506 switch ($srch_option) {
507 case "Medications":
508 case "Allergies":
509 case "Problems":
510 $odrstmt = " ORDER BY lists_date asc";
511 break;
512 case "Lab results":
513 $odrstmt = " ORDER BY procedure_result_date asc";
514 break;
515 case "Communication":
516 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) asc, communications asc";
517 break;
518 case "Demographics":
519 $odrstmt = " ORDER BY patient_date asc";
520 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
521 break;
524 if (!empty($_REQUEST['sortby']) && !empty($_REQUEST['sortorder'])) {
525 if ($_REQUEST['sortby'] =="communications") {
526 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) ".escape_sort_order($_REQUEST['sortorder']).", communications ".escape_sort_order($_REQUEST['sortorder']);
527 } else {
528 $odrstmt = "ORDER BY ".escape_identifier($_REQUEST['sortby'], $sort, true)." ".escape_sort_order($_REQUEST['sortorder']);
532 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
533 //echo $sqlstmt."<hr>";
534 $result = sqlStatement($sqlstmt, $sqlBindArray);
535 //print_r($result);
536 $row_id = 1.1;//given to each row to identify and toggle
537 $img_id = 1.2;
538 $k=1.3;
540 if (sqlNumRows($result) > 0) {
541 $patArr = array();
543 $patDataArr = array();
544 $smoke_codes_arr = getSmokeCodes();
545 while ($row = sqlFetchArray($result)) {
546 $patArr[] = $row['patient_id'];
547 $patInfoArr = array();
548 $patInfoArr['patient_id'] = $row['patient_id'];
549 //Diagnosis Check
550 if ($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems") {
551 $patInfoArr['lists_date'] = $row['lists_date'];
552 $patInfoArr['lists_diagnosis'] = $row['lists_diagnosis'];
553 $patInfoArr['lists_title'] = $row['lists_title'];
554 $patInfoArr['patient_name'] = $row['patient_name'];
555 $patInfoArr['patient_age'] = $row['patient_age'];
556 $patInfoArr['patient_sex'] = $row['patient_sex'];
557 $patInfoArr['patient_race'] = $row['patient_race'];
558 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
559 $patInfoArr['users_provider'] = $row['users_provider'];
560 } elseif ($srch_option == "Lab results") {
561 $patInfoArr['procedure_result_date'] = $row['procedure_result_date'];
562 $patInfoArr['procedure_result_facility'] = $row['procedure_result_facility'];
563 $patInfoArr['procedure_result_units'] = $row['procedure_result_units'];
564 $patInfoArr['procedure_result_result'] = $row['procedure_result_result'];
565 $patInfoArr['procedure_result_range'] = $row['procedure_result_range'];
566 $patInfoArr['procedure_result_abnormal'] = $row['procedure_result_abnormal'];
567 $patInfoArr['procedure_result_comments'] = $row['procedure_result_comments'];
568 $patInfoArr['procedure_result_document_id'] = $row['procedure_result_document_id'];
569 } elseif ($srch_option == "Communication") {
570 $patInfoArr['patient_date'] = $row['patient_date'];
571 $patInfoArr['patient_name'] = $row['patient_name'];
572 $patInfoArr['patient_age'] = $row['patient_age'];
573 $patInfoArr['patient_sex'] = $row['patient_sex'];
574 $patInfoArr['users_provider'] = $row['users_provider'];
575 $patInfoArr['communications'] = $row['communications'];
576 } elseif ($srch_option == "Demographics") {
577 $patInfoArr['patient_date'] = $row['patient_date'];
578 $patInfoArr['patient_name'] = $row['patient_name'];
579 $patInfoArr['patient_age'] = $row['patient_age'];
580 $patInfoArr['patient_sex'] = $row['patient_sex'];
581 $patInfoArr['patient_race'] = $row['patient_race'];
582 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
583 $patInfoArr['users_provider'] = $row['users_provider'];
586 $patFinalDataArr[] = $patInfoArr;
592 <br>
594 <input type="hidden" name="sortby" id="sortby" value="<?php echo attr($sortby); ?>" />
595 <input type="hidden" name="sortorder" id="sortorder" value="<?php echo attr($sortorder); ?>" />
596 <div id = "report_results">
597 <table>
598 <tr>
599 <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>
600 </tr>
601 </table>
603 <table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0">
605 <?php if ($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems") { ?>
606 <tr style="font-size:15px;">
607 <td width="15%"><b><?php echo xlt('Diagnosis Date'); ?><?php echo $sortlink[0]; ?></b></td>
608 <td width="15%"><b><?php echo xlt('Diagnosis'); ?><?php echo $sortlink[1]; ?></b></td>
609 <td width="15%"><b><?php echo xlt('Diagnosis Name');?><?php echo $sortlink[2]; ?></b></td>
610 <td width="15%"><b><?php echo xlt('Patient Name'); ?></b></td>
611 <td width="5%"><b><?php echo xlt('PID');?></b></td>
612 <td width="5%"><b><?php echo xlt('Age');?></b></td>
613 <td width="10%"><b><?php echo xlt('Gender');?></b></td>
614 <td colspan=4><b><?php echo xlt('Provider');?></b></td>
615 </tr>
616 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
617 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
618 <td ><?php echo text($patDetailVal['lists_date']); ?></td>
619 <td ><?php echo text($patDetailVal['lists_diagnosis']); ?></td>
620 <td ><?php echo text($patDetailVal['lists_title']); ?></td>
621 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
622 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
623 <td ><?php echo text($patDetailVal['patient_age']);?></td>
624 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
625 <td colspan=4><?php echo text($patDetailVal['users_provider']);?></td>
626 </tr>
627 <?php }
628 } elseif ($srch_option == "Lab results") { ?>
629 <tr bgcolor="#C3FDB8" align= "left" >
630 <td width="15%"><b><?php echo xlt('Date'); ?><?php echo $sortlink[0]; ?></b></td>
631 <td width="15%"><b><?php echo xlt('Facility');?><?php echo $sortlink[1]; ?></b></td>
632 <td width="10%"><b><?php echo xlt('Unit');?></b><?php echo $sortlink[2]; ?></td>
633 <td width="10%"><b><?php echo xlt('Result');?></b><?php echo $sortlink[3]; ?></td>
634 <td width="10%"><b><?php echo xlt('Range');?></b><?php echo $sortlink[4]; ?></td>
635 <td width="10%"><b><?php echo xlt('Abnormal');?><?php echo $sortlink[5]; ?></b></td>
636 <td><b><?php echo xlt('Comments');?></b></td>
637 <td width="5%"><b><?php echo xlt('Document ID');?></b></td>
638 <td width="5%"><b><?php echo xlt('PID');?></b></td>
639 </tr>
640 <?php
641 foreach ($patFinalDataArr as $patKey => $labResInsideArr) {?>
642 <tr bgcolor = "#CCCCCC" >
643 <td> <?php echo text($labResInsideArr['procedure_result_date']);?>&nbsp;</td>
644 <td> <?php echo text($labResInsideArr['procedure_result_facility'], ENT_NOQUOTES); ?>&nbsp;</td>
645 <td> <?php echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'), $labResInsideArr['procedure_result_units']); ?>&nbsp;</td>
646 <td> <?php echo text($labResInsideArr['procedure_result_result']); ?>&nbsp;</td>
647 <td> <?php echo text($labResInsideArr['procedure_result_range']); ?>&nbsp;</td>
648 <td> <?php echo text($labResInsideArr['procedure_result_abnormal']); ?>&nbsp;</td>
649 <td> <?php echo text($labResInsideArr['procedure_result_comments']); ?>&nbsp;</td>
650 <td> <?php echo text($labResInsideArr['procedure_result_document_id']); ?>&nbsp;</td>
651 <td colspan="3"> <?php echo text($labResInsideArr['patient_id']); ?>&nbsp;</td>
652 </tr>
653 <?php
655 } elseif ($srch_option == "Communication") { ?>
656 <tr style="font-size:15px;">
657 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
658 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
659 <td width="5%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
660 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
661 <td width="10%"><b><?php echo xlt('Gender');?></b><?php echo $sortlink[4]; ?></td>
662 <td width="15%"><b><?php echo xlt('Provider');?></b><?php echo $sortlink[5]; ?></td>
663 <td ><b><?php echo xlt('Communication');?></b><?php echo $sortlink[6]; ?></td>
664 </tr>
665 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
666 <tr bgcolor = "#CCCCCC" >
667 <td ><?php if ($patDetailVal['patient_date'] != '') {
668 echo text($patDetailVal['patient_date']);
669 } else {
670 echo "";
671 }; ?></td>
672 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
673 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
674 <td ><?php echo text($patDetailVal['patient_age']);?></td>
675 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
676 <td ><?php echo text($patDetailVal['users_provider']);?></td>
677 <td ><?php echo text($patDetailVal['communications']);?></td>
678 </tr>
679 <?php
681 } elseif ($srch_option == "Demographics") { ?>
682 <tr style="font-size:15px;">
683 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
684 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
685 <td width="15%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
686 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
687 <td width="10%"><b><?php echo xlt('Gender'); ?></b><?php echo $sortlink[4]; ?></td>
688 <td width="20%"><b><?php echo xlt('Race');?></b><?php echo $sortlink[5]; ?></td>
689 <td colspan=5><b><?php echo xlt('Provider');?></b><?php echo $sortlink[7]; ?></td>
690 </tr>
691 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
692 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
693 <td ><?php if ($patDetailVal['patient_date'] != '') {
694 echo text($patDetailVal['patient_date']);
695 } else {
696 echo "";
697 };?></td>
698 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
699 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
700 <td ><?php echo text($patDetailVal['patient_age']);?></td>
701 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
702 <td ><?php echo generate_display_field(array('data_type'=>'36','list_id'=>'race'), $patDetailVal['patient_race']); ?></td>
703 <td colspan=5><?php echo text($patDetailVal['users_provider']);?></td>
704 </tr>
705 <?php }
706 } ?>
708 </table>
709 <!-- Main table ends -->
710 <?php
711 } else {//End if $result?>
712 <table>
713 <tr>
714 <td class="text">&nbsp;&nbsp;<?php echo xlt('No records found.')?></td>
715 </tr>
716 </table>
717 <?php
720 </div>
722 <?php
723 } else {//End if form_refresh
724 ?><div class='text'> <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?> </div><?php
727 </form>
729 </body>
730 </html>