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">
24 <!-- include jQuery support
-->
25 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
27 <script language
='JavaScript'>
29 function checkAll(check
) {
30 var f
= document
.forms
['report_form'];
31 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
32 if (f
.elements
[i
].type
== 'checkbox') f
.elements
[i
].checked
= check
;
41 <body
class="body_top">
42 <div id
="patient_reports"> <!-- large outer DIV
-->
44 <?php
if ( $GLOBALS['activate_ccr_ccd_report'] ) { // show CCR/CCD reporting options ?>
46 <!-- Disabled CCR
/CCD reporting in production release until functional
49 <form name
='ccr_form' id
='ccr_form' method
='post' action
='../../../ccr/createCCR.php'>
50 <span
class='title'><?php
xl('Continuity of Care Record (CCR)','e'); ?
></span
> 
; 
;
52 <input type
='hidden' name
='ccrAction'>
53 <input type
='hidden' name
='raw'>
54 <input type
="button" class="generateCCR" value
="<?php xl('Formatted Report','e'); ?>" />
55 <input type
="button" class="generateCCR_raw" value
="<?php xl('Raw Report','e'); ?>" />
57 <span
class='title'><?php
xl('Continuity of Care Document (CCD)','e'); ?
></span
> 
; 
;
59 <input type
="button" class="viewCCD" value
="<?php xl('Formatted Report','e'); ?>" />
60 <input type
="button" class="viewCCD_raw" value
="<?php xl('Raw Report','e'); ?>" />
66 Disabled CCR
/CCD reporting in production release until functional
-->
68 <?php
} // end CCR/CCD reporting options ?>
70 <form name
='report_form' id
="report_form" method
='post' action
='custom_report.php'>
73 <span
class='title'><?php
xl('Patient Report','e'); ?
></span
> 
; 
;
76 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
77 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
79 <a
class="link_submit" href
="#" onclick
="return checkAll(true)"><?php
xl('Check All','e'); ?
></a
>
81 <a
class="link_submit" href
="#" onclick
="return checkAll(false)"><?php
xl('Clear All','e'); ?
></a
>
84 <table
class="includes">
87 <input type
='checkbox' name
='include_demographics' id
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
88 <?php
if (acl_check('patients', 'med')): ?
>
89 <input type
='checkbox' name
='include_history' id
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
92 <input type
='checkbox' name
='include_employer' id
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
94 <input type
='checkbox' name
='include_insurance' id
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
95 <input type
='checkbox' name
='include_billing' id
='include_billing' value
="billing"
96 <?php
if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?
>><?php
xl('Billing','e'); ?
><br
>
100 <input type
='checkbox' name
='include_allergies' id
='include_allergies' value
="allergies">Allergies
<br
>
101 <input type
='checkbox' name
='include_medications' id
='include_medications' value
="medications">Medications
<br
>
103 <input type
='checkbox' name
='include_immunizations' id
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
105 <input type
='checkbox' name
='include_medical_problems' id
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
107 <input type
='checkbox' name
='include_notes' id
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
108 <input type
='checkbox' name
='include_transactions' id
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
109 <input type
='checkbox' name
='include_batchcom' id
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
115 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
118 <!-- old ccr button position
-->
121 <table
class="issues_encounters_forms">
127 <span
class='bold'><?php
xl('Issues','e'); ?
>:</span
>
131 <?php
if (! acl_check('patients', 'med')): ?
>
132 <br
>(Issues not authorized
)
139 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
140 "ORDER BY type, begdate");
142 while ($prow = sqlFetchArray($pres)) {
143 if ($lasttype != $prow['type']) {
144 $lasttype = $prow['type'];
147 $disptype = $lasttype;
149 case "allergy" : $disptype = "Allergies" ; break;
151 case "medical_problem": $disptype = "Medical Problems"; break;
152 case "medication" : $disptype = "Medications" ; break;
153 case "surgery" : $disptype = "Surgeries" ; break;
156 $disptype = $ISSUE_TYPES[$lasttype][0];
159 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
162 $rowid = $prow['id'];
163 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
165 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
166 "pid = '$pid' AND list_id = '$rowid'");
168 echo " <tr class='text'>\n";
169 echo " <td> </td>\n";
171 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
172 while ($ierow = sqlFetchArray($ieres)) {
173 echo $ierow['encounter'] . "/";
175 echo "' />$disptitle</td>\n";
176 echo " <td>" . $prow['begdate'];
178 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
179 else { echo " Active"; }
187 <?php
endif; // end of Issues output ?>
189 </div
> <!-- end issues DIV
-->
192 <!-- Encounters
and Forms
-->
195 <div
class='encounters'>
196 <span
class='bold'><?php
xl('Encounters & Forms','e'); ?
>:</span
>
199 <?php
if (!($auth_notes_a ||
$auth_notes ||
$auth_coding_a ||
$auth_coding ||
$auth_med ||
$auth_relaxed)): ?
>
200 (Encounters not authorized
)
206 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
207 "forms.formdir, forms.date AS fdate, form_encounter.date " .
208 ",form_encounter.reason ".
209 "FROM forms, form_encounter WHERE " .
210 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
211 "form_encounter.encounter = forms.encounter " .
212 " AND forms.deleted=0 ". // --JRM--
213 "ORDER BY form_encounter.date DESC, fdate ASC");
214 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
215 $html_strings = array();
216 $registry_form_name = array();
217 while($result2 = sqlFetchArray($res2)) {
218 array_push($registry_form_name,trim($result2['name']));
220 while($result = sqlFetchArray($res)) {
221 if ($result{"form_name"} == "New Patient Encounter") {
223 foreach($registry_form_name as $var) {
224 if ($toprint = $html_strings[$var]) {
225 foreach($toprint as $var) {print $var;}
228 $html_strings = array();
229 echo "</div>\n"; // end DIV encounter_forms
230 echo "</div>\n\n"; //end DIV encounter_data
234 echo "<div class='encounter_data'>\n";
235 echo "<input type=checkbox ".
236 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
237 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
238 " value='" . $result{"encounter"} . "'" .
239 " class='encounter'".
242 // show encounter reason, not just 'New Encounter'
243 // trim to a reasonable length for display purposes --cfapress
244 $maxReasonLength = 20;
245 if (strlen($result["reason"]) > $maxReasonLength) {
246 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
249 echo $result{"reason"}.
250 " (" . date("Y-m-d",strtotime($result{"date"})) .
252 echo "<div class='encounter_forms'>\n";
255 $form_name = trim($result{"form_name"});
256 //if form name is not in registry, look for the closest match by
257 // finding a registry name which is at the start of the form name.
258 //this is to allow for forms to put additional helpful information
259 //in the database in the same string as their form name after the name
260 $form_name_found_flag = 0;
261 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
262 // if the form does not match precisely with any names in the registry, now see if any front partial matches
263 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
264 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
266 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
267 array_push($html_strings[$form_name], "<input type='checkbox' ".
268 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
269 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
270 " value='" . $result{"encounter"} . "'" .
271 " class='encounter_form' ".
272 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
275 foreach($registry_form_name as $var) {
276 if ($toprint = $html_strings[$var]) {
277 foreach($toprint as $var) {print $var;}
284 </div
> <!-- end encounters DIV
-->
288 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
292 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
295 // show available documents
296 $db = $GLOBALS['adodb']['db'];
297 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
298 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
299 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
300 "d.foreign_id = " . $db->qstr($pid);
301 $result = $db->Execute($sql);
302 if ($db->ErrorMsg()) echo $db->ErrorMsg();
303 while ($result && !$result->EOF
) {
304 echo "<li class='bold'>";
305 echo '<input type="checkbox" name="documents[]" value="' .
306 $result->fields
['id'] . '">';
307 echo ' <i>' . xl_document_category($result->fields
['name']) . "</i>";
308 echo ' ' . xl('Name') . ': <i>' . basename($result->fields
['url']) . "</i>";
316 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
318 </div
> <!-- close patient_reports DIV
-->
321 <script language
="javascript">
323 // jQuery stuff to make the page a little easier to use
324 $
(document
).ready(function(){
325 $
(".genreport").click(function() { top
.restoreSession(); $
("#report_form").submit(); });
326 $
("#genfullreport").click(function() { location
.href
='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
327 //$("#printform").click(function() { PrintForm(); });
328 $
(".issuecheckbox").click(function() { issueClick(this
); });
330 // check/uncheck all Forms of an encounter
331 $
(".encounter").click(function() { SelectForms($
(this
)); });
336 $
(".generateCCR").click(
338 //alert('in generateCCR');
339 var ccrAction
= document
.getElementsByName('ccrAction');
340 ccrAction
[0].value
= 'generate';
341 var raw
= document
.getElementsByName('raw');
343 top
.restoreSession();
344 $
("#ccr_form").submit();
346 $
(".generateCCR_raw").click(
348 //alert('in generateCCR');
349 var ccrAction
= document
.getElementsByName('ccrAction');
350 ccrAction
[0].value
= 'generate';
351 var raw
= document
.getElementsByName('raw');
352 raw
[0].value
= 'yes';
353 top
.restoreSession();
354 $
("#ccr_form").submit();
358 //alert('in viewCCD');
359 var ccrAction
= document
.getElementsByName('ccrAction');
360 ccrAction
[0].value
= 'viewccd';
361 var raw
= document
.getElementsByName('raw');
363 top
.restoreSession();
364 $
("#ccr_form").submit();
366 $
(".viewCCD_raw").click(
368 //alert('in viewCCD');
369 var ccrAction
= document
.getElementsByName('ccrAction');
370 ccrAction
[0].value
= 'viewccd';
371 var raw
= document
.getElementsByName('raw');
372 raw
[0].value
= 'yes';
373 top
.restoreSession();
374 $
("#ccr_form").submit();
378 // select/deselect the Forms related to the selected Encounter
379 // (it ain't pretty code folks)
380 var SelectForms
= function (selectedEncounter
) {
381 if ($
(selectedEncounter
).attr("checked")) {
382 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
383 $
(this
).children().each(function(i
, obj
) {
384 $
(this
).attr("checked", "checked");
389 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
390 $
(this
).children().each(function(i
, obj
) {
391 $
(this
).removeAttr("checked");
397 // When an issue is checked, auto-check all the related encounters and forms
398 function issueClick(issue
) {
399 // do nothing when unchecked
400 if (! $
(issue
).attr("checked")) return;
402 $
("#report_form :checkbox").each(function(i
, obj
) {
403 if ($
(issue
).val().indexOf('/' + $
(this
).val() +
'/') >= 0) {
404 $
(this
).attr("checked", "checked");