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>;.
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/formatting.inc.php");
36 require_once("$srcdir/payment_jav.inc.php");
38 $DateFormat=DateFormatRead();
39 $search_options = array("Demographics"=>xl("Demographics"),"Problems"=>xl("Problems"),"Medications"=>xl("Medications"),"Allergies"=>xl("Allergies"),"Lab results"=>xl("Lab Results"),"Communication"=>xl("Communication"));
40 $comarr = array("allow_sms"=>xl("Allow SMS"),"allow_voice"=>xl("Allow Voice Message"),"allow_mail"=>xl("Allow Mail Message"),"allow_email"=>xl("Allow Email"));
41 $_POST['form_details'] = true;
42 function add_date($givendate,$day=0,$mth=0,$yr=0) {
43 $cd = strtotime($givendate);
44 $newdate = date('Y-m-d H:i:s', mktime(date('h',$cd),
45 date('i',$cd), date('s',$cd), date('m',$cd)+
$mth,
46 date('d',$cd)+
$day, date('Y',$cd)+
$yr));
49 if($_POST['date_from'] != "")
50 $sql_date_from = $_POST['date_from'];
52 $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'];
57 $sql_date_to = fixDate($_POST['date_to'] , add_date(date('Y-m-d H:i:s')));
59 //echo "<pre>";print_r($_POST);
60 $patient_id = trim($_POST["patient_id"]);
61 $age_from = $_POST["age_from"];
62 $age_to = $_POST["age_to"];
63 $sql_gender = $_POST["gender"];
64 $sql_ethnicity = $_POST["cpms_ethnicity"];
65 $sql_race=$_POST["race"];
66 $form_drug_name = trim($_POST["form_drug_name"]);
67 $form_diagnosis = trim($_POST["form_diagnosis"]);
68 $form_lab_results = trim($_POST["form_lab_results"]);
69 $form_service_codes = trim($_POST["form_service_codes"]);
70 $form_immunization = trim($_POST["form_immunization"]);
71 $communication = trim($_POST["communication"]);
75 <?php
html_header_show();?
>
77 <?php
echo xlt('Patient List Creation'); ?
>
79 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
80 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
81 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
82 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
83 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.min.js"></script
>
84 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.patched.js"></script
>
85 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
86 <script language
="JavaScript">
87 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
88 var global_date_format
= '%Y-%m-%d';
90 function Form_Validate() {
91 var d
= document
.forms
[0];
92 FromDate
= d
.date_from
.value
;
93 ToDate
= d
.date_to
.value
;
94 if ( (FromDate
.length
> 0) && (ToDate
.length
> 0) ) {
95 if ( FromDate
> ToDate
){
96 alert("<?php echo xls('To date must be later than From date!'); ?>");
100 $
("#processing").show();
105 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
106 <link rel
="stylesheet" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.css" type
="text/css" />
107 <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" />
108 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
109 <style type
="text/css">
110 /* specifically include & exclude from printing */
116 #report_parameters_daterange {
120 #report_results table {
129 /* specifically exclude some from the screen */
131 #report_parameters_daterange {
138 <script language
="javascript" type
="text/javascript">
140 function submitForm() {
141 var d_from
= new String($
('#date_from').val());
142 var d_to
= new String($
('#date_to').val());
144 var d_from_arr
= d_from
.split('-');
145 var d_to_arr
= d_to
.split('-');
147 var dt_from
= new Date(d_from_arr
[0], d_from_arr
[1], d_from_arr
[2]);
148 var dt_to
= new Date(d_to_arr
[0], d_to_arr
[1], d_to_arr
[2]);
150 var mili_from
= dt_from
.getTime();
151 var mili_to
= dt_to
.getTime();
152 var diff
= mili_to
- mili_from
;
154 $
('#date_error').css("display", "none");
156 if(diff
< 0) //negative
158 $
('#date_error').css("display", "inline");
162 $
("#form_refresh").attr("value","true");
163 top
.restoreSession();
164 $
("#theform").submit();
169 function sortingCols(sort_by
,sort_order
)
171 $
("#sortby").val(sort_by
);
172 $
("#sortorder").val(sort_order
);
173 $
("#form_refresh").attr("value","true");
174 $
("#theform").submit();
177 $
(document
).ready(function() {
178 $
(".numeric_only").keydown(function(event
) {
179 //alert(event.keyCode);
180 // Allow only backspace and delete
181 if ( event
.keyCode
== 46 || event
.keyCode
== 8 ) {
182 // let it happen, don't do anything
185 if(!((event
.keyCode
>= 96 && event
.keyCode
<= 105) ||
(event
.keyCode
>= 48 && event
.keyCode
<= 57)))
187 event
.preventDefault();
191 <?php
if($_POST['srch_option'] == "Communication"){ ?
>
192 $
('#com_pref').show();
195 $
('.datetimepicker').datetimepicker({
196 <?php
$datetimepicker_timepicker = true; ?
>
197 <?php
$datetimepicker_formatInput = false; ?
>
198 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
199 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
203 function printForm(){
204 var win
= top
.printLogPrint ? top
: opener
.top
;
205 win
.printLogPrint(window
);
210 <body
class="body_top">
211 <!-- Required
for the popup date selectors
-->
212 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
214 <?php
echo xlt('Report - Patient List Creation');?
>
216 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
217 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
220 <div id
="report_parameters_daterange">
222 <?php
echo "<span style='margin-left:5px;'><b>".xlt('Date Range').":</b> ".text(date($sql_date_from, strtotime($sql_date_from))) .
223 " to ". text(date($sql_date_to, strtotime($sql_date_to)))."</span>"; ?
>
224 <span style
="margin-left:5px; " ><b
><?php
echo xlt('Option'); ?
>:</b
> 
;<?php
echo text($_POST['srch_option']);
225 if($_POST['srch_option'] == "Communication" && $_POST['communication'] != ""){
226 if(isset($comarr[$_POST['communication']]))
227 echo "(".text($comarr[$_POST['communication']]).")";
229 echo "(".xlt('All').")";
233 <form name
='theform' id
='theform' method
='post' action
='patient_list_creation.php' onSubmit
="return Form_Validate();">
234 <div id
="report_parameters">
235 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
239 <div
class="cancel-float" style
='float:left'>
242 <td
class='label' ><?php
echo xlt('From'); ?
>: </td
>
243 <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) ?>'>
245 <td
class='label'><?php
echo xlt('To{{range}}'); ?
>: </td
>
246 <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) ?>'>
248 <td
class='label'><?php
echo xlt('Option'); ?
>: </td
>
250 <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();}">
251 <?php
foreach($search_options as $skey => $svalue){ ?
>
252 <option
<?php
if($_POST['srch_option'] == $skey) echo 'selected'; ?
> value
="<?php echo attr($skey); ?>"><?php
echo text($svalue); ?
></option
>
259 <span id
="com_pref" style
="display:none">
260 <select name
="communication" id
="communication" title
="<?php echo xlt('Select Communication Preferences'); ?>">
261 <option
> <?php
echo xlt('All'); ?
></option
>
262 <option value
="allow_sms" <?php
if($communication == "allow_sms"){ echo "selected";}?
>><?php
echo xlt('Allow SMS'); ?
></option
>
263 <option value
="allow_voice" <?php
if($communication == "allow_voice"){ echo "selected";}?
>><?php
echo xlt('Allow Voice Message'); ?
></option
>
264 <option value
="allow_mail" <?php
if($communication == "allow_mail"){ echo "selected";}?
>><?php
echo xlt('Allow Mail Message'); ?
></option
>
265 <option value
="allow_email" <?php
if($communication == "allow_email"){ echo "selected";}?
>><?php
echo xlt('Allow Email'); ?
></option
>
272 <td
class='label'><?php
echo xlt('Patient ID'); ?
>:</td
>
273 <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
>
274 <td
class='label'><?php
echo xlt('Age Range'); ?
>:</td
>
275 <td
><?php
echo xlt('From'); ?
>
276 <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}}'); ?
>
277 <input name
='age_to' class="numeric_only" type
='text' id
="age_to" value
="<?php echo attr($age_to); ?>" size
='3' maxlength
='3' /></td
>
278 <td
class='label'><?php
echo xlt('Gender'); ?
>:</td
>
279 <td colspan
="2"><?php
echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?
></td
>
285 <td height
="100%" valign
='middle' width
="175"><table style
='border-left:1px solid; width:100%; height:100%'>
287 <td width
="130px"><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
='submitForm();'> <span
>
288 <?php
echo xlt('Submit'); ?
>
292 <?php
if(isset($_POST['form_refresh'])){?
>
293 <td width
="130px"><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
="printForm()"> <span
>
294 <?php
echo xlt('Print'); ?
>
300 <div id
='processing' style
='display:none;' ><img src
='../pic/ajax-loader.gif'/></div
>
308 <!-- end of parameters
-->
310 //$sql_date_from=DateTimeToYYYYMMDD($sql_date_from);
311 //$sql_date_to=DateTimeToYYYYMMDD($sql_date_to);
313 // SQL scripts for the various searches
314 $sqlBindArray = array();
315 if ($_POST['form_refresh']){
318 pd.date as patient_date,
319 concat(pd.lname, ', ', pd.fname) AS patient_name,
320 pd.pid AS patient_id,
321 DATE_FORMAT(FROM_DAYS(DATEDIFF('".date('Y-m-d H:i:s')."',pd.dob)), '%Y')+0 AS patient_age,
322 pd.sex AS patient_sex,
323 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
324 concat(u.lname, ', ', u.fname) AS users_provider";
326 $srch_option = $_POST['srch_option'];
327 switch ($srch_option) {
331 $sqlstmt=$sqlstmt.",li.date AS lists_date,
332 li.diagnosis AS lists_diagnosis,
333 li.title AS lists_title";
336 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
337 pr.facility AS procedure_result_facility,
338 pr.units AS procedure_result_units,
339 pr.result AS procedure_result_result,
340 pr.range AS procedure_result_range,
341 pr.abnormal AS procedure_result_abnormal,
342 pr.comments AS procedure_result_comments,
343 pr.document_id AS procedure_result_document_id";
345 case "Communication":
346 $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";
351 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid";
353 switch ($srch_option) {
355 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND li.type='medical_problem')";
358 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medication')) ";
361 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
365 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
366 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
367 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
368 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id
369 left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id";
373 //WHERE Conditions started
374 $whr_stmt="where 1=1";
375 switch ($srch_option) {
378 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
379 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
382 $whr_stmt = $whr_stmt." AND li.title != '' ";
383 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
384 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
387 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND pr.date <= ?";
388 $whr_stmt= $whr_stmt." AND (pr.result != '') ";
389 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
391 case "Communication":
392 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
396 if(strlen($patient_id) != 0) {
397 $whr_stmt = $whr_stmt." and pd.pid = ?";
398 array_push($sqlBindArray, $patient_id);
401 if(strlen($age_from) != 0) {
402 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
403 array_push($sqlBindArray, $age_from);
406 if(strlen($age_to) != 0) {
407 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
408 array_push($sqlBindArray, $age_to);
411 if(strlen($sql_gender) != 0) {
412 $whr_stmt = $whr_stmt." and pd.sex = ?";
413 array_push($sqlBindArray, $sql_gender);
416 if($srch_option == "Communication" && strlen($communication) > 0){
417 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
418 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
419 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
420 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
423 //Sorting By filter fields
424 $sortby = $_REQUEST['sortby'];
425 $sortorder = $_REQUEST['sortorder'];
427 // This is for sorting the records.
428 switch ($srch_option) {
432 $sort = array("lists_date","lists_diagnosis","lists_title");
433 if($sortby == "")$sortby = $sort[1];
436 $sort = array("procedure_result_date","procedure_result_facility","procedure_result_units","procedure_result_result","procedure_result_range","procedure_result_abnormal");
437 //$odrstmt = " procedure_result_result";
439 case "Communication":
440 //$commsort = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(','))";
441 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","users_provider", "communications");
442 if($sortby == "")$sortby = $sort[6];
443 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
446 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","patient_race","patient_ethinic","users_provider");
452 if($sortorder == "") {
455 for($i = 0; $i < count($sort); $i++
) {
456 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sort[$i]','asc');\" ><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Up')."\"></a>";
458 for($i = 0; $i < count($sort); $i++
) {
459 if($sortby == $sort[$i]) {
461 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;
462 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;
467 switch ($srch_option) {
471 $odrstmt = " ORDER BY lists_date asc";
474 $odrstmt = " ORDER BY procedure_result_date asc";
476 case "Communication":
477 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) asc, communications asc";
480 $odrstmt = " ORDER BY patient_date asc";
481 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
484 if(!empty($_REQUEST['sortby']) && !empty($_REQUEST['sortorder'])){
485 if($_REQUEST['sortby'] =="communications"){
486 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) ".escape_sort_order($_REQUEST['sortorder']).", communications ".escape_sort_order($_REQUEST['sortorder']);
488 $odrstmt = "ORDER BY ".escape_identifier($_REQUEST['sortby'],$sort,TRUE)." ".escape_sort_order($_REQUEST['sortorder']);
492 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
493 //echo $sqlstmt."<hr>";
494 $result = sqlStatement($sqlstmt,$sqlBindArray);
496 $row_id = 1.1;//given to each row to identify and toggle
500 if(sqlNumRows($result) > 0){
503 $patDataArr = array();
504 $smoke_codes_arr = getSmokeCodes();
505 while ($row = sqlFetchArray($result)) {
507 $patArr[] = $row['patient_id'];
508 $patInfoArr = array();
509 $patInfoArr['patient_id'] = $row['patient_id'];
511 if($srch_option == "Medications" ||
$srch_option == "Allergies" ||
$srch_option == "Problems"){
512 $patInfoArr['lists_date'] = $row['lists_date'];
513 $patInfoArr['lists_diagnosis'] = $row['lists_diagnosis'];
514 $patInfoArr['lists_title'] = $row['lists_title'];
515 $patInfoArr['patient_name'] = $row['patient_name'];
516 $patInfoArr['patient_age'] = $row['patient_age'];
517 $patInfoArr['patient_sex'] = $row['patient_sex'];
518 $patInfoArr['patient_race'] = $row['patient_race'];
519 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
520 $patInfoArr['users_provider'] = $row['users_provider'];
521 }elseif($srch_option == "Lab results"){
522 $patInfoArr['procedure_result_date'] = $row['procedure_result_date'];
523 $patInfoArr['procedure_result_facility'] = $row['procedure_result_facility'];
524 $patInfoArr['procedure_result_units'] = $row['procedure_result_units'];
525 $patInfoArr['procedure_result_result'] = $row['procedure_result_result'];
526 $patInfoArr['procedure_result_range'] = $row['procedure_result_range'];
527 $patInfoArr['procedure_result_abnormal'] = $row['procedure_result_abnormal'];
528 $patInfoArr['procedure_result_comments'] = $row['procedure_result_comments'];
529 $patInfoArr['procedure_result_document_id'] = $row['procedure_result_document_id'];
530 }elseif($srch_option == "Communication"){
531 $patInfoArr['patient_date'] = $row['patient_date'];
532 $patInfoArr['patient_name'] = $row['patient_name'];
533 $patInfoArr['patient_age'] = $row['patient_age'];
534 $patInfoArr['patient_sex'] = $row['patient_sex'];
535 $patInfoArr['users_provider'] = $row['users_provider'];
536 $patInfoArr['communications'] = $row['communications'];
537 }elseif($srch_option == "Demographics"){
538 $patInfoArr['patient_date'] = $row['patient_date'];
539 $patInfoArr['patient_name'] = $row['patient_name'];
540 $patInfoArr['patient_age'] = $row['patient_age'];
541 $patInfoArr['patient_sex'] = $row['patient_sex'];
542 $patInfoArr['patient_race'] = $row['patient_race'];
543 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
544 $patInfoArr['users_provider'] = $row['users_provider'];
547 $patFinalDataArr[] = $patInfoArr;
556 <input type
="hidden" name
="sortby" id
="sortby" value
="<?php echo attr($sortby); ?>" />
557 <input type
="hidden" name
="sortorder" id
="sortorder" value
="<?php echo attr($sortorder); ?>" />
558 <div id
= "report_results">
561 <td
class="text"><strong
><?php
echo xlt('Total Number of Patients')?
>:</strong
> 
;<span id
="total_patients"><?php
echo attr(count(array_unique($patArr)));?
></span
></td
>
565 <table width
=90% align
="center" cellpadding
="5" cellspacing
="0" style
="font-family:tahoma;color:black;" border
="0">
567 <?php
if($srch_option == "Medications" ||
$srch_option == "Allergies" ||
$srch_option == "Problems"){ ?
>
568 <tr style
="font-size:15px;">
569 <td width
="15%"><b
><?php
echo xlt('Diagnosis Date'); ?
><?php
echo $sortlink[0]; ?
></b
></td
>
570 <td width
="15%"><b
><?php
echo xlt('Diagnosis'); ?
><?php
echo $sortlink[1]; ?
></b
></td
>
571 <td width
="15%"><b
><?php
echo xlt('Diagnosis Name');?
><?php
echo $sortlink[2]; ?
></b
></td
>
572 <td width
="15%"><b
><?php
echo xlt('Patient Name'); ?
></b
></td
>
573 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
></td
>
574 <td width
="5%"><b
><?php
echo xlt('Age');?
></b
></td
>
575 <td width
="10%"><b
><?php
echo xlt('Gender');?
></b
></td
>
576 <td colspan
=4><b
><?php
echo xlt('Provider');?
></b
></td
>
578 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
579 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
580 <td
><?php
echo text($patDetailVal['lists_date']); ?
></td
>
581 <td
><?php
echo text($patDetailVal['lists_diagnosis']); ?
></td
>
582 <td
><?php
echo text($patDetailVal['lists_title']); ?
></td
>
583 <td
><?php
echo text($patDetailVal['patient_name']); ?
></td
>
584 <td
><?php
echo text($patDetailVal['patient_id']); ?
></td
>
585 <td
><?php
echo text($patDetailVal['patient_age']);?
></td
>
586 <td
><?php
echo text($patDetailVal['patient_sex']);?
></td
>
587 <td colspan
=4><?php
echo text($patDetailVal['users_provider']);?
></td
>
590 }elseif($srch_option == "Lab results"){ ?
>
591 <tr bgcolor
="#C3FDB8" align
= "left" >
592 <td width
="15%"><b
><?php
echo xlt('Date'); ?
><?php
echo $sortlink[0]; ?
></b
></td
>
593 <td width
="15%"><b
><?php
echo xlt('Facility');?
><?php
echo $sortlink[1]; ?
></b
></td
>
594 <td width
="10%"><b
><?php
echo xlt('Unit');?
></b
><?php
echo $sortlink[2]; ?
></td
>
595 <td width
="10%"><b
><?php
echo xlt('Result');?
></b
><?php
echo $sortlink[3]; ?
></td
>
596 <td width
="10%"><b
><?php
echo xlt('Range');?
></b
><?php
echo $sortlink[4]; ?
></td
>
597 <td width
="10%"><b
><?php
echo xlt('Abnormal');?
><?php
echo $sortlink[5]; ?
></b
></td
>
598 <td
><b
><?php
echo xlt('Comments');?
></b
></td
>
599 <td width
="5%"><b
><?php
echo xlt('Document ID');?
></b
></td
>
600 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
></td
>
603 foreach($patFinalDataArr as $patKey => $labResInsideArr){?
>
604 <tr bgcolor
= "#CCCCCC" >
605 <td
> <?php
echo text($labResInsideArr['procedure_result_date']);?
> 
;</td
>
606 <td
> <?php
echo text($labResInsideArr['procedure_result_facility'],ENT_NOQUOTES
); ?
> 
;</td
>
607 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$labResInsideArr['procedure_result_units']); ?
> 
;</td
>
608 <td
> <?php
echo text($labResInsideArr['procedure_result_result']); ?
> 
;</td
>
609 <td
> <?php
echo text($labResInsideArr['procedure_result_range']); ?
> 
;</td
>
610 <td
> <?php
echo text($labResInsideArr['procedure_result_abnormal']); ?
> 
;</td
>
611 <td
> <?php
echo text($labResInsideArr['procedure_result_comments']); ?
> 
;</td
>
612 <td
> <?php
echo text($labResInsideArr['procedure_result_document_id']); ?
> 
;</td
>
613 <td colspan
="3"> <?php
echo text($labResInsideArr['patient_id']); ?
> 
;</td
>
617 }elseif($srch_option == "Communication"){ ?
>
618 <tr style
="font-size:15px;">
619 <td width
="15%"><b
><?php
echo xlt('Date'); ?
></b
><?php
echo $sortlink[0]; ?
></td
>
620 <td width
="20%"><b
><?php
echo xlt('Patient Name'); ?
></b
><?php
echo $sortlink[1]; ?
></td
>
621 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
><?php
echo $sortlink[2]; ?
></td
>
622 <td width
="5%"><b
><?php
echo xlt('Age');?
></b
><?php
echo $sortlink[3]; ?
></td
>
623 <td width
="10%"><b
><?php
echo xlt('Gender');?
></b
><?php
echo $sortlink[4]; ?
></td
>
624 <td width
="15%"><b
><?php
echo xlt('Provider');?
></b
><?php
echo $sortlink[5]; ?
></td
>
625 <td
><b
><?php
echo xlt('Communication');?
></b
><?php
echo $sortlink[6]; ?
></td
>
627 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
628 <tr bgcolor
= "#CCCCCC" >
629 <td
><?php
if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; }; ?
></td
>
630 <td
><?php
echo text($patDetailVal['patient_name']); ?
></td
>
631 <td
><?php
echo text($patDetailVal['patient_id']); ?
></td
>
632 <td
><?php
echo text($patDetailVal['patient_age']);?
></td
>
633 <td
><?php
echo text($patDetailVal['patient_sex']);?
></td
>
634 <td
><?php
echo text($patDetailVal['users_provider']);?
></td
>
635 <td
><?php
echo text($patDetailVal['communications']);?
></td
>
639 }elseif($srch_option == "Demographics"){ ?
>
640 <tr style
="font-size:15px;">
641 <td width
="15%"><b
><?php
echo xlt('Date'); ?
></b
><?php
echo $sortlink[0]; ?
></td
>
642 <td width
="20%"><b
><?php
echo xlt('Patient Name'); ?
></b
><?php
echo $sortlink[1]; ?
></td
>
643 <td width
="15%"><b
><?php
echo xlt('PID');?
></b
><?php
echo $sortlink[2]; ?
></td
>
644 <td width
="5%"><b
><?php
echo xlt('Age');?
></b
><?php
echo $sortlink[3]; ?
></td
>
645 <td width
="10%"><b
><?php
echo xlt('Gender'); ?
></b
><?php
echo $sortlink[4]; ?
></td
>
646 <td width
="20%"><b
><?php
echo xlt('Race');?
></b
><?php
echo $sortlink[5]; ?
></td
>
647 <td colspan
=5><b
><?php
echo xlt('Provider');?
></b
><?php
echo $sortlink[7]; ?
></td
>
649 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
650 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
651 <td
><?php
if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; };?
></td
>
652 <td
><?php
echo text($patDetailVal['patient_name']); ?
></td
>
653 <td
><?php
echo text($patDetailVal['patient_id']); ?
></td
>
654 <td
><?php
echo text($patDetailVal['patient_age']);?
></td
>
655 <td
><?php
echo text($patDetailVal['patient_sex']);?
></td
>
656 <td
><?php
echo generate_display_field(array('data_type'=>'36','list_id'=>'race'), $patDetailVal['patient_race']); ?
></td
>
657 <td colspan
=5><?php
echo text($patDetailVal['users_provider']);?
></td
>
663 <!-- Main table ends
-->
665 }else{//End if $result?>
668 <td
class="text"> 
; 
;<?php
echo xlt('No records found.')?
></td
>
677 }else{//End if form_refresh
678 ?
><div
class='text'> <?php
echo xlt('Please input search criteria above, and click Submit to view results.'); ?
> </div
><?php