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
[0];
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 ?>
47 <form name
='ccr_form' id
='ccr_form' method
='post' action
='../../../ccr/createCCR.php'>
48 <span
class='title'><?php
xl('Continuity of Care Record','e'); ?
></span
> 
; 
;
50 <input type
='hidden' name
='ccrAction'>
51 <!-- call to generate CCR document
-->
52 <input type
="button" class="generateCCR" value
="<?php xl('View CCR','e'); ?>" />
54 <span
class='title'><?php
xl('Continuity of Care Document','e'); ?
></span
> 
; 
;
56 <input type
="button" class="viewCCD" value
="<?php xl('View CCD','e'); ?>" />
62 <?php
} // end CCR/CCD reporting options ?>
64 <form name
='report_form' id
="report_form" method
='post' action
='custom_report.php'>
67 <span
class='title'><?php
xl('Patient Report','e'); ?
></span
> 
; 
;
70 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
71 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
73 <a
class="link_submit" href
="#" onclick
="return checkAll(true)"><?php
xl('Check All','e'); ?
></a
>
75 <a
class="link_submit" href
="#" onclick
="return checkAll(false)"><?php
xl('Clear All','e'); ?
></a
>
78 <table
class="includes">
81 <input type
='checkbox' name
='include_demographics' id
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
82 <?php
if (acl_check('patients', 'med')): ?
>
83 <input type
='checkbox' name
='include_history' id
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
86 <input type
='checkbox' name
='include_employer' id
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
88 <input type
='checkbox' name
='include_insurance' id
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
89 <input type
='checkbox' name
='include_billing' id
='include_billing' value
="billing"
90 <?php
if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?
>><?php
xl('Billing','e'); ?
><br
>
94 <input type
='checkbox' name
='include_allergies' id
='include_allergies' value
="allergies">Allergies
<br
>
95 <input type
='checkbox' name
='include_medications' id
='include_medications' value
="medications">Medications
<br
>
97 <input type
='checkbox' name
='include_immunizations' id
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
99 <input type
='checkbox' name
='include_medical_problems' id
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
101 <input type
='checkbox' name
='include_notes' id
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
102 <input type
='checkbox' name
='include_transactions' id
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
103 <input type
='checkbox' name
='include_batchcom' id
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
109 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
112 <!-- old ccr button position
-->
115 <table
class="issues_encounters_forms">
121 <span
class='bold'><?php
xl('Issues','e'); ?
>:</span
>
125 <?php
if (! acl_check('patients', 'med')): ?
>
126 <br
>(Issues not authorized
)
133 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
134 "ORDER BY type, begdate");
136 while ($prow = sqlFetchArray($pres)) {
137 if ($lasttype != $prow['type']) {
138 $lasttype = $prow['type'];
141 $disptype = $lasttype;
143 case "allergy" : $disptype = "Allergies" ; break;
145 case "medical_problem": $disptype = "Medical Problems"; break;
146 case "medication" : $disptype = "Medications" ; break;
147 case "surgery" : $disptype = "Surgeries" ; break;
150 $disptype = $ISSUE_TYPES[$lasttype][0];
153 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
156 $rowid = $prow['id'];
157 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
159 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
160 "pid = '$pid' AND list_id = '$rowid'");
162 echo " <tr class='text'>\n";
163 echo " <td> </td>\n";
165 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
166 while ($ierow = sqlFetchArray($ieres)) {
167 echo $ierow['encounter'] . "/";
169 echo "' />$disptitle</td>\n";
170 echo " <td>" . $prow['begdate'];
172 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
173 else { echo " Active"; }
181 <?php
endif; // end of Issues output ?>
183 </div
> <!-- end issues DIV
-->
186 <!-- Encounters
and Forms
-->
189 <div
class='encounters'>
190 <span
class='bold'><?php
xl('Encounters & Forms','e'); ?
>:</span
>
193 <?php
if (!($auth_notes_a ||
$auth_notes ||
$auth_coding_a ||
$auth_coding ||
$auth_med ||
$auth_relaxed)): ?
>
194 (Encounters not authorized
)
200 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
201 "forms.formdir, forms.date AS fdate, form_encounter.date " .
202 ",form_encounter.reason ".
203 "FROM forms, form_encounter WHERE " .
204 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
205 "form_encounter.encounter = forms.encounter " .
206 " AND forms.deleted=0 ". // --JRM--
207 "ORDER BY form_encounter.date DESC, fdate ASC");
208 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
209 $html_strings = array();
210 $registry_form_name = array();
211 while($result2 = sqlFetchArray($res2)) {
212 array_push($registry_form_name,trim($result2['name']));
214 while($result = sqlFetchArray($res)) {
215 if ($result{"form_name"} == "New Patient Encounter") {
217 foreach($registry_form_name as $var) {
218 if ($toprint = $html_strings[$var]) {
219 foreach($toprint as $var) {print $var;}
222 $html_strings = array();
223 echo "</div>\n"; // end DIV encounter_forms
224 echo "</div>\n\n"; //end DIV encounter_data
228 echo "<div class='encounter_data'>\n";
229 echo "<input type=checkbox ".
230 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
231 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
232 " value='" . $result{"encounter"} . "'" .
233 " class='encounter'".
236 // show encounter reason, not just 'New Encounter'
237 // trim to a reasonable length for display purposes --cfapress
238 $maxReasonLength = 20;
239 if (strlen($result["reason"]) > $maxReasonLength) {
240 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
243 echo $result{"reason"}.
244 " (" . date("Y-m-d",strtotime($result{"date"})) .
246 echo "<div class='encounter_forms'>\n";
249 $form_name = trim($result{"form_name"});
250 //if form name is not in registry, look for the closest match by
251 // finding a registry name which is at the start of the form name.
252 //this is to allow for forms to put additional helpful information
253 //in the database in the same string as their form name after the name
254 $form_name_found_flag = 0;
255 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
256 // if the form does not match precisely with any names in the registry, now see if any front partial matches
257 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
258 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
260 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
261 array_push($html_strings[$form_name], "<input type='checkbox' ".
262 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
263 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
264 " value='" . $result{"encounter"} . "'" .
265 " class='encounter_form' ".
266 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
269 foreach($registry_form_name as $var) {
270 if ($toprint = $html_strings[$var]) {
271 foreach($toprint as $var) {print $var;}
278 </div
> <!-- end encounters DIV
-->
282 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
286 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
289 // show available documents
290 $db = $GLOBALS['adodb']['db'];
291 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
292 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
293 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
294 "d.foreign_id = " . $db->qstr($pid);
295 $result = $db->Execute($sql);
296 if ($db->ErrorMsg()) echo $db->ErrorMsg();
297 while ($result && !$result->EOF
) {
298 echo "<li class='bold'>";
299 echo '<input type="checkbox" name="documents[]" value="' .
300 $result->fields
['id'] . '">';
301 echo ' <i>' . xl_document_category($result->fields
['name']) . "</i>";
302 echo ' ' . xl('Name') . ': <i>' . basename($result->fields
['url']) . "</i>";
310 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
312 </div
> <!-- close patient_reports DIV
-->
315 <script language
="javascript">
317 // jQuery stuff to make the page a little easier to use
318 $
(document
).ready(function(){
319 $
(".genreport").click(function() { top
.restoreSession(); $
("#report_form").submit(); });
320 $
("#genfullreport").click(function() { location
.href
='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
321 //$("#printform").click(function() { PrintForm(); });
322 $
(".issuecheckbox").click(function() { issueClick(this
); });
324 // check/uncheck all Forms of an encounter
325 $
(".encounter").click(function() { SelectForms($
(this
)); });
330 $
(".generateCCR").click(
332 //alert('in generateCCR');
333 var ccrAction
= document
.getElementsByName('ccrAction');
334 ccrAction
[0].value
= 'generate';
335 top
.restoreSession();
336 $
("#ccr_form").submit();
341 //alert('in viewCCD');
342 var ccrAction
= document
.getElementsByName('ccrAction');
343 ccrAction
[0].value
= 'viewccd';
344 top
.restoreSession();
345 $
("#ccr_form").submit();
350 // select/deselect the Forms related to the selected Encounter
351 // (it ain't pretty code folks)
352 var SelectForms
= function (selectedEncounter
) {
353 if ($
(selectedEncounter
).attr("checked")) {
354 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
355 $
(this
).children().each(function(i
, obj
) {
356 $
(this
).attr("checked", "checked");
361 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
362 $
(this
).children().each(function(i
, obj
) {
363 $
(this
).removeAttr("checked");
369 // When an issue is checked, auto-check all the related encounters and forms
370 function issueClick(issue
) {
371 // do nothing when unchecked
372 if (! $
(issue
).attr("checked")) return;
374 $
("#report_form :checkbox").each(function(i
, obj
) {
375 if ($
(issue
).val().indexOf('/' + $
(this
).val() +
'/') >= 0) {
376 $
(this
).attr("checked", "checked");