3 * This report lists prescriptions and their dispensations according
4 * to various input selection criteria.
6 * Prescription report written by Rod Roark, 2010
7 * Fixed drug name search to work in a broader sense - tony@mi-squared.com, 2010
8 * Added five new reports as per EHR certification requirements for Patient Lists - OpenEMR Support LLC, 2010
10 * Copyright (C) 2010 OpenEMR Support LLC
11 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
13 * LICENSE: This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 3
16 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
25 * @author Brady Miller <brady.g.miller@gmail.com>
26 * @link http://www.open-emr.org
29 //SANITIZE ALL ESCAPES
30 $sanitize_all_escapes=true;
33 //STOP FAKE REGISTER GLOBALS
34 $fake_register_globals=false;
36 require_once("../globals.php");
37 require_once("$srcdir/patient.inc");
38 require_once("$srcdir/options.inc.php");
39 require_once("../drugs/drugs.inc.php");
40 require_once("../../custom/code_types.inc.php");
41 $comarr = array('allow_sms'=>xl('Allow SMS'),'allow_voice'=>xl('Allow Voice Message'),'allow_mail'=>xl('Allow Mail Message'),'allow_email'=>xl('Allow Email'));
42 function add_date($givendate,$day=0,$mth=0,$yr=0) {
43 $cd = strtotime($givendate);
44 $newdate = date('Y-m-d H:i:s', mktime(date('h',$cd),
45 date('i',$cd), date('s',$cd), date('m',$cd)+
$mth,
46 date('d',$cd)+
$day, date('Y',$cd)+
$yr));
49 $type = $_POST["type"];
50 $facility = isset($_POST['facility']) ?
$_POST['facility'] : '';
51 if($_POST['date_from'] != "")
52 $sql_date_from = $_POST['date_from'];
54 $sql_date_from = fixDate($_POST['date_from'], date('Y-01-01 H:i:s'));
56 if($_POST['date_to'] != "")
57 $sql_date_to = $_POST['date_to'];
59 $sql_date_to = fixDate($_POST['date_to'] , add_date(date('Y-m-d H:i:s')));
62 $patient_id = trim($_POST["patient_id"]);
63 $age_from = $_POST["age_from"];
64 $age_to = $_POST["age_to"];
65 $sql_gender = $_POST["gender"];
66 $sql_ethnicity = $_POST["ethnicity"];
67 $sql_race=$_POST["race"];
68 $form_drug_name = trim($_POST["form_drug_name"]);
69 $form_diagnosis = trim($_POST["form_diagnosis"]);
70 $form_lab_results = trim($_POST["form_lab_results"]);
71 $form_service_codes = trim($_POST["form_service_codes"]);
72 $form_immunization = trim($_POST["form_immunization"]);
73 $communication = trim($_POST["communication"]);
78 <?php
html_header_show();?
>
80 <?php
echo htmlspecialchars(xl('Clinical Reports'),ENT_NOQUOTES
); ?
>
82 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
83 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
84 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
85 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
86 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
87 <script language
="JavaScript">
89 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
91 $
(document
).ready(function() {
92 var win
= top
.printLogSetup ? top
: opener
.top
;
93 win
.printLogSetup(document
.getElementById('printbutton'));
97 var tr
= document
.getElementById(id
);
98 if (tr
==null) { return; }
99 var bExpand
= tr
.style
.display
== '';
100 tr
.style
.display
= (bExpand ?
'none' : '');
102 function changeimage(id
, sMinus
, sPlus
) {
103 var img
= document
.getElementById(id
);
105 var bExpand
= img
.src
.indexOf(sPlus
) >= 0;
107 img
.src
= "../pic/blue-up-arrow.gif";
109 img
.src
= "../pic/blue-down-arrow.gif";
112 function Toggle_trGrpHeader2(t_id
,i_id
) {
114 changeimage(img
, 'blue-down-arrow.gif', 'blue-up-arrow.gif');
118 // This is for callback by the find-code popup.
119 // Appends to or erases the current list of diagnoses.
120 function set_related(codetype
, code
, selector
, codedesc
) {
121 var f
= document
.forms
[0][current_sel_name
];
124 if (s
.length
> 0) s +
= ';';
125 s +
= codetype +
':' + code
;
132 //This invokes the find-code popup.
133 function sel_diagnosis(e
) {
134 current_sel_name
= e
.name
;
135 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("diagnosis","csv"); ?>', '_blank', 500, 400);
138 //This invokes the find-code popup.
139 function sel_procedure(e
) {
140 current_sel_name
= e
.name
;
141 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("procedure","csv"); ?>', '_blank', 500, 400);
145 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
146 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
147 <style type
="text/css">
148 /* specifically include & exclude from printing */
154 #report_parameters_daterange {
158 #report_results table {
163 /* specifically exclude some from the screen */
165 #report_parameters_daterange {
170 .optional_area_service_codes
{
172 if($type != 'Service Codes' ||
$type == '')
181 <script language
="javascript" type
="text/javascript">
182 function checkType() {
183 if($
('#type').val() == 'Service Codes')
185 $
('.optional_area_service_codes').css("display", "inline");
189 $
('.optional_area_service_codes').css("display", "none");
193 function submitForm() {
194 var d_from
= new String($
('#date_from').val());
195 var d_to
= new String($
('#date_to').val());
197 var d_from_arr
= d_from
.split('-');
198 var d_to_arr
= d_to
.split('-');
200 var dt_from
= new Date(d_from_arr
[0], d_from_arr
[1], d_from_arr
[2]);
201 var dt_to
= new Date(d_to_arr
[0], d_to_arr
[1], d_to_arr
[2]);
203 var mili_from
= dt_from
.getTime();
204 var mili_to
= dt_to
.getTime();
205 var diff
= mili_to
- mili_from
;
207 $
('#date_error').css("display", "none");
209 if(diff
< 0) //negative
211 $
('#date_error').css("display", "inline");
215 $
("#form_refresh").attr("value","true");
216 $
("#theform").submit();
220 $
(document
).ready(function() {
221 $
(".numeric_only").keydown(function(event
) {
222 //alert(event.keyCode);
223 // Allow only backspace and delete
224 if ( event
.keyCode
== 46 || event
.keyCode
== 8 ) {
225 // let it happen, don't do anything
228 if(!((event
.keyCode
>= 96 && event
.keyCode
<= 105) ||
(event
.keyCode
>= 48 && event
.keyCode
<= 57)))
230 event
.preventDefault();
235 $
('.datetimepicker').datetimepicker({
236 <?php
$datetimepicker_timepicker = true; ?
>
237 <?php
$datetimepicker_formatInput = false; ?
>
238 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
239 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
244 <body
class="body_top">
245 <!-- Required
for the popup date selectors
-->
246 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
248 <?php
echo htmlspecialchars(xl('Report - Clinical'),ENT_NOQUOTES
); ?
>
250 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
251 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
253 <div id
="report_parameters_daterange"> <?php
echo htmlspecialchars(date("d F Y", strtotime($sql_date_from)),ENT_NOQUOTES
) .
254 " to ". htmlspecialchars(date("d F Y", strtotime($sql_date_to)),ENT_NOQUOTES
); ?
> </div
>
255 <form name
='theform' id
='theform' method
='post' action
='clinical_reports.php'>
256 <div id
="report_parameters">
257 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
260 <td width
='740px'><div style
='float:left'>
263 <td
class='label' width
="100"><?php
echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES
); ?
>: </td
>
264 <td width
="250"> <?php
dropdown_facility($facility,'facility',false); ?
> </td
>
265 <td
class='label' width
="100"><?php
echo htmlspecialchars(xl('From'),ENT_NOQUOTES
); ?
>: </td
>
266 <td
><input type
='text' class='datetimepicker' name
='date_from' id
="date_from" size
='18' value
='<?php echo htmlspecialchars($sql_date_from,ENT_QUOTES); ?>' title
='yyyy-mm-dd H:m:s'></td
>
269 <td
class='label'><?php
echo htmlspecialchars(xl('Patient ID'),ENT_NOQUOTES
); ?
>:</td
>
270 <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
>
271 <td
class='label'><?php
echo htmlspecialchars(xl('To'),ENT_NOQUOTES
); ?
>: </td
>
272 <td
><input type
='text' class='datetimepicker' name
='date_to' id
="date_to" size
='18' value
='<?php echo htmlspecialchars($sql_date_to,ENT_QUOTES); ?>' title
='yyyy-mm-dd H:m:s'></td
>
275 <td
class='label'><?php
echo htmlspecialchars(xl('Age Range'),ENT_NOQUOTES
); ?
>:</td
>
276 <td
><?php
echo htmlspecialchars(xl('From'),ENT_NOQUOTES
); ?
>
277 <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
); ?
>
278 <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
>
279 <td
class='label'><?php
echo htmlspecialchars(xl('Problem DX'),ENT_NOQUOTES
); ?
>:</td
>
280 <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
>
285 <td
class='label'><?php
echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES
); ?
>:</td
>
286 <td
><?php
echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?
></td
>
287 <td
class='label'><?php
echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES
); ?
>:</td
>
288 <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
>
292 <td
class='label'><?php
echo htmlspecialchars(xl('Race'),ENT_NOQUOTES
); ?
>:</td
>
293 <td
><?php
echo generate_select_list('race', 'race', $sql_race, 'Select Race', 'Unassigned', '', ''); ?
></td
>
294 <td
class='label'><?php
echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES
); ?
>:</td
>
295 <td
><?php
echo generate_select_list('ethnicity', 'ethnicity', $sql_ethnicity, 'Select Ethnicity', 'Unassigned', '', ''); ?
></td
>
296 <td
class='label'><?php
echo htmlspecialchars(xl('Immunization'),ENT_NOQUOTES
); ?
>:</td
>
297 <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
>
300 <td
class='label' width
='100'><?php
echo htmlspecialchars(xl('Lab Result'),ENT_NOQUOTES
); ?
>:</td
>
301 <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
>
303 <td
class='label' width
='100'><?php
echo htmlspecialchars(xl('Option'),ENT_NOQUOTES
); ?
>:</td
>
304 <td
><select name
="type" id
="type" onChange
="checkType();">
305 <option
> <?php
echo htmlspecialchars(xl('Select'),ENT_NOQUOTES
); ?
></option
>
306 <option value
="Procedure" <?php
if($type == 'Procedure') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES
); ?
></option
>
307 <option value
="Medical History" <?php
if($type == 'Medical History') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES
); ?
></option
>
308 <option value
="Service Codes" <?php
if($type == 'Service Codes') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES
); ?
></option
>
311 <td
class='label'><?php
echo htmlspecialchars(xl('Communication'),ENT_NOQUOTES
); ?
>:</td
>
313 <select name
="communication" id
="communication" title
="<?php echo htmlspecialchars(xl('Select Communication Preferences'),ENT_NOQUOTES); ?>">
314 <option value
=""> <?php
echo htmlspecialchars(xl('Select'),ENT_NOQUOTES
); ?
></option
>
315 <?php
foreach($comarr as $comkey => $comvalue){ ?
>
316 <option value
="<?php echo attr($comkey); ?>" <?php
if($communication == $comkey){ echo "selected";}?
>><?php
echo text($comvalue); ?
></option
>
323 <tr
class="optional_area_service_codes">
324 <td width
='100'> 
;</td
>
325 <td width
='100'> 
;</td
>
326 <td width
='195'> 
;</td
>
327 <td
class='label' width
='76'><?php
echo htmlspecialchars(xl('Code'),ENT_NOQUOTES
); ?
>:</td
>
328 <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
/> 
;</td
>
333 <!-- Sort by Start
-->
334 <td
class='label' width
='63'><?php
echo htmlspecialchars(xl('Sort By'),ENT_NOQUOTES
); ?
>:</td
>
336 <input type
='checkbox' name
='form_pt_name'<?php
if ($_POST['form_pt_name'] == true) echo ' checked'; ?
>>
337 <?php
echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES
); ?
> 
;
339 <input type
='checkbox' name
='form_pt_age'<?php
if ($_POST['form_pt_age'] == true) echo ' checked'; ?
>>
340 <?php
echo htmlspecialchars(xl('Age'),ENT_NOQUOTES
); ?
> 
;
342 <input type
='checkbox' name
='form_diagnosis_allergy'<?php
if ($_POST['form_diagnosis_allergy'] == true) echo ' checked'; ?
>>
343 <?php
echo htmlspecialchars(xl('Allergies'),ENT_NOQUOTES
); ?
> 
;
345 <input type
='checkbox' name
='form_diagnosis_medprb'<?php
if ($_POST['form_diagnosis_medprb'] == true) echo ' checked'; ?
>>
346 <?php
echo htmlspecialchars(xl('Medical Problems'),ENT_NOQUOTES
); ?
> 
;
348 <input type
='checkbox' name
='form_drug'<?php
if ($_POST['form_drug'] == true) echo ' checked'; ?
>>
349 <?php
echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES
); ?
> 
;
351 <input type
='checkbox' name
='ndc_no'<?php
if ($_POST['ndc_no'] == true) echo ' checked'; ?
>>
352 <?php
echo htmlspecialchars(xl('NDC Number'),ENT_NOQUOTES
); ?
> 
;
353 <input type
='checkbox' name
='lab_results'<?php
if ($_POST['lab_results'] == true) echo ' checked'; ?
>>
354 <?php
echo htmlspecialchars(xl('Lab Results'),ENT_NOQUOTES
); ?
> 
;
355 <input type
='checkbox' name
='communication_check'<?php
if ($_POST['communication_check'] == true) echo ' checked'; ?
>>
356 <?php
echo xlt('Communication'); ?
>
359 <!-- Sort by ends
-->
362 <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
>
366 <td height
="100%" valign
='middle' width
="175"><table style
='border-left:1px solid; width:100%; height:100%'>
368 <td
><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
='submitForm();'> <span
>
369 <?php
echo htmlspecialchars(xl('Submit'),ENT_NOQUOTES
); ?
>
371 <?php
if ($_POST['form_refresh']) { ?
>
372 <a href
='#' class='css_button' id
='printbutton'> <span
>
373 <?php
echo xlt('Print'); ?
>
382 <!-- end of parameters
-->
384 // SQL scripts for the various searches
385 $sqlBindArray = array();
386 if ($_POST['form_refresh'])
389 concat(pd.fname, ' ', pd.lname) AS patient_name,
390 pd.pid AS patient_id,
391 DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 AS patient_age,
392 pd.sex AS patient_sex,
393 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
394 concat(u.fname, ' ', u.lname) AS users_provider,
395 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";
396 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
397 $sqlstmt=$sqlstmt.",li.date AS lists_date,
398 li.diagnosis AS lists_diagnosis,
399 li.title AS lists_title";
401 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
403 $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,
404 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";
407 if(strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true) {
408 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
409 pr.facility AS procedure_result_facility,
410 pr.units AS procedure_result_units,
411 pr.result AS procedure_result_result,
412 pr.range AS procedure_result_range,
413 pr.abnormal AS procedure_result_abnormal,
414 pr.comments AS procedure_result_comments,
415 pr.document_id AS procedure_result_document_id";
418 if ( $type == 'Procedure') {
419 $sqlstmt = $sqlstmt.",po.date_ordered AS procedure_order_date_ordered,
420 pt.standard_code AS procedure_type_standard_code,
421 pc.procedure_name as procedure_name,
422 po.order_priority AS procedure_order_order_priority,
423 po.order_status AS procedure_order_order_status,
424 po.encounter_id AS procedure_order_encounter,
425 po.patient_instructions AS procedure_order_patient_instructions,
426 po.activity AS procedure_order_activity,
427 po.control_id AS procedure_order_control_id ";
430 if ( $type == 'Medical History') {
431 $sqlstmt = $sqlstmt.",hd.date AS history_data_date,
432 hd.tobacco AS history_data_tobacco,
433 hd.alcohol AS history_data_alcohol,
434 hd.recreational_drugs AS history_data_recreational_drugs ";
436 if($type == 'Service Codes') {
437 $sqlstmt .= ", c.code as code,
438 c.code_text as code_text,
439 fe.encounter as encounter,
441 $mh_stmt = $mh_stmt.",code,code_text,encounter,date";
443 if (strlen($form_immunization) > 0) {
444 $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 ";
447 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid
448 left outer join facility as f on f.id = u.facility_id";
450 if(strlen($form_diagnosis) > 0 ||
($_POST['form_diagnosis_allergy'] == true && $_POST['form_diagnosis_medprb'] == true)){
451 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem' OR li.type='allergy')) ";
452 }elseif($_POST['form_diagnosis_allergy'] == true){
453 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
454 }elseif($_POST['form_diagnosis_medprb'] == true){
455 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem')) ";
457 if ( $type == 'Procedure' ||
( strlen($form_lab_results)!=0) ||
$_POST['lab_results'] == true) {
458 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
459 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
460 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
461 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id ";
464 if (strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
465 $sqlstmt = $sqlstmt." left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id ";
467 //Immunization added in clinical report
468 if (strlen($form_immunization)!=0 ) {
469 $sqlstmt = $sqlstmt." LEFT OUTER JOIN immunizations as imm ON imm.patient_id = pd.pid
470 LEFT OUTER JOIN codes as immc ON imm.cvx_code = immc.id ";
472 if(strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
473 $sqlstmt=$sqlstmt." left outer join prescriptions AS r on r.patient_id=pd.pid
474 LEFT OUTER JOIN drugs AS d ON d.drug_id = r.drug_id";
476 if ( $type == 'Medical History') {
477 $sqlstmt = $sqlstmt." left outer join history_data as hd on hd.pid = pd.pid
478 and (isnull(hd.tobacco) = 0
479 or isnull(hd.alcohol) = 0
480 or isnull(hd.recreational_drugs) = 0)";
482 if($type == 'Service Codes') {
483 $sqlstmt = $sqlstmt." left outer join billing as b on b.pid = pd.pid
484 left outer join form_encounter as fe on fe.encounter = b.encounter and b.code_type = 'CPT4'
485 left outer join codes as c on c.code = b.code ";
488 $whr_stmt="where 1=1";
489 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
490 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(li.date) <= ?";
491 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
493 if(strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
494 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(pr.date) <= ?";
495 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
497 if(strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
498 $whr_stmt=$whr_stmt." AND r.date_modified >= ? AND r.date_modified < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(r.date_modified) <= ?";
499 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
501 if($type == 'Medical History') {
502 $whr_stmt=$whr_stmt." AND hd.date >= ? AND hd.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(hd.date) <= ?";
503 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
505 if($type == 'Procedure') {
506 $whr_stmt=$whr_stmt." AND po.date_ordered >= ? AND po.date_ordered < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(po.date_ordered) <= ?";
507 array_push($sqlBindArray, substr($sql_date_from,0,10), substr($sql_date_to,0,10), date("Y-m-d"));
509 if($type == "Service Codes") {
510 $whr_stmt=$whr_stmt." AND b.date >= ? AND b.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(b.date) <= ?";
511 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
513 if(strlen($form_lab_results) != 0 ||
$_POST['lab_results'] == true) {
514 $whr_stmt= $whr_stmt." AND (pr.result LIKE ?) ";
515 if(empty($form_lab_results)) $form_lab_results ="%";
516 array_push($sqlBindArray, $form_lab_results);
518 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
523 if(empty($form_drug_name)) $form_drug_name ="%";
524 array_push($sqlBindArray, $form_drug_name, $form_drug_name);
526 if($type == 'Service Codes') {
527 if(strlen($form_service_codes) != 0) {
528 $whr_stmt = $whr_stmt." AND (b.code = ?) ";
529 $service_code = explode(":",$form_service_codes);
530 array_push($sqlBindArray, $service_code[1]);
533 if(strlen($patient_id) != 0) {
534 $whr_stmt = $whr_stmt." and pd.pid = ?";
535 array_push($sqlBindArray, $patient_id);
538 if(strlen($age_from) != 0) {
539 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
540 array_push($sqlBindArray, $age_from);
542 if(strlen($age_to) != 0) {
543 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
544 array_push($sqlBindArray, $age_to);
546 if(strlen($sql_gender) != 0) {
547 $whr_stmt = $whr_stmt." and pd.sex = ?";
548 array_push($sqlBindArray, $sql_gender);
550 if(strlen($sql_ethnicity) != 0) {
551 $whr_stmt = $whr_stmt." and pd.ethnicity = ?";
552 array_push($sqlBindArray, $sql_ethnicity);
554 if(strlen($sql_race) != 0) {
555 $whr_stmt = $whr_stmt." and pd.race = ?";
556 array_push($sqlBindArray, $sql_race);
558 if($facility != '') {
559 $whr_stmt = $whr_stmt." and f.id = ? ";
560 array_push($sqlBindArray, $facility);
562 if(strlen($form_diagnosis) > 0) {
563 $whr_stmt = $whr_stmt." AND (li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis = ?) ";
564 array_push($sqlBindArray, $form_diagnosis."%", '%'.$form_diagnosis.'%', '%'.$form_diagnosis, $form_diagnosis);
566 //communication preferences added in clinical report
567 if(strlen($communication) > 0 ||
$_POST['communication_check'] == true){
569 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
570 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
571 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
572 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
573 else if($communication == "" && $_POST['communication_check'] == true){
574 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
578 //Immunization where condition for full text or short text
579 if(strlen($form_immunization) > 0) {
581 immc.code_text LIKE ?
582 OR immc.code_text_short LIKE ?
584 array_push($sqlBindArray, '%'.$form_immunization.'%', '%'.$form_immunization.'%');
587 if ($_POST['form_pt_name'] == true){
588 $odrstmt=$odrstmt.",patient_name";
590 if ($_POST['form_pt_age'] == true) {
591 $odrstmt=$odrstmt.",patient_age";
593 if((strlen($form_diagnosis) > 0)){
594 $odrstmt=$odrstmt.",lists_diagnosis";
595 }elseif (($_POST['form_diagnosis_allergy'] == true) ||
($_POST['form_diagnosis_medprb'] == true)){
596 $odrstmt=$odrstmt.",lists_title";
598 if (($_POST['form_drug'] == true) ||
(strlen($form_drug_name) > 0)){
599 $odrstmt=$odrstmt.",r.drug";
601 if (($_POST['ndc_no'] == true) && (strlen($form_drug_name) > 0)) {
602 $odrstmt=$odrstmt.",d.ndc_number";
604 if (($_POST['lab_results'] == true) ||
(strlen($form_lab_results) > 0)) {
605 $odrstmt=$odrstmt.",procedure_result_result";
607 if (strlen($communication) > 0 ||
$_POST['communication_check'] == true) {
608 $odrstmt=$odrstmt.",ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
613 $odrstmt = " ORDER BY patient_id";
616 $odrstmt = " ORDER BY ".ltrim($odrstmt,",");
619 if($type == 'Medical History') {
620 $sqlstmt="select * from (".$sqlstmt." ".$whr_stmt." ".$odrstmt.",history_data_date desc) a group by patient_id";
623 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
626 $result = sqlStatement($sqlstmt,$sqlBindArray);
628 $row_id = 1.1;//given to each row to identify and toggle
632 if(sqlNumRows($result) > 0)
634 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
635 $smoke_codes_arr = getSmokeCodes();
638 <div id
= "report_results">
640 <?php
$pidarr = array();
641 while ($row = sqlFetchArray($result)) { ?
>
642 <table width
=90% align
="center" cellpadding
="5" cellspacing
="0" style
="font-family:tahoma;color:black;" border
="0">
643 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
644 <td
><b
><?php
echo htmlspecialchars(xl('Summary of'),ENT_NOQUOTES
); echo " "; ?
> <?php
echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES
); ?
></b
></td
>
648 <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
>
650 <table width
="100%" align
="center" id
= "<?php echo $row_id; $row_id++;?>" class="border1" style
="display:none; font-size:13px;" cellpadding
=5>
651 <tr bgcolor
="#C3FDB8" align
="left">
652 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES
); ?
></b
></td
>
653 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('PID'),ENT_NOQUOTES
);?
></b
></td
>
654 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('Age'),ENT_NOQUOTES
);?
></b
></td
>
655 <td width
="10%"><b
><?php
echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES
); ?
></b
></td
>
656 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Race'),ENT_NOQUOTES
);?
></b
></td
>
657 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES
);?
></b
></td
>
658 <td width
="15%" <?php
if(strlen($communication) == 0 ||
$_POST['communication_check'] == true){ ?
> colspan
=5 <?php
} ?
>><b
><?php
echo htmlspecialchars(xl('Provider'),ENT_NOQUOTES
);?
></b
></td
>
659 <?php
if(strlen($communication) > 0 ||
($_POST['communication_check'] == true)){ ?
>
660 <td colspan
=4><b
><?php
echo xlt('Communication');?
></b
></td
>
663 <tr bgcolor
="#FFFFFF">
664 <td
><?php
echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES
); ?
> 
;</td
>
665 <td
> <?php
echo htmlspecialchars($row['patient_id'],ENT_NOQUOTES
); ?
> 
;</td
>
666 <td
> <?php
echo htmlspecialchars($row['patient_age'],ENT_NOQUOTES
); ?
> 
;</td
>
667 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'sex'), $row['patient_sex']),ENT_NOQUOTES
); ?
> 
;</td
>
668 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'race'), $row['patient_race']),ENT_NOQUOTES
); ?
> 
;</td
>
669 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ethnicity'), $row['patient_ethinic']),ENT_NOQUOTES
); ?
> 
;</td
>
670 <td
<?php
if(strlen($communication) == 0 ||
($_POST['communication_check'] == true)){ ?
> colspan
=5 <?php
} ?
>> <?php
echo htmlspecialchars($row['users_provider'],ENT_NOQUOTES
); ?
> 
;</td
>
672 <?php
if(strlen($communication) > 0 ||
$_POST['communication_check'] == true){ ?
>
673 <td colspan
=4><?php
echo text($row['communications']); ?
></td
>
676 <!-- Diagnosis Report Start
-->
678 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true)
681 <tr bgcolor
="#C3FDB8" align
= "left">
682 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Diagnosis Report'),ENT_NOQUOTES
);?
></b
></td
>
684 <tr bgcolor
="#C3FDB8" align
= "left">
685 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis Date'),ENT_NOQUOTES
);?
></b
></td
>
686 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis'),ENT_NOQUOTES
);?
></b
></td
>
687 <td colspan
=10><b
><?php
echo htmlspecialchars(xl('Diagnosis Name'),ENT_NOQUOTES
);?
></b
></td
>
689 <tr bgcolor
="#FFFFFF">
690 <td
><?php
echo htmlspecialchars($row['lists_date'],ENT_NOQUOTES
); ?
> 
;</td
>
691 <td
><?php
echo htmlspecialchars($row['lists_diagnosis'],ENT_NOQUOTES
); ?
> 
;</td
>
692 <td colspan
=10><?php
echo htmlspecialchars($row['lists_title'],ENT_NOQUOTES
); ?
> 
;</td
>
695 <!-- Diagnosis Report End
-->
697 <!-- Prescription Report Start
-->
699 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true)
702 <tr bgcolor
="#C3FDB8" align
= "left">
703 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Prescription Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
704 <tr bgcolor
="#C3FDB8" align
= "left">
705 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
706 <td
><b
><?php
echo htmlspecialchars(xl('Drug Name'),ENT_NOQUOTES
);?
></b
></td
>
707 <td
><b
><?php
echo htmlspecialchars(xl('Route'),ENT_NOQUOTES
);?
></b
></td
>
708 <td
><b
><?php
echo htmlspecialchars(xl('Dosage'),ENT_NOQUOTES
);?
></b
></td
>
709 <td
><b
><?php
echo htmlspecialchars(xl('Form'),ENT_NOQUOTES
);?
></b
></td
>
710 <td
><b
><?php
echo htmlspecialchars(xl('Interval'),ENT_NOQUOTES
);?
></b
></td
>
711 <td
><b
><?php
echo htmlspecialchars(xl('Size'),ENT_NOQUOTES
);?
></b
></td
>
712 <td
><b
><?php
echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES
);?
></b
></td
>
713 <td
><b
><?php
echo htmlspecialchars(xl('ReFill'),ENT_NOQUOTES
);?
></b
></td
>
714 <td
><b
><?php
echo htmlspecialchars(xl('Quantity'),ENT_NOQUOTES
);?
></b
></td
>
715 <td colspan
="2"><b
><?php
echo htmlspecialchars(xl('NDC'),ENT_NOQUOTES
);?
></b
></td
>
717 <tr bgcolor
="#FFFFFF" align
="">
719 $rx_route = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) ;
720 $rx_form = generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['hform']) ;
721 $rx_interval = generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'), $row['hinterval']) ;
722 $rx_units = generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['hunit']);
724 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['prescriptions_date_modified']),ENT_NOQUOTES
); ?
> 
;</td
>
725 <td
><?php
echo htmlspecialchars($row['drug'],ENT_NOQUOTES
); ?
></td
>
726 <td
><?php
echo htmlspecialchars($rx_route,ENT_NOQUOTES
); ?
></td
>
727 <td
><?php
echo htmlspecialchars($row['dosage'],ENT_NOQUOTES
); ?
></td
>
728 <td
><?php
echo htmlspecialchars($rx_form,ENT_NOQUOTES
); ?
></td
>
729 <td
><?php
echo htmlspecialchars($rx_interval,ENT_NOQUOTES
); ?
></td
>
730 <td
><?php
echo htmlspecialchars($row['size'],ENT_NOQUOTES
); ?
></td
>
731 <td
><?php
echo htmlspecialchars($rx_units,ENT_NOQUOTES
); ?
></td
>
732 <td
><?php
echo htmlspecialchars($row['refills'],ENT_NOQUOTES
); ?
></td
>
733 <td
><?php
echo htmlspecialchars($row['quantity'],ENT_NOQUOTES
); ?
></td
>
734 <td colspan
="2"><?php
echo htmlspecialchars($row['ndc_number'],ENT_NOQUOTES
); ?
></td
>
737 <!-- Prescription Report End
-->
739 <!-- Lab Results Report Start
-->
741 if(strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true)
744 <tr bgcolor
="#C3FDB8" align
= "left">
745 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Lab Results Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
746 <tr bgcolor
="#C3FDB8" align
= "left">
747 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
748 <td
><b
><?php
echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES
);?
></b
></td
>
749 <td
><b
><?php
echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES
);?
></b
></td
>
750 <td
><b
><?php
echo htmlspecialchars(xl('Result'),ENT_NOQUOTES
);?
></b
></td
>
751 <td
><b
><?php
echo htmlspecialchars(xl('Range'),ENT_NOQUOTES
);?
></b
></td
>
752 <td
><b
><?php
echo htmlspecialchars(xl('Abnormal'),ENT_NOQUOTES
);?
></b
></td
>
753 <td
><b
><?php
echo htmlspecialchars(xl('Comments'),ENT_NOQUOTES
);?
></b
></td
>
754 <td colspan
=5><b
><?php
echo htmlspecialchars(xl('Document ID'),ENT_NOQUOTES
);?
></b
></td
>
756 <tr bgcolor
="#FFFFFF">
757 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_result_date']),ENT_NOQUOTES
); ?
> 
;</td
>
758 <td
> <?php
echo htmlspecialchars($row['procedure_result_facility'],ENT_NOQUOTES
); ?
> 
;</td
>
759 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$row['procedure_result_units']),ENT_NOQUOTES
); ?
> 
;</td
>
760 <td
> <?php
echo htmlspecialchars($row['procedure_result_result'],ENT_NOQUOTES
); ?
> 
;</td
>
761 <td
> <?php
echo htmlspecialchars($row['procedure_result_range'],ENT_NOQUOTES
); ?
> 
;</td
>
762 <td
> <?php
echo htmlspecialchars($row['procedure_result_abnormal'],ENT_NOQUOTES
); ?
> 
;</td
>
763 <td
> <?php
echo htmlspecialchars($row['procedure_result_comments'],ENT_NOQUOTES
); ?
> 
;</td
>
764 <td colspan
=5> <?php
echo htmlspecialchars($row['procedure_result_document_id'],ENT_NOQUOTES
); ?
> 
;</td
>
767 <!-- Lab Results End
-->
769 <!-- Procedures Report Start
-->
771 if ( $type == 'Procedure')
774 <tr bgcolor
="#C3FDB8" align
= "left">
775 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Procedure Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
776 <tr bgcolor
="#C3FDB8" align
= "left">
777 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
778 <td
><b
><?php
echo htmlspecialchars(xl('Standard Name'),ENT_NOQUOTES
);?
></b
></td
>
779 <td
><b
><?php
echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES
); ?
></b
></td
>
780 <td
><b
><?php
echo htmlspecialchars(xl('Encounter'),ENT_NOQUOTES
);?
></b
></td
>
781 <td
><b
><?php
echo htmlspecialchars(xl('Priority'),ENT_NOQUOTES
);?
></b
></td
>
782 <td
><b
><?php
echo htmlspecialchars(xl('Status'),ENT_NOQUOTES
);?
></b
></td
>
783 <td
><b
><?php
echo htmlspecialchars(xl('Instruction'),ENT_NOQUOTES
);?
></b
></td
>
784 <td
><b
><?php
echo htmlspecialchars(xl('Activity'),ENT_NOQUOTES
);?
></b
></td
>
785 <td colspan
=3><b
><?php
echo htmlspecialchars(xl('Control ID'),ENT_NOQUOTES
);?
></b
></td
>
787 <tr bgcolor
="#FFFFFF">
789 $procedure_type_standard_code_arr = explode(':', $row['procedure_type_standard_code']);
790 $procedure_type_standard_code = $procedure_type_standard_code_arr[1];
793 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_order_date_ordered']),ENT_NOQUOTES
); ?
> 
;</td
>
794 <td
> <?php
echo htmlspecialchars($procedure_type_standard_code,ENT_NOQUOTES
); ?
> 
;</td
>
795 <td
> <?php
echo htmlspecialchars($row['procedure_name'],ENT_NOQUOTES
); ?
> 
;</td
>
796 <td
> <?php
echo htmlspecialchars($row['procedure_order_encounter'],ENT_NOQUOTES
); ?
> 
;</td
>
797 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_priority'),$row['procedure_order_order_priority']),ENT_NOQUOTES
); ?
> 
;</td
>
798 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_status'),$row['procedure_order_order_status']),ENT_NOQUOTES
); ?
> 
;</td
>
799 <td
> <?php
echo htmlspecialchars($row['procedure_order_patient_instructions'],ENT_NOQUOTES
); ?
> 
;</td
>
800 <td
> <?php
echo htmlspecialchars($row['procedure_order_activity'],ENT_NOQUOTES
); ?
> 
;</td
>
801 <td colspan
=3> <?php
echo htmlspecialchars($row['procedure_order_control_id'],ENT_NOQUOTES
); ?
> 
;</td
>
805 <!-- Procedure Report End
-->
807 <!-- Medical History Report Start
-->
809 if ( $type == 'Medical History')
812 <tr bgcolor
="#C3FDB8" align
= "left">
813 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES
);?
><b
></td
></tr
>
814 <tr bgcolor
="#C3FDB8" align
= "left">
815 <td
><b
><?php
echo htmlspecialchars(xl('History Date'),ENT_NOQUOTES
); ?
></b
></td
>
816 <td
><b
><?php
echo htmlspecialchars(xl('Tobacco'),ENT_NOQUOTES
);?
></b
></td
>
817 <td
><b
><?php
echo htmlspecialchars(xl('Alcohol'),ENT_NOQUOTES
);?
></b
></td
>
818 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Recreational Drugs'),ENT_NOQUOTES
);?
></b
></td
>
820 <tr bgcolor
="#FFFFFF">
822 $tmp_t = explode('|', $row['history_data_tobacco']);
823 $tmp_a = explode('|', $row['history_data_alcohol']);
824 $tmp_d = explode('|', $row['history_data_recreational_drugs']);
825 $his_tobac = generate_display_field(array('data_type'=>'1','list_id'=>'smoking_status'), $tmp_t[3]) ;
827 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['history_data_date']),ENT_NOQUOTES
); ?
> 
;</td
>
829 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
830 if(!empty($smoke_codes_arr[$tmp_t[3]])){
831 $his_tobac.= " ( ".$smoke_codes_arr[$tmp_t[3]]." )";
833 echo htmlspecialchars($his_tobac,ENT_NOQUOTES
); ?
> 
;</td
>
835 if ($tmp_a[1] == "currentalcohol") $res = xl('Current Alcohol');
836 if ($tmp_a[1] == "quitalcohol") $res = xl('Quit Alcohol');
837 if ($tmp_a[1] == "neveralcohol") $res = xl('Never Alcohol');
838 if ($tmp_a[1] == "not_applicablealcohol") $res = xl('N/A');
840 <td
> <?php
echo htmlspecialchars($res,ENT_NOQUOTES
); ?
> 
;</td
>
842 if ($tmp_d[1] == "currentrecreational_drugs") $resd = xl('Current Recreational Drugs');
843 if ($tmp_d[1] == "quitrecreational_drugs") $resd = xl('Quit');
844 if ($tmp_d[1] == "neverrecreational_drugs") $resd = xl('Never');
845 if ($tmp_d[1] == "not_applicablerecreational_drugs") $resd = xl('N/A');
847 <td colspan
=8> <?php
echo htmlspecialchars($resd,ENT_NOQUOTES
); ?
> 
;</td
>
850 <!-- Medical History Report End
-->
852 <!-- Service Codes Report Start
-->
854 if ( $type == 'Service Codes') {
856 <tr bgcolor
="#C3FDB8" align
= "left">
857 <td colspan
=11><b
><?php
echo "#"; echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES
);?
><b
></td
></tr
>
858 <tr bgcolor
="#C3FDB8" align
= "left">
859 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
860 <td
><b
><?php
echo htmlspecialchars(xl('Code'),ENT_NOQUOTES
);?
></b
></td
>
861 <td
><b
><?php
echo htmlspecialchars(xl('Encounter ID'),ENT_NOQUOTES
);?
></b
></td
>
862 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Code Text'),ENT_NOQUOTES
);?
></b
></td
></tr
>
863 <tr bgcolor
="#FFFFFF">
864 <td
><?php
echo htmlspecialchars(oeFormatShortDate($row['date']),ENT_NOQUOTES
); ?
> 
;</td
>
865 <td
><?php
echo htmlspecialchars($row['code'],ENT_NOQUOTES
); ?
> 
;</td
>
866 <td
><?php
echo htmlspecialchars($row['encounter'],ENT_NOQUOTES
); ?
> 
;</td
>
867 <td colspan
=8><?php
echo htmlspecialchars($row['code_text'],ENT_NOQUOTES
); ?
> 
;</td
>
870 <!-- Service Codes Report End
-->
872 <!-- Immunization Report Start
-->
874 if(strlen($form_immunization) > 0){?
>
875 <tr bgcolor
="#C3FDB8" align
= "left">
876 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Immunization Report'),ENT_NOQUOTES
);?
></b
></td
>
878 <tr bgcolor
="#C3FDB8" align
= "left">
879 <td
><b
><?php
echo htmlspecialchars(xl('Immunization Date'),ENT_NOQUOTES
);?
></b
></td
>
880 <td
><b
><?php
echo htmlspecialchars(xl('CVX Code'),ENT_NOQUOTES
);?
></b
></td
>
881 <td
><b
><?php
echo htmlspecialchars(xl('Vaccine'),ENT_NOQUOTES
);?
></b
></td
>
882 <td
><b
><?php
echo htmlspecialchars(xl('Amount'),ENT_NOQUOTES
);?
></b
></td
>
883 <td
><b
><?php
echo htmlspecialchars(xl('Administered Site'),ENT_NOQUOTES
);?
></b
></td
>
884 <td colspan
="7"><b
><?php
echo htmlspecialchars(xl('Notes'),ENT_NOQUOTES
);?
></b
></td
>
886 <tr bgcolor
="#FFFFFF">
887 <td
><?php
echo htmlspecialchars($row['imm_date'],ENT_NOQUOTES
); ?
> 
;</td
>
888 <td
><?php
echo htmlspecialchars($row['cvx_code'],ENT_NOQUOTES
); ?
> 
;</td
>
889 <td
><?php
echo htmlspecialchars($row['imm_code_short'],ENT_NOQUOTES
)." (".htmlspecialchars($row['imm_code']).")"; ?
> 
;</td
>
892 if ($row["amount_administered"] > 0) {
893 echo htmlspecialchars( $row["amount_administered"] . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']) , ENT_NOQUOTES
);
902 <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']); ?
>
906 <?php
echo htmlspecialchars($row['notes']); ?
>
910 <!-- Immunization Report End
-->
912 <?php
} //while loop end ?>
913 </table
> <!-- Main table ends
-->
916 } //End if form_refresh
919 ?
><div
class='text'> <?php
echo htmlspecialchars(xl('Please input search criteria above, and click Submit to view results.'),ENT_NOQUOTES
); ?
> </div
><?php