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_download" value
="<?php echo htmlspecialchars( xl('Download', ENT_QUOTES)); ?>" />
120 <!-- <input type
="button" class="viewCCD_raw" value
="<?php xl('Raw Report','e'); ?>" /> -->
121 <?php
if ($GLOBALS['phimail_enable']==true) { ?
>
122 <input type
="button" class="viewCCD_send_dialog" value
="<?php echo htmlspecialchars( xl('Transmit', ENT_QUOTES)); ?>" />
124 <div id
="ccd_send_dialog" style
="display:none" >
126 <table border
="0" cellpadding
="0" cellspacing
="0" >
129 <span
class='bold'><?php
echo htmlspecialchars( xl('Enter Recipient\'s Direct Address'), ENT_NOQUOTES
);?
>: </span
>
130 <input type
="text" size
="64" name
="ccd_send_to" id
="ccd_send_to" value
="">
131 <input type
="hidden" name
="ccd_sent_by" id
="ccd_sent_by" value
="user">
132 <input type
="button" class="viewCCD_transmit" value
="<?php echo htmlspecialchars( xl('Send', ENT_QUOTES)); ?>" />
133 <div id
="ccd_send_result" style
="display:none" >
134 <span
class="text" id
="ccd_send_message"></span
>
147 <?php
} // end CCR/CCD reporting options ?>
149 <form name
='report_form' id
="report_form" method
='post' action
='custom_report.php'>
152 <span
class='title'><?php
xl('Patient Report','e'); ?
></span
> 
; 
;
155 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
156 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
158 <a
class="link_submit" href
="#" onclick
="return checkAll(true)"><?php
xl('Check All','e'); ?
></a
>
160 <a
class="link_submit" href
="#" onclick
="return checkAll(false)"><?php
xl('Clear All','e'); ?
></a
>
163 <table
class="includes">
166 <input type
='checkbox' name
='include_demographics' id
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
167 <?php
if (acl_check('patients', 'med')): ?
>
168 <input type
='checkbox' name
='include_history' id
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
171 <input type
='checkbox' name
='include_employer' id
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
173 <input type
='checkbox' name
='include_insurance' id
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
174 <input type
='checkbox' name
='include_billing' id
='include_billing' value
="billing"
175 <?php
if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?
>><?php
xl('Billing','e'); ?
><br
>
179 <input type
='checkbox' name
='include_allergies' id
='include_allergies' value
="allergies">Allergies
<br
>
180 <input type
='checkbox' name
='include_medications' id
='include_medications' value
="medications">Medications
<br
>
182 <input type
='checkbox' name
='include_immunizations' id
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
184 <input type
='checkbox' name
='include_medical_problems' id
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
186 <input type
='checkbox' name
='include_notes' id
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
187 <input type
='checkbox' name
='include_transactions' id
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
188 <input type
='checkbox' name
='include_batchcom' id
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
194 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" /> 
;
195 <input type
="button" class="genpdfrep" value
="<?php xl('Download PDF','e'); ?>" />
196 <input type
='hidden' name
='pdf' value
='0'>
199 <!-- old ccr button position
-->
202 <table
class="issues_encounters_forms">
208 <span
class='bold'><?php
xl('Issues','e'); ?
>:</span
>
212 <?php
if (! acl_check('patients', 'med')): ?
>
213 <br
>(Issues not authorized
)
220 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
221 "ORDER BY type, begdate");
223 while ($prow = sqlFetchArray($pres)) {
224 if ($lasttype != $prow['type']) {
225 $lasttype = $prow['type'];
228 $disptype = $lasttype;
230 case "allergy" : $disptype = "Allergies" ; break;
232 case "medical_problem": $disptype = "Medical Problems"; break;
233 case "medication" : $disptype = "Medications" ; break;
234 case "surgery" : $disptype = "Surgeries" ; break;
237 $disptype = $ISSUE_TYPES[$lasttype][0];
240 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
243 $rowid = $prow['id'];
244 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
246 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
247 "pid = '$pid' AND list_id = '$rowid'");
249 echo " <tr class='text'>\n";
250 echo " <td> </td>\n";
252 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
253 while ($ierow = sqlFetchArray($ieres)) {
254 echo $ierow['encounter'] . "/";
256 echo "' />$disptitle</td>\n";
257 echo " <td>" . $prow['begdate'];
259 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
260 else { echo " Active"; }
268 <?php
endif; // end of Issues output ?>
270 </div
> <!-- end issues DIV
-->
273 <!-- Encounters
and Forms
-->
276 <div
class='encounters'>
277 <span
class='bold'><?php
xl('Encounters & Forms','e'); ?
>:</span
>
280 <?php
if (!($auth_notes_a ||
$auth_notes ||
$auth_coding_a ||
$auth_coding ||
$auth_med ||
$auth_relaxed)): ?
>
281 (Encounters not authorized
)
287 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
288 "forms.formdir, forms.date AS fdate, form_encounter.date " .
289 ",form_encounter.reason ".
290 "FROM forms, form_encounter WHERE " .
291 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
292 "form_encounter.encounter = forms.encounter " .
293 " AND forms.deleted=0 ". // --JRM--
294 "ORDER BY form_encounter.date DESC, fdate ASC");
295 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
296 $html_strings = array();
297 $registry_form_name = array();
298 while($result2 = sqlFetchArray($res2)) {
299 array_push($registry_form_name,trim($result2['name']));
301 while($result = sqlFetchArray($res)) {
302 if ($result{"form_name"} == "New Patient Encounter") {
304 foreach($registry_form_name as $var) {
305 if ($toprint = $html_strings[$var]) {
306 foreach($toprint as $var) {print $var;}
309 $html_strings = array();
310 echo "</div>\n"; // end DIV encounter_forms
311 echo "</div>\n\n"; //end DIV encounter_data
315 echo "<div class='encounter_data'>\n";
316 echo "<input type=checkbox ".
317 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
318 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
319 " value='" . $result{"encounter"} . "'" .
320 " class='encounter'".
323 // show encounter reason, not just 'New Encounter'
324 // trim to a reasonable length for display purposes --cfapress
325 $maxReasonLength = 20;
326 if (strlen($result["reason"]) > $maxReasonLength) {
327 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
330 echo $result{"reason"}.
331 " (" . date("Y-m-d",strtotime($result{"date"})) .
333 echo "<div class='encounter_forms'>\n";
336 $form_name = trim($result{"form_name"});
337 //if form name is not in registry, look for the closest match by
338 // finding a registry name which is at the start of the form name.
339 //this is to allow for forms to put additional helpful information
340 //in the database in the same string as their form name after the name
341 $form_name_found_flag = 0;
342 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
343 // if the form does not match precisely with any names in the registry, now see if any front partial matches
344 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
345 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
347 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
348 array_push($html_strings[$form_name], "<input type='checkbox' ".
349 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
350 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
351 " value='" . $result{"encounter"} . "'" .
352 " class='encounter_form' ".
353 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
356 foreach($registry_form_name as $var) {
357 if ($toprint = $html_strings[$var]) {
358 foreach($toprint as $var) {print $var;}
365 </div
> <!-- end encounters DIV
-->
369 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" /> 
;
370 <input type
="button" class="genpdfrep" value
="<?php xl('Download PDF','e'); ?>" />
374 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
377 // show available documents
378 $db = $GLOBALS['adodb']['db'];
379 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
380 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
381 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
382 "d.foreign_id = " . $db->qstr($pid);
383 $result = $db->Execute($sql);
384 if ($db->ErrorMsg()) echo $db->ErrorMsg();
385 while ($result && !$result->EOF
) {
386 echo "<li class='bold'>";
387 echo '<input type="checkbox" name="documents[]" value="' .
388 $result->fields
['id'] . '">';
389 echo ' <i>' . xl_document_category($result->fields
['name']) . "</i>";
390 echo ' ' . xl('Name') . ': <i>' . basename($result->fields
['url']) . "</i>";
398 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" /> 
;
399 <input type
="button" class="genpdfrep" value
="<?php xl('Download PDF','e'); ?>" />
401 </div
> <!-- close patient_reports DIV
-->
404 <script language
="javascript">
406 // jQuery stuff to make the page a little easier to use
407 $
(document
).ready(function(){
408 $
(".genreport").click(function() { top
.restoreSession(); document
.report_form
.pdf
.value
= 0; $
("#report_form").submit(); });
409 $
(".genpdfrep").click(function() { top
.restoreSession(); document
.report_form
.pdf
.value
= 1; $
("#report_form").submit(); });
410 $
("#genfullreport").click(function() { location
.href
='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
411 //$("#printform").click(function() { PrintForm(); });
412 $
(".issuecheckbox").click(function() { issueClick(this
); });
414 // check/uncheck all Forms of an encounter
415 $
(".encounter").click(function() { SelectForms($
(this
)); });
417 $
(".generateCCR").click(
419 if(document
.getElementById('show_date').checked
== true){
420 if(document
.getElementById('Start').value
== '' || document
.getElementById('End').value
== ''){
421 alert('<?php echo addslashes( xl('Please select a start date
and end date
')) ?>');
425 var ccrAction
= document
.getElementsByName('ccrAction');
426 ccrAction
[0].value
= 'generate';
427 var raw
= document
.getElementsByName('raw');
429 top
.restoreSession();
430 ccr_form
.setAttribute("target", "_blank");
431 $
("#ccr_form").submit();
432 ccr_form
.setAttribute("target", "");
434 $
(".generateCCR_raw").click(
436 var ccrAction
= document
.getElementsByName('ccrAction');
437 ccrAction
[0].value
= 'generate';
438 var raw
= document
.getElementsByName('raw');
439 raw
[0].value
= 'yes';
440 top
.restoreSession();
441 ccr_form
.setAttribute("target", "_blank");
442 $
("#ccr_form").submit();
443 ccr_form
.setAttribute("target", "");
445 $
(".generateCCR_download_h").click(
447 var ccrAction
= document
.getElementsByName('ccrAction');
448 ccrAction
[0].value
= 'generate';
449 var raw
= document
.getElementsByName('raw');
450 raw
[0].value
= 'hybrid';
451 top
.restoreSession();
452 $
("#ccr_form").submit();
454 $
(".generateCCR_download_p").click(
456 if(document
.getElementById('show_date').checked
== true){
457 if(document
.getElementById('Start').value
== '' || document
.getElementById('End').value
== ''){
458 alert('<?php echo addslashes( xl('Please select a start date
and end date
')) ?>');
462 var ccrAction
= document
.getElementsByName('ccrAction');
463 ccrAction
[0].value
= 'generate';
464 var raw
= document
.getElementsByName('raw');
465 raw
[0].value
= 'pure';
466 top
.restoreSession();
467 $
("#ccr_form").submit();
471 var ccrAction
= document
.getElementsByName('ccrAction');
472 ccrAction
[0].value
= 'viewccd';
473 var raw
= document
.getElementsByName('raw');
475 top
.restoreSession();
476 ccr_form
.setAttribute("target", "_blank");
477 $
("#ccr_form").submit();
478 ccr_form
.setAttribute("target", "");
480 $
(".viewCCD_raw").click(
482 var ccrAction
= document
.getElementsByName('ccrAction');
483 ccrAction
[0].value
= 'viewccd';
484 var raw
= document
.getElementsByName('raw');
485 raw
[0].value
= 'yes';
486 top
.restoreSession();
487 ccr_form
.setAttribute("target", "_blank");
488 $
("#ccr_form").submit();
489 ccr_form
.setAttribute("target", "");
491 $
(".viewCCD_download").click(
493 var ccrAction
= document
.getElementsByName('ccrAction');
494 ccrAction
[0].value
= 'viewccd';
495 var raw
= document
.getElementsByName('raw');
496 raw
[0].value
= 'pure';
497 $
("#ccr_form").submit();
499 <?php
if ($GLOBALS['phimail_enable']==true) { ?
>
500 $
(".viewCCD_send_dialog").click(
502 $
("#ccd_send_dialog").toggle();
504 $
(".viewCCD_transmit").click(
506 $
(".viewCCD_transmit").attr('disabled','disabled');
507 var ccrAction
= document
.getElementsByName('ccrAction');
508 ccrAction
[0].value
= 'viewccd';
509 var ccdRecipient
= $
("#ccd_send_to").val();
510 var raw
= document
.getElementsByName('raw');
511 raw
[0].value
= 'send '+ccdRecipient
;
512 if(ccdRecipient
=="") {
513 $
("#ccd_send_message").html("<?php
514 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
515 $
("#ccd_send_result").show();
517 $
(".viewCCD_transmit").attr('disabled','disabled');
518 $
("#ccd_send_message").html("<?php
519 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
520 $
("#ccd_send_result").show();
521 var action
=$
("#ccr_form").attr('action');
522 $
.post(action
, {ccrAction
:'viewccd',raw
:'send '+ccdRecipient
,requested_by
:'user'},
524 if(data
=="SUCCESS") {
525 $
("#ccd_send_message").html("<?php
526 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
528 $
("#ccd_send_to").val("");
530 $
("#ccd_send_message").html(data
);
532 $
(".viewCCD_transmit").removeAttr('disabled');
540 // select/deselect the Forms related to the selected Encounter
541 // (it ain't pretty code folks)
542 var SelectForms
= function (selectedEncounter
) {
543 if ($
(selectedEncounter
).attr("checked")) {
544 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
545 $
(this
).children().each(function(i
, obj
) {
546 $
(this
).attr("checked", "checked");
551 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
552 $
(this
).children().each(function(i
, obj
) {
553 $
(this
).removeAttr("checked");
559 // When an issue is checked, auto-check all the related encounters and forms
560 function issueClick(issue
) {
561 // do nothing when unchecked
562 if (! $
(issue
).attr("checked")) return;
564 $
("#report_form :checkbox").each(function(i
, obj
) {
565 if ($
(issue
).val().indexOf('/' + $
(this
).val() +
'/') >= 0) {
566 $
(this
).attr("checked", "checked");