3 * This report lists all the demographics allergies,problems,drugs and lab results
5 * Copyright (C) 2014 Ensoftek, Inc
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @link http://www.open-emr.org
22 //SANITIZE ALL ESCAPES
23 $sanitize_all_escapes=true;
26 //STOP FAKE REGISTER GLOBALS
27 $fake_register_globals=false;
29 require_once("../globals.php");
30 require_once("$srcdir/patient.inc");
31 require_once("$srcdir/options.inc.php");
32 require_once("../drugs/drugs.inc.php");
33 require_once("$srcdir/formatting.inc.php");
34 require_once("$srcdir/payment_jav.inc.php");
36 $DateFormat=DateFormatRead();
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));
47 if($_POST['date_from'] != "")
48 $sql_date_from = $_POST['date_from'];
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'];
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"]);
73 <?php
html_header_show();?
>
75 <?php
echo xlt('Patient List Creation'); ?
>
77 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
78 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
79 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
80 <script language
="JavaScript">
81 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
82 var global_date_format
= '%Y-%m-%d';
83 function Form_Validate() {
84 var d
= document
.forms
[0];
85 FromDate
= d
.date_from
.value
;
86 ToDate
= d
.date_to
.value
;
87 if ( (FromDate
.length
> 0) && (ToDate
.length
> 0) ) {
88 if ( FromDate
> ToDate
){
89 alert("<?php echo xls('To date must be later than From date!'); ?>");
93 $
("#processing").show();
98 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
99 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
100 <link rel
="stylesheet" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.css" type
="text/css" />
101 <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" />
102 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-4-3/index.js"></script
>
103 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.min.js"></script
>
104 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.patched.js"></script
>
105 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script
>
106 <style type
="text/css">
107 /* specifically include & exclude from printing */
113 #report_parameters_daterange {
117 #report_results table {
126 /* specifically exclude some from the screen */
128 #report_parameters_daterange {
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");
159 $
("#form_refresh").attr("value","true");
160 top
.restoreSession();
161 $
("#theform").submit();
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
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();
193 function printForm(){
194 var win
= top
.printLogPrint ? top
: opener
.top
;
195 win
.printLogPrint(window
);
200 <body
class="body_top">
201 <!-- Required
for the popup date selectors
-->
202 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
204 <?php
echo xlt('Report - Patient List Creation');?
>
206 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
207 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
210 <div id
="report_parameters_daterange">
212 <?php
echo "<span style='margin-left:5px;'><b>".xlt('Date Range').":</b> ".text(date($sql_date_from, strtotime($sql_date_from))) .
213 " to ". text(date($sql_date_to, strtotime($sql_date_to)))."</span>"; ?
>
214 <span style
="margin-left:5px; " ><b
><?php
echo xlt('Option'); ?
>:</b
> 
;<?php
echo text($_POST['srch_option']);
215 if($_POST['srch_option'] == "Communication" && $_POST['communication'] != ""){
216 if(isset($comarr[$_POST['communication']]))
217 echo "(".text($comarr[$_POST['communication']]).")";
219 echo "(".xlt('All').")";
223 <form name
='theform' id
='theform' method
='post' action
='patient_list_creation.php' onSubmit
="return Form_Validate();">
224 <div id
="report_parameters">
225 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
229 <div
class="cancel-float" style
='float:left'>
232 <td
class='label' ><?php
echo xlt('From'); ?
>: </td
>
233 <td
><input type
='text' name
='date_from' id
="date_from" size
='18' value
='<?php echo attr($sql_date_from); ?>' readonly
="readonly" title
='<?php echo attr($title_tooltip) ?>'> <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer' title
='<?php echo xla('Click here to choose a date
'); ?>'></td
>
234 <td
class='label'><?php
echo xlt('To{{range}}'); ?
>: </td
>
235 <td
><input type
='text' name
='date_to' id
="date_to" size
='18' value
='<?php echo attr($sql_date_to); ?>' readonly
="readonly" title
='<?php echo attr($title_tooltip) ?>'> <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer' title
='<?php echo xla('Click here to choose a date
'); ?>'></td
>
236 <td
class='label'><?php
echo xlt('Option'); ?
>: </td
>
238 <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();}">
239 <?php
foreach($search_options as $skey => $svalue){ ?
>
240 <option
<?php
if($_POST['srch_option'] == $skey) echo 'selected'; ?
> value
="<?php echo attr($skey); ?>"><?php
echo text($svalue); ?
></option
>
247 <span id
="com_pref" style
="display:none">
248 <select name
="communication" id
="communication" title
="<?php echo xlt('Select Communication Preferences'); ?>">
249 <option
> <?php
echo xlt('All'); ?
></option
>
250 <option value
="allow_sms" <?php
if($communication == "allow_sms"){ echo "selected";}?
>><?php
echo xlt('Allow SMS'); ?
></option
>
251 <option value
="allow_voice" <?php
if($communication == "allow_voice"){ echo "selected";}?
>><?php
echo xlt('Allow Voice Message'); ?
></option
>
252 <option value
="allow_mail" <?php
if($communication == "allow_mail"){ echo "selected";}?
>><?php
echo xlt('Allow Mail Message'); ?
></option
>
253 <option value
="allow_email" <?php
if($communication == "allow_email"){ echo "selected";}?
>><?php
echo xlt('Allow Email'); ?
></option
>
260 <td
class='label'><?php
echo xlt('Patient ID'); ?
>:</td
>
261 <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
>
262 <td
class='label'><?php
echo xlt('Age Range'); ?
>:</td
>
263 <td
><?php
echo xlt('From'); ?
>
264 <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}}'); ?
>
265 <input name
='age_to' class="numeric_only" type
='text' id
="age_to" value
="<?php echo attr($age_to); ?>" size
='3' maxlength
='3' /></td
>
266 <td
class='label'><?php
echo xlt('Gender'); ?
>:</td
>
267 <td colspan
="2"><?php
echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?
></td
>
273 <td height
="100%" valign
='middle' width
="175"><table style
='border-left:1px solid; width:100%; height:100%'>
275 <td width
="130px"><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
='submitForm();'> <span
>
276 <?php
echo xlt('Submit'); ?
>
280 <?php
if(isset($_POST['form_refresh'])){?
>
281 <td width
="130px"><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
="printForm()"> <span
>
282 <?php
echo xlt('Print'); ?
>
288 <div id
='processing' style
='display:none;' ><img src
='../pic/ajax-loader.gif'/></div
>
296 <!-- end of parameters
-->
298 //$sql_date_from=DateTimeToYYYYMMDD($sql_date_from);
299 //$sql_date_to=DateTimeToYYYYMMDD($sql_date_to);
301 // SQL scripts for the various searches
302 $sqlBindArray = array();
303 if ($_POST['form_refresh']){
306 pd.date as patient_date,
307 concat(pd.lname, ', ', pd.fname) AS patient_name,
308 pd.pid AS patient_id,
309 DATE_FORMAT(FROM_DAYS(DATEDIFF('".date('Y-m-d H:i:s')."',pd.dob)), '%Y')+0 AS patient_age,
310 pd.sex AS patient_sex,
311 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
312 concat(u.lname, ', ', u.fname) AS users_provider";
314 $srch_option = $_POST['srch_option'];
315 switch ($srch_option) {
319 $sqlstmt=$sqlstmt.",li.date AS lists_date,
320 li.diagnosis AS lists_diagnosis,
321 li.title AS lists_title";
324 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
325 pr.facility AS procedure_result_facility,
326 pr.units AS procedure_result_units,
327 pr.result AS procedure_result_result,
328 pr.range AS procedure_result_range,
329 pr.abnormal AS procedure_result_abnormal,
330 pr.comments AS procedure_result_comments,
331 pr.document_id AS procedure_result_document_id";
333 case "Communication":
334 $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";
339 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid";
341 switch ($srch_option) {
343 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND li.type='medical_problem')";
346 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medication')) ";
349 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
353 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
354 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
355 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
356 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id
357 left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id";
361 //WHERE Conditions started
362 $whr_stmt="where 1=1";
363 switch ($srch_option) {
366 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
367 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
370 $whr_stmt = $whr_stmt." AND li.title != '' ";
371 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND li.date <= ?";
372 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
375 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND pr.date <= ?";
376 $whr_stmt= $whr_stmt." AND (pr.result != '') ";
377 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d H:i:s"));
379 case "Communication":
380 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
384 if(strlen($patient_id) != 0) {
385 $whr_stmt = $whr_stmt." and pd.pid = ?";
386 array_push($sqlBindArray, $patient_id);
389 if(strlen($age_from) != 0) {
390 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
391 array_push($sqlBindArray, $age_from);
394 if(strlen($age_to) != 0) {
395 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
396 array_push($sqlBindArray, $age_to);
399 if(strlen($sql_gender) != 0) {
400 $whr_stmt = $whr_stmt." and pd.sex = ?";
401 array_push($sqlBindArray, $sql_gender);
404 if($srch_option == "Communication" && strlen($communication) > 0){
405 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
406 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
407 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
408 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
411 //Sorting By filter fields
412 $sortby = $_REQUEST['sortby'];
413 $sortorder = $_REQUEST['sortorder'];
415 // This is for sorting the records.
416 switch ($srch_option) {
420 $sort = array("lists_date","lists_diagnosis","lists_title");
421 if($sortby == "")$sortby = $sort[1];
424 $sort = array("procedure_result_date","procedure_result_facility","procedure_result_units","procedure_result_result","procedure_result_range","procedure_result_abnormal");
425 //$odrstmt = " procedure_result_result";
427 case "Communication":
428 //$commsort = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(','))";
429 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","users_provider", "communications");
430 if($sortby == "")$sortby = $sort[6];
431 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
434 $sort = array("patient_date","patient_name","patient_id","patient_age","patient_sex","patient_race","patient_ethinic","users_provider");
440 if($sortorder == "") {
443 for($i = 0; $i < count($sort); $i++
) {
444 $sortlink[$i] = "<a href=\"#\" onclick=\"sortingCols('$sort[$i]','asc');\" ><img src=\"../../images/sortdown.gif\" border=0 alt=\"".xla('Sort Up')."\"></a>";
446 for($i = 0; $i < count($sort); $i++
) {
447 if($sortby == $sort[$i]) {
449 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;
450 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;
455 switch ($srch_option) {
459 $odrstmt = " ORDER BY lists_date asc";
462 $odrstmt = " ORDER BY procedure_result_date asc";
464 case "Communication":
465 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) asc, communications asc";
468 $odrstmt = " ORDER BY patient_date asc";
469 //$odrstmt = " ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
472 if(!empty($_REQUEST['sortby']) && !empty($_REQUEST['sortorder'])){
473 if($_REQUEST['sortby'] =="communications"){
474 $odrstmt = "ORDER BY ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) ".escape_sort_order($_REQUEST['sortorder']).", communications ".escape_sort_order($_REQUEST['sortorder']);
476 $odrstmt = "ORDER BY ".escape_identifier($_REQUEST['sortby'],$sort,TRUE)." ".escape_sort_order($_REQUEST['sortorder']);
480 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
481 //echo $sqlstmt."<hr>";
482 $result = sqlStatement($sqlstmt,$sqlBindArray);
484 $row_id = 1.1;//given to each row to identify and toggle
488 if(sqlNumRows($result) > 0){
491 $patDataArr = array();
492 $smoke_codes_arr = getSmokeCodes();
493 while ($row = sqlFetchArray($result)) {
495 $patArr[] = $row['patient_id'];
496 $patInfoArr = array();
497 $patInfoArr['patient_id'] = $row['patient_id'];
499 if($srch_option == "Medications" ||
$srch_option == "Allergies" ||
$srch_option == "Problems"){
500 $patInfoArr['lists_date'] = $row['lists_date'];
501 $patInfoArr['lists_diagnosis'] = $row['lists_diagnosis'];
502 $patInfoArr['lists_title'] = $row['lists_title'];
503 $patInfoArr['patient_name'] = $row['patient_name'];
504 $patInfoArr['patient_age'] = $row['patient_age'];
505 $patInfoArr['patient_sex'] = $row['patient_sex'];
506 $patInfoArr['patient_race'] = $row['patient_race'];
507 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
508 $patInfoArr['users_provider'] = $row['users_provider'];
509 }elseif($srch_option == "Lab results"){
510 $patInfoArr['procedure_result_date'] = $row['procedure_result_date'];
511 $patInfoArr['procedure_result_facility'] = $row['procedure_result_facility'];
512 $patInfoArr['procedure_result_units'] = $row['procedure_result_units'];
513 $patInfoArr['procedure_result_result'] = $row['procedure_result_result'];
514 $patInfoArr['procedure_result_range'] = $row['procedure_result_range'];
515 $patInfoArr['procedure_result_abnormal'] = $row['procedure_result_abnormal'];
516 $patInfoArr['procedure_result_comments'] = $row['procedure_result_comments'];
517 $patInfoArr['procedure_result_document_id'] = $row['procedure_result_document_id'];
518 }elseif($srch_option == "Communication"){
519 $patInfoArr['patient_date'] = $row['patient_date'];
520 $patInfoArr['patient_name'] = $row['patient_name'];
521 $patInfoArr['patient_age'] = $row['patient_age'];
522 $patInfoArr['patient_sex'] = $row['patient_sex'];
523 $patInfoArr['users_provider'] = $row['users_provider'];
524 $patInfoArr['communications'] = $row['communications'];
525 }elseif($srch_option == "Demographics"){
526 $patInfoArr['patient_date'] = $row['patient_date'];
527 $patInfoArr['patient_name'] = $row['patient_name'];
528 $patInfoArr['patient_age'] = $row['patient_age'];
529 $patInfoArr['patient_sex'] = $row['patient_sex'];
530 $patInfoArr['patient_race'] = $row['patient_race'];
531 $patInfoArr['patient_ethinic'] = $row['patient_ethinic'];
532 $patInfoArr['users_provider'] = $row['users_provider'];
535 $patFinalDataArr[] = $patInfoArr;
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">
549 <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
>
553 <table width
=90% align
="center" cellpadding
="5" cellspacing
="0" style
="font-family:tahoma;color:black;" border
="0">
555 <?php
if($srch_option == "Medications" ||
$srch_option == "Allergies" ||
$srch_option == "Problems"){ ?
>
556 <tr style
="font-size:15px;">
557 <td width
="15%"><b
><?php
echo xlt('Diagnosis Date'); ?
><?php
echo $sortlink[0]; ?
></b
></td
>
558 <td width
="15%"><b
><?php
echo xlt('Diagnosis'); ?
><?php
echo $sortlink[1]; ?
></b
></td
>
559 <td width
="15%"><b
><?php
echo xlt('Diagnosis Name');?
><?php
echo $sortlink[2]; ?
></b
></td
>
560 <td width
="15%"><b
><?php
echo xlt('Patient Name'); ?
></b
></td
>
561 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
></td
>
562 <td width
="5%"><b
><?php
echo xlt('Age');?
></b
></td
>
563 <td width
="10%"><b
><?php
echo xlt('Gender');?
></b
></td
>
564 <td colspan
=4><b
><?php
echo xlt('Provider');?
></b
></td
>
566 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
567 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
568 <td
><?php
echo text($patDetailVal['lists_date']); ?
></td
>
569 <td
><?php
echo text($patDetailVal['lists_diagnosis']); ?
></td
>
570 <td
><?php
echo text($patDetailVal['lists_title']); ?
></td
>
571 <td
><?php
echo text($patDetailVal['patient_name']); ?
></td
>
572 <td
><?php
echo text($patDetailVal['patient_id']); ?
></td
>
573 <td
><?php
echo text($patDetailVal['patient_age']);?
></td
>
574 <td
><?php
echo text($patDetailVal['patient_sex']);?
></td
>
575 <td colspan
=4><?php
echo text($patDetailVal['users_provider']);?
></td
>
578 }elseif($srch_option == "Lab results"){ ?
>
579 <tr bgcolor
="#C3FDB8" align
= "left" >
580 <td width
="15%"><b
><?php
echo xlt('Date'); ?
><?php
echo $sortlink[0]; ?
></b
></td
>
581 <td width
="15%"><b
><?php
echo xlt('Facility');?
><?php
echo $sortlink[1]; ?
></b
></td
>
582 <td width
="10%"><b
><?php
echo xlt('Unit');?
></b
><?php
echo $sortlink[2]; ?
></td
>
583 <td width
="10%"><b
><?php
echo xlt('Result');?
></b
><?php
echo $sortlink[3]; ?
></td
>
584 <td width
="10%"><b
><?php
echo xlt('Range');?
></b
><?php
echo $sortlink[4]; ?
></td
>
585 <td width
="10%"><b
><?php
echo xlt('Abnormal');?
><?php
echo $sortlink[5]; ?
></b
></td
>
586 <td
><b
><?php
echo xlt('Comments');?
></b
></td
>
587 <td width
="5%"><b
><?php
echo xlt('Document ID');?
></b
></td
>
588 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
></td
>
591 foreach($patFinalDataArr as $patKey => $labResInsideArr){?
>
592 <tr bgcolor
= "#CCCCCC" >
593 <td
> <?php
echo text($labResInsideArr['procedure_result_date']);?
> 
;</td
>
594 <td
> <?php
echo text($labResInsideArr['procedure_result_facility'],ENT_NOQUOTES
); ?
> 
;</td
>
595 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$labResInsideArr['procedure_result_units']); ?
> 
;</td
>
596 <td
> <?php
echo text($labResInsideArr['procedure_result_result']); ?
> 
;</td
>
597 <td
> <?php
echo text($labResInsideArr['procedure_result_range']); ?
> 
;</td
>
598 <td
> <?php
echo text($labResInsideArr['procedure_result_abnormal']); ?
> 
;</td
>
599 <td
> <?php
echo text($labResInsideArr['procedure_result_comments']); ?
> 
;</td
>
600 <td
> <?php
echo text($labResInsideArr['procedure_result_document_id']); ?
> 
;</td
>
601 <td colspan
="3"> <?php
echo text($labResInsideArr['patient_id']); ?
> 
;</td
>
605 }elseif($srch_option == "Communication"){ ?
>
606 <tr style
="font-size:15px;">
607 <td width
="15%"><b
><?php
echo xlt('Date'); ?
></b
><?php
echo $sortlink[0]; ?
></td
>
608 <td width
="20%"><b
><?php
echo xlt('Patient Name'); ?
></b
><?php
echo $sortlink[1]; ?
></td
>
609 <td width
="5%"><b
><?php
echo xlt('PID');?
></b
><?php
echo $sortlink[2]; ?
></td
>
610 <td width
="5%"><b
><?php
echo xlt('Age');?
></b
><?php
echo $sortlink[3]; ?
></td
>
611 <td width
="10%"><b
><?php
echo xlt('Gender');?
></b
><?php
echo $sortlink[4]; ?
></td
>
612 <td width
="15%"><b
><?php
echo xlt('Provider');?
></b
><?php
echo $sortlink[5]; ?
></td
>
613 <td
><b
><?php
echo xlt('Communication');?
></b
><?php
echo $sortlink[6]; ?
></td
>
615 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
616 <tr bgcolor
= "#CCCCCC" >
617 <td
><?php
if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; }; ?
></td
>
618 <td
><?php
echo text($patDetailVal['patient_name']); ?
></td
>
619 <td
><?php
echo text($patDetailVal['patient_id']); ?
></td
>
620 <td
><?php
echo text($patDetailVal['patient_age']);?
></td
>
621 <td
><?php
echo text($patDetailVal['patient_sex']);?
></td
>
622 <td
><?php
echo text($patDetailVal['users_provider']);?
></td
>
623 <td
><?php
echo text($patDetailVal['communications']);?
></td
>
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
>
637 <?php
foreach($patFinalDataArr as $patKey => $patDetailVal){ ?
>
638 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
639 <td
><?php
if($patDetailVal['patient_date'] != ''){ echo text($patDetailVal['patient_date']); }else{ echo ""; };?
></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
>
651 <!-- Main table ends
-->
653 }else{//End if $result?>
656 <td
class="text"> 
; 
;<?php
echo xlt('No records found.')?
></td
>
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
671 <!-- stuff
for the popup calendar
-->
672 <style type
="text/css">
673 @import
url(../../library
/dynarch_calendar
.css
);
675 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
676 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
677 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
678 <script language
="Javascript">
679 Calendar
.setup({inputField
:"date_from", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_from_date", showsTime
:true});
680 Calendar
.setup({inputField
:"date_to", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_to_date", showsTime
:true});