2 // Copyright (C) 2010 OpenEMR Support LLC
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));
37 $type = $_POST["type"];
38 $facility = isset($_POST['facility']) ?
$_POST['facility'] : '';
39 if($_POST['date_from'] != "")
40 $sql_date_from = $_POST['date_from'];
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'];
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"]);
66 <?php
html_header_show();?
>
68 <?php
echo htmlspecialchars(xl('Clinical Reports'),ENT_NOQUOTES
); ?
>
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
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
74 <script language
="JavaScript">
76 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
78 $
(document
).ready(function() {
79 var win
= top
.printLogSetup ? top
: opener
.top
;
80 win
.printLogSetup(document
.getElementById('printbutton'));
84 var tr
= document
.getElementById(id
);
85 if (tr
==null) { return; }
86 var bExpand
= tr
.style
.display
== '';
87 tr
.style
.display
= (bExpand ?
'none' : '');
89 function changeimage(id
, sMinus
, sPlus
) {
90 var img
= document
.getElementById(id
);
92 var bExpand
= img
.src
.indexOf(sPlus
) >= 0;
94 img
.src
= "../pic/blue-up-arrow.gif";
96 img
.src
= "../pic/blue-down-arrow.gif";
99 function Toggle_trGrpHeader2(t_id
,i_id
) {
101 changeimage(img
, 'blue-down-arrow.gif', 'blue-up-arrow.gif');
105 // This is for callback by the find-code popup.
106 // Appends to or erases the current list of diagnoses.
107 function set_related(codetype
, code
, selector
, codedesc
) {
108 var f
= document
.forms
[0][current_sel_name
];
111 if (s
.length
> 0) s +
= ';';
112 s +
= codetype +
':' + code
;
119 //This invokes the find-code popup.
120 function sel_diagnosis(e
) {
121 current_sel_name
= e
.name
;
122 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("diagnosis","csv"); ?>', '_blank', 500, 400);
125 //This invokes the find-code popup.
126 function sel_procedure(e
) {
127 current_sel_name
= e
.name
;
128 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo collect_codetypes("procedure","csv"); ?>', '_blank', 500, 400);
131 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
132 <style type
="text/css">
133 /* specifically include & exclude from printing */
139 #report_parameters_daterange {
143 #report_results table {
148 /* specifically exclude some from the screen */
150 #report_parameters_daterange {
155 .optional_area_service_codes
{
157 if($type != 'Service Codes' ||
$type == '')
166 <script language
="javascript" type
="text/javascript">
167 function checkType() {
168 if($
('#type').val() == 'Service Codes')
170 $
('.optional_area_service_codes').css("display", "inline");
174 $
('.optional_area_service_codes').css("display", "none");
178 function submitForm() {
179 var d_from
= new String($
('#date_from').val());
180 var d_to
= new String($
('#date_to').val());
182 var d_from_arr
= d_from
.split('-');
183 var d_to_arr
= d_to
.split('-');
185 var dt_from
= new Date(d_from_arr
[0], d_from_arr
[1], d_from_arr
[2]);
186 var dt_to
= new Date(d_to_arr
[0], d_to_arr
[1], d_to_arr
[2]);
188 var mili_from
= dt_from
.getTime();
189 var mili_to
= dt_to
.getTime();
190 var diff
= mili_to
- mili_from
;
192 $
('#date_error').css("display", "none");
194 if(diff
< 0) //negative
196 $
('#date_error').css("display", "inline");
200 $
("#form_refresh").attr("value","true");
201 $
("#theform").submit();
205 $
(document
).ready(function() {
206 $
(".numeric_only").keydown(function(event
) {
207 //alert(event.keyCode);
208 // Allow only backspace and delete
209 if ( event
.keyCode
== 46 || event
.keyCode
== 8 ) {
210 // let it happen, don't do anything
213 if(!((event
.keyCode
>= 96 && event
.keyCode
<= 105) ||
(event
.keyCode
>= 48 && event
.keyCode
<= 57)))
215 event
.preventDefault();
222 <body
class="body_top">
223 <!-- Required
for the popup date selectors
-->
224 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
226 <?php
echo htmlspecialchars(xl('Report - Clinical'),ENT_NOQUOTES
); ?
>
228 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
229 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
231 <div id
="report_parameters_daterange"> <?php
echo htmlspecialchars(date("d F Y", strtotime($sql_date_from)),ENT_NOQUOTES
) .
232 " to ". htmlspecialchars(date("d F Y", strtotime($sql_date_to)),ENT_NOQUOTES
); ?
> </div
>
233 <form name
='theform' id
='theform' method
='post' action
='clinical_reports.php'>
234 <div id
="report_parameters">
235 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
238 <td width
='740px'><div style
='float:left'>
241 <td
class='label' width
="100"><?php
echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES
); ?
>: </td
>
242 <td width
="250"> <?php
dropdown_facility($facility,'facility',false); ?
> </td
>
243 <td
class='label' width
="100"><?php
echo htmlspecialchars(xl('From'),ENT_NOQUOTES
); ?
>: </td
>
244 <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
>
247 <td
class='label'><?php
echo htmlspecialchars(xl('Patient ID'),ENT_NOQUOTES
); ?
>:</td
>
248 <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
>
249 <td
class='label'><?php
echo htmlspecialchars(xl('To'),ENT_NOQUOTES
); ?
>: </td
>
250 <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
>
253 <td
class='label'><?php
echo htmlspecialchars(xl('Age Range'),ENT_NOQUOTES
); ?
>:</td
>
254 <td
><?php
echo htmlspecialchars(xl('From'),ENT_NOQUOTES
); ?
>
255 <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
); ?
>
256 <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
>
257 <td
class='label'><?php
echo htmlspecialchars(xl('Problem DX'),ENT_NOQUOTES
); ?
>:</td
>
258 <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
>
263 <td
class='label'><?php
echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES
); ?
>:</td
>
264 <td
><?php
echo generate_select_list('gender', 'sex', $sql_gender, 'Select Gender', 'Unassigned', '', ''); ?
></td
>
265 <td
class='label'><?php
echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES
); ?
>:</td
>
266 <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
>
270 <td
class='label'><?php
echo htmlspecialchars(xl('Race'),ENT_NOQUOTES
); ?
>:</td
>
271 <td
><?php
echo generate_select_list('race', 'race', $sql_race, 'Select Race', 'Unassigned', '', ''); ?
></td
>
272 <td
class='label'><?php
echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES
); ?
>:</td
>
273 <td
><?php
echo generate_select_list('ethnicity', 'ethnicity', $sql_ethnicity, 'Select Ethnicity', 'Unassigned', '', ''); ?
></td
>
274 <td
class='label'><?php
echo htmlspecialchars(xl('Immunization'),ENT_NOQUOTES
); ?
>:</td
>
275 <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
>
278 <td
class='label' width
='100'><?php
echo htmlspecialchars(xl('Lab Result'),ENT_NOQUOTES
); ?
>:</td
>
279 <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
>
281 <td
class='label' width
='100'><?php
echo htmlspecialchars(xl('Option'),ENT_NOQUOTES
); ?
>:</td
>
282 <td
><select name
="type" id
="type" onChange
="checkType();">
283 <option
> <?php
echo htmlspecialchars(xl('Select'),ENT_NOQUOTES
); ?
></option
>
284 <option value
="Procedure" <?php
if($type == 'Procedure') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES
); ?
></option
>
285 <option value
="Medical History" <?php
if($type == 'Medical History') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES
); ?
></option
>
286 <option value
="Service Codes" <?php
if($type == 'Service Codes') { echo "selected"; } ?
>><?php
echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES
); ?
></option
>
289 <td
class='label'><?php
echo htmlspecialchars(xl('Communication'),ENT_NOQUOTES
); ?
>:</td
>
291 <select name
="communication" id
="communication" title
="<?php echo htmlspecialchars(xl('Select Communication Preferences'),ENT_NOQUOTES); ?>">
292 <option value
=""> <?php
echo htmlspecialchars(xl('Select'),ENT_NOQUOTES
); ?
></option
>
293 <?php
foreach($comarr as $comkey => $comvalue){ ?
>
294 <option value
="<?php echo attr($comkey); ?>" <?php
if($communication == $comkey){ echo "selected";}?
>><?php
echo text($comvalue); ?
></option
>
301 <tr
class="optional_area_service_codes">
302 <td width
='100'> 
;</td
>
303 <td width
='100'> 
;</td
>
304 <td width
='195'> 
;</td
>
305 <td
class='label' width
='76'><?php
echo htmlspecialchars(xl('Code'),ENT_NOQUOTES
); ?
>:</td
>
306 <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
>
311 <!-- Sort by Start
-->
312 <td
class='label' width
='63'><?php
echo htmlspecialchars(xl('Sort By'),ENT_NOQUOTES
); ?
>:</td
>
314 <input type
='checkbox' name
='form_pt_name'<?php
if ($_POST['form_pt_name'] == true) echo ' checked'; ?
>>
315 <?php
echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES
); ?
> 
;
317 <input type
='checkbox' name
='form_pt_age'<?php
if ($_POST['form_pt_age'] == true) echo ' checked'; ?
>>
318 <?php
echo htmlspecialchars(xl('Age'),ENT_NOQUOTES
); ?
> 
;
320 <input type
='checkbox' name
='form_diagnosis_allergy'<?php
if ($_POST['form_diagnosis_allergy'] == true) echo ' checked'; ?
>>
321 <?php
echo htmlspecialchars(xl('Allergies'),ENT_NOQUOTES
); ?
> 
;
323 <input type
='checkbox' name
='form_diagnosis_medprb'<?php
if ($_POST['form_diagnosis_medprb'] == true) echo ' checked'; ?
>>
324 <?php
echo htmlspecialchars(xl('Medical Problems'),ENT_NOQUOTES
); ?
> 
;
326 <input type
='checkbox' name
='form_drug'<?php
if ($_POST['form_drug'] == true) echo ' checked'; ?
>>
327 <?php
echo htmlspecialchars(xl('Drug'),ENT_NOQUOTES
); ?
> 
;
329 <input type
='checkbox' name
='ndc_no'<?php
if ($_POST['ndc_no'] == true) echo ' checked'; ?
>>
330 <?php
echo htmlspecialchars(xl('NDC Number'),ENT_NOQUOTES
); ?
> 
;
331 <input type
='checkbox' name
='lab_results'<?php
if ($_POST['lab_results'] == true) echo ' checked'; ?
>>
332 <?php
echo htmlspecialchars(xl('Lab Results'),ENT_NOQUOTES
); ?
> 
;
333 <input type
='checkbox' name
='communication_check'<?php
if ($_POST['communication_check'] == true) echo ' checked'; ?
>>
334 <?php
echo xlt('Communication'); ?
>
337 <!-- Sort by ends
-->
340 <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
>
344 <td height
="100%" valign
='middle' width
="175"><table style
='border-left:1px solid; width:100%; height:100%'>
346 <td
><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
='submitForm();'> <span
>
347 <?php
echo htmlspecialchars(xl('Submit'),ENT_NOQUOTES
); ?
>
349 <?php
if ($_POST['form_refresh']) { ?
>
350 <a href
='#' class='css_button' id
='printbutton'> <span
>
351 <?php
echo xlt('Print'); ?
>
360 <!-- end of parameters
-->
362 // SQL scripts for the various searches
363 $sqlBindArray = array();
364 if ($_POST['form_refresh'])
367 concat(pd.fname, ' ', pd.lname) AS patient_name,
368 pd.pid AS patient_id,
369 DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 AS patient_age,
370 pd.sex AS patient_sex,
371 pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
372 concat(u.fname, ' ', u.lname) AS users_provider,
373 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";
374 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
375 $sqlstmt=$sqlstmt.",li.date AS lists_date,
376 li.diagnosis AS lists_diagnosis,
377 li.title AS lists_title";
379 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
381 $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,
382 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";
385 if(strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true) {
386 $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date,
387 pr.facility AS procedure_result_facility,
388 pr.units AS procedure_result_units,
389 pr.result AS procedure_result_result,
390 pr.range AS procedure_result_range,
391 pr.abnormal AS procedure_result_abnormal,
392 pr.comments AS procedure_result_comments,
393 pr.document_id AS procedure_result_document_id";
396 if ( $type == 'Procedure') {
397 $sqlstmt = $sqlstmt.",po.date_ordered AS procedure_order_date_ordered,
398 pt.standard_code AS procedure_type_standard_code,
399 pc.procedure_name as procedure_name,
400 po.order_priority AS procedure_order_order_priority,
401 po.order_status AS procedure_order_order_status,
402 po.encounter_id AS procedure_order_encounter,
403 po.patient_instructions AS procedure_order_patient_instructions,
404 po.activity AS procedure_order_activity,
405 po.control_id AS procedure_order_control_id ";
408 if ( $type == 'Medical History') {
409 $sqlstmt = $sqlstmt.",hd.date AS history_data_date,
410 hd.tobacco AS history_data_tobacco,
411 hd.alcohol AS history_data_alcohol,
412 hd.recreational_drugs AS history_data_recreational_drugs ";
414 if($type == 'Service Codes') {
415 $sqlstmt .= ", c.code as code,
416 c.code_text as code_text,
417 fe.encounter as encounter,
419 $mh_stmt = $mh_stmt.",code,code_text,encounter,date";
421 if (strlen($form_immunization) > 0) {
422 $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 ";
425 $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid
426 left outer join facility as f on f.id = u.facility_id";
428 if(strlen($form_diagnosis) > 0 ||
($_POST['form_diagnosis_allergy'] == true && $_POST['form_diagnosis_medprb'] == true)){
429 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem' OR li.type='allergy')) ";
430 }elseif($_POST['form_diagnosis_allergy'] == true){
431 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
432 }elseif($_POST['form_diagnosis_medprb'] == true){
433 $sqlstmt = $sqlstmt." left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem')) ";
435 if ( $type == 'Procedure' ||
( strlen($form_lab_results)!=0) ||
$_POST['lab_results'] == true) {
436 $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid
437 left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id
438 left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id
439 left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id ";
442 if (strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
443 $sqlstmt = $sqlstmt." left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id ";
445 //Immunization added in clinical report
446 if (strlen($form_immunization)!=0 ) {
447 $sqlstmt = $sqlstmt." LEFT OUTER JOIN immunizations as imm ON imm.patient_id = pd.pid
448 LEFT OUTER JOIN codes as immc ON imm.cvx_code = immc.id ";
450 if(strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
451 $sqlstmt=$sqlstmt." left outer join prescriptions AS r on r.patient_id=pd.pid
452 LEFT OUTER JOIN drugs AS d ON d.drug_id = r.drug_id";
454 if ( $type == 'Medical History') {
455 $sqlstmt = $sqlstmt." left outer join history_data as hd on hd.pid = pd.pid
456 and (isnull(hd.tobacco) = 0
457 or isnull(hd.alcohol) = 0
458 or isnull(hd.recreational_drugs) = 0)";
460 if($type == 'Service Codes') {
461 $sqlstmt = $sqlstmt." left outer join billing as b on b.pid = pd.pid
462 left outer join form_encounter as fe on fe.encounter = b.encounter and b.code_type = 'CPT4'
463 left outer join codes as c on c.code = b.code ";
466 $whr_stmt="where 1=1";
467 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true) {
468 $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(li.date) <= ?";
469 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
471 if(strlen($form_lab_results)!=0 ||
$_POST['lab_results'] == true) {
472 $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(pr.date) <= ?";
473 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
475 if(strlen($form_drug_name)!=0 ||
$_POST['form_drug'] == true) {
476 $whr_stmt=$whr_stmt." AND r.date_modified >= ? AND r.date_modified < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(r.date_modified) <= ?";
477 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
479 if($type == 'Medical History') {
480 $whr_stmt=$whr_stmt." AND hd.date >= ? AND hd.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(hd.date) <= ?";
481 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
483 if($type == 'Procedure') {
484 $whr_stmt=$whr_stmt." AND po.date_ordered >= ? AND po.date_ordered < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(po.date_ordered) <= ?";
485 array_push($sqlBindArray, substr($sql_date_from,0,10), substr($sql_date_to,0,10), date("Y-m-d"));
487 if($type == "Service Codes") {
488 $whr_stmt=$whr_stmt." AND b.date >= ? AND b.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(b.date) <= ?";
489 array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d"));
491 if(strlen($form_lab_results) != 0 ||
$_POST['lab_results'] == true) {
492 $whr_stmt= $whr_stmt." AND (pr.result LIKE ?) ";
493 if(empty($form_lab_results)) $form_lab_results ="%";
494 array_push($sqlBindArray, $form_lab_results);
496 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true) {
501 if(empty($form_drug_name)) $form_drug_name ="%";
502 array_push($sqlBindArray, $form_drug_name, $form_drug_name);
504 if($type == 'Service Codes') {
505 if(strlen($form_service_codes) != 0) {
506 $whr_stmt = $whr_stmt." AND (b.code = ?) ";
507 $service_code = explode(":",$form_service_codes);
508 array_push($sqlBindArray, $service_code[1]);
511 if(strlen($patient_id) != 0) {
512 $whr_stmt = $whr_stmt." and pd.pid = ?";
513 array_push($sqlBindArray, $patient_id);
516 if(strlen($age_from) != 0) {
517 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 >= ?";
518 array_push($sqlBindArray, $age_from);
520 if(strlen($age_to) != 0) {
521 $whr_stmt = $whr_stmt." and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 <= ?";
522 array_push($sqlBindArray, $age_to);
524 if(strlen($sql_gender) != 0) {
525 $whr_stmt = $whr_stmt." and pd.sex = ?";
526 array_push($sqlBindArray, $sql_gender);
528 if(strlen($sql_ethnicity) != 0) {
529 $whr_stmt = $whr_stmt." and pd.ethnicity = ?";
530 array_push($sqlBindArray, $sql_ethnicity);
532 if(strlen($sql_race) != 0) {
533 $whr_stmt = $whr_stmt." and pd.race = ?";
534 array_push($sqlBindArray, $sql_race);
536 if($facility != '') {
537 $whr_stmt = $whr_stmt." and f.id = ? ";
538 array_push($sqlBindArray, $facility);
540 if(strlen($form_diagnosis) > 0) {
541 $whr_stmt = $whr_stmt." AND (li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis = ?) ";
542 array_push($sqlBindArray, $form_diagnosis."%", '%'.$form_diagnosis.'%', '%'.$form_diagnosis, $form_diagnosis);
544 //communication preferences added in clinical report
545 if(strlen($communication) > 0 ||
$_POST['communication_check'] == true){
547 if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' ";
548 else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' ";
549 else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' ";
550 else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' ";
551 else if($communication == "" && $_POST['communication_check'] == true){
552 $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') ";
556 //Immunization where condition for full text or short text
557 if(strlen($form_immunization) > 0) {
559 immc.code_text LIKE ?
560 OR immc.code_text_short LIKE ?
562 array_push($sqlBindArray, '%'.$form_immunization.'%', '%'.$form_immunization.'%');
565 if ($_POST['form_pt_name'] == true){
566 $odrstmt=$odrstmt.",patient_name";
568 if ($_POST['form_pt_age'] == true) {
569 $odrstmt=$odrstmt.",patient_age";
571 if((strlen($form_diagnosis) > 0)){
572 $odrstmt=$odrstmt.",lists_diagnosis";
573 }elseif (($_POST['form_diagnosis_allergy'] == true) ||
($_POST['form_diagnosis_medprb'] == true)){
574 $odrstmt=$odrstmt.",lists_title";
576 if (($_POST['form_drug'] == true) ||
(strlen($form_drug_name) > 0)){
577 $odrstmt=$odrstmt.",r.drug";
579 if (($_POST['ndc_no'] == true) && (strlen($form_drug_name) > 0)) {
580 $odrstmt=$odrstmt.",d.ndc_number";
582 if (($_POST['lab_results'] == true) ||
(strlen($form_lab_results) > 0)) {
583 $odrstmt=$odrstmt.",procedure_result_result";
585 if (strlen($communication) > 0 ||
$_POST['communication_check'] == true) {
586 $odrstmt=$odrstmt.",ROUND((LENGTH(communications) - LENGTH(REPLACE(communications, ',', '')))/LENGTH(',')) , communications";
591 $odrstmt = " ORDER BY patient_id";
594 $odrstmt = " ORDER BY ".ltrim($odrstmt,",");
597 if($type == 'Medical History') {
598 $sqlstmt="select * from (".$sqlstmt." ".$whr_stmt." ".$odrstmt.",history_data_date desc) a group by patient_id";
601 $sqlstmt=$sqlstmt." ".$whr_stmt." ".$odrstmt;
604 $result = sqlStatement($sqlstmt,$sqlBindArray);
606 $row_id = 1.1;//given to each row to identify and toggle
610 if(sqlNumRows($result) > 0)
612 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
613 $smoke_codes_arr = getSmokeCodes();
616 <div id
= "report_results">
618 <?php
$pidarr = array();
619 while ($row = sqlFetchArray($result)) { ?
>
620 <table width
=90% align
="center" cellpadding
="5" cellspacing
="0" style
="font-family:tahoma;color:black;" border
="0">
621 <tr bgcolor
= "#CCCCCC" style
="font-size:15px;">
622 <td
><b
><?php
echo htmlspecialchars(xl('Summary of'),ENT_NOQUOTES
); echo " "; ?
> <?php
echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES
); ?
></b
></td
>
626 <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
>
628 <table width
="100%" align
="center" id
= "<?php echo $row_id; $row_id++;?>" class="border1" style
="display:none; font-size:13px;" cellpadding
=5>
629 <tr bgcolor
="#C3FDB8" align
="left">
630 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Patient Name'),ENT_NOQUOTES
); ?
></b
></td
>
631 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('PID'),ENT_NOQUOTES
);?
></b
></td
>
632 <td width
="5%"><b
><?php
echo htmlspecialchars(xl('Age'),ENT_NOQUOTES
);?
></b
></td
>
633 <td width
="10%"><b
><?php
echo htmlspecialchars(xl('Gender'),ENT_NOQUOTES
); ?
></b
></td
>
634 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Race'),ENT_NOQUOTES
);?
></b
></td
>
635 <td width
="15%"><b
><?php
echo htmlspecialchars(xl('Ethnicity'),ENT_NOQUOTES
);?
></b
></td
>
636 <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
>
637 <?php
if(strlen($communication) > 0 ||
($_POST['communication_check'] == true)){ ?
>
638 <td colspan
=4><b
><?php
echo xlt('Communication');?
></b
></td
>
641 <tr bgcolor
="#FFFFFF">
642 <td
><?php
echo htmlspecialchars($row['patient_name'],ENT_NOQUOTES
); ?
> 
;</td
>
643 <td
> <?php
echo htmlspecialchars($row['patient_id'],ENT_NOQUOTES
); ?
> 
;</td
>
644 <td
> <?php
echo htmlspecialchars($row['patient_age'],ENT_NOQUOTES
); ?
> 
;</td
>
645 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'sex'), $row['patient_sex']),ENT_NOQUOTES
); ?
> 
;</td
>
646 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'race'), $row['patient_race']),ENT_NOQUOTES
); ?
> 
;</td
>
647 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ethnicity'), $row['patient_ethinic']),ENT_NOQUOTES
); ?
> 
;</td
>
648 <td
<?php
if(strlen($communication) == 0 ||
($_POST['communication_check'] == true)){ ?
> colspan
=5 <?php
} ?
>> <?php
echo htmlspecialchars($row['users_provider'],ENT_NOQUOTES
); ?
> 
;</td
>
650 <?php
if(strlen($communication) > 0 ||
$_POST['communication_check'] == true){ ?
>
651 <td colspan
=4><?php
echo text($row['communications']); ?
></td
>
654 <!-- Diagnosis Report Start
-->
656 if(strlen($form_diagnosis) > 0 ||
$_POST['form_diagnosis_allergy'] == true ||
$_POST['form_diagnosis_medprb'] == true)
659 <tr bgcolor
="#C3FDB8" align
= "left">
660 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Diagnosis Report'),ENT_NOQUOTES
);?
></b
></td
>
662 <tr bgcolor
="#C3FDB8" align
= "left">
663 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis Date'),ENT_NOQUOTES
);?
></b
></td
>
664 <td
><b
><?php
echo htmlspecialchars(xl('Diagnosis'),ENT_NOQUOTES
);?
></b
></td
>
665 <td colspan
=10><b
><?php
echo htmlspecialchars(xl('Diagnosis Name'),ENT_NOQUOTES
);?
></b
></td
>
667 <tr bgcolor
="#FFFFFF">
668 <td
><?php
echo htmlspecialchars($row['lists_date'],ENT_NOQUOTES
); ?
> 
;</td
>
669 <td
><?php
echo htmlspecialchars($row['lists_diagnosis'],ENT_NOQUOTES
); ?
> 
;</td
>
670 <td colspan
=10><?php
echo htmlspecialchars($row['lists_title'],ENT_NOQUOTES
); ?
> 
;</td
>
673 <!-- Diagnosis Report End
-->
675 <!-- Prescription Report Start
-->
677 if(strlen($form_drug_name) > 0 ||
$_POST['form_drug'] == true)
680 <tr bgcolor
="#C3FDB8" align
= "left">
681 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Prescription Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
682 <tr bgcolor
="#C3FDB8" align
= "left">
683 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
684 <td
><b
><?php
echo htmlspecialchars(xl('Drug Name'),ENT_NOQUOTES
);?
></b
></td
>
685 <td
><b
><?php
echo htmlspecialchars(xl('Route'),ENT_NOQUOTES
);?
></b
></td
>
686 <td
><b
><?php
echo htmlspecialchars(xl('Dosage'),ENT_NOQUOTES
);?
></b
></td
>
687 <td
><b
><?php
echo htmlspecialchars(xl('Form'),ENT_NOQUOTES
);?
></b
></td
>
688 <td
><b
><?php
echo htmlspecialchars(xl('Interval'),ENT_NOQUOTES
);?
></b
></td
>
689 <td
><b
><?php
echo htmlspecialchars(xl('Size'),ENT_NOQUOTES
);?
></b
></td
>
690 <td
><b
><?php
echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES
);?
></b
></td
>
691 <td
><b
><?php
echo htmlspecialchars(xl('ReFill'),ENT_NOQUOTES
);?
></b
></td
>
692 <td
><b
><?php
echo htmlspecialchars(xl('Quantity'),ENT_NOQUOTES
);?
></b
></td
>
693 <td colspan
="2"><b
><?php
echo htmlspecialchars(xl('NDC'),ENT_NOQUOTES
);?
></b
></td
>
695 <tr bgcolor
="#FFFFFF" align
="">
697 $rx_route = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) ;
698 $rx_form = generate_display_field(array('data_type'=>'1','list_id'=>'drug_form'), $row['hform']) ;
699 $rx_interval = generate_display_field(array('data_type'=>'1','list_id'=>'drug_interval'), $row['hinterval']) ;
700 $rx_units = generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['hunit']);
702 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['prescriptions_date_modified']),ENT_NOQUOTES
); ?
> 
;</td
>
703 <td
><?php
echo htmlspecialchars($row['drug'],ENT_NOQUOTES
); ?
></td
>
704 <td
><?php
echo htmlspecialchars($rx_route,ENT_NOQUOTES
); ?
></td
>
705 <td
><?php
echo htmlspecialchars($row['dosage'],ENT_NOQUOTES
); ?
></td
>
706 <td
><?php
echo htmlspecialchars($rx_form,ENT_NOQUOTES
); ?
></td
>
707 <td
><?php
echo htmlspecialchars($rx_interval,ENT_NOQUOTES
); ?
></td
>
708 <td
><?php
echo htmlspecialchars($row['size'],ENT_NOQUOTES
); ?
></td
>
709 <td
><?php
echo htmlspecialchars($rx_units,ENT_NOQUOTES
); ?
></td
>
710 <td
><?php
echo htmlspecialchars($row['refills'],ENT_NOQUOTES
); ?
></td
>
711 <td
><?php
echo htmlspecialchars($row['quantity'],ENT_NOQUOTES
); ?
></td
>
712 <td colspan
="2"><?php
echo htmlspecialchars($row['ndc_number'],ENT_NOQUOTES
); ?
></td
>
715 <!-- Prescription Report End
-->
717 <!-- Lab Results Report Start
-->
719 if(strlen($form_lab_results) > 0 ||
$_POST['lab_results'] == true)
722 <tr bgcolor
="#C3FDB8" align
= "left">
723 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Lab Results Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
724 <tr bgcolor
="#C3FDB8" align
= "left">
725 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
726 <td
><b
><?php
echo htmlspecialchars(xl('Facility'),ENT_NOQUOTES
);?
></b
></td
>
727 <td
><b
><?php
echo htmlspecialchars(xl('Unit'),ENT_NOQUOTES
);?
></b
></td
>
728 <td
><b
><?php
echo htmlspecialchars(xl('Result'),ENT_NOQUOTES
);?
></b
></td
>
729 <td
><b
><?php
echo htmlspecialchars(xl('Range'),ENT_NOQUOTES
);?
></b
></td
>
730 <td
><b
><?php
echo htmlspecialchars(xl('Abnormal'),ENT_NOQUOTES
);?
></b
></td
>
731 <td
><b
><?php
echo htmlspecialchars(xl('Comments'),ENT_NOQUOTES
);?
></b
></td
>
732 <td colspan
=5><b
><?php
echo htmlspecialchars(xl('Document ID'),ENT_NOQUOTES
);?
></b
></td
>
734 <tr bgcolor
="#FFFFFF">
735 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_result_date']),ENT_NOQUOTES
); ?
> 
;</td
>
736 <td
> <?php
echo htmlspecialchars($row['procedure_result_facility'],ENT_NOQUOTES
); ?
> 
;</td
>
737 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'proc_unit'),$row['procedure_result_units']),ENT_NOQUOTES
); ?
> 
;</td
>
738 <td
> <?php
echo htmlspecialchars($row['procedure_result_result'],ENT_NOQUOTES
); ?
> 
;</td
>
739 <td
> <?php
echo htmlspecialchars($row['procedure_result_range'],ENT_NOQUOTES
); ?
> 
;</td
>
740 <td
> <?php
echo htmlspecialchars($row['procedure_result_abnormal'],ENT_NOQUOTES
); ?
> 
;</td
>
741 <td
> <?php
echo htmlspecialchars($row['procedure_result_comments'],ENT_NOQUOTES
); ?
> 
;</td
>
742 <td colspan
=5> <?php
echo htmlspecialchars($row['procedure_result_document_id'],ENT_NOQUOTES
); ?
> 
;</td
>
745 <!-- Lab Results End
-->
747 <!-- Procedures Report Start
-->
749 if ( $type == 'Procedure')
752 <tr bgcolor
="#C3FDB8" align
= "left">
753 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Procedure Report'),ENT_NOQUOTES
);?
><b
></td
></tr
>
754 <tr bgcolor
="#C3FDB8" align
= "left">
755 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
756 <td
><b
><?php
echo htmlspecialchars(xl('Standard Name'),ENT_NOQUOTES
);?
></b
></td
>
757 <td
><b
><?php
echo htmlspecialchars(xl('Procedure'),ENT_NOQUOTES
); ?
></b
></td
>
758 <td
><b
><?php
echo htmlspecialchars(xl('Encounter'),ENT_NOQUOTES
);?
></b
></td
>
759 <td
><b
><?php
echo htmlspecialchars(xl('Priority'),ENT_NOQUOTES
);?
></b
></td
>
760 <td
><b
><?php
echo htmlspecialchars(xl('Status'),ENT_NOQUOTES
);?
></b
></td
>
761 <td
><b
><?php
echo htmlspecialchars(xl('Instruction'),ENT_NOQUOTES
);?
></b
></td
>
762 <td
><b
><?php
echo htmlspecialchars(xl('Activity'),ENT_NOQUOTES
);?
></b
></td
>
763 <td colspan
=3><b
><?php
echo htmlspecialchars(xl('Control ID'),ENT_NOQUOTES
);?
></b
></td
>
765 <tr bgcolor
="#FFFFFF">
767 $procedure_type_standard_code_arr = explode(':', $row['procedure_type_standard_code']);
768 $procedure_type_standard_code = $procedure_type_standard_code_arr[1];
771 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['procedure_order_date_ordered']),ENT_NOQUOTES
); ?
> 
;</td
>
772 <td
> <?php
echo htmlspecialchars($procedure_type_standard_code,ENT_NOQUOTES
); ?
> 
;</td
>
773 <td
> <?php
echo htmlspecialchars($row['procedure_name'],ENT_NOQUOTES
); ?
> 
;</td
>
774 <td
> <?php
echo htmlspecialchars($row['procedure_order_encounter'],ENT_NOQUOTES
); ?
> 
;</td
>
775 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_priority'),$row['procedure_order_order_priority']),ENT_NOQUOTES
); ?
> 
;</td
>
776 <td
> <?php
echo htmlspecialchars(generate_display_field(array('data_type'=>'1','list_id'=>'ord_status'),$row['procedure_order_order_status']),ENT_NOQUOTES
); ?
> 
;</td
>
777 <td
> <?php
echo htmlspecialchars($row['procedure_order_patient_instructions'],ENT_NOQUOTES
); ?
> 
;</td
>
778 <td
> <?php
echo htmlspecialchars($row['procedure_order_activity'],ENT_NOQUOTES
); ?
> 
;</td
>
779 <td colspan
=3> <?php
echo htmlspecialchars($row['procedure_order_control_id'],ENT_NOQUOTES
); ?
> 
;</td
>
783 <!-- Procedure Report End
-->
785 <!-- Medical History Report Start
-->
787 if ( $type == 'Medical History')
790 <tr bgcolor
="#C3FDB8" align
= "left">
791 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Medical History'),ENT_NOQUOTES
);?
><b
></td
></tr
>
792 <tr bgcolor
="#C3FDB8" align
= "left">
793 <td
><b
><?php
echo htmlspecialchars(xl('History Date'),ENT_NOQUOTES
); ?
></b
></td
>
794 <td
><b
><?php
echo htmlspecialchars(xl('Tobacco'),ENT_NOQUOTES
);?
></b
></td
>
795 <td
><b
><?php
echo htmlspecialchars(xl('Alcohol'),ENT_NOQUOTES
);?
></b
></td
>
796 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Recreational Drugs'),ENT_NOQUOTES
);?
></b
></td
>
798 <tr bgcolor
="#FFFFFF">
800 $tmp_t = explode('|', $row['history_data_tobacco']);
801 $tmp_a = explode('|', $row['history_data_alcohol']);
802 $tmp_d = explode('|', $row['history_data_recreational_drugs']);
803 $his_tobac = generate_display_field(array('data_type'=>'1','list_id'=>'smoking_status'), $tmp_t[3]) ;
805 <td
> <?php
echo htmlspecialchars(oeFormatShortDate($row['history_data_date']),ENT_NOQUOTES
); ?
> 
;</td
>
807 //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
808 if(!empty($smoke_codes_arr[$tmp_t[3]])){
809 $his_tobac.= " ( ".$smoke_codes_arr[$tmp_t[3]]." )";
811 echo htmlspecialchars($his_tobac,ENT_NOQUOTES
); ?
> 
;</td
>
813 if ($tmp_a[1] == "currentalcohol") $res = xl('Current Alcohol');
814 if ($tmp_a[1] == "quitalcohol") $res = xl('Quit Alcohol');
815 if ($tmp_a[1] == "neveralcohol") $res = xl('Never Alcohol');
816 if ($tmp_a[1] == "not_applicablealcohol") $res = xl('N/A');
818 <td
> <?php
echo htmlspecialchars($res,ENT_NOQUOTES
); ?
> 
;</td
>
820 if ($tmp_d[1] == "currentrecreational_drugs") $resd = xl('Current Recreational Drugs');
821 if ($tmp_d[1] == "quitrecreational_drugs") $resd = xl('Quit');
822 if ($tmp_d[1] == "neverrecreational_drugs") $resd = xl('Never');
823 if ($tmp_d[1] == "not_applicablerecreational_drugs") $resd = xl('N/A');
825 <td colspan
=8> <?php
echo htmlspecialchars($resd,ENT_NOQUOTES
); ?
> 
;</td
>
828 <!-- Medical History Report End
-->
830 <!-- Service Codes Report Start
-->
832 if ( $type == 'Service Codes') {
834 <tr bgcolor
="#C3FDB8" align
= "left">
835 <td colspan
=11><b
><?php
echo "#"; echo htmlspecialchars(xl('Service Codes'),ENT_NOQUOTES
);?
><b
></td
></tr
>
836 <tr bgcolor
="#C3FDB8" align
= "left">
837 <td
><b
><?php
echo htmlspecialchars(xl('Date'),ENT_NOQUOTES
); ?
></b
></td
>
838 <td
><b
><?php
echo htmlspecialchars(xl('Code'),ENT_NOQUOTES
);?
></b
></td
>
839 <td
><b
><?php
echo htmlspecialchars(xl('Encounter ID'),ENT_NOQUOTES
);?
></b
></td
>
840 <td colspan
=8><b
><?php
echo htmlspecialchars(xl('Code Text'),ENT_NOQUOTES
);?
></b
></td
></tr
>
841 <tr bgcolor
="#FFFFFF">
842 <td
><?php
echo htmlspecialchars(oeFormatShortDate($row['date']),ENT_NOQUOTES
); ?
> 
;</td
>
843 <td
><?php
echo htmlspecialchars($row['code'],ENT_NOQUOTES
); ?
> 
;</td
>
844 <td
><?php
echo htmlspecialchars($row['encounter'],ENT_NOQUOTES
); ?
> 
;</td
>
845 <td colspan
=8><?php
echo htmlspecialchars($row['code_text'],ENT_NOQUOTES
); ?
> 
;</td
>
848 <!-- Service Codes Report End
-->
850 <!-- Immunization Report Start
-->
852 if(strlen($form_immunization) > 0){?
>
853 <tr bgcolor
="#C3FDB8" align
= "left">
854 <td colspan
=12><b
><?php
echo "#"; echo htmlspecialchars(xl('Immunization Report'),ENT_NOQUOTES
);?
></b
></td
>
856 <tr bgcolor
="#C3FDB8" align
= "left">
857 <td
><b
><?php
echo htmlspecialchars(xl('Immunization Date'),ENT_NOQUOTES
);?
></b
></td
>
858 <td
><b
><?php
echo htmlspecialchars(xl('CVX Code'),ENT_NOQUOTES
);?
></b
></td
>
859 <td
><b
><?php
echo htmlspecialchars(xl('Vaccine'),ENT_NOQUOTES
);?
></b
></td
>
860 <td
><b
><?php
echo htmlspecialchars(xl('Amount'),ENT_NOQUOTES
);?
></b
></td
>
861 <td
><b
><?php
echo htmlspecialchars(xl('Administered Site'),ENT_NOQUOTES
);?
></b
></td
>
862 <td colspan
="7"><b
><?php
echo htmlspecialchars(xl('Notes'),ENT_NOQUOTES
);?
></b
></td
>
864 <tr bgcolor
="#FFFFFF">
865 <td
><?php
echo htmlspecialchars($row['imm_date'],ENT_NOQUOTES
); ?
> 
;</td
>
866 <td
><?php
echo htmlspecialchars($row['cvx_code'],ENT_NOQUOTES
); ?
> 
;</td
>
867 <td
><?php
echo htmlspecialchars($row['imm_code_short'],ENT_NOQUOTES
)." (".htmlspecialchars($row['imm_code']).")"; ?
> 
;</td
>
870 if ($row["amount_administered"] > 0) {
871 echo htmlspecialchars( $row["amount_administered"] . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']) , ENT_NOQUOTES
);
880 <?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']); ?
>
884 <?php
echo htmlspecialchars($row['notes']); ?
>
888 <!-- Immunization Report End
-->
890 <?php
} //while loop end ?>
891 </table
> <!-- Main table ends
-->
894 } //End if form_refresh
897 ?
><div
class='text'> <?php
echo htmlspecialchars(xl('Please input search criteria above, and click Submit to view results.'),ENT_NOQUOTES
); ?
> </div
><?php
903 <!-- stuff
for the popup calendar
-->
904 <style type
="text/css">
905 @import
url(../../library
/dynarch_calendar
.css
);
907 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
908 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
909 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
910 <script language
="Javascript">
911 Calendar
.setup({inputField
:"date_from", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_from_date", showsTime
:true});
912 Calendar
.setup({inputField
:"date_to", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_to_date", showsTime
:true});