2 include_once("../../globals.php");
3 include_once("$srcdir/lists.inc");
7 <?php
html_header_show();?
>
8 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
9 <script language
='JavaScript'>
10 // When an issue is checked, auto-check all the related encounters.
11 function issueClick(icb
) {
12 if (! icb
.checked
) return;
13 var f
= document
.forms
[0];
14 var nel
= f
.elements
.length
;
15 for (var i
= 0; i
< nel
; ++i
) {
16 var ecb
= f
.elements
[i
];
17 if (ecb
.name
== 'documents[]' ||
18 ecb
.name
.indexOf('include_') == 0 ||
19 ecb
.name
.indexOf('issue_' ) == 0)
21 if (icb
.value
.indexOf('/' + ecb
.value +
'/') >= 0) {
29 <body
class="body_top">
31 <font
class='title'><?php
xl('Patient Report','e'); ?
></font
><br
>
33 <a
class="link_submit" href
="full_report.php" onclick
="top.restoreSession()">
34 [<?php
xl('View Comprehensive Patient Report','e'); ?
>]</a
>
36 <form name
='report_form' method
='post' action
='custom_report.php'>
40 <td
class='text' valign
='top'>
41 <input type
='checkbox' name
='include_demographics' value
="demographics" checked
><?php
xl('Demographics','e'); ?
><br
>
42 <input type
='checkbox' name
='include_history' value
="history"><?php
xl(' History','e'); ?
><br
>
44 <input type
='checkbox' name
='include_employer' value
="employer"><?php
xl('Employer','e'); ?
><br
>
46 <input type
='checkbox' name
='include_insurance' value
="insurance"><?php
xl('Insurance','e'); ?
><br
>
47 <input type
='checkbox' name
='include_billing' value
="billing" checked
><?php
xl('Billing','e'); ?
><br
>
49 <td
class='text' valign
='top'>
51 <input type
='checkbox' name
='include_allergies' value
="allergies">Allergies
<br
>
52 <input type
='checkbox' name
='include_medications' value
="medications">Medications
<br
>
54 <input type
='checkbox' name
='include_immunizations' value
="immunizations"><?php
xl('Immunizations','e'); ?
><br
>
56 <input type
='checkbox' name
='include_medical_problems' value
="medical_problems">Medical Problems
<br
>
58 <input type
='checkbox' name
='include_notes' value
="notes"><?php
xl('Patient Notes','e'); ?
><br
>
59 <input type
='checkbox' name
='include_transactions' value
="transactions"><?php
xl('Transactions','e'); ?
><br
>
60 <input type
='checkbox' name
='include_batchcom' value
="batchcom"><?php
xl('Communications','e'); ?
><br
>
66 <a href
='javascript:top.restoreSession();document.report_form.submit()' class='link_submit'><?php
xl('Generate Report','e'); ?
></a
>
72 <td valign
='top' class='text'>
73 <span
class='bold'><?php
xl('Issues to Include in this Report','e'); ?
>:  
;  
;</span
>
75 <table cellpadding
='1' cellspacing
='2'>
81 <td
>End
 
;  
;  
;</td
>
86 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
87 "ORDER BY type, begdate");
89 while ($prow = sqlFetchArray($pres)) {
90 if ($lasttype != $prow['type']) {
91 $lasttype = $prow['type'];
94 $disptype = $lasttype;
96 case "allergy" : $disptype = "Allergies" ; break;
98 case "medical_problem": $disptype = "Medical Problems"; break;
99 case "medication" : $disptype = "Medications" ; break;
100 case "surgery" : $disptype = "Surgeries" ; break;
103 $disptype = $ISSUE_TYPES[$lasttype][0];
106 echo " <td valign='top' colspan='4' class='bold'><b>$disptype</b></td>\n";
109 $rowid = $prow['id'];
110 $disptitle = trim($prow['title']) ?
$prow['title'] : "[Missing Title]";
112 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
113 "pid = '$pid' AND list_id = '$rowid'");
115 echo " <tr class='text'>\n";
116 echo " <td valign='top'> </td>\n";
117 echo " <td valign='top'>";
118 echo "<input type='checkbox' name='issue_$rowid' onclick='issueClick(this)' value='/";
119 while ($ierow = sqlFetchArray($ieres)) {
120 echo $ierow['encounter'] . "/";
122 echo "' />$disptitle</td>\n";
123 echo " <td valign='top'>" . $prow['begdate'];
124 if ($prow['enddate']) {
125 echo " - " . $prow['enddate'];
129 echo " </td>\n";
137 <td valign
='top' class='text'>
138 <span
class='bold'><?php
xl('Encounter Forms to Include in this Report','e'); ?
>:</span
>
142 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
143 "forms.formdir, forms.date AS fdate, form_encounter.date " .
144 "FROM forms, form_encounter WHERE " .
145 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
146 "form_encounter.encounter = forms.encounter " .
147 "ORDER BY form_encounter.date DESC, fdate ASC");
148 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
149 $html_strings = array();
150 $registry_form_name = array();
151 while($result2 = sqlFetchArray($res2)) {
152 array_push($registry_form_name,trim($result2['name']));
154 while($result = sqlFetchArray($res)) {
155 if ($result{"form_name"} == "New Patient Encounter") {
157 foreach($registry_form_name as $var) {
158 if ($toprint = $html_strings[$var]) {
159 {foreach($toprint as $var) {print $var;}}
162 $html_strings = array();
163 print "</blockquote>\n\n";
166 print "<input type=checkbox name='" . $result{"formdir"} . "_" .
167 $result{"form_id"} . "' value='" . $result{"encounter"} . "'";
168 print " >New Encounter" .
169 " (" . date("Y-m-d",strtotime($result{"date"})) .
173 $form_name = trim($result{"form_name"});
174 //if form name is not in registry, look for the closest match by
175 // finding a registry name which is at the start of the form name.
176 //this is to allow for forms to put additional helpful information
177 //in the database in the same string as their form name after the name
178 $form_name_found_flag = 0;
179 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
180 // if the form does not match precisely with any names in the registry, now see if any front partial matches
181 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
182 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
184 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
185 array_push($html_strings[$form_name], "<input type='checkbox' name='"
186 . $result{"formdir"} . "_"
187 . $result{"form_id"} . "' value='" . $result{"encounter"} . "'"
188 . ">" . $result{"form_name"} . "<br>\n");
191 foreach($registry_form_name as $var) {
192 if ($toprint = $html_strings[$var]) {
193 {foreach($toprint as $var) {print $var;}}
203 <span
class="bold"><?php
xl('Documents','e'); ?
></span
>:<br
>
206 //code lists available images
207 $db = $GLOBALS['adodb']['db'];
208 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
209 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
210 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
211 "d.foreign_id = " . $db->qstr($pid);
212 $result = $db->Execute($sql);
213 echo $db->ErrorMsg();
214 while ($result && !$result->EOF
) {
215 echo '<span class="bold"><input type="checkbox" name="documents[]" value="' .
216 $result->fields
['id'] . '">';
217 echo ' <i>' . $result->fields
['name'] . "</i>";
218 echo ' Name: <i>' . basename($result->fields
['url']) . "</i>";
226 <a href
='javascript:top.restoreSession();document.report_form.submit()' class='link_submit'><?php
xl('Generate Report','e'); ?
></a
>