fixes for prior commit
[openemr.git] / interface / reports / clinical_reports.php
blobf35810bd66210cc680bd6ef73eb930513bed0ccb
1 <?php
2 // Copyright (C) 2010 OpenEMR Support LLC
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This report lists prescriptions and their dispensations according
10 // to various input selection criteria.
12 // Prescription report written by Rod Roark, 2010
13 // Fixed drug name search to work in a broader sense - tony@mi-squared.com, 2010
14 // Added five new reports as per EHR certification requirements for Patient Lists - OpenEMR Support LLC, 2010
16 //SANITIZE ALL ESCAPES
17 $sanitize_all_escapes=true;
20 //STOP FAKE REGISTER GLOBALS
21 $fake_register_globals=false;
23 require_once("../globals.php");
24 require_once("$srcdir/patient.inc");
25 require_once("$srcdir/options.inc.php");
26 require_once("../drugs/drugs.inc.php");
27 require_once("$srcdir/formatting.inc.php");
28 require_once("../../custom/code_types.inc.php");
29 $comarr = array('allow_sms'=>xl('Allow SMS'),'allow_voice'=>xl('Allow Voice Message'),'allow_mail'=>xl('Allow Mail Message'),'allow_email'=>xl('Allow Email'));
30 function add_date($givendate,$day=0,$mth=0,$yr=0) {
31 $cd = strtotime($givendate);
32 $newdate = date('Y-m-d H:i:s', mktime(date('h',$cd),
33 date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
34 date('d',$cd)+$day, date('Y',$cd)+$yr));
35 return $newdate;
37 $type = $_POST["type"];
38 $facility = isset($_POST['facility']) ? $_POST['facility'] : '';
39 if($_POST['date_from'] != "")
40 $sql_date_from = $_POST['date_from'];
41 else
42 $sql_date_from = fixDate($_POST['date_from'], date('Y-01-01 H:i:s'));
44 if($_POST['date_to'] != "")
45 $sql_date_to = $_POST['date_to'];
46 else
47 $sql_date_to = fixDate($_POST['date_to'] , add_date(date('Y-m-d H:i:s')));
50 $patient_id = trim($_POST["patient_id"]);
51 $age_from = $_POST["age_from"];
52 $age_to = $_POST["age_to"];
53 $sql_gender = $_POST["gender"];
54 $sql_ethnicity = $_POST["ethnicity"];
55 $sql_race=$_POST["race"];
56 $form_drug_name = trim($_POST["form_drug_name"]);
57 $form_diagnosis = trim($_POST["form_diagnosis"]);
58 $form_lab_results = trim($_POST["form_lab_results"]);
59 $form_service_codes = trim($_POST["form_service_codes"]);
60 $form_immunization = trim($_POST["form_immunization"]);
61 $communication = trim($_POST["communication"]);
64 <html>
65 <head>
66 <?php html_header_show();?>
67 <title>
68 <?php echo htmlspecialchars(xl('Clinical Reports'),ENT_NOQUOTES); ?>
69 </title>
70 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
71 <script type="text/javascript" src="../../library/textformat.js"></script>
72 <script type="text/javascript" src="../../library/dialog.js"></script>
73 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
74 <script language="JavaScript">
76 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
78 function toggle(id) {
79 var tr = document.getElementById(id);
80 if (tr==null) { return; }
81 var bExpand = tr.style.display == '';
82 tr.style.display = (bExpand ? 'none' : '');
84 function changeimage(id, sMinus, sPlus) {
85 var img = document.getElementById(id);
86 if (img!=null) {
87 var bExpand = img.src.indexOf(sPlus) >= 0;
88 if (!bExpand)
89 img.src = "../pic/blue-up-arrow.gif";
90 else
91 img.src = "../pic/blue-down-arrow.gif";
94 function Toggle_trGrpHeader2(t_id,i_id) {
95 var img=i_id;
96 changeimage(img, 'blue-down-arrow.gif', 'blue-up-arrow.gif');
97 var id1=t_id;
98 toggle(id1);
100 // This is for callback by the find-code popup.
101 // Appends to or erases the current list of diagnoses.
102 function set_related(codetype, code, selector, codedesc) {
103 var f = document.forms[0][current_sel_name];
104 var s = f.value;
105 if (code) {
106 if (s.length > 0) s += ';';
107 s += codetype + ':' + code;
108 } else {
109 s = '';
111 f.value = s;
114 //This invokes the find-code popup.
115 function sel_diagnosis(e) {
116 current_sel_name = e.name;
117 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("diagnosis","csv"); ?>', '_blank', 500, 400);
120 //This invokes the find-code popup.
121 function sel_procedure(e) {
122 current_sel_name = e.name;
123 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("procedure","csv"); ?>', '_blank', 500, 400);
125 </script>
126 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
127 <style type="text/css">
128 /* specifically include & exclude from printing */
129 @media print {
130 #report_parameters {
131 visibility: hidden;
132 display: none;
134 #report_parameters_daterange {
135 visibility: visible;
136 display: inline;
138 #report_results table {
139 margin-top: 0px;
143 /* specifically exclude some from the screen */
144 @media screen {
145 #report_parameters_daterange {
146 visibility: hidden;
147 display: none;
150 .optional_area_service_codes {
151 <?php
152 if($type != 'Service Codes' || $type == '')
155 display: none;
156 <?php
160 </style>
161 <script language="javascript" type="text/javascript">
162 function checkType() {
163 if($('#type').val() == 'Service Codes')
165 $('.optional_area_service_codes').css("display", "inline");
167 else
169 $('.optional_area_service_codes').css("display", "none");
173 function submitForm() {
174 var d_from = new String($('#date_from').val());
175 var d_to = new String($('#date_to').val());
177 var d_from_arr = d_from.split('-');
178 var d_to_arr = d_to.split('-');
180 var dt_from = new Date(d_from_arr[0], d_from_arr[1], d_from_arr[2]);
181 var dt_to = new Date(d_to_arr[0], d_to_arr[1], d_to_arr[2]);
183 var mili_from = dt_from.getTime();
184 var mili_to = dt_to.getTime();
185 var diff = mili_to - mili_from;
187 $('#date_error').css("display", "none");
189 if(diff < 0) //negative
191 $('#date_error').css("display", "inline");
193 else
195 $("#form_refresh").attr("value","true");
196 $("#theform").submit();
200 $(document).ready(function() {
201 $(".numeric_only").keydown(function(event) {
202 //alert(event.keyCode);
203 // Allow only backspace and delete
204 if ( event.keyCode == 46 || event.keyCode == 8 ) {
205 // let it happen, don't do anything
207 else {
208 if(!((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57)))
210 event.preventDefault();
215 </script>
216 </head>
217 <body class="body_top">
218 <!-- Required for the popup date selectors -->
219 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
220 <span class='title'>
221 <?php echo htmlspecialchars(xl('Report - Clinical'),ENT_NOQUOTES); ?>
222 </span>
223 <!-- Search can be done using age range, gender, and ethnicity filters.
224 Search options include diagnosis, procedure, prescription, medical history, and lab results.
226 <div id="report_parameters_daterange"> <?php echo htmlspecialchars(date("d F Y", strtotime($sql_date_from)),ENT_NOQUOTES) .
227 " &nbsp; to &nbsp; ". htmlspecialchars(date("d F Y", strtotime($sql_date_to)),ENT_NOQUOTES); ?> </div>
228 <form name='theform' id='theform' method='post' action='clinical_reports.php'>
229 <div id="report_parameters">
230 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
231 <table>
232 <tr>
233 <td width='740px'><div style='float:left'>
234 <table class='text'>
235 <tr>
236 <td class='label' width="100"><?php echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES); ?>: </td>
237 <td width="250"> <?php dropdown_facility($facility,'facility',false); ?> </td>
238 <td class='label' width="100"><?php echo htmlspecialchars(xl('From'),ENT_NOQUOTES); ?>: </td>
239 <td><input type='text' name='date_from' id="date_from" size='18' value='<?php echo htmlspecialchars($sql_date_from,ENT_QUOTES); ?>' onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)' title='yyyy-mm-dd H:m:s'> <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 htmlspecialchars(xl('Click here to choose date time from'),ENT_QUOTES); ?>'></td>
240 </tr>
241 <tr>
242 <td class='label'><?php echo htmlspecialchars(xl('Patient ID'),ENT_NOQUOTES); ?>:</td>
243 <td><input name='patient_id' class="numeric_only" type='text' id="patient_id" title='<?php echo htmlspecialchars(xl('Optional numeric patient ID'),ENT_QUOTES); ?>' value='<?php echo htmlspecialchars($patient_id,ENT_QUOTES); ?>' size='10' maxlength='20' /></td>
244 <td class='label'><?php echo htmlspecialchars(xl('To'),ENT_NOQUOTES); ?>: </td>
245 <td><input type='text' name='date_to' id="date_to" size='18' value='<?php echo htmlspecialchars($sql_date_to,ENT_QUOTES); ?>' onKeyUp='datekeyup(this,mypcc,true)' onBlur='dateblur(this,mypcc,true)' title='yyyy-mm-dd H:m:s'> <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 htmlspecialchars(xl('Click here to choose date time to'),ENT_QUOTES); ?>'></td>
246 </tr>
247 <tr>
248 <td class='label'><?php echo htmlspecialchars(xl('Age Range'),ENT_NOQUOTES); ?>:</td>
249 <td><?php echo htmlspecialchars(xl('From'),ENT_NOQUOTES); ?>
250 <input name='age_from' class="numeric_only" type='text' id="age_from" value="<?php echo htmlspecialchars($age_from,ENT_QUOTES); ?>" size='3' maxlength='3' /> <?php echo htmlspecialchars(xl('To'),ENT_NOQUOTES); ?>
251 <input name='age_to' class="numeric_only" type='text' id="age_to" value="<?php echo htmlspecialchars($age_to,ENT_QUOTES); ?>" size='3' maxlength='3' /></td>
252 <td class='label'><?php echo htmlspecialchars(xl('Problem DX'),ENT_NOQUOTES); ?>:</td>
253 <td><input type='text' name='form_diagnosis' size='10' maxlength='250' value='<?php echo htmlspecialchars($form_diagnosis,ENT_QUOTES); ?>' onclick='sel_diagnosis(this)' title='<?php echo htmlspecialchars(xl('Click to select or change diagnoses'),ENT_QUOTES); ?>' readonly /></td>
254 <td>&nbsp;</td>
255 <!-- Visolve -->
256 </tr>
257 <tr>
258 <td class='label'><?php echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES); ?>:</td>
259 <td><?php echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?></td>
260 <td class='label'><?php echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES); ?>:</td>
261 <td><input type='text' name='form_drug_name' size='10' maxlength='250' value='<?php echo htmlspecialchars($form_drug_name,ENT_QUOTES); ?>' title='<?php echo htmlspecialchars(xl('Optional drug name, use % as a wildcard'),ENT_QUOTES); ?>' /></td>
263 </tr>
264 <tr>
265 <td class='label'><?php echo htmlspecialchars(xl('Race'),ENT_NOQUOTES); ?>:</td>
266 <td><?php echo generate_select_list('race', 'race', $sql_race, 'Select Race', 'Unassigned', '', ''); ?></td>
267 <td class='label'><?php echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES); ?>:</td>
268 <td><?php echo generate_select_list('ethnicity', 'ethnicity', $sql_ethnicity, 'Select Ethnicity', 'Unassigned', '', ''); ?></td>
269 <td class='label'><?php echo htmlspecialchars(xl('Immunization'),ENT_NOQUOTES); ?>:</td>
270 <td><input type='text' name='form_immunization' size='10' maxlength='250' value='<?php echo htmlspecialchars($form_immunization,ENT_QUOTES); ?>' title='<?php echo htmlspecialchars(xl('Optional immunization name or code, use % as a wildcard'),ENT_QUOTES); ?>' /></td>
271 </tr>
272 <tr>
273 <td class='label' width='100'><?php echo htmlspecialchars(xl('Lab Result'),ENT_NOQUOTES); ?>:</td>
274 <td width='100'><input type='text' name='form_lab_results' size='13' maxlength='250' value='<?php echo htmlspecialchars($form_lab_results,ENT_QUOTES); ?>' title='<?php echo htmlspecialchars(xl('Result, use % as a wildcard'),ENT_QUOTES); ?>' /></td>
276 <td class='label' width='100'><?php echo htmlspecialchars(xl('Option'),ENT_NOQUOTES); ?>:</td>
277 <td><select name="type" id="type" onChange="checkType();">
278 <option> <?php echo htmlspecialchars(xl('Select'),ENT_NOQUOTES); ?></option>
279 <option value="Procedure" <?php if($type == 'Procedure') { echo "selected"; } ?>><?php echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES); ?></option>
280 <option value="Medical History" <?php if($type == 'Medical History') { echo "selected"; } ?>><?php echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES); ?></option>
281 <option value="Service Codes" <?php if($type == 'Service Codes') { echo "selected"; } ?>><?php echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES); ?></option>
282 </select>
283 </td>
284 <td class='label'><?php echo htmlspecialchars(xl('Communication'),ENT_NOQUOTES); ?>:</td>
285 <td>
286 <select name="communication" id="communication" title="<?php echo htmlspecialchars(xl('Select Communication Preferences'),ENT_NOQUOTES); ?>">
287 <option value=""> <?php echo htmlspecialchars(xl('Select'),ENT_NOQUOTES); ?></option>
288 <?php foreach($comarr as $comkey => $comvalue){ ?>
289 <option value="<?php echo attr($comkey); ?>" <?php if($communication == $comkey){ echo "selected";}?>><?php echo text($comvalue); ?></option>
290 <?php } ?>
291 </select>
292 </td>
293 </tr>
294 </table>
295 <table>
296 <tr class="optional_area_service_codes">
297 <td width='100'>&nbsp;</td>
298 <td width='100'>&nbsp;</td>
299 <td width='195'>&nbsp;</td>
300 <td class='label' width='76'><?php echo htmlspecialchars(xl('Code'),ENT_NOQUOTES); ?>:</td>
301 <td> <input type='text' name='form_service_codes' size='10' maxlength='250' value='<?php echo htmlspecialchars($form_service_codes,ENT_QUOTES); ?>' onclick='sel_procedure(this)' title='<?php echo htmlspecialchars(xl('Click to select or change service codes'),ENT_QUOTES); ?>' readonly />&nbsp;</td>
302 </tr>
303 </table>
304 <table class='text'>
305 <tr>
306 <!-- Sort by Start -->
307 <td class='label' width='63'><?php echo htmlspecialchars(xl('Sort By'),ENT_NOQUOTES); ?>:</td>
308 <td>
309 <input type='checkbox' name='form_pt_name'<?php if ($_POST['form_pt_name'] == true) echo ' checked'; ?>>
310 <?php echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES); ?>&nbsp;
312 <input type='checkbox' name='form_pt_age'<?php if ($_POST['form_pt_age'] == true) echo ' checked'; ?>>
313 <?php echo htmlspecialchars(xl('Age'),ENT_NOQUOTES); ?>&nbsp;
315 <input type='checkbox' name='form_diagnosis_code'<?php if ($_POST['form_diagnosis_code'] == true) echo ' checked'; ?>>
316 <?php echo htmlspecialchars(xl('Diagnosis Code'),ENT_NOQUOTES); ?>&nbsp;
318 <input type='checkbox' name='form_diagnosis_tit'<?php if ($_POST['form_diagnosis_tit'] == true) echo ' checked'; ?>>
319 <?php echo htmlspecialchars(xl('Diagnosis Title'),ENT_NOQUOTES); ?>&nbsp;
321 <input type='checkbox' name='form_drug'<?php if ($_POST['form_drug'] == true) echo ' checked'; ?>>
322 <?php echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES); ?>&nbsp;
324 <input type='checkbox' name='ndc_no'<?php if ($_POST['ndc_no'] == true) echo ' checked'; ?>>
325 <?php echo htmlspecialchars(xl('NDC Number'),ENT_NOQUOTES); ?>&nbsp;
326 <input type='checkbox' name='lab_results'<?php if ($_POST['lab_results'] == true) echo ' checked'; ?>>
327 <?php echo htmlspecialchars(xl('Lab Results'),ENT_NOQUOTES); ?>&nbsp;
328 </td>
329 </tr>
330 <!-- Sort by ends -->
331 </tr>
332 <tr>
333 <td colspan=3><span id="date_error" style="color: #F00; font-siz: 11px; display: none;"><?php echo htmlspecialchars(xl('From Date Cannot be Greater than To Date.'),ENT_NOQUOTES); ?></span>&nbsp;</td>
334 </tr>
335 </table>
336 </div></td>
337 <td height="100%" valign='middle' width="175"><table style='border-left:1px solid; width:100%; height:100%'>
338 <tr>
339 <td><div style='margin-left:15px'> <a href='#' class='css_button' onclick='submitForm();'> <span>
340 <?php echo htmlspecialchars(xl('Submit'),ENT_NOQUOTES); ?>
341 </span> </a>
342 <?php if ($_POST['form_refresh']) { ?>
343 <a href='#' class='css_button' onclick='window.print()'> <span>
344 <?php echo htmlspecialchars(xl('Print'),ENT_NOQUOTES); ?>
345 </span> </a>
346 <?php } ?>
347 </div></td>
348 </tr>
349 </table></td>
350 </tr>
351 </table>
352 </div>
353 <!-- end of parameters -->
354 <?php
355 // SQL scripts for the various searches
356 $sqlBindArray = array();
357 if ($_POST['form_refresh'])
359 $sqlstmt = "select
360 concat(pd.fname, ' ', pd.lname) AS patient_name,
361 pd.pid AS patient_id,
362 DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 AS patient_age,
363 pd.sex AS patient_sex,
364 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
365 concat(u.fname, ' ', u.lname) AS users_provider";
366 if(strlen($form_diagnosis) > 0) {
367 $sqlstmt=$sqlstmt.",li.date AS lists_date,
368 li.diagnosis AS lists_diagnosis,
369 li.title AS lists_title";
371 if(strlen($form_drug_name) > 0) {
373 $sqlstmt=$sqlstmt.",r.id as id, r.date_modified AS prescriptions_date_modified, r.dosage as dosage, r.route as route, r.interval as hinterval, r.refills as refills, r.drug as drug,
374 r.form as hform, r.size as size, r.unit as hunit, d.name as name, d.ndc_number as ndc_number,r.quantity as quantity";
377 if(strlen($form_lab_results) > 0) {
378 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
379 pr.facility AS procedure_result_facility,
380 pr.units AS procedure_result_units,
381 pr.result AS procedure_result_result,
382 pr.range AS procedure_result_range,
383 pr.abnormal AS procedure_result_abnormal,
384 pr.comments AS procedure_result_comments,
385 pr.document_id AS procedure_result_document_id";
388 if ( $type == 'Procedure') {
389 $sqlstmt = $sqlstmt.",po.date_ordered AS procedure_order_date_ordered,
390 pt.standard_code AS procedure_type_standard_code,
391 pc.procedure_name as procedure_name,
392 po.order_priority AS procedure_order_order_priority,
393 po.order_status AS procedure_order_order_status,
394 po.encounter_id AS procedure_order_encounter,
395 po.patient_instructions AS procedure_order_patient_instructions,
396 po.activity AS procedure_order_activity,
397 po.control_id AS procedure_order_control_id ";
400 if ( $type == 'Medical History') {
401 $sqlstmt = $sqlstmt.",hd.date AS history_data_date,
402 hd.tobacco AS history_data_tobacco,
403 hd.alcohol AS history_data_alcohol,
404 hd.recreational_drugs AS history_data_recreational_drugs ";
406 if($type == 'Service Codes') {
407 $sqlstmt .= ", c.code as code,
408 c.code_text as code_text,
409 fe.encounter as encounter,
410 b.date as date";
411 $mh_stmt = $mh_stmt.",code,code_text,encounter,date";
413 if (strlen($form_immunization) > 0) {
414 $sqlstmt .= ", immc.code_text as imm_code, immc.code_text_short as imm_code_short, immc.id as cvx_code, imm.administered_date as imm_date, imm.amount_administered, imm.amount_administered_unit, imm.administration_site, imm.note as notes ";
416 //from
417 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid
418 left outer join facility as f on f.id = u.facility_id";
420 if(strlen($form_diagnosis) > 0 ){
421 $sqlstmt = $sqlstmt." left outer join lists as li on li.pid = pd.pid ";
424 if ( $type == 'Procedure' ||( strlen($form_lab_results)!=0) ) {
425 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
426 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
427 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
428 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id ";
431 if (strlen($form_lab_results)!=0 ) {
432 $sqlstmt = $sqlstmt." left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id ";
434 //Immunization added in clinical report
435 if (strlen($form_immunization)!=0 ) {
436 $sqlstmt = $sqlstmt." LEFT OUTER JOIN immunizations as imm ON imm.patient_id = pd.pid
437 LEFT OUTER JOIN codes as immc ON imm.cvx_code = immc.id ";
439 if(strlen($form_drug_name)!=0) {
440 $sqlstmt=$sqlstmt." left outer join prescriptions AS r on r.patient_id=pd.pid
441 LEFT OUTER JOIN drugs AS d ON d.drug_id = r.drug_id";
443 if ( $type == 'Medical History') {
444 $sqlstmt = $sqlstmt." left outer join history_data as hd on hd.pid = pd.pid
445 and (isnull(hd.tobacco) = 0
446 or isnull(hd.alcohol) = 0
447 or isnull(hd.recreational_drugs) = 0)";
449 if($type == 'Service Codes') {
450 $sqlstmt = $sqlstmt." left outer join billing as b on b.pid = pd.pid
451 left outer join form_encounter as fe on fe.encounter = b.encounter and b.code_type = 'CPT4'
452 left outer join codes as c on c.code = b.code ";
454 //where
455 $whr_stmt="where 1=1";
456 if(strlen($form_diagnosis) > 0 ) {
457 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(li.date) <= ?";
458 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
460 if(strlen($form_lab_results)!=0 ) {
461 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(pr.date) <= ?";
462 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
464 if(strlen($form_drug_name)!=0) {
465 $whr_stmt=$whr_stmt." AND r.date_modified >= ? AND r.date_modified < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(r.date_modified) <= ?";
466 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
468 if($type == 'Medical History') {
469 $whr_stmt=$whr_stmt." AND hd.date >= ? AND hd.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(hd.date) <= ?";
470 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
472 if($type == 'Procedure') {
473 $whr_stmt=$whr_stmt." AND po.date_ordered >= ? AND po.date_ordered < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(po.date_ordered) <= ?";
474 array_push($sqlBindArray, substr($sql_date_from,0,10), substr($sql_date_to,0,10), date("Y-m-d"));
476 if($type == "Service Codes") {
477 $whr_stmt=$whr_stmt." AND b.date >= ? AND b.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(b.date) <= ?";
478 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
480 if(strlen($form_lab_results) != 0) {
481 $whr_stmt= $whr_stmt." AND (pr.result LIKE ?) ";
482 array_push($sqlBindArray, $form_lab_results);
484 if(strlen($form_drug_name) > 0) {
485 $whr_stmt .= " AND (
486 d.name LIKE ?
487 OR r.drug LIKE ?
488 ) ";
489 array_push($sqlBindArray, $form_drug_name, $form_drug_name);
491 if($type == 'Service Codes') {
492 if(strlen($form_service_codes) != 0) {
493 $whr_stmt = $whr_stmt." AND (b.code = ?) ";
494 $service_code = explode(":",$form_service_codes);
495 array_push($sqlBindArray, $service_code[1]);
498 if(strlen($patient_id) != 0) {
499 $whr_stmt = $whr_stmt." and pd.pid = ?";
500 array_push($sqlBindArray, $patient_id);
503 if(strlen($age_from) != 0) {
504 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
505 array_push($sqlBindArray, $age_from);
507 if(strlen($age_to) != 0) {
508 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
509 array_push($sqlBindArray, $age_to);
511 if(strlen($sql_gender) != 0) {
512 $whr_stmt = $whr_stmt." and pd.sex = ?";
513 array_push($sqlBindArray, $sql_gender);
515 if(strlen($sql_ethnicity) != 0) {
516 $whr_stmt = $whr_stmt." and pd.ethnicity = ?";
517 array_push($sqlBindArray, $sql_ethnicity);
519 if(strlen($sql_race) != 0) {
520 $whr_stmt = $whr_stmt." and pd.race = ?";
521 array_push($sqlBindArray, $sql_race);
523 if($facility != '') {
524 $whr_stmt = $whr_stmt." and f.id = ? ";
525 array_push($sqlBindArray, $facility);
527 if(strlen($form_diagnosis) > 0) {
528 $whr_stmt = $whr_stmt." AND (li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis = ?) ";
529 array_push($sqlBindArray, $form_diagnosis.";%", '%;'.$form_diagnosis.';%', '%;'.$form_diagnosis, $form_diagnosis);
531 //communication preferences added in clinical report
532 if(strlen($communication) > 0){
533 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
534 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
535 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
536 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
539 //Immunization where condition for full text or short text
540 if(strlen($form_immunization) > 0) {
541 $whr_stmt .= " AND (
542 immc.code_text LIKE ?
543 OR immc.code_text_short LIKE ?
544 ) ";
545 array_push($sqlBindArray, '%'.$form_immunization.'%', '%'.$form_immunization.'%');
547 // order by
548 if ($_POST['form_pt_name'] == true){
549 $odrstmt=$odrstmt.",patient_name";
551 if ($_POST['form_pt_age'] == true) {
552 $odrstmt=$odrstmt.",patient_age";
554 if (($_POST['form_diagnosis_code'] == true) && (strlen($form_diagnosis) > 0)){
555 $odrstmt=$odrstmt.",lists_diagnosis";
557 if (($_POST['form_diagnosis_tit'] == true) && (strlen($form_diagnosis) > 0)){
558 $odrstmt=$odrstmt.",lists_title";
560 if (($_POST['form_drug'] == true)&& (strlen($form_drug_name) > 0)){
561 $odrstmt=$odrstmt.",r.drug";
563 if (($_POST['ndc_no'] == true) && (strlen($form_drug_name) > 0)) {
564 $odrstmt=$odrstmt.",d.ndc_number";
566 if (($_POST['lab_results'] == true) && (strlen($form_lab_results) > 0)) {
567 $odrstmt=$odrstmt.",procedure_result_result";
570 if($odrstmt == '') {
571 $odrstmt = " ORDER BY patient_id";
573 else {
574 $odrstmt = " ORDER BY ".ltrim($odrstmt,",");
577 if($type == 'Medical History') {
578 $sqlstmt="select * from (".$sqlstmt." ".$whr_stmt." ".$odrstmt.",history_data_date desc) a group by patient_id";
580 else {
581 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
584 $result = sqlStatement($sqlstmt,$sqlBindArray);
586 $row_id = 1.1;//given to each row to identify and toggle
587 $img_id = 1.2;
588 $k=1.3;
590 if(sqlNumRows($result) > 0)
592 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
593 $smoke_codes_arr = getSmokeCodes();
595 <br>
596 <div id = "report_results">
597 <?php while ($row = sqlFetchArray($result)) { ?>
598 <table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0">
599 <tr bgcolor = "#CCCCCC" style="font-size:15px;">
600 <td><b><?php echo htmlspecialchars(xl('Summary of'),ENT_NOQUOTES); echo " "; ?> <?php echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES); ?></b></td>
601 <td>&nbsp;</td>
602 <td>&nbsp;</td>
603 <td align="center">
604 <span onclick="javascript:Toggle_trGrpHeader2(<?php echo $row_id; ?>,<?php echo $img_id; ?>);"><img src="../pic/blue-down-arrow.gif" id="<?php echo $img_id; $img_id++; ?>" title="<?php echo htmlspecialchars( xl('Click here to view patient details'), ENT_QUOTES); ?>" /></span>
605 </td></tr>
606 <table width="100%" align="center" id = "<?php echo $row_id; $row_id++;?>" class="border1" style="display:none; font-size:13px;" cellpadding=5>
607 <tr bgcolor="#C3FDB8" align="left">
608 <td width="15%"><b><?php echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES); ?></b></td>
609 <td width="5%"><b><?php echo htmlspecialchars(xl('PID'),ENT_NOQUOTES);?></b></td>
610 <td width="5%"><b><?php echo htmlspecialchars(xl('Age'),ENT_NOQUOTES);?></b></td>
611 <td width="10%"><b><?php echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES); ?></b></td>
612 <td width="15%"><b><?php echo htmlspecialchars(xl('Race'),ENT_NOQUOTES);?></b></td>
613 <td width="15%"><b><?php echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES);?></b></td>
614 <td width="15%" <?php if(strlen($communication) == 0){ ?> colspan=5 <?php } ?>><b><?php echo htmlspecialchars(xl('Provider'),ENT_NOQUOTES);?></b></td>
615 <?php if(strlen($communication) > 0){ ?>
616 <td colspan=4><b><?php echo xlt('Communication');?></b></td>
617 <?php } ?>
618 </tr>
619 <tr bgcolor="#FFFFFF">
620 <td><?php echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES); ?>&nbsp;</td>
621 <td> <?php echo htmlspecialchars($row['patient_id'],ENT_NOQUOTES); ?>&nbsp;</td>
622 <td> <?php echo htmlspecialchars($row['patient_age'],ENT_NOQUOTES); ?>&nbsp;</td>
623 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'sex'), $row['patient_sex']),ENT_NOQUOTES); ?>&nbsp;</td>
624 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'race'), $row['patient_race']),ENT_NOQUOTES); ?>&nbsp;</td>
625 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ethnicity'), $row['patient_ethinic']),ENT_NOQUOTES); ?>&nbsp;</td>
626 <td <?php if(strlen($communication) == 0){ ?> colspan=5 <?php } ?>> <?php echo htmlspecialchars($row['users_provider'],ENT_NOQUOTES); ?>&nbsp;</td>
627 <?php if(strlen($communication) > 0){ ?>
628 <td colspan=4><?php echo text($comarr["$communication"]); ?></td>
629 <?php } ?>
630 </tr>
631 <!-- Diagnosis Report Start-->
632 <?php
633 if(strlen($form_diagnosis) > 0)
636 <tr bgcolor="#C3FDB8" align= "left">
637 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Diagnosis Report'),ENT_NOQUOTES);?></b></td>
638 </tr>
639 <tr bgcolor="#C3FDB8" align= "left">
640 <td><b><?php echo htmlspecialchars(xl('Diagnosis Date'),ENT_NOQUOTES);?></b></td>
641 <td><b><?php echo htmlspecialchars(xl('Diagnosis'),ENT_NOQUOTES);?></b></td>
642 <td colspan=9><b><?php echo htmlspecialchars(xl('Diagnosis Name'),ENT_NOQUOTES);?></b></td>
643 </tr>
644 <tr bgcolor="#FFFFFF">
645 <td><?php echo htmlspecialchars($row['lists_date'],ENT_NOQUOTES); ?>&nbsp;</td>
646 <td><?php echo htmlspecialchars($row['lists_diagnosis'],ENT_NOQUOTES); ?>&nbsp;</td>
647 <td colspan=9><?php echo htmlspecialchars($row['lists_title'],ENT_NOQUOTES); ?>&nbsp;</td>
648 </tr>
649 <?php } ?>
650 <!-- Diagnosis Report End-->
652 <!-- Prescription Report Start-->
653 <?php
654 if(strlen($form_drug_name) > 0)
657 <tr bgcolor="#C3FDB8" align= "left">
658 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Prescription Report'),ENT_NOQUOTES);?><b></td></tr>
659 <tr bgcolor="#C3FDB8" align= "left">
660 <td><b><?php echo htmlspecialchars(xl('Date'),ENT_NOQUOTES); ?></b></td>
661 <td><b><?php echo htmlspecialchars(xl('Drug Name'),ENT_NOQUOTES);?></b></td>
662 <td><b><?php echo htmlspecialchars(xl('Route'),ENT_NOQUOTES);?></b></td>
663 <td><b><?php echo htmlspecialchars(xl('Dosage'),ENT_NOQUOTES);?></b></td>
664 <td><b><?php echo htmlspecialchars(xl('Form'),ENT_NOQUOTES);?></b></td>
665 <td><b><?php echo htmlspecialchars(xl('Interval'),ENT_NOQUOTES);?></b></td>
666 <td><b><?php echo htmlspecialchars(xl('Size'),ENT_NOQUOTES);?></b></td>
667 <td><b><?php echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES);?></b></td>
668 <td><b><?php echo htmlspecialchars(xl('ReFill'),ENT_NOQUOTES);?></b></td>
669 <td><b><?php echo htmlspecialchars(xl('Quantity'),ENT_NOQUOTES);?></b></td>
670 <td><b><?php echo htmlspecialchars(xl('NDC'),ENT_NOQUOTES);?></b></td>
671 </tr>
672 <tr bgcolor="#FFFFFF" align="">
673 <?php
674 $rx_route = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) ;
675 $rx_form = generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['hform']) ;
676 $rx_interval = generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'), $row['hinterval']) ;
677 $rx_units = generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['hunit']);
679 <td> <?php echo htmlspecialchars(oeFormatShortDate($row['prescriptions_date_modified']),ENT_NOQUOTES); ?>&nbsp;</td>
680 <td><?php echo htmlspecialchars($row['drug'],ENT_NOQUOTES); ?></td>
681 <td><?php echo htmlspecialchars($rx_route,ENT_NOQUOTES); ?></td>
682 <td><?php echo htmlspecialchars($row['dosage'],ENT_NOQUOTES); ?></td>
683 <td><?php echo htmlspecialchars($rx_form,ENT_NOQUOTES); ?></td>
684 <td><?php echo htmlspecialchars($rx_interval,ENT_NOQUOTES); ?></td>
685 <td><?php echo htmlspecialchars($row['size'],ENT_NOQUOTES); ?></td>
686 <td><?php echo htmlspecialchars($rx_units,ENT_NOQUOTES); ?></td>
687 <td><?php echo htmlspecialchars($row['refills'],ENT_NOQUOTES); ?></td>
688 <td><?php echo htmlspecialchars($row['quantity'],ENT_NOQUOTES); ?></td>
689 <td><?php echo htmlspecialchars($row['ndc_number'],ENT_NOQUOTES); ?></td>
690 </tr>
691 <?php } ?>
692 <!-- Prescription Report End-->
694 <!-- Lab Results Report Start-->
695 <?php
696 if(strlen($form_lab_results) > 0)
699 <tr bgcolor="#C3FDB8" align= "left">
700 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Lab Results Report'),ENT_NOQUOTES);?><b></td></tr>
701 <tr bgcolor="#C3FDB8" align= "left">
702 <td><b><?php echo htmlspecialchars(xl('Date'),ENT_NOQUOTES); ?></b></td>
703 <td><b><?php echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES);?></b></td>
704 <td><b><?php echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES);?></b></td>
705 <td><b><?php echo htmlspecialchars(xl('Result'),ENT_NOQUOTES);?></b></td>
706 <td><b><?php echo htmlspecialchars(xl('Range'),ENT_NOQUOTES);?></b></td>
707 <td><b><?php echo htmlspecialchars(xl('Abnormal'),ENT_NOQUOTES);?></b></td>
708 <td><b><?php echo htmlspecialchars(xl('Comments'),ENT_NOQUOTES);?></b></td>
709 <td colspan=4><b><?php echo htmlspecialchars(xl('Document ID'),ENT_NOQUOTES);?></b></td>
710 </tr>
711 <tr bgcolor="#FFFFFF">
712 <td> <?php echo htmlspecialchars(oeFormatShortDate($row['procedure_result_date']),ENT_NOQUOTES); ?>&nbsp;</td>
713 <td> <?php echo htmlspecialchars($row['procedure_result_facility'],ENT_NOQUOTES); ?>&nbsp;</td>
714 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$row['procedure_result_units']),ENT_NOQUOTES); ?>&nbsp;</td>
715 <td> <?php echo htmlspecialchars($row['procedure_result_result'],ENT_NOQUOTES); ?>&nbsp;</td>
716 <td> <?php echo htmlspecialchars($row['procedure_result_range'],ENT_NOQUOTES); ?>&nbsp;</td>
717 <td> <?php echo htmlspecialchars($row['procedure_result_abnormal'],ENT_NOQUOTES); ?>&nbsp;</td>
718 <td> <?php echo htmlspecialchars($row['procedure_result_comments'],ENT_NOQUOTES); ?>&nbsp;</td>
719 <td colspan=4> <?php echo htmlspecialchars($row['procedure_result_document_id'],ENT_NOQUOTES); ?>&nbsp;</td>
720 </tr>
721 <?php } ?>
722 <!-- Lab Results End-->
724 <!-- Procedures Report Start-->
725 <?php
726 if ( $type == 'Procedure')
729 <tr bgcolor="#C3FDB8" align= "left">
730 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Procedure Report'),ENT_NOQUOTES);?><b></td></tr>
731 <tr bgcolor="#C3FDB8" align= "left">
732 <td><b><?php echo htmlspecialchars(xl('Date'),ENT_NOQUOTES); ?></b></td>
733 <td><b><?php echo htmlspecialchars(xl('Standard Name'),ENT_NOQUOTES);?></b></td>
734 <td><b><?php echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES); ?></b></td>
735 <td><b><?php echo htmlspecialchars(xl('Encounter'),ENT_NOQUOTES);?></b></td>
736 <td><b><?php echo htmlspecialchars(xl('Priority'),ENT_NOQUOTES);?></b></td>
737 <td><b><?php echo htmlspecialchars(xl('Status'),ENT_NOQUOTES);?></b></td>
738 <td><b><?php echo htmlspecialchars(xl('Instruction'),ENT_NOQUOTES);?></b></td>
739 <td><b><?php echo htmlspecialchars(xl('Activity'),ENT_NOQUOTES);?></b></td>
740 <td colspan=3><b><?php echo htmlspecialchars(xl('Control ID'),ENT_NOQUOTES);?></b></td>
741 </tr>
742 <tr bgcolor="#FFFFFF">
743 <?php
744 $procedure_type_standard_code_arr = explode(':', $row['procedure_type_standard_code']);
745 $procedure_type_standard_code = $procedure_type_standard_code_arr[1];
747 <!-- Procedure -->
748 <td> <?php echo htmlspecialchars(oeFormatShortDate($row['procedure_order_date_ordered']),ENT_NOQUOTES); ?>&nbsp;</td>
749 <td> <?php echo htmlspecialchars($procedure_type_standard_code,ENT_NOQUOTES); ?>&nbsp;</td>
750 <td> <?php echo htmlspecialchars($row['procedure_name'],ENT_NOQUOTES); ?>&nbsp;</td>
751 <td> <?php echo htmlspecialchars($row['procedure_order_encounter'],ENT_NOQUOTES); ?>&nbsp;</td>
752 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_priority'),$row['procedure_order_order_priority']),ENT_NOQUOTES); ?>&nbsp;</td>
753 <td> <?php echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_status'),$row['procedure_order_order_status']),ENT_NOQUOTES); ?>&nbsp;</td>
754 <td> <?php echo htmlspecialchars($row['procedure_order_patient_instructions'],ENT_NOQUOTES); ?>&nbsp;</td>
755 <td> <?php echo htmlspecialchars($row['procedure_order_activity'],ENT_NOQUOTES); ?>&nbsp;</td>
756 <td colspan=3> <?php echo htmlspecialchars($row['procedure_order_control_id'],ENT_NOQUOTES); ?>&nbsp;</td>
758 </tr>
759 <?php } ?>
760 <!-- Procedure Report End-->
762 <!-- Medical History Report Start-->
763 <?php
764 if ( $type == 'Medical History')
767 <tr bgcolor="#C3FDB8" align= "left">
768 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES);?><b></td></tr>
769 <tr bgcolor="#C3FDB8" align= "left">
770 <td><b><?php echo htmlspecialchars(xl('History Date'),ENT_NOQUOTES); ?></b></td>
771 <td><b><?php echo htmlspecialchars(xl('Tobacco'),ENT_NOQUOTES);?></b></td>
772 <td><b><?php echo htmlspecialchars(xl('Alcohol'),ENT_NOQUOTES);?></b></td>
773 <td colspan=8><b><?php echo htmlspecialchars(xl('Recreational Drugs'),ENT_NOQUOTES);?></b></td>
774 </tr>
775 <tr bgcolor="#FFFFFF">
776 <?php
777 $tmp_t = explode('|', $row['history_data_tobacco']);
778 $tmp_a = explode('|', $row['history_data_alcohol']);
779 $tmp_d = explode('|', $row['history_data_recreational_drugs']);
780 $his_tobac = generate_display_field(array('data_type'=>'1','list_id'=>'smoking_status'), $tmp_t[3]) ;
782 <td> <?php echo htmlspecialchars(oeFormatShortDate($row['history_data_date']),ENT_NOQUOTES); ?>&nbsp;</td>
783 <td> <?php
784 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
785 if(!empty($smoke_codes_arr[$tmp_t[3]])){
786 $his_tobac.= " ( ".$smoke_codes_arr[$tmp_t[3]]." )";
788 echo htmlspecialchars($his_tobac,ENT_NOQUOTES); ?>&nbsp;</td>
789 <?php
790 if ($tmp_a[1] == "currentalcohol") $res = xl('Current Alcohol');
791 if ($tmp_a[1] == "quitalcohol") $res = xl('Quit Alcohol');
792 if ($tmp_a[1] == "neveralcohol") $res = xl('Never Alcohol');
793 if ($tmp_a[1] == "not_applicablealcohol") $res = xl('N/A');
795 <td> <?php echo htmlspecialchars($res,ENT_NOQUOTES); ?>&nbsp;</td>
796 <?php
797 if ($tmp_d[1] == "currentrecreational_drugs") $resd = xl('Current Recreational Drugs');
798 if ($tmp_d[1] == "quitrecreational_drugs") $resd = xl('Quit');
799 if ($tmp_d[1] == "neverrecreational_drugs") $resd = xl('Never');
800 if ($tmp_d[1] == "not_applicablerecreational_drugs") $resd = xl('N/A');
802 <td colspan=8> <?php echo htmlspecialchars($resd,ENT_NOQUOTES); ?>&nbsp;</td>
803 </tr>
804 <?php } ?>
805 <!-- Medical History Report End-->
807 <!-- Service Codes Report Start-->
808 <?php
809 if ( $type == 'Service Codes') {
811 <tr bgcolor="#C3FDB8" align= "left">
812 <td colspan=11><b><?php echo "#"; echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES);?><b></td></tr>
813 <tr bgcolor="#C3FDB8" align= "left">
814 <td><b><?php echo htmlspecialchars(xl('Date'),ENT_NOQUOTES); ?></b></td>
815 <td><b><?php echo htmlspecialchars(xl('Code'),ENT_NOQUOTES);?></b></td>
816 <td><b><?php echo htmlspecialchars(xl('Encounter ID'),ENT_NOQUOTES);?></b></td>
817 <td colspan=8><b><?php echo htmlspecialchars(xl('Code Text'),ENT_NOQUOTES);?></b></td></tr>
818 <tr bgcolor="#FFFFFF">
819 <td><?php echo htmlspecialchars(oeFormatShortDate($row['date']),ENT_NOQUOTES); ?>&nbsp;</td>
820 <td><?php echo htmlspecialchars($row['code'],ENT_NOQUOTES); ?>&nbsp;</td>
821 <td><?php echo htmlspecialchars($row['encounter'],ENT_NOQUOTES); ?>&nbsp;</td>
822 <td colspan=8><?php echo htmlspecialchars($row['code_text'],ENT_NOQUOTES); ?>&nbsp;</td>
823 </tr>
824 <?php } ?>
825 <!-- Service Codes Report End-->
827 <!-- Immunization Report Start-->
828 <?php
829 if(strlen($form_immunization) > 0){?>
830 <tr bgcolor="#C3FDB8" align= "left">
831 <td colspan=12><b><?php echo "#"; echo htmlspecialchars(xl('Immunization Report'),ENT_NOQUOTES);?></b></td>
832 </tr>
833 <tr bgcolor="#C3FDB8" align= "left">
834 <td><b><?php echo htmlspecialchars(xl('Immunization Date'),ENT_NOQUOTES);?></b></td>
835 <td><b><?php echo htmlspecialchars(xl('CVX Code'),ENT_NOQUOTES);?></b></td>
836 <td><b><?php echo htmlspecialchars(xl('Vaccine'),ENT_NOQUOTES);?></b></td>
837 <td><b><?php echo htmlspecialchars(xl('Amount'),ENT_NOQUOTES);?></b></td>
838 <td><b><?php echo htmlspecialchars(xl('Administered Site'),ENT_NOQUOTES);?></b></td>
839 <td colspan="7"><b><?php echo htmlspecialchars(xl('Notes'),ENT_NOQUOTES);?></b></td>
840 </tr>
841 <tr bgcolor="#FFFFFF">
842 <td><?php echo htmlspecialchars($row['imm_date'],ENT_NOQUOTES); ?>&nbsp;</td>
843 <td><?php echo htmlspecialchars($row['cvx_code'],ENT_NOQUOTES); ?>&nbsp;</td>
844 <td><?php echo htmlspecialchars($row['imm_code_short'],ENT_NOQUOTES)." (".htmlspecialchars($row['imm_code']).")"; ?>&nbsp;</td>
845 <td>
846 <?php
847 if ($row["amount_administered"] > 0) {
848 echo htmlspecialchars( $row["amount_administered"] . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']) , ENT_NOQUOTES);
849 }else{
850 echo "&nbsp;";
854 </td>
856 <td>
857 <?php echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']); ?>
858 </td>
860 <td colspan="7">
861 <?php echo htmlspecialchars($row['notes']); ?>
862 </td>
863 </tr>
864 <?php } ?>
865 <!-- Immunization Report End-->
866 </table>
867 <?php } //while loop end ?>
868 </table> <!-- Main table ends -->
869 <?php
870 } //End if $result
871 } //End if form_refresh
872 else
874 ?><div class='text'> <?php echo htmlspecialchars(xl('Please input search criteria above, and click Submit to view results.'),ENT_NOQUOTES); ?> </div><?php
877 </form>
878 </body>
880 <!-- stuff for the popup calendar -->
881 <style type="text/css">
882 @import url(../../library/dynarch_calendar.css);
883 </style>
884 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
885 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
886 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
887 <script language="Javascript">
888 Calendar.setup({inputField:"date_from", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_from_date", showsTime:true});
889 Calendar.setup({inputField:"date_to", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_to_date", showsTime:true});
890 </script>
891 </html>