2 include_once("../../globals.php");
3 include_once("$srcdir/lists.inc");
4 include_once("$srcdir/acl.inc");
5 include_once("$srcdir/forms.inc");
7 // get various authorization levels
8 $auth_notes_a = acl_check('encounters', 'notes_a');
9 $auth_notes = acl_check('encounters', 'notes');
10 $auth_coding_a = acl_check('encounters', 'coding_a');
11 $auth_coding = acl_check('encounters', 'coding');
12 $auth_relaxed = acl_check('encounters', 'relaxed');
13 $auth_med = acl_check('patients' , 'med');
14 $auth_demo = acl_check('patients' , 'demo');
19 <?php
html_header_show();?
>
21 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
23 <!-- include jQuery support
-->
24 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
26 <script language
='JavaScript'>
28 function checkAll(check
) {
29 var f
= document
.forms
[0];
30 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
31 if (f
.elements
[i
].type
== 'checkbox') f
.elements
[i
].checked
= check
;
40 <body
class="body_top">
41 <div id
="patient_reports"> <!-- large outer DIV
-->
43 <span
class='title'><?php
xl('Patient Report','e'); ?
></span
> 
; 
;
46 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
47 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
49 <a
class="link_submit" href
="#" onclick
="return checkAll(true)">[<?php
xl('Check All','e'); ?
>]</a
>
51 <a
class="link_submit" href
="#" onclick
="return checkAll(false)">[<?php
xl('Clear All','e'); ?
>]</a
>
54 <form name
='report_form' id
="report_form" method
='post' action
='custom_report.php'>
56 <table
class="includes">
59 <input type
='checkbox' name
='include_demographics' id
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
60 <?php
if (acl_check('patients', 'med')): ?
>
61 <input type
='checkbox' name
='include_history' id
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
64 <input type
='checkbox' name
='include_employer' id
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
66 <input type
='checkbox' name
='include_insurance' id
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
67 <input type
='checkbox' name
='include_billing' id
='include_billing' value
="billing"
68 <?php
if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?
>><?php
xl('Billing','e'); ?
><br
>
72 <input type
='checkbox' name
='include_allergies' id
='include_allergies' value
="allergies">Allergies
<br
>
73 <input type
='checkbox' name
='include_medications' id
='include_medications' value
="medications">Medications
<br
>
75 <input type
='checkbox' name
='include_immunizations' id
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
77 <input type
='checkbox' name
='include_medical_problems' id
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
79 <input type
='checkbox' name
='include_notes' id
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
80 <input type
='checkbox' name
='include_transactions' id
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
81 <input type
='checkbox' name
='include_batchcom' id
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
87 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
90 <table
class="issues_encounters_forms">
96 <span
class='bold'><?php
xl('Issues','e'); ?
>:</span
>
100 <?php
if (! acl_check('patients', 'med')): ?
>
101 <br
>(Issues not authorized
)
108 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
109 "ORDER BY type, begdate");
111 while ($prow = sqlFetchArray($pres)) {
112 if ($lasttype != $prow['type']) {
113 $lasttype = $prow['type'];
116 $disptype = $lasttype;
118 case "allergy" : $disptype = "Allergies" ; break;
120 case "medical_problem": $disptype = "Medical Problems"; break;
121 case "medication" : $disptype = "Medications" ; break;
122 case "surgery" : $disptype = "Surgeries" ; break;
125 $disptype = $ISSUE_TYPES[$lasttype][0];
128 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
131 $rowid = $prow['id'];
132 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
134 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
135 "pid = '$pid' AND list_id = '$rowid'");
137 echo " <tr class='text'>\n";
138 echo " <td> </td>\n";
140 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
141 while ($ierow = sqlFetchArray($ieres)) {
142 echo $ierow['encounter'] . "/";
144 echo "' />$disptitle</td>\n";
145 echo " <td>" . $prow['begdate'];
147 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
148 else { echo " Active"; }
156 <?php
endif; // end of Issues output ?>
158 </div
> <!-- end issues DIV
-->
161 <!-- Encounters
and Forms
-->
164 <div
class='encounters'>
165 <span
class='bold'><?php
xl('Encounters & Forms','e'); ?
>:</span
>
168 <?php
if (!($auth_notes_a ||
$auth_notes ||
$auth_coding_a ||
$auth_coding ||
$auth_med ||
$auth_relaxed)): ?
>
169 (Encounters not authorized
)
175 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
176 "forms.formdir, forms.date AS fdate, form_encounter.date " .
177 ",form_encounter.reason ".
178 "FROM forms, form_encounter WHERE " .
179 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
180 "form_encounter.encounter = forms.encounter " .
181 " AND forms.deleted=0 ". // --JRM--
182 "ORDER BY form_encounter.date DESC, fdate ASC");
183 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
184 $html_strings = array();
185 $registry_form_name = array();
186 while($result2 = sqlFetchArray($res2)) {
187 array_push($registry_form_name,trim($result2['name']));
189 while($result = sqlFetchArray($res)) {
190 if ($result{"form_name"} == "New Patient Encounter") {
192 foreach($registry_form_name as $var) {
193 if ($toprint = $html_strings[$var]) {
194 foreach($toprint as $var) {print $var;}
197 $html_strings = array();
198 echo "</div>\n"; // end DIV encounter_forms
199 echo "</div>\n\n"; //end DIV encounter_data
203 echo "<div class='encounter_data'>\n";
204 echo "<input type=checkbox ".
205 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
206 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
207 " value='" . $result{"encounter"} . "'" .
208 " class='encounter'".
211 // show encounter reason, not just 'New Encounter'
212 // trim to a reasonable length for display purposes --cfapress
213 $maxReasonLength = 20;
214 if (strlen($result["reason"]) > $maxReasonLength) {
215 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
218 echo $result{"reason"}.
219 " (" . date("Y-m-d",strtotime($result{"date"})) .
221 echo "<div class='encounter_forms'>\n";
224 $form_name = trim($result{"form_name"});
225 //if form name is not in registry, look for the closest match by
226 // finding a registry name which is at the start of the form name.
227 //this is to allow for forms to put additional helpful information
228 //in the database in the same string as their form name after the name
229 $form_name_found_flag = 0;
230 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
231 // if the form does not match precisely with any names in the registry, now see if any front partial matches
232 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
233 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
235 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
236 array_push($html_strings[$form_name], "<input type='checkbox' ".
237 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
238 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
239 " value='" . $result{"encounter"} . "'" .
240 " class='encounter_form' ".
241 ">" . $result{"form_name"} . "<br>\n");
244 foreach($registry_form_name as $var) {
245 if ($toprint = $html_strings[$var]) {
246 foreach($toprint as $var) {print $var;}
253 </div
> <!-- end encounters DIV
-->
257 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
261 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
264 // show available documents
265 $db = $GLOBALS['adodb']['db'];
266 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
267 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
268 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
269 "d.foreign_id = " . $db->qstr($pid);
270 $result = $db->Execute($sql);
271 if ($db->ErrorMsg()) echo $db->ErrorMsg();
272 while ($result && !$result->EOF
) {
273 echo "<li class='bold'>";
274 echo '<input type="checkbox" name="documents[]" value="' .
275 $result->fields
['id'] . '">';
276 echo ' <i>' . $result->fields
['name'] . "</i>";
277 echo ' Name: <i>' . basename($result->fields
['url']) . "</i>";
285 <input type
="button" class="genreport" value
="<?php xl('Generate Report','e'); ?>" />
287 </div
> <!-- close patient_reports DIV
-->
290 <script language
="javascript">
292 // jQuery stuff to make the page a little easier to use
293 $
(document
).ready(function(){
294 $
(".genreport").click(function() { top
.restoreSession(); $
("#report_form").submit(); });
295 $
("#genfullreport").click(function() { location
.href
='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
296 //$("#printform").click(function() { PrintForm(); });
297 $
(".issuecheckbox").click(function() { issueClick(this
); });
299 // check/uncheck all Forms of an encounter
300 $
(".encounter").click(function() { SelectForms($
(this
)); });
304 // select/deselect the Forms related to the selected Encounter
305 // (it ain't pretty code folks)
306 var SelectForms
= function (selectedEncounter
) {
307 if ($
(selectedEncounter
).attr("checked")) {
308 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
309 $
(this
).children().each(function(i
, obj
) {
310 $
(this
).attr("checked", "checked");
315 $
(selectedEncounter
).parent().children().each(function(i
, obj
) {
316 $
(this
).children().each(function(i
, obj
) {
317 $
(this
).removeAttr("checked");
323 // When an issue is checked, auto-check all the related encounters and forms
324 function issueClick(issue
) {
325 // do nothing when unchecked
326 if (! $
(issue
).attr("checked")) return;
328 $
("#report_form :checkbox").each(function(i
, obj
) {
329 if ($
(issue
).val().indexOf('/' + $
(this
).val() +
'/') >= 0) {
330 $
(this
).attr("checked", "checked");