3 include_once("../../globals.php");
4 include_once("$srcdir/lists.inc");
5 include_once("$srcdir/acl.inc");
6 include_once("$srcdir/forms.inc");
8 // get various authorization levels
9 $auth_notes_a = acl_check('encounters', 'notes_a');
10 $auth_notes = acl_check('encounters', 'notes');
11 $auth_coding_a = acl_check('encounters', 'coding_a');
12 $auth_coding = acl_check('encounters', 'coding');
13 $auth_relaxed = acl_check('encounters', 'relaxed');
14 $auth_med = acl_check('patients' , 'med');
15 $auth_demo = acl_check('patients' , 'demo');
20 <?php
html_header_show();?
>
22 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
23 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
24 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
25 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
26 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
27 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
29 <!-- include jQuery support
-->
30 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
32 <script language
='JavaScript'>
34 function checkAll(check
) {
35 var f
= document
.forms
['report_form'];
36 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
37 if (f
.elements
[i
].type
== 'checkbox') f
.elements
[i
].checked
= check
;
42 function show_date_fun(){
43 if(document
.getElementById('show_date').checked
== true){
44 document
.getElementById('date_div').style
.display
= '';
46 document
.getElementById('date_div').style
.display
= 'none';
55 <body
class="body_top">
56 <div id
="patient_reports"> <!-- large outer DIV
-->
58 <?php
if ( $GLOBALS['activate_ccr_ccd_report'] ) { // show CCR/CCD reporting options ?>
61 <form name
='ccr_form' id
='ccr_form' method
='post' action
='../../../ccr/createCCR.php'>
62 <span
class='title'><?php
xl('Continuity of Care Record (CCR)','e'); ?
></span
> 
; 
;
64 <span
class='text'>(<?php
xl('Pop ups need to be enabled to see these reports','e'); ?
>)</span
>
67 <input type
='hidden' name
='ccrAction'>
68 <input type
='hidden' name
='raw'>
69 <input type
="checkbox" name
="show_date" id
="show_date" onchange
="show_date_fun();" ><span
class='text'><?php
xl('Use Date Range','e'); ?
>
71 <div id
="date_div" style
="display:none" >
73 <table border
="0" cellpadding
="0" cellspacing
="0" >
76 <span
class='bold'><?php
xl('Start Date','e');?
>: </span
>
79 <input type
='text' size
='10' name
='Start' id
='Start'
80 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
81 title
='<?php xl('yyyy
-mm
-dd
','e
'); ?>' />
82 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
83 id
='img_start' border
='0' alt
='[?]' style
='cursor:pointer'
84 title
='<?php xl('Click here to choose a date
','e
'); ?>' >
85 <script LANGUAGE
="JavaScript">
86 Calendar
.setup({inputField
:"Start", ifFormat
:"%Y-%m-%d", button
:"img_start"});
91 <span
class='bold'><?php
xl('End Date','e');?
>: </span
>
94 <input type
='text' size
='10' name
='End' id
='End'
95 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
96 title
='<?php xl('yyyy
-mm
-dd
','e
'); ?>' />
97 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
98 id
='img_end' border
='0' alt
='[?]' style
='cursor:pointer'
99 title
='<?php xl('Click here to choose a date
','e
'); ?>' >
100 <script LANGUAGE
="JavaScript">
101 Calendar
.setup({inputField
:"End", ifFormat
:"%Y-%m-%d", button
:"img_end"});
108 <input type
="button" class="generateCCR" value
="<?php xl('View/Print','e'); ?>" />
109 <!-- <input type
="button" class="generateCCR_download_h" value
="<?php echo xl('Download')." (Hybrid
)"; ?>" /> -->
110 <input type
="button" class="generateCCR_download_p" value
="<?php echo xl('Download'); ?>" />
111 <!-- <input type
="button" class="generateCCR_raw" value
="<?php xl('Raw Report','e'); ?>" /> -->
113 <span
class='title'><?php
xl('Continuity of Care Document (CCD)','e'); ?
></span
> 
; 
;
115 <span
class='text'>(<?php
xl('Pop ups need to be enabled to see these reports','e'); ?
>)</span
>
118 <input type
="button" class="viewCCD" value
="<?php xl('View/Print','e'); ?>" />
119 <!-- <input type
="button" class="viewCCD_raw" value
="<?php xl('Raw Report','e'); ?>" /> -->
126 <?php
} // end CCR/CCD reporting options ?>
128 <form name
='report_form' id
="report_form" method
='post' action
='custom_report.php'>
131 <span
class='title'><?php
xl('Patient Report','e'); ?
></span
> 
; 
;
134 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
135 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
137 <a
class="link_submit" href
="#" onclick
="return checkAll(true)"><?php
xl('Check All','e'); ?
></a
>
139 <a
class="link_submit" href
="#" onclick
="return checkAll(false)"><?php
xl('Clear All','e'); ?
></a
>
142 <table
class="includes">
145 <input type
='checkbox' name
='include_demographics' id
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
146 <?php
if (acl_check('patients', 'med')): ?
>
147 <input type
='checkbox' name
='include_history' id
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
150 <input type
='checkbox' name
='include_employer' id
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
152 <input type
='checkbox' name
='include_insurance' id
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
153 <input type
='checkbox' name
='include_billing' id
='include_billing' value
="billing"
154 <?php
if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?
>><?php
xl('Billing','e'); ?
><br
>
158 <input type
='checkbox' name
='include_allergies' id
='include_allergies' value
="allergies">Allergies
<br
>
159 <input type
='checkbox' name
='include_medications' id
='include_medications' value
="medications">Medications
<br
>
161 <input type
='checkbox' name
='include_immunizations' id
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
163 <input type
='checkbox' name
='include_medical_problems' id
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
165 <input type
='checkbox' name
='include_notes' id
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
166 <input type
='checkbox' name
='include_transactions' id
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
167 <input type
='checkbox' name
='include_batchcom' id
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
173 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
176 <!-- old ccr button position
-->
179 <table
class="issues_encounters_forms">
185 <span
class='bold'><?php
xl('Issues','e'); ?
>:</span
>
189 <?php
if (! acl_check('patients', 'med')): ?
>
190 <br
>(Issues not authorized
)
197 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
198 "ORDER BY type, begdate");
200 while ($prow = sqlFetchArray($pres)) {
201 if ($lasttype != $prow['type']) {
202 $lasttype = $prow['type'];
205 $disptype = $lasttype;
207 case "allergy" : $disptype = "Allergies" ; break;
209 case "medical_problem": $disptype = "Medical Problems"; break;
210 case "medication" : $disptype = "Medications" ; break;
211 case "surgery" : $disptype = "Surgeries" ; break;
214 $disptype = $ISSUE_TYPES[$lasttype][0];
217 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
220 $rowid = $prow['id'];
221 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
223 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
224 "pid = '$pid' AND list_id = '$rowid'");
226 echo " <tr class='text'>\n";
227 echo " <td> </td>\n";
229 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
230 while ($ierow = sqlFetchArray($ieres)) {
231 echo $ierow['encounter'] . "/";
233 echo "' />$disptitle</td>\n";
234 echo " <td>" . $prow['begdate'];
236 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
237 else { echo " Active"; }
245 <?php
endif; // end of Issues output ?>
247 </div
> <!-- end issues DIV
-->
250 <!-- Encounters
and Forms
-->
253 <div
class='encounters'>
254 <span
class='bold'><?php
xl('Encounters & Forms','e'); ?
>:</span
>
257 <?php
if (!($auth_notes_a ||
$auth_notes ||
$auth_coding_a ||
$auth_coding ||
$auth_med ||
$auth_relaxed)): ?
>
258 (Encounters not authorized
)
264 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
265 "forms.formdir, forms.date AS fdate, form_encounter.date " .
266 ",form_encounter.reason ".
267 "FROM forms, form_encounter WHERE " .
268 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
269 "form_encounter.encounter = forms.encounter " .
270 " AND forms.deleted=0 ". // --JRM--
271 "ORDER BY form_encounter.date DESC, fdate ASC");
272 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
273 $html_strings = array();
274 $registry_form_name = array();
275 while($result2 = sqlFetchArray($res2)) {
276 array_push($registry_form_name,trim($result2['name']));
278 while($result = sqlFetchArray($res)) {
279 if ($result{"form_name"} == "New Patient Encounter") {
281 foreach($registry_form_name as $var) {
282 if ($toprint = $html_strings[$var]) {
283 foreach($toprint as $var) {print $var;}
286 $html_strings = array();
287 echo "</div>\n"; // end DIV encounter_forms
288 echo "</div>\n\n"; //end DIV encounter_data
292 echo "<div class='encounter_data'>\n";
293 echo "<input type=checkbox ".
294 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
295 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
296 " value='" . $result{"encounter"} . "'" .
297 " class='encounter'".
300 // show encounter reason, not just 'New Encounter'
301 // trim to a reasonable length for display purposes --cfapress
302 $maxReasonLength = 20;
303 if (strlen($result["reason"]) > $maxReasonLength) {
304 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
307 echo $result{"reason"}.
308 " (" . date("Y-m-d",strtotime($result{"date"})) .
310 echo "<div class='encounter_forms'>\n";
313 $form_name = trim($result{"form_name"});
314 //if form name is not in registry, look for the closest match by
315 // finding a registry name which is at the start of the form name.
316 //this is to allow for forms to put additional helpful information
317 //in the database in the same string as their form name after the name
318 $form_name_found_flag = 0;
319 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
320 // if the form does not match precisely with any names in the registry, now see if any front partial matches
321 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
322 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
324 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
325 array_push($html_strings[$form_name], "<input type='checkbox' ".
326 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
327 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
328 " value='" . $result{"encounter"} . "'" .
329 " class='encounter_form' ".
330 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
333 foreach($registry_form_name as $var) {
334 if ($toprint = $html_strings[$var]) {
335 foreach($toprint as $var) {print $var;}
342 </div
> <!-- end encounters DIV
-->
346 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
350 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
353 // show available documents
354 $db = $GLOBALS['adodb']['db'];
355 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
356 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
357 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
358 "d.foreign_id = " . $db->qstr($pid);
359 $result = $db->Execute($sql);
360 if ($db->ErrorMsg()) echo $db->ErrorMsg();
361 while ($result && !$result->EOF
) {
362 echo "<li class='bold'>";
363 echo '<input type="checkbox" name="documents[]" value="' .
364 $result->fields
['id'] . '">';
365 echo ' <i>' . xl_document_category($result->fields
['name']) . "</i>";
366 echo ' ' . xl('Name') . ': <i>' . basename($result->fields
['url']) . "</i>";
374 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
376 </div
> <!-- close patient_reports DIV
-->
379 <script language
="javascript">
381 // jQuery stuff to make the page a little easier to use
382 $
(document
).ready(function(){
383 $
(".genreport").click(function() { top
.restoreSession(); $
("#report_form").submit(); });
384 $
("#genfullreport").click(function() { location
.href
='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
385 //$("#printform").click(function() { PrintForm(); });
386 $
(".issuecheckbox").click(function() { issueClick(this
); });
388 // check/uncheck all Forms of an encounter
389 $
(".encounter").click(function() { SelectForms($
(this
)); });
391 $
(".generateCCR").click(
393 if(document
.getElementById('show_date').checked
== true){
394 if(document
.getElementById('Start').value
== '' || document
.getElementById('End').value
== ''){
395 alert('<?php echo addslashes( xl('Please select a start date
and end date
')) ?>');
399 var ccrAction
= document
.getElementsByName('ccrAction');
400 ccrAction
[0].value
= 'generate';
401 var raw
= document
.getElementsByName('raw');
403 top
.restoreSession();
404 ccr_form
.setAttribute("target", "_blank");
405 $
("#ccr_form").submit();
406 ccr_form
.setAttribute("target", "");
408 $
(".generateCCR_raw").click(
410 var ccrAction
= document
.getElementsByName('ccrAction');
411 ccrAction
[0].value
= 'generate';
412 var raw
= document
.getElementsByName('raw');
413 raw
[0].value
= 'yes';
414 top
.restoreSession();
415 ccr_form
.setAttribute("target", "_blank");
416 $
("#ccr_form").submit();
417 ccr_form
.setAttribute("target", "");
419 $
(".generateCCR_download_h").click(
421 var ccrAction
= document
.getElementsByName('ccrAction');
422 ccrAction
[0].value
= 'generate';
423 var raw
= document
.getElementsByName('raw');
424 raw
[0].value
= 'hybrid';
425 top
.restoreSession();
426 $
("#ccr_form").submit();
428 $
(".generateCCR_download_p").click(
430 if(document
.getElementById('show_date').checked
== true){
431 if(document
.getElementById('Start').value
== '' || document
.getElementById('End').value
== ''){
432 alert('<?php echo addslashes( xl('Please select a start date
and end date
')) ?>');
436 var ccrAction
= document
.getElementsByName('ccrAction');
437 ccrAction
[0].value
= 'generate';
438 var raw
= document
.getElementsByName('raw');
439 raw
[0].value
= 'pure';
440 top
.restoreSession();
441 $
("#ccr_form").submit();
445 var ccrAction
= document
.getElementsByName('ccrAction');
446 ccrAction
[0].value
= 'viewccd';
447 var raw
= document
.getElementsByName('raw');
449 top
.restoreSession();
450 ccr_form
.setAttribute("target", "_blank");
451 $
("#ccr_form").submit();
452 ccr_form
.setAttribute("target", "");
454 $
(".viewCCD_raw").click(
456 var ccrAction
= document
.getElementsByName('ccrAction');
457 ccrAction
[0].value
= 'viewccd';
458 var raw
= document
.getElementsByName('raw');
459 raw
[0].value
= 'yes';
460 top
.restoreSession();
461 ccr_form
.setAttribute("target", "_blank");
462 $
("#ccr_form").submit();
463 ccr_form
.setAttribute("target", "");
467 // select/deselect the Forms related to the selected Encounter
468 // (it ain't pretty code folks)
469 var SelectForms
= function (selectedEncounter
) {
470 if ($
(selectedEncounter
).attr("checked")) {
471 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
472 $
(this
).children().each(function(i
, obj
) {
473 $
(this
).attr("checked", "checked");
478 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
479 $
(this
).children().each(function(i
, obj
) {
480 $
(this
).removeAttr("checked");
486 // When an issue is checked, auto-check all the related encounters and forms
487 function issueClick(issue
) {
488 // do nothing when unchecked
489 if (! $
(issue
).attr("checked")) return;
491 $
("#report_form :checkbox").each(function(i
, obj
) {
492 if ($
(issue
).val().indexOf('/' + $
(this
).val() +
'/') >= 0) {
493 $
(this
).attr("checked", "checked");