Revert "1. add edit event fails when save edited single provider recurring events...
[openemr.git] / interface / reports / patient_list_creation.php
blob655342ea7a8f7ad13066f8b5739fc286a2557d78
1 <?php
2 /**
3 * This report lists all the demographics allergies,problems,drugs and lab results
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2014 Ensoftek, Inc
9 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/options.inc.php");
17 require_once("../drugs/drugs.inc.php");
18 require_once("$srcdir/payment_jav.inc.php");
20 use OpenEMR\Core\Header;
22 $search_options = array("Demographics"=>xl("Demographics"),"Problems"=>xl("Problems"),"Medications"=>xl("Medications"),"Allergies"=>xl("Allergies"),"Lab results"=>xl("Lab Results"),"Communication"=>xl("Communication"));
23 $comarr = array("allow_sms"=>xl("Allow SMS"),"allow_voice"=>xl("Allow Voice Message"),"allow_mail"=>xl("Allow Mail Message"),"allow_email"=>xl("Allow Email"));
24 $_POST['form_details'] = true;
26 $sql_date_from = (!empty($_POST['date_from'])) ? DateTimeToYYYYMMDDHHMMSS($_POST['date_from']) : date('Y-01-01 H:i:s');
27 $sql_date_to = (!empty($_POST['date_to'])) ? DateTimeToYYYYMMDDHHMMSS($_POST['date_to']) : date('Y-m-d H:i:s');
29 $patient_id = trim($_POST["patient_id"]);
30 $age_from = $_POST["age_from"];
31 $age_to = $_POST["age_to"];
32 $sql_gender = $_POST["gender"];
33 $sql_ethnicity = $_POST["cpms_ethnicity"];
34 $sql_race=$_POST["race"];
35 $form_drug_name = trim($_POST["form_drug_name"]);
36 $form_diagnosis = trim($_POST["form_diagnosis"]);
37 $form_lab_results = trim($_POST["form_lab_results"]);
38 $form_service_codes = trim($_POST["form_service_codes"]);
39 $form_immunization = trim($_POST["form_immunization"]);
40 $communication = trim($_POST["communication"]);
42 <html>
43 <head>
45 <title>
46 <?php echo xlt('Patient List Creation'); ?>
47 </title>
49 <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
51 <script language="JavaScript">
52 function Form_Validate() {
53 var d = document.forms[0];
54 FromDate = d.date_from.value;
55 ToDate = d.date_to.value;
56 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
57 if ( FromDate > ToDate ){
58 alert("<?php echo xls('To date must be later than From date!'); ?>");
59 return false;
62 $("#processing").show();
63 return true;
65 </script>
67 <style type="text/css">
68 /* specifically include & exclude from printing */
69 @media print {
70 #report_parameters {
71 visibility: hidden;
72 display: none;
74 #report_parameters_daterange {
75 visibility: visible;
76 display: inline;
78 #report_results table {
79 margin-top: 0px;
81 #report_image {
82 visibility: hidden;
83 display: none;
87 /* specifically exclude some from the screen */
88 @media screen {
89 #report_parameters_daterange {
90 visibility: hidden;
91 display: none;
94 </style>
95 <script language="javascript" type="text/javascript">
96 function submitForm() {
97 var d_from = new String($('#date_from').val());
98 var d_to = new String($('#date_to').val());
100 var d_from_arr = d_from.split('-');
101 var d_to_arr = d_to.split('-');
103 var dt_from = new Date(d_from_arr[0], d_from_arr[1], d_from_arr[2]);
104 var dt_to = new Date(d_to_arr[0], d_to_arr[1], d_to_arr[2]);
106 var mili_from = dt_from.getTime();
107 var mili_to = dt_to.getTime();
108 var diff = mili_to - mili_from;
110 $('#date_error').css("display", "none");
112 if(diff < 0) //negative
114 $('#date_error').css("display", "inline");
116 else
118 $("#form_refresh").attr("value","true");
119 top.restoreSession();
120 $("#theform").submit();
124 //sorting changes
125 function sortingCols(sort_by,sort_order)
127 $("#sortby").val(sort_by);
128 $("#sortorder").val(sort_order);
129 $("#form_refresh").attr("value","true");
130 $("#theform").submit();
133 $(document).ready(function() {
134 $(".numeric_only").keydown(function(event) {
135 //alert(event.keyCode);
136 // Allow only backspace and delete
137 if ( event.keyCode == 46 || event.keyCode == 8 ) {
138 // let it happen, don't do anything
140 else {
141 if(!((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57)))
143 event.preventDefault();
147 <?php if ($_POST['srch_option'] == "Communication") { ?>
148 $('#com_pref').show();
149 <?php } ?>
151 $('.datetimepicker').datetimepicker({
152 <?php $datetimepicker_timepicker = true; ?>
153 <?php $datetimepicker_showseconds = true; ?>
154 <?php $datetimepicker_formatInput = true; ?>
155 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
156 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
160 function printForm(){
161 var win = top.printLogPrint ? top : opener.top;
162 win.printLogPrint(window);
164 </script>
165 </head>
167 <body class="body_top">
168 <!-- Required for the popup date selectors -->
169 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
170 <span class='title'>
171 <?php echo xlt('Report - Patient List Creation');?>
172 </span>
173 <!-- Search can be done using age range, gender, and ethnicity filters.
174 Search options include diagnosis, procedure, prescription, medical history, and lab results.
177 <div id="report_parameters_daterange">
179 <?php echo "<span style='margin-left:5px;'><b>".xlt('Date Range').":</b>&nbsp;".text(oeFormatDateTime($sql_date_from, "global", true)) .
180 " &nbsp; " . xlt('to') . " &nbsp; ". text(oeFormatDateTime($sql_date_to, "global", true))."</span>"; ?>
181 <span style="margin-left:5px; " ><b><?php echo xlt('Option'); ?>:</b>&nbsp;<?php echo text($_POST['srch_option']);
182 if ($_POST['srch_option'] == "Communication" && $_POST['communication'] != "") {
183 if (isset($comarr[$_POST['communication']])) {
184 echo "(".text($comarr[$_POST['communication']]).")";
185 } else {
186 echo "(".xlt('All').")";
188 } ?></span>
189 </p>
190 </div>
191 <form name='theform' id='theform' method='post' action='patient_list_creation.php' onSubmit="return Form_Validate();">
192 <div id="report_parameters">
193 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
194 <table>
195 <tr>
196 <td width='640px'>
197 <div class="cancel-float" style='float:left'>
198 <table class='text'>
199 <tr>
200 <td class='control-label' ><?php echo xlt('From'); ?>: </td>
201 <td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_from, 0, true)); ?>'>
202 </td>
203 <td class='control-label'><?php echo xlt('To{{range}}'); ?>: </td>
204 <td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_to, 0, true)); ?>'>
205 </td>
206 <td class='control-label'><?php echo xlt('Option'); ?>: </td>
207 <td class='control-label'>
208 <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();}">
209 <?php foreach ($search_options as $skey => $svalue) { ?>
210 <option <?php echo ($_POST['srch_option'] == $skey) ? 'selected' : ''; ?> value="<?php echo attr($skey); ?>"><?php echo text($svalue); ?></option>
211 <?php } ?>
212 </select>
213 <?php ?>
214 </td>
216 <td >
217 <span id="com_pref" style="display:none">
218 <select class="form-control" name="communication" id="communication" title="<?php echo xlt('Select Communication Preferences'); ?>">
219 <option> <?php echo xlt('All'); ?></option>
220 <option value="allow_sms" <?php echo ($communication == "allow_sms") ? "selected" : ""; ?>><?php echo xlt('Allow SMS'); ?></option>
221 <option value="allow_voice" <?php echo ($communication == "allow_voice") ? "selected" : ""; ?>><?php echo xlt('Allow Voice Message'); ?></option>
222 <option value="allow_mail" <?php echo ($communication == "allow_mail") ? "selected" : ""; ?>><?php echo xlt('Allow Mail Message'); ?></option>
223 <option value="allow_email" <?php echo ($communication == "allow_email") ? "selected" : ""; ?>><?php echo xlt('Allow Email'); ?></option>
224 </select>
225 </span>
226 </td>
228 </tr>
229 <tr>
230 <td class='control-label'><?php echo xlt('Patient ID'); ?>:</td>
231 <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>
232 <td class='control-label'><?php echo xlt('Age Range'); ?>:</td>
234 <td>
235 <table>
236 <tr>
237 <td class='control-label'>
238 <?php echo xlt('From'); ?>:
239 </td>
240 <td>
241 <input name='age_from' class="numeric_only form-control" type='text' id="age_from" value="<?php echo attr($age_from); ?>" size='3' maxlength='3' />
242 </td>
243 <td class='control-label'>
244 <?php echo xlt('To{{range}}'); ?>:
245 </td>
246 <td>
247 <input name='age_to' class="numeric_only form-control" type='text' id="age_to" value="<?php echo attr($age_to); ?>" size='3' maxlength='3' />
248 </td>
249 </tr>
250 </table>
251 </td>
253 <td class='control-label'><?php echo xlt('Gender'); ?>:</td>
254 <td colspan="2"><?php echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?></td>
255 </tr>
257 </table>
259 </div></td>
260 <td height="100%" valign='middle' width="175"><table style='border-left:1px solid; width:100%; height:100%'>
261 <tr>
262 <td>
263 <div class="text-center">
264 <div class="btn-group" role="group">
265 <a href='#' class='btn btn-default btn-save' onclick='submitForm();'>
266 <?php echo xlt('Submit'); ?>
267 </a>
268 <?php if (isset($_POST['form_refresh'])) {?>
269 <a href='#' class='btn btn-default btn-print' onclick="printForm()">
270 <?php echo xlt('Print'); ?>
271 </a>
272 <?php }?>
273 </div>
274 </div>
275 </td>
276 <td>
277 <div id='processing' style='display:none;' ><img src='../pic/ajax-loader.gif'/></div>
278 </td>
280 </tr>
281 </table></td>
282 </tr>
283 </table>
284 </div>
285 <!-- end of parameters -->
286 <?php
288 // SQL scripts for the various searches
289 $sqlBindArray = array();
290 if ($_POST['form_refresh']) {
291 $sqlstmt = "select
292 pd.date as patient_date,
293 concat(pd.lname, ', ', pd.fname) AS patient_name,
294 pd.pid AS patient_id,
295 DATE_FORMAT(FROM_DAYS(DATEDIFF('".date('Y-m-d H:i:s')."',pd.dob)), '%Y')+0 AS patient_age,
296 pd.sex AS patient_sex,
297 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
298 concat(u.lname, ', ', u.fname) AS users_provider";
300 $srch_option = $_POST['srch_option'];
301 switch ($srch_option) {
302 case "Medications":
303 case "Allergies":
304 case "Problems":
305 $sqlstmt=$sqlstmt.",li.date AS lists_date,
306 li.diagnosis AS lists_diagnosis,
307 li.title AS lists_title";
308 break;
309 case "Lab results":
310 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
311 pr.facility AS procedure_result_facility,
312 pr.units AS procedure_result_units,
313 pr.result AS procedure_result_result,
314 pr.range AS procedure_result_range,
315 pr.abnormal AS procedure_result_abnormal,
316 pr.comments AS procedure_result_comments,
317 pr.document_id AS procedure_result_document_id";
318 break;
319 case "Communication":
320 $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";
321 break;
324 //from
325 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid";
326 //JOINS
327 switch ($srch_option) {
328 case "Problems":
329 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND li.type='medical_problem')";
330 break;
331 case "Medications":
332 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medication')) ";
333 break;
334 case "Allergies":
335 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
336 break;
337 case "Lab results":
338 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
339 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
340 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
341 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id
342 left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id";
343 break;
346 //WHERE Conditions started
347 $whr_stmt="where 1=1";
348 switch ($srch_option) {
349 case "Medications":
350 case "Allergies":
351 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
352 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
353 break;
354 case "Problems":
355 $whr_stmt = $whr_stmt." AND li.title != '' ";
356 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
357 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
358 break;
359 case "Lab results":
360 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND pr.date <= ?";
361 $whr_stmt= $whr_stmt." AND (pr.result != '') ";
362 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
363 break;
364 case "Communication":
365 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
366 break;
369 if (strlen($patient_id) != 0) {
370 $whr_stmt = $whr_stmt." and pd.pid = ?";
371 array_push($sqlBindArray, $patient_id);
374 if (strlen($age_from) != 0) {
375 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
376 array_push($sqlBindArray, $age_from);
379 if (strlen($age_to) != 0) {
380 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
381 array_push($sqlBindArray, $age_to);
384 if (strlen($sql_gender) != 0) {
385 $whr_stmt = $whr_stmt." and pd.sex = ?";
386 array_push($sqlBindArray, $sql_gender);
389 if ($srch_option == "Communication" && strlen($communication) > 0) {
390 if ($communication == "allow_sms") {
391 $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
392 } else if ($communication == "allow_voice") {
393 $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
394 } else if ($communication == "allow_mail") {
395 $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
396 } else if ($communication == "allow_email") {
397 $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
401 //Sorting By filter fields
402 $sortby = $_REQUEST['sortby'];
403 $sortorder = $_REQUEST['sortorder'];
405 // This is for sorting the records.
406 switch ($srch_option) {
407 case "Medications":
408 case "Allergies":
409 case "Problems":
410 $sort = array("lists_date","lists_diagnosis","lists_title");
411 if ($sortby == "") {
412 $sortby = $sort[1];
414 break;
415 case "Lab results":
416 $sort = array("procedure_result_date","procedure_result_facility","procedure_result_units","procedure_result_result","procedure_result_range","procedure_result_abnormal");
417 //$odrstmt = " procedure_result_result";
418 break;
419 case "Communication":
420 //$commsort = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(','))";
421 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","users_provider", "communications");
422 if ($sortby == "") {
423 $sortby = $sort[6];
426 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
427 break;
428 case "Demographics":
429 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","patient_race","patient_ethinic","users_provider");
430 break;
433 if ($sortby == "") {
434 $sortby = $sort[0];
437 if ($sortorder == "") {
438 $sortorder = "asc";
441 for ($i = 0; $i < count($sort); $i++) {
442 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sort[$i]','asc');\" ><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Up')."\"></a>";
445 for ($i = 0; $i < count($sort); $i++) {
446 if ($sortby == $sort[$i]) {
447 switch ($sortorder) {
448 case "asc":
449 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','desc');\" ><img src=\"../../images/sortup.gif\" border=0 alt=\"".htmlspecialchars(xl('Sort Up'), ENT_QUOTES)."\"></a>";
450 break;
451 case "desc":
452 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sortby','asc');\" onclick=\"top.restoreSession()\"><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Down')."\"></a>";
453 break;
454 } break;
458 switch ($srch_option) {
459 case "Medications":
460 case "Allergies":
461 case "Problems":
462 $odrstmt = " ORDER BY lists_date asc";
463 break;
464 case "Lab results":
465 $odrstmt = " ORDER BY procedure_result_date asc";
466 break;
467 case "Communication":
468 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) asc, communications asc";
469 break;
470 case "Demographics":
471 $odrstmt = " ORDER BY patient_date asc";
472 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
473 break;
476 if (!empty($_REQUEST['sortby']) && !empty($_REQUEST['sortorder'])) {
477 if ($_REQUEST['sortby'] =="communications") {
478 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) ".escape_sort_order($_REQUEST['sortorder']).", communications ".escape_sort_order($_REQUEST['sortorder']);
479 } else {
480 $odrstmt = "ORDER BY ".escape_identifier($_REQUEST['sortby'], $sort, true)." ".escape_sort_order($_REQUEST['sortorder']);
484 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
485 //echo $sqlstmt."<hr>";
486 $result = sqlStatement($sqlstmt, $sqlBindArray);
487 //print_r($result);
488 $row_id = 1.1;//given to each row to identify and toggle
489 $img_id = 1.2;
490 $k=1.3;
492 if (sqlNumRows($result) > 0) {
493 $patArr = array();
495 $patDataArr = array();
496 $smoke_codes_arr = getSmokeCodes();
497 while ($row = sqlFetchArray($result)) {
498 $patArr[] = $row['patient_id'];
499 $patInfoArr = array();
500 $patInfoArr['patient_id'] = $row['patient_id'];
501 //Diagnosis Check
502 if ($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems") {
503 $patInfoArr['lists_date'] = $row['lists_date'];
504 $patInfoArr['lists_diagnosis'] = $row['lists_diagnosis'];
505 $patInfoArr['lists_title'] = $row['lists_title'];
506 $patInfoArr['patient_name'] = $row['patient_name'];
507 $patInfoArr['patient_age'] = $row['patient_age'];
508 $patInfoArr['patient_sex'] = $row['patient_sex'];
509 $patInfoArr['patient_race'] = $row['patient_race'];
510 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
511 $patInfoArr['users_provider'] = $row['users_provider'];
512 } elseif ($srch_option == "Lab results") {
513 $patInfoArr['procedure_result_date'] = $row['procedure_result_date'];
514 $patInfoArr['procedure_result_facility'] = $row['procedure_result_facility'];
515 $patInfoArr['procedure_result_units'] = $row['procedure_result_units'];
516 $patInfoArr['procedure_result_result'] = $row['procedure_result_result'];
517 $patInfoArr['procedure_result_range'] = $row['procedure_result_range'];
518 $patInfoArr['procedure_result_abnormal'] = $row['procedure_result_abnormal'];
519 $patInfoArr['procedure_result_comments'] = $row['procedure_result_comments'];
520 $patInfoArr['procedure_result_document_id'] = $row['procedure_result_document_id'];
521 } elseif ($srch_option == "Communication") {
522 $patInfoArr['patient_date'] = $row['patient_date'];
523 $patInfoArr['patient_name'] = $row['patient_name'];
524 $patInfoArr['patient_age'] = $row['patient_age'];
525 $patInfoArr['patient_sex'] = $row['patient_sex'];
526 $patInfoArr['users_provider'] = $row['users_provider'];
527 $patInfoArr['communications'] = $row['communications'];
528 } elseif ($srch_option == "Demographics") {
529 $patInfoArr['patient_date'] = $row['patient_date'];
530 $patInfoArr['patient_name'] = $row['patient_name'];
531 $patInfoArr['patient_age'] = $row['patient_age'];
532 $patInfoArr['patient_sex'] = $row['patient_sex'];
533 $patInfoArr['patient_race'] = $row['patient_race'];
534 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
535 $patInfoArr['users_provider'] = $row['users_provider'];
538 $patFinalDataArr[] = $patInfoArr;
542 <br>
544 <input type="hidden" name="sortby" id="sortby" value="<?php echo attr($sortby); ?>" />
545 <input type="hidden" name="sortorder" id="sortorder" value="<?php echo attr($sortorder); ?>" />
546 <div id = "report_results">
547 <table>
548 <tr>
549 <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>
550 </tr>
551 </table>
553 <table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0">
555 <?php
556 if ($srch_option == "Medications" || $srch_option == "Allergies" || $srch_option == "Problems") { ?>
557 <tr style="font-size:15px;">
558 <td width="15%"><b><?php echo xlt('Diagnosis Date'); ?><?php echo $sortlink[0]; ?></b></td>
559 <td width="15%"><b><?php echo xlt('Diagnosis'); ?><?php echo $sortlink[1]; ?></b></td>
560 <td width="15%"><b><?php echo xlt('Diagnosis Name');?><?php echo $sortlink[2]; ?></b></td>
561 <td width="15%"><b><?php echo xlt('Patient Name'); ?></b></td>
562 <td width="5%"><b><?php echo xlt('PID');?></b></td>
563 <td width="5%"><b><?php echo xlt('Age');?></b></td>
564 <td width="10%"><b><?php echo xlt('Gender');?></b></td>
565 <td colspan=4><b><?php echo xlt('Provider');?></b></td>
566 </tr>
567 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
568 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
569 <td ><?php echo text(oeFormatDateTime($patDetailVal['lists_date'], "global", true)); ?></td>
570 <td ><?php echo text($patDetailVal['lists_diagnosis']); ?></td>
571 <td ><?php echo text($patDetailVal['lists_title']); ?></td>
572 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
573 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
574 <td ><?php echo text($patDetailVal['patient_age']);?></td>
575 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
576 <td colspan=4><?php echo text($patDetailVal['users_provider']);?></td>
577 </tr>
578 <?php }
579 } elseif ($srch_option == "Lab results") { ?>
580 <tr bgcolor="#C3FDB8" align= "left" >
581 <td width="15%"><b><?php echo xlt('Date'); ?><?php echo $sortlink[0]; ?></b></td>
582 <td width="15%"><b><?php echo xlt('Facility');?><?php echo $sortlink[1]; ?></b></td>
583 <td width="10%"><b><?php echo xlt('Unit');?></b><?php echo $sortlink[2]; ?></td>
584 <td width="10%"><b><?php echo xlt('Result');?></b><?php echo $sortlink[3]; ?></td>
585 <td width="10%"><b><?php echo xlt('Range');?></b><?php echo $sortlink[4]; ?></td>
586 <td width="10%"><b><?php echo xlt('Abnormal');?><?php echo $sortlink[5]; ?></b></td>
587 <td><b><?php echo xlt('Comments');?></b></td>
588 <td width="5%"><b><?php echo xlt('Document ID');?></b></td>
589 <td width="5%"><b><?php echo xlt('PID');?></b></td>
590 </tr>
591 <?php
592 foreach ($patFinalDataArr as $patKey => $labResInsideArr) {?>
593 <tr bgcolor = "#CCCCCC" >
594 <td> <?php echo text(oeFormatDateTime($labResInsideArr['procedure_result_date'], "global", true));?>&nbsp;</td>
595 <td> <?php echo text($labResInsideArr['procedure_result_facility'], ENT_NOQUOTES); ?>&nbsp;</td>
596 <td> <?php echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'), $labResInsideArr['procedure_result_units']); ?>&nbsp;</td>
597 <td> <?php echo text($labResInsideArr['procedure_result_result']); ?>&nbsp;</td>
598 <td> <?php echo text($labResInsideArr['procedure_result_range']); ?>&nbsp;</td>
599 <td> <?php echo text($labResInsideArr['procedure_result_abnormal']); ?>&nbsp;</td>
600 <td> <?php echo text($labResInsideArr['procedure_result_comments']); ?>&nbsp;</td>
601 <td> <?php echo text($labResInsideArr['procedure_result_document_id']); ?>&nbsp;</td>
602 <td colspan="3"> <?php echo text($labResInsideArr['patient_id']); ?>&nbsp;</td>
603 </tr>
604 <?php
606 } elseif ($srch_option == "Communication") { ?>
607 <tr style="font-size:15px;">
608 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
609 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
610 <td width="5%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
611 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
612 <td width="10%"><b><?php echo xlt('Gender');?></b><?php echo $sortlink[4]; ?></td>
613 <td width="15%"><b><?php echo xlt('Provider');?></b><?php echo $sortlink[5]; ?></td>
614 <td ><b><?php echo xlt('Communication');?></b><?php echo $sortlink[6]; ?></td>
615 </tr>
616 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
617 <tr bgcolor = "#CCCCCC" >
618 <td ><?php echo ($patDetailVal['patient_date'] != '') ? text(oeFormatDateTime($patDetailVal['patient_date'], "global", true)) : ""; ?></td>
619 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
620 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
621 <td ><?php echo text($patDetailVal['patient_age']);?></td>
622 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
623 <td ><?php echo text($patDetailVal['users_provider']);?></td>
624 <td ><?php echo text($patDetailVal['communications']);?></td>
625 </tr>
626 <?php }
627 } elseif ($srch_option == "Demographics") { ?>
628 <tr style="font-size:15px;">
629 <td width="15%"><b><?php echo xlt('Date'); ?></b><?php echo $sortlink[0]; ?></td>
630 <td width="20%"><b><?php echo xlt('Patient Name'); ?></b><?php echo $sortlink[1]; ?></td>
631 <td width="15%"><b><?php echo xlt('PID');?></b><?php echo $sortlink[2]; ?></td>
632 <td width="5%"><b><?php echo xlt('Age');?></b><?php echo $sortlink[3]; ?></td>
633 <td width="10%"><b><?php echo xlt('Gender'); ?></b><?php echo $sortlink[4]; ?></td>
634 <td width="20%"><b><?php echo xlt('Race');?></b><?php echo $sortlink[5]; ?></td>
635 <td colspan=5><b><?php echo xlt('Provider');?></b><?php echo $sortlink[7]; ?></td>
636 </tr>
637 <?php foreach ($patFinalDataArr as $patKey => $patDetailVal) { ?>
638 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
639 <td ><?php echo ($patDetailVal['patient_date'] != '') ? text(oeFormatDateTime($patDetailVal['patient_date'], "global", true)) : ""; ?></td>
640 <td ><?php echo text($patDetailVal['patient_name']); ?></td>
641 <td ><?php echo text($patDetailVal['patient_id']); ?></td>
642 <td ><?php echo text($patDetailVal['patient_age']);?></td>
643 <td ><?php echo text($patDetailVal['patient_sex']);?></td>
644 <td ><?php echo generate_display_field(array('data_type'=>'36','list_id'=>'race'), $patDetailVal['patient_race']); ?></td>
645 <td colspan=5><?php echo text($patDetailVal['users_provider']);?></td>
646 </tr>
647 <?php }
648 } ?>
650 </table>
651 <!-- Main table ends -->
652 <?php
653 } else {//End if $result?>
654 <table>
655 <tr>
656 <td class="text">&nbsp;&nbsp;<?php echo xlt('No records found.')?></td>
657 </tr>
658 </table>
659 <?php
662 </div>
664 <?php
665 } else {//End if form_refresh
666 ?><div class='text'> <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?> </div><?php
669 </form>
671 </body>
672 </html>