6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2010 OpenEMR Support LLC
9 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("$srcdir/patient.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("../drugs/drugs.inc.php");
17 require_once("../../custom/code_types.inc.php");
19 use OpenEMR\Core\Header
;
21 $comarr = array('allow_sms'=>xl('Allow SMS'),'allow_voice'=>xl('Allow Voice Message'),'allow_mail'=>xl('Allow Mail Message'),'allow_email'=>xl('Allow Email'));
23 $sql_date_from = (!empty($_POST['date_from'])) ?
DateTimeToYYYYMMDDHHMMSS($_POST['date_from']) : date('Y-01-01 H:i:s');
24 $sql_date_to = (!empty($_POST['date_to'])) ?
DateTimeToYYYYMMDDHHMMSS($_POST['date_to']) : date('Y-m-d H:i:s');
26 $type = $_POST["type"];
27 $facility = isset($_POST['facility']) ?
$_POST['facility'] : '';
28 $patient_id = trim($_POST["patient_id"]);
29 $age_from = $_POST["age_from"];
30 $age_to = $_POST["age_to"];
31 $sql_gender = $_POST["gender"];
32 $sql_ethnicity = $_POST["ethnicity"];
33 $sql_race=$_POST["race"];
34 $form_drug_name = trim($_POST["form_drug_name"]);
35 $form_diagnosis = trim($_POST["form_diagnosis"]);
36 $form_lab_results = trim($_POST["form_lab_results"]);
37 $form_service_codes = trim($_POST["form_service_codes"]);
38 $form_immunization = trim($_POST["form_immunization"]);
39 $communication = trim($_POST["communication"]);
46 <?php
echo htmlspecialchars(xl('Clinical Reports'), ENT_NOQUOTES
); ?
>
49 <?php Header
::setupHeader(['datetime-picker', 'report-helper']); ?
>
51 <script language
="JavaScript">
52 $
(document
).ready(function() {
53 var win
= top
.printLogSetup ? top
: opener
.top
;
54 win
.printLogSetup(document
.getElementById('printbutton'));
58 var tr
= document
.getElementById(id
);
59 if (tr
==null) { return; }
60 var bExpand
= tr
.style
.display
== '';
61 tr
.style
.display
= (bExpand ?
'none' : '');
63 function changeimage(id
, sMinus
, sPlus
) {
64 var img
= document
.getElementById(id
);
66 var bExpand
= img
.src
.indexOf(sPlus
) >= 0;
68 img
.src
= "../pic/blue-up-arrow.gif";
70 img
.src
= "../pic/blue-down-arrow.gif";
73 function Toggle_trGrpHeader2(t_id
,i_id
) {
75 changeimage(img
, 'blue-down-arrow.gif', 'blue-up-arrow.gif');
79 // This is for callback by the find-code popup.
80 // Appends to or erases the current list of diagnoses.
81 function set_related(codetype
, code
, selector
, codedesc
) {
82 var f
= document
.forms
[0][current_sel_name
];
85 if (s
.length
> 0) s +
= ';';
86 s +
= codetype +
':' + code
;
93 //This invokes the find-code popup.
94 function sel_diagnosis(e
) {
95 current_sel_name
= e
.name
;
96 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("diagnosis", "csv"); ?>', '_blank', 500, 400);
99 //This invokes the find-code popup.
100 function sel_procedure(e
) {
101 current_sel_name
= e
.name
;
102 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("procedure", "csv"); ?>', '_blank', 500, 400);
106 <style type
="text/css">
107 /* specifically include & exclude from printing */
113 #report_parameters_daterange {
117 #report_results table {
122 /* specifically exclude some from the screen */
124 #report_parameters_daterange {
129 .optional_area_service_codes
{
131 if ($type != 'Service Codes' ||
$type == '') {
139 <script language
="javascript" type
="text/javascript">
140 function checkType() {
141 if($
('#type').val() == 'Service Codes')
143 $
('.optional_area_service_codes').css("display", "inline");
147 $
('.optional_area_service_codes').css("display", "none");
151 function submitForm() {
152 var d_from
= new String($
('#date_from').val());
153 var d_to
= new String($
('#date_to').val());
155 var d_from_arr
= d_from
.split('-');
156 var d_to_arr
= d_to
.split('-');
158 var dt_from
= new Date(d_from_arr
[0], d_from_arr
[1], d_from_arr
[2]);
159 var dt_to
= new Date(d_to_arr
[0], d_to_arr
[1], d_to_arr
[2]);
161 var mili_from
= dt_from
.getTime();
162 var mili_to
= dt_to
.getTime();
163 var diff
= mili_to
- mili_from
;
165 $
('#date_error').css("display", "none");
167 if(diff
< 0) //negative
169 $
('#date_error').css("display", "inline");
173 $
("#form_refresh").attr("value","true");
174 $
("#theform").submit();
178 $
(document
).ready(function() {
179 $
(".numeric_only").keydown(function(event
) {
180 //alert(event.keyCode);
181 // Allow only backspace and delete
182 if ( event
.keyCode
== 46 || event
.keyCode
== 8 ) {
183 // let it happen, don't do anything
186 if(!((event
.keyCode
>= 96 && event
.keyCode
<= 105) ||
(event
.keyCode
>= 48 && event
.keyCode
<= 57)))
188 event
.preventDefault();
193 $
('.datetimepicker').datetimepicker({
194 <?php
$datetimepicker_timepicker = true; ?
>
195 <?php
$datetimepicker_showseconds = true; ?
>
196 <?php
$datetimepicker_formatInput = true; ?
>
197 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
198 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
203 <body
class="body_top">
204 <!-- Required
for the popup date selectors
-->
205 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
207 <?php
echo htmlspecialchars(xl('Report - Clinical'), ENT_NOQUOTES
); ?
>
209 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
210 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
212 <div id
="report_parameters_daterange"> <?php
echo text(oeFormatDateTime($sql_date_from, "global", true)) .
213 " " . xlt("to") . " ". text(oeFormatDateTime($sql_date_to, "global", true)); ?
> </div
>
214 <form name
='theform' id
='theform' method
='post' action
='clinical_reports.php' onsubmit
='return top.restoreSession()'>
215 <div id
="report_parameters">
216 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
219 <td width
='740px'><div style
='float:left'>
222 <td
class='control-label' width
="100"><?php
echo htmlspecialchars(xl('Facility'), ENT_NOQUOTES
); ?
>: </td
>
223 <td width
="250"> <?php
dropdown_facility($facility, 'facility', false); ?
> </td
>
224 <td
class='control-label' width
="100"><?php
echo htmlspecialchars(xl('From'), ENT_NOQUOTES
); ?
>: </td
>
225 <td
><input type
='text' class='datetimepicker form-control' name
='date_from' id
="date_from" size
='18' value
='<?php echo attr(oeFormatDateTime($sql_date_from, 0, true)); ?>'></td
>
228 <td
class='control-label'><?php
echo htmlspecialchars(xl('Patient ID'), ENT_NOQUOTES
); ?
>:</td
>
229 <td
><input name
='patient_id' class="numeric_only form-control" 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
>
230 <td
class='control-label'><?php
echo htmlspecialchars(xl('To'), ENT_NOQUOTES
); ?
>: </td
>
231 <td
><input type
='text' class='datetimepicker form-control' name
='date_to' id
="date_to" size
='18' value
='<?php echo attr(oeFormatDateTime($sql_date_to, 0, true)); ?>'></td
>
234 <td
class='control-label'><?php
echo htmlspecialchars(xl('Age Range'), ENT_NOQUOTES
); ?
>:</td
>
237 <td
class='control-label'><?php
echo htmlspecialchars(xl('From'), ENT_NOQUOTES
); ?
></td
>
239 <input name
='age_from' class="numeric_only form-control" type
='text' id
="age_from" value
="<?php echo htmlspecialchars($age_from, ENT_QUOTES); ?>" size
='3' maxlength
='3' />
241 <td
class='control-label'><?php
echo htmlspecialchars(xl('To'), ENT_NOQUOTES
); ?
></td
>
243 <input name
='age_to' class="numeric_only form-control" type
='text' id
="age_to" value
="<?php echo htmlspecialchars($age_to, ENT_QUOTES); ?>" size
='3' maxlength
='3' />
247 <td
class='control-label'><?php
echo htmlspecialchars(xl('Problem DX'), ENT_NOQUOTES
); ?
>:</td
>
248 <td
><input type
='text' name
='form_diagnosis form-control' class= 'form-control' 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
>
253 <td
class='control-label'><?php
echo htmlspecialchars(xl('Gender'), ENT_NOQUOTES
); ?
>:</td
>
254 <td
><?php
echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?
></td
>
255 <td
class='control-label'><?php
echo htmlspecialchars(xl('Drug'), ENT_NOQUOTES
); ?
>:</td
>
256 <td
><input type
='text' name
='form_drug_name' class='form-control' 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
>
260 <td
class='control-label'><?php
echo htmlspecialchars(xl('Race'), ENT_NOQUOTES
); ?
>:</td
>
261 <td
><?php
echo generate_select_list('race', 'race', $sql_race, 'Select Race', 'Unassigned', '', ''); ?
></td
>
262 <td
class='control-label'><?php
echo htmlspecialchars(xl('Ethnicity'), ENT_NOQUOTES
); ?
>:</td
>
263 <td
><?php
echo generate_select_list('ethnicity', 'ethnicity', $sql_ethnicity, 'Select Ethnicity', 'Unassigned', '', ''); ?
></td
>
264 <td
class='control-label'><?php
echo htmlspecialchars(xl('Immunization'), ENT_NOQUOTES
); ?
>:</td
>
265 <td
><input type
='text' name
='form_immunization' class='form-control' 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
>
268 <td
class='control-label' width
='100'><?php
echo htmlspecialchars(xl('Lab Result'), ENT_NOQUOTES
); ?
>:</td
>
269 <td width
='100'><input type
='text' name
='form_lab_results' class='form-control' 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
>
271 <td
class='control-label' width
='100'><?php
echo htmlspecialchars(xl('Option'), ENT_NOQUOTES
); ?
>:</td
>
272 <td
><select name
="type" class='form-control' id
="type" onChange
="checkType();">
273 <option
> <?php
echo htmlspecialchars(xl('Select'), ENT_NOQUOTES
); ?
></option
>
274 <option value
="Procedure" <?php
275 if ($type == 'Procedure') {
277 } ?
>><?php
echo htmlspecialchars(xl('Procedure'), ENT_NOQUOTES
); ?
></option
>
278 <option value
="Medical History" <?php
279 if ($type == 'Medical History') {
281 } ?
>><?php
echo htmlspecialchars(xl('Medical History'), ENT_NOQUOTES
); ?
></option
>
282 <option value
="Service Codes" <?php
283 if ($type == 'Service Codes') {
285 } ?
>><?php
echo htmlspecialchars(xl('Service Codes'), ENT_NOQUOTES
); ?
></option
>
288 <td
class='control-label'><?php
echo htmlspecialchars(xl('Communication'), ENT_NOQUOTES
); ?
>:</td
>
290 <select name
="communication" class='form-control' id
="communication" title
="<?php echo htmlspecialchars(xl('Select Communication Preferences'), ENT_NOQUOTES); ?>">
291 <option value
=""> <?php
echo htmlspecialchars(xl('Select'), ENT_NOQUOTES
); ?
></option
>
292 <?php
foreach ($comarr as $comkey => $comvalue) { ?
>
293 <option value
="<?php echo attr($comkey); ?>" <?php
294 if ($communication == $comkey) {
296 } ?
>><?php
echo text($comvalue); ?
></option
>
303 <tr
class="optional_area_service_codes">
304 <td width
='100'> 
;</td
>
305 <td width
='100'> 
;</td
>
306 <td width
='195'> 
;</td
>
307 <td
class='control-label' width
='76'><?php
echo htmlspecialchars(xl('Code'), ENT_NOQUOTES
); ?
>:</td
>
308 <td
> <input type
='text' name
='form_service_codes' class='form-control' 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
/> 
;</td
>
313 <!-- Sort by Start
-->
314 <td
class='control-label' width
='63'><?php
echo htmlspecialchars(xl('Sort By'), ENT_NOQUOTES
); ?
>:</td
>
319 <input type
='checkbox' class='form-control' name
='form_pt_name'<?php
320 if ($_POST['form_pt_name'] == true) {
324 <td
class='control-label'>
325 <?php
echo htmlspecialchars(xl('Patient Name'), ENT_NOQUOTES
); ?
> 
;
328 <input type
='checkbox' class='form-control' name
='form_pt_age'<?php
329 if ($_POST['form_pt_age'] == true) {
333 <td
class='control-label'>
334 <?php
echo htmlspecialchars(xl('Age'), ENT_NOQUOTES
); ?
> 
;
337 <input type
='checkbox' class='form-control' name
='form_diagnosis_allergy'<?php
338 if ($_POST['form_diagnosis_allergy'] == true) {
342 <td
class='control-label'>
343 <?php
echo htmlspecialchars(xl('Allergies'), ENT_NOQUOTES
); ?
> 
;
346 <input type
='checkbox' class='form-control' name
='form_diagnosis_medprb'<?php
347 if ($_POST['form_diagnosis_medprb'] == true) {
351 <td
class='control-label'>
352 <?php
echo htmlspecialchars(xl('Medical Problems'), ENT_NOQUOTES
); ?
> 
;
355 <input type
='checkbox' class='form-control' name
='form_drug'<?php
356 if ($_POST['form_drug'] == true) {
360 <td
class='control-label'>
361 <?php
echo htmlspecialchars(xl('Drug'), ENT_NOQUOTES
); ?
> 
;
364 <input type
='checkbox' class='form-control' name
='ndc_no'<?php
365 if ($_POST['ndc_no'] == true) {
369 <td
class='control-label'>
370 <?php
echo htmlspecialchars(xl('NDC Number'), ENT_NOQUOTES
); ?
> 
;
373 <input type
='checkbox' class='form-control' name
='lab_results'<?php
374 if ($_POST['lab_results'] == true) {
378 <td
class='control-label'>
379 <?php
echo htmlspecialchars(xl('Lab Results'), ENT_NOQUOTES
); ?
> 
;
382 <input type
='checkbox' class='form-control' name
='communication_check'<?php
383 if ($_POST['communication_check'] == true) {
387 <td
class='control-label'>
388 <?php
echo xlt('Communication'); ?
>
394 <!-- Sort by ends
-->
397 <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
> 
;</td
>
401 <td height
="100%" valign
='middle' width
="175"><table style
='border-left:1px solid; width:100%; height:100%'>
404 <div
class="text-center">
405 <div
class="btn-group" role
="group">
406 <a href
='#' class='btn btn-default btn-save' onclick
='submitForm();'>
407 <?php
echo xlt('Submit'); ?
>
409 <?php
if ($_POST['form_refresh']) { ?
>
410 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
411 <?php
echo xlt('Print'); ?
>
422 <!-- end of parameters
-->
424 // SQL scripts for the various searches
425 $sqlBindArray = array();
426 if ($_POST['form_refresh']) {
428 concat(pd.fname, ' ', pd.lname) AS patient_name,
429 pd.pid AS patient_id,
430 DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 AS patient_age,
431 pd.sex AS patient_sex,
432 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
433 concat(u.fname, ' ', u.lname) AS users_provider,
434 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";
435 if (strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
436 $sqlstmt=$sqlstmt.",li.date AS lists_date,
437 li.diagnosis AS lists_diagnosis,
438 li.title AS lists_title";
441 if (strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
442 $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,
443 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";
446 if (strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true) {
447 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
448 pr.facility AS procedure_result_facility,
449 pr.units AS procedure_result_units,
450 pr.result AS procedure_result_result,
451 pr.range AS procedure_result_range,
452 pr.abnormal AS procedure_result_abnormal,
453 pr.comments AS procedure_result_comments,
454 pr.document_id AS procedure_result_document_id";
457 if ($type == 'Procedure') {
458 $sqlstmt = $sqlstmt.",po.date_ordered AS procedure_order_date_ordered,
459 pt.standard_code AS procedure_type_standard_code,
460 pc.procedure_name as procedure_name,
461 po.order_priority AS procedure_order_order_priority,
462 po.order_status AS procedure_order_order_status,
463 po.encounter_id AS procedure_order_encounter,
464 po.patient_instructions AS procedure_order_patient_instructions,
465 po.activity AS procedure_order_activity,
466 po.control_id AS procedure_order_control_id ";
469 if ($type == 'Medical History') {
470 $sqlstmt = $sqlstmt.",hd.date AS history_data_date,
471 hd.tobacco AS history_data_tobacco,
472 hd.alcohol AS history_data_alcohol,
473 hd.recreational_drugs AS history_data_recreational_drugs ";
476 if ($type == 'Service Codes') {
477 $sqlstmt .= ", c.code as code,
478 c.code_text as code_text,
479 fe.encounter as encounter,
481 $mh_stmt = $mh_stmt.",code,code_text,encounter,date";
484 if (strlen($form_immunization) > 0) {
485 $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 ";
489 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid
490 left outer join facility as f on f.id = u.facility_id";
492 if (strlen($form_diagnosis) > 0 ||
($_POST['form_diagnosis_allergy'] == true && $_POST['form_diagnosis_medprb'] == true)) {
493 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem' OR li.type='allergy')) ";
494 } elseif ($_POST['form_diagnosis_allergy'] == true) {
495 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
496 } elseif ($_POST['form_diagnosis_medprb'] == true) {
497 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem')) ";
500 if ($type == 'Procedure' ||
( strlen($form_lab_results)!=0) ||
$_POST['lab_results'] == true) {
501 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
502 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
503 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
504 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id ";
507 if (strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
508 $sqlstmt = $sqlstmt." left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id ";
511 //Immunization added in clinical report
512 if (strlen($form_immunization)!=0) {
513 $sqlstmt = $sqlstmt." LEFT OUTER JOIN immunizations as imm ON imm.patient_id = pd.pid
514 LEFT OUTER JOIN codes as immc ON imm.cvx_code = immc.id ";
517 if (strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
518 $sqlstmt=$sqlstmt." left outer join prescriptions AS r on r.patient_id=pd.pid
519 LEFT OUTER JOIN drugs AS d ON d.drug_id = r.drug_id";
522 if ($type == 'Medical History') {
523 $sqlstmt = $sqlstmt." left outer join history_data as hd on hd.pid = pd.pid
524 and (isnull(hd.tobacco) = 0
525 or isnull(hd.alcohol) = 0
526 or isnull(hd.recreational_drugs) = 0)";
529 if ($type == 'Service Codes') {
530 $sqlstmt = $sqlstmt." left outer join billing as b on b.pid = pd.pid
531 left outer join form_encounter as fe on fe.encounter = b.encounter and b.code_type = 'CPT4'
532 left outer join codes as c on c.code = b.code ";
536 $whr_stmt="where 1=1";
537 if (strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
538 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(li.date) <= ?";
539 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
542 if (strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
543 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(pr.date) <= ?";
544 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
547 if (strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
548 $whr_stmt=$whr_stmt." AND r.date_modified >= ? AND r.date_modified < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(r.date_modified) <= ?";
549 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
552 if ($type == 'Medical History') {
553 $whr_stmt=$whr_stmt." AND hd.date >= ? AND hd.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(hd.date) <= ?";
554 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
557 if ($type == 'Procedure') {
558 $whr_stmt=$whr_stmt." AND po.date_ordered >= ? AND po.date_ordered < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(po.date_ordered) <= ?";
559 array_push($sqlBindArray, substr($sql_date_from, 0, 10), substr($sql_date_to, 0, 10), date("Y-m-d"));
562 if ($type == "Service Codes") {
563 $whr_stmt=$whr_stmt." AND b.date >= ? AND b.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(b.date) <= ?";
564 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
567 if (strlen($form_lab_results) != 0 ||
$_POST['lab_results'] == true) {
568 $whr_stmt= $whr_stmt." AND (pr.result LIKE ?) ";
569 if (empty($form_lab_results)) {
570 $form_lab_results ="%";
573 array_push($sqlBindArray, $form_lab_results);
576 if (strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
581 if (empty($form_drug_name)) {
582 $form_drug_name ="%";
585 array_push($sqlBindArray, $form_drug_name, $form_drug_name);
588 if ($type == 'Service Codes') {
589 if (strlen($form_service_codes) != 0) {
590 $whr_stmt = $whr_stmt." AND (b.code = ?) ";
591 $service_code = explode(":", $form_service_codes);
592 array_push($sqlBindArray, $service_code[1]);
596 if (strlen($patient_id) != 0) {
597 $whr_stmt = $whr_stmt." and pd.pid = ?";
598 array_push($sqlBindArray, $patient_id);
601 if (strlen($age_from) != 0) {
602 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
603 array_push($sqlBindArray, $age_from);
606 if (strlen($age_to) != 0) {
607 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
608 array_push($sqlBindArray, $age_to);
611 if (strlen($sql_gender) != 0) {
612 $whr_stmt = $whr_stmt." and pd.sex = ?";
613 array_push($sqlBindArray, $sql_gender);
616 if (strlen($sql_ethnicity) != 0) {
617 $whr_stmt = $whr_stmt." and pd.ethnicity = ?";
618 array_push($sqlBindArray, $sql_ethnicity);
621 if (strlen($sql_race) != 0) {
622 $whr_stmt = $whr_stmt." and pd.race = ?";
623 array_push($sqlBindArray, $sql_race);
626 if ($facility != '') {
627 $whr_stmt = $whr_stmt." and f.id = ? ";
628 array_push($sqlBindArray, $facility);
631 if (strlen($form_diagnosis) > 0) {
632 $whr_stmt = $whr_stmt." AND (li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis = ?) ";
633 array_push($sqlBindArray, $form_diagnosis."%", '%'.$form_diagnosis.'%', '%'.$form_diagnosis, $form_diagnosis);
636 //communication preferences added in clinical report
637 if (strlen($communication) > 0 ||
$_POST['communication_check'] == true) {
638 if ($communication == "allow_sms") {
639 $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
640 } else if ($communication == "allow_voice") {
641 $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
642 } else if ($communication == "allow_mail") {
643 $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
644 } else if ($communication == "allow_email") {
645 $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
646 } else if ($communication == "" && $_POST['communication_check'] == true) {
647 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
651 //Immunization where condition for full text or short text
652 if (strlen($form_immunization) > 0) {
654 immc.code_text LIKE ?
655 OR immc.code_text_short LIKE ?
657 array_push($sqlBindArray, '%'.$form_immunization.'%', '%'.$form_immunization.'%');
661 if ($_POST['form_pt_name'] == true) {
662 $odrstmt=$odrstmt.",patient_name";
665 if ($_POST['form_pt_age'] == true) {
666 $odrstmt=$odrstmt.",patient_age";
669 if ((strlen($form_diagnosis) > 0)) {
670 $odrstmt=$odrstmt.",lists_diagnosis";
671 } elseif (($_POST['form_diagnosis_allergy'] == true) ||
($_POST['form_diagnosis_medprb'] == true)) {
672 $odrstmt=$odrstmt.",lists_title";
675 if (($_POST['form_drug'] == true) ||
(strlen($form_drug_name) > 0)) {
676 $odrstmt=$odrstmt.",r.drug";
679 if (($_POST['ndc_no'] == true) && (strlen($form_drug_name) > 0)) {
680 $odrstmt=$odrstmt.",d.ndc_number";
683 if (($_POST['lab_results'] == true) ||
(strlen($form_lab_results) > 0)) {
684 $odrstmt=$odrstmt.",procedure_result_result";
687 if (strlen($communication) > 0 ||
$_POST['communication_check'] == true) {
688 $odrstmt=$odrstmt.",ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
692 if ($odrstmt == '') {
693 $odrstmt = " ORDER BY patient_id";
695 $odrstmt = " ORDER BY ".ltrim($odrstmt, ",");
698 if ($type == 'Medical History') {
699 $sqlstmt="select * from (".$sqlstmt." ".$whr_stmt." ".$odrstmt.",history_data_date desc) a group by patient_id";
701 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
704 $result = sqlStatement($sqlstmt, $sqlBindArray);
706 $row_id = 1.1;//given to each row to identify and toggle
710 if (sqlNumRows($result) > 0) {
711 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
712 $smoke_codes_arr = getSmokeCodes();
715 <div id
= "report_results">
717 <?php
$pidarr = array();
718 while ($row = sqlFetchArray($result)) { ?
>
719 <table width
=90% align
="center" cellpadding
="5" cellspacing
="0" style
="font-family:tahoma;color:black;" border
="0">
720 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
721 <td
><b
><?php
echo htmlspecialchars(xl('Summary of'), ENT_NOQUOTES
);
722 echo " "; ?
> <?php
echo htmlspecialchars($row['patient_name'], ENT_NOQUOTES
); ?
></b
></td
>
726 <span onclick
="javascript:Toggle_trGrpHeader2(<?php echo attr($row_id); ?>,<?php echo attr($img_id); ?>);"><img src
="../pic/blue-down-arrow.gif" id
="<?php echo attr($img_id);
727 $img_id++; ?>" title
="<?php echo htmlspecialchars(xl('Click here to view patient details'), ENT_QUOTES); ?>" /></span
>
729 <table width
="100%" align
="center" id
= "<?php echo attr($row_id);
730 $row_id++;?>" class="border1" style
="display:none; font-size:13px;" cellpadding
=5>
731 <tr bgcolor
="#C3FDB8" align
="left">
732 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Patient Name'), ENT_NOQUOTES
); ?
></b
></td
>
733 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('PID'), ENT_NOQUOTES
);?
></b
></td
>
734 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('Age'), ENT_NOQUOTES
);?
></b
></td
>
735 <td width
="10%"><b
><?php
echo htmlspecialchars(xl('Gender'), ENT_NOQUOTES
); ?
></b
></td
>
736 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Race'), ENT_NOQUOTES
);?
></b
></td
>
737 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Ethnicity'), ENT_NOQUOTES
);?
></b
></td
>
738 <td width
="15%" <?php
739 if (strlen($communication) == 0 ||
$_POST['communication_check'] == true) {
741 } ?
>><b
><?php
echo htmlspecialchars(xl('Provider'), ENT_NOQUOTES
);?
></b
></td
>
742 <?php
if (strlen($communication) > 0 ||
($_POST['communication_check'] == true)) { ?
>
743 <td colspan
=4><b
><?php
echo xlt('Communication');?
></b
></td
>
746 <tr bgcolor
="#FFFFFF">
747 <td
><?php
echo htmlspecialchars($row['patient_name'], ENT_NOQUOTES
); ?
> 
;</td
>
748 <td
> <?php
echo htmlspecialchars($row['patient_id'], ENT_NOQUOTES
); ?
> 
;</td
>
749 <td
> <?php
echo htmlspecialchars($row['patient_age'], ENT_NOQUOTES
); ?
> 
;</td
>
750 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'sex'), $row['patient_sex']); ?
> 
;</td
>
751 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'race'), $row['patient_race']); ?
> 
;</td
>
752 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'ethnicity'), $row['patient_ethinic']); ?
> 
;</td
>
754 if (strlen($communication) == 0 ||
($_POST['communication_check'] == true)) {
756 } ?
>> <?php
echo htmlspecialchars($row['users_provider'], ENT_NOQUOTES
); ?
> 
;</td
>
758 <?php
if (strlen($communication) > 0 ||
$_POST['communication_check'] == true) { ?
>
759 <td colspan
=4><?php
echo text($row['communications']); ?
></td
>
762 <!-- Diagnosis Report Start
-->
764 if (strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
766 <tr bgcolor
="#C3FDB8" align
= "left">
767 <td colspan
=12><b
><?php
echo "#";
768 echo htmlspecialchars(xl('Diagnosis Report'), ENT_NOQUOTES
);?
></b
></td
>
770 <tr bgcolor
="#C3FDB8" align
= "left">
771 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis Date'), ENT_NOQUOTES
);?
></b
></td
>
772 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis'), ENT_NOQUOTES
);?
></b
></td
>
773 <td colspan
=10><b
><?php
echo htmlspecialchars(xl('Diagnosis Name'), ENT_NOQUOTES
);?
></b
></td
>
775 <tr bgcolor
="#FFFFFF">
776 <td
><?php
echo text(oeFormatDateTime($row['lists_date'], "global", true)); ?
> 
;</td
>
777 <td
><?php
echo htmlspecialchars($row['lists_diagnosis'], ENT_NOQUOTES
); ?
> 
;</td
>
778 <td colspan
=10><?php
echo htmlspecialchars($row['lists_title'], ENT_NOQUOTES
); ?
> 
;</td
>
782 <!-- Diagnosis Report End
-->
784 <!-- Prescription Report Start
-->
786 if (strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
788 <tr bgcolor
="#C3FDB8" align
= "left">
789 <td colspan
=12><b
><?php
echo "#";
790 echo htmlspecialchars(xl('Prescription Report'), ENT_NOQUOTES
);?
><b
></td
></tr
>
791 <tr bgcolor
="#C3FDB8" align
= "left">
792 <td
><b
><?php
echo htmlspecialchars(xl('Date'), ENT_NOQUOTES
); ?
></b
></td
>
793 <td
><b
><?php
echo htmlspecialchars(xl('Drug Name'), ENT_NOQUOTES
);?
></b
></td
>
794 <td
><b
><?php
echo htmlspecialchars(xl('Route'), ENT_NOQUOTES
);?
></b
></td
>
795 <td
><b
><?php
echo htmlspecialchars(xl('Dosage'), ENT_NOQUOTES
);?
></b
></td
>
796 <td
><b
><?php
echo htmlspecialchars(xl('Form'), ENT_NOQUOTES
);?
></b
></td
>
797 <td
><b
><?php
echo htmlspecialchars(xl('Interval'), ENT_NOQUOTES
);?
></b
></td
>
798 <td
><b
><?php
echo htmlspecialchars(xl('Size'), ENT_NOQUOTES
);?
></b
></td
>
799 <td
><b
><?php
echo htmlspecialchars(xl('Unit'), ENT_NOQUOTES
);?
></b
></td
>
800 <td
><b
><?php
echo htmlspecialchars(xl('ReFill'), ENT_NOQUOTES
);?
></b
></td
>
801 <td
><b
><?php
echo htmlspecialchars(xl('Quantity'), ENT_NOQUOTES
);?
></b
></td
>
802 <td colspan
="2"><b
><?php
echo htmlspecialchars(xl('NDC'), ENT_NOQUOTES
);?
></b
></td
>
804 <tr bgcolor
="#FFFFFF" align
="">
806 $rx_route = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) ;
807 $rx_form = generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['hform']) ;
808 $rx_interval = generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'), $row['hinterval']) ;
809 $rx_units = generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['hunit']);
811 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['prescriptions_date_modified']), ENT_NOQUOTES
); ?
> 
;</td
>
812 <td
><?php
echo htmlspecialchars($row['drug'], ENT_NOQUOTES
); ?
></td
>
813 <td
><?php
echo $rx_route; ?
></td
>
814 <td
><?php
echo htmlspecialchars($row['dosage'], ENT_NOQUOTES
); ?
></td
>
815 <td
><?php
echo $rx_form; ?
></td
>
816 <td
><?php
echo $rx_interval; ?
></td
>
817 <td
><?php
echo htmlspecialchars($row['size'], ENT_NOQUOTES
); ?
></td
>
818 <td
><?php
echo $rx_units; ?
></td
>
819 <td
><?php
echo htmlspecialchars($row['refills'], ENT_NOQUOTES
); ?
></td
>
820 <td
><?php
echo htmlspecialchars($row['quantity'], ENT_NOQUOTES
); ?
></td
>
821 <td colspan
="2"><?php
echo htmlspecialchars($row['ndc_number'], ENT_NOQUOTES
); ?
></td
>
825 <!-- Prescription Report End
-->
827 <!-- Lab Results Report Start
-->
829 if (strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true) {
831 <tr bgcolor
="#C3FDB8" align
= "left">
832 <td colspan
=12><b
><?php
echo "#";
833 echo htmlspecialchars(xl('Lab Results Report'), ENT_NOQUOTES
);?
><b
></td
></tr
>
834 <tr bgcolor
="#C3FDB8" align
= "left">
835 <td
><b
><?php
echo htmlspecialchars(xl('Date'), ENT_NOQUOTES
); ?
></b
></td
>
836 <td
><b
><?php
echo htmlspecialchars(xl('Facility'), ENT_NOQUOTES
);?
></b
></td
>
837 <td
><b
><?php
echo htmlspecialchars(xl('Unit'), ENT_NOQUOTES
);?
></b
></td
>
838 <td
><b
><?php
echo htmlspecialchars(xl('Result'), ENT_NOQUOTES
);?
></b
></td
>
839 <td
><b
><?php
echo htmlspecialchars(xl('Range'), ENT_NOQUOTES
);?
></b
></td
>
840 <td
><b
><?php
echo htmlspecialchars(xl('Abnormal'), ENT_NOQUOTES
);?
></b
></td
>
841 <td
><b
><?php
echo htmlspecialchars(xl('Comments'), ENT_NOQUOTES
);?
></b
></td
>
842 <td colspan
=5><b
><?php
echo htmlspecialchars(xl('Document ID'), ENT_NOQUOTES
);?
></b
></td
>
844 <tr bgcolor
="#FFFFFF">
845 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_result_date']), ENT_NOQUOTES
); ?
> 
;</td
>
846 <td
> <?php
echo htmlspecialchars($row['procedure_result_facility'], ENT_NOQUOTES
); ?
> 
;</td
>
847 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'), $row['procedure_result_units']); ?
> 
;</td
>
848 <td
> <?php
echo htmlspecialchars($row['procedure_result_result'], ENT_NOQUOTES
); ?
> 
;</td
>
849 <td
> <?php
echo htmlspecialchars($row['procedure_result_range'], ENT_NOQUOTES
); ?
> 
;</td
>
850 <td
> <?php
echo htmlspecialchars($row['procedure_result_abnormal'], ENT_NOQUOTES
); ?
> 
;</td
>
851 <td
> <?php
echo htmlspecialchars($row['procedure_result_comments'], ENT_NOQUOTES
); ?
> 
;</td
>
852 <td colspan
=5> <?php
echo htmlspecialchars($row['procedure_result_document_id'], ENT_NOQUOTES
); ?
> 
;</td
>
856 <!-- Lab Results End
-->
858 <!-- Procedures Report Start
-->
860 if ($type == 'Procedure') {
862 <tr bgcolor
="#C3FDB8" align
= "left">
863 <td colspan
=12><b
><?php
echo "#";
864 echo htmlspecialchars(xl('Procedure Report'), ENT_NOQUOTES
);?
><b
></td
></tr
>
865 <tr bgcolor
="#C3FDB8" align
= "left">
866 <td
><b
><?php
echo htmlspecialchars(xl('Date'), ENT_NOQUOTES
); ?
></b
></td
>
867 <td
><b
><?php
echo htmlspecialchars(xl('Standard Name'), ENT_NOQUOTES
);?
></b
></td
>
868 <td
><b
><?php
echo htmlspecialchars(xl('Procedure'), ENT_NOQUOTES
); ?
></b
></td
>
869 <td
><b
><?php
echo htmlspecialchars(xl('Encounter'), ENT_NOQUOTES
);?
></b
></td
>
870 <td
><b
><?php
echo htmlspecialchars(xl('Priority'), ENT_NOQUOTES
);?
></b
></td
>
871 <td
><b
><?php
echo htmlspecialchars(xl('Status'), ENT_NOQUOTES
);?
></b
></td
>
872 <td
><b
><?php
echo htmlspecialchars(xl('Instruction'), ENT_NOQUOTES
);?
></b
></td
>
873 <td
><b
><?php
echo htmlspecialchars(xl('Activity'), ENT_NOQUOTES
);?
></b
></td
>
874 <td colspan
=3><b
><?php
echo htmlspecialchars(xl('Control ID'), ENT_NOQUOTES
);?
></b
></td
>
876 <tr bgcolor
="#FFFFFF">
878 $procedure_type_standard_code_arr = explode(':', $row['procedure_type_standard_code']);
879 $procedure_type_standard_code = $procedure_type_standard_code_arr[1];
882 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_order_date_ordered']), ENT_NOQUOTES
); ?
> 
;</td
>
883 <td
> <?php
echo htmlspecialchars($procedure_type_standard_code, ENT_NOQUOTES
); ?
> 
;</td
>
884 <td
> <?php
echo htmlspecialchars($row['procedure_name'], ENT_NOQUOTES
); ?
> 
;</td
>
885 <td
> <?php
echo htmlspecialchars($row['procedure_order_encounter'], ENT_NOQUOTES
); ?
> 
;</td
>
886 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'ord_priority'), $row['procedure_order_order_priority']); ?
> 
;</td
>
887 <td
> <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'ord_status'), $row['procedure_order_order_status']); ?
> 
;</td
>
888 <td
> <?php
echo htmlspecialchars($row['procedure_order_patient_instructions'], ENT_NOQUOTES
); ?
> 
;</td
>
889 <td
> <?php
echo htmlspecialchars($row['procedure_order_activity'], ENT_NOQUOTES
); ?
> 
;</td
>
890 <td colspan
=3> <?php
echo htmlspecialchars($row['procedure_order_control_id'], ENT_NOQUOTES
); ?
> 
;</td
>
895 <!-- Procedure Report End
-->
897 <!-- Medical History Report Start
-->
899 if ($type == 'Medical History') {
901 <tr bgcolor
="#C3FDB8" align
= "left">
902 <td colspan
=12><b
><?php
echo "#";
903 echo htmlspecialchars(xl('Medical History'), ENT_NOQUOTES
);?
><b
></td
></tr
>
904 <tr bgcolor
="#C3FDB8" align
= "left">
905 <td
><b
><?php
echo htmlspecialchars(xl('History Date'), ENT_NOQUOTES
); ?
></b
></td
>
906 <td
><b
><?php
echo htmlspecialchars(xl('Tobacco'), ENT_NOQUOTES
);?
></b
></td
>
907 <td
><b
><?php
echo htmlspecialchars(xl('Alcohol'), ENT_NOQUOTES
);?
></b
></td
>
908 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Recreational Drugs'), ENT_NOQUOTES
);?
></b
></td
>
910 <tr bgcolor
="#FFFFFF">
912 $tmp_t = explode('|', $row['history_data_tobacco']);
913 $tmp_a = explode('|', $row['history_data_alcohol']);
914 $tmp_d = explode('|', $row['history_data_recreational_drugs']);
915 $his_tobac = generate_display_field(array('data_type'=>'1','list_id'=>'smoking_status'), $tmp_t[3]) ;
917 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['history_data_date']), ENT_NOQUOTES
); ?
> 
;</td
>
919 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
920 if (!empty($smoke_codes_arr[$tmp_t[3]])) {
921 $his_tobac.= " ( ".text($smoke_codes_arr[$tmp_t[3]])." )";
924 echo $his_tobac; ?
> 
;</td
>
926 if ($tmp_a[1] == "currentalcohol") {
927 $res = xl('Current Alcohol');
930 if ($tmp_a[1] == "quitalcohol") {
931 $res = xl('Quit Alcohol');
934 if ($tmp_a[1] == "neveralcohol") {
935 $res = xl('Never Alcohol');
938 if ($tmp_a[1] == "not_applicablealcohol") {
942 <td
> <?php
echo htmlspecialchars($res, ENT_NOQUOTES
); ?
> 
;</td
>
944 if ($tmp_d[1] == "currentrecreational_drugs") {
945 $resd = xl('Current Recreational Drugs');
948 if ($tmp_d[1] == "quitrecreational_drugs") {
952 if ($tmp_d[1] == "neverrecreational_drugs") {
956 if ($tmp_d[1] == "not_applicablerecreational_drugs") {
960 <td colspan
=8> <?php
echo htmlspecialchars($resd, ENT_NOQUOTES
); ?
> 
;</td
>
964 <!-- Medical History Report End
-->
966 <!-- Service Codes Report Start
-->
968 if ($type == 'Service Codes') {
970 <tr bgcolor
="#C3FDB8" align
= "left">
971 <td colspan
=11><b
><?php
echo "#";
972 echo htmlspecialchars(xl('Service Codes'), ENT_NOQUOTES
);?
><b
></td
></tr
>
973 <tr bgcolor
="#C3FDB8" align
= "left">
974 <td
><b
><?php
echo htmlspecialchars(xl('Date'), ENT_NOQUOTES
); ?
></b
></td
>
975 <td
><b
><?php
echo htmlspecialchars(xl('Code'), ENT_NOQUOTES
);?
></b
></td
>
976 <td
><b
><?php
echo htmlspecialchars(xl('Encounter ID'), ENT_NOQUOTES
);?
></b
></td
>
977 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Code Text'), ENT_NOQUOTES
);?
></b
></td
></tr
>
978 <tr bgcolor
="#FFFFFF">
979 <td
><?php
echo htmlspecialchars(oeFormatShortDate($row['date']), ENT_NOQUOTES
); ?
> 
;</td
>
980 <td
><?php
echo htmlspecialchars($row['code'], ENT_NOQUOTES
); ?
> 
;</td
>
981 <td
><?php
echo htmlspecialchars($row['encounter'], ENT_NOQUOTES
); ?
> 
;</td
>
982 <td colspan
=8><?php
echo htmlspecialchars($row['code_text'], ENT_NOQUOTES
); ?
> 
;</td
>
986 <!-- Service Codes Report End
-->
988 <!-- Immunization Report Start
-->
990 if (strlen($form_immunization) > 0) {?
>
991 <tr bgcolor
="#C3FDB8" align
= "left">
992 <td colspan
=12><b
><?php
echo "#";
993 echo htmlspecialchars(xl('Immunization Report'), ENT_NOQUOTES
);?
></b
></td
>
995 <tr bgcolor
="#C3FDB8" align
= "left">
996 <td
><b
><?php
echo htmlspecialchars(xl('Immunization Date'), ENT_NOQUOTES
);?
></b
></td
>
997 <td
><b
><?php
echo htmlspecialchars(xl('CVX Code'), ENT_NOQUOTES
);?
></b
></td
>
998 <td
><b
><?php
echo htmlspecialchars(xl('Vaccine'), ENT_NOQUOTES
);?
></b
></td
>
999 <td
><b
><?php
echo htmlspecialchars(xl('Amount'), ENT_NOQUOTES
);?
></b
></td
>
1000 <td
><b
><?php
echo htmlspecialchars(xl('Administered Site'), ENT_NOQUOTES
);?
></b
></td
>
1001 <td colspan
="7"><b
><?php
echo htmlspecialchars(xl('Notes'), ENT_NOQUOTES
);?
></b
></td
>
1003 <tr bgcolor
="#FFFFFF">
1004 <td
><?php
echo text(oeFormatDateTime($row['imm_date'])); ?
> 
;</td
>
1005 <td
><?php
echo htmlspecialchars($row['cvx_code'], ENT_NOQUOTES
); ?
> 
;</td
>
1006 <td
><?php
echo htmlspecialchars($row['imm_code_short'], ENT_NOQUOTES
)." (".htmlspecialchars($row['imm_code']).")"; ?
> 
;</td
>
1009 if ($row["amount_administered"] > 0) {
1010 echo text($row["amount_administered"]) . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']);
1019 <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']); ?
>
1023 <?php
echo htmlspecialchars($row['notes']); ?
>
1028 <!-- Immunization Report End
-->
1031 } //while loop end ?>
1032 </table
> <!-- Main table ends
-->
1035 } //End if form_refresh
1037 ?
><div
class='text'> <?php
echo htmlspecialchars(xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES
); ?
> </div
><?php