simplified adding/removing issue types and added dental as a type
[openemr.git] / interface / patient_file / report / patient_report.php
blob1a19422dd3fe018cbfaffccff689048ab922d0dd
1 <?
2 include_once("../../globals.php");
3 include_once("$srcdir/lists.inc");
4 ?>
5 <html>
6 <head>
7 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
8 <script language='JavaScript'>
9 // When an issue is checked, auto-check all the related encounters.
10 function issueClick(icb) {
11 if (! icb.checked) return;
12 var f = document.forms[0];
13 var nel = f.elements.length;
14 for (var i = 0; i < nel; ++i) {
15 var ecb = f.elements[i];
16 if (ecb.name == 'documents[]' ||
17 ecb.name.indexOf('include_') == 0 ||
18 ecb.name.indexOf('issue_' ) == 0)
19 continue;
20 if (icb.value.indexOf('/' + ecb.value + '/') >= 0) {
21 ecb.checked = true;
25 </script>
26 </head>
28 <body <?echo $top_bg_line;?> topmargin='0' rightmargin='0' leftmargin='2'
29 bottommargin='0' marginwidth='2' marginheight='0'>
31 <font class='title'>Patient Report</font><br>
33 <a class="link_submit" href="full_report.php">[View Comprehensive Patient Report]</a>
35 <form name='report_form' method='post' action='custom_report.php'>
37 <table>
38 <tr>
39 <td class='text' valign='top'>
40 <input type='checkbox' name='include_demographics' value="demographics" checked>Demographics<br>
41 <input type='checkbox' name='include_history' value="history">History<br>
42 <input type='checkbox' name='include_employer' value="employer">Employer<br>
43 <input type='checkbox' name='include_insurance' value="insurance">Insurance<br>
44 <input type='checkbox' name='include_billing' value="billing" checked>Billing<br>
45 </td>
46 <td class='text' valign='top'>
47 <!--
48 <input type='checkbox' name='include_allergies' value="allergies">Allergies<br>
49 <input type='checkbox' name='include_medications' value="medications">Medications<br>
50 -->
51 <input type='checkbox' name='include_immunizations' value="immunizations">Immunizations<br>
52 <!--
53 <input type='checkbox' name='include_medical_problems' value="medical_problems">Medical Problems<br>
54 -->
55 <input type='checkbox' name='include_notes' value="notes">Patient Notes<br>
56 <input type='checkbox' name='include_transactions' value="transactions">Transactions<br>
57 </td>
58 </tr>
59 </table>
61 <br>
62 <a href='javascript:document.report_form.submit()' class='link_submit'>Generate Report</a>
63 <hr>
65 <table>
66 <tr>
68 <td valign='top' class='text'>
69 <span class='bold'>Issues to Include in this Report: &nbsp; &nbsp;</span>
70 <br>&nbsp;
71 <table cellpadding='1' cellspacing='2'>
72 <!--
73 <tr class='bold'>
74 <td>Type</td>
75 <td>Title</td>
76 <td>Begin</td>
77 <td>End &nbsp; &nbsp; &nbsp;</td>
78 </tr>
79 -->
81 // get issues
82 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
83 "ORDER BY type, begdate");
84 $lasttype = "";
85 while ($prow = sqlFetchArray($pres)) {
86 if ($lasttype != $prow['type']) {
87 $lasttype = $prow['type'];
89 /****
90 $disptype = $lasttype;
91 switch ($lasttype) {
92 case "allergy" : $disptype = "Allergies" ; break;
93 case "problem" :
94 case "medical_problem": $disptype = "Medical Problems"; break;
95 case "medication" : $disptype = "Medications" ; break;
96 case "surgery" : $disptype = "Surgeries" ; break;
98 ****/
99 $disptype = $ISSUE_TYPES[$lasttype][0];
101 echo " <tr>\n";
102 echo " <td valign='top' colspan='4' class='bold'><b>$disptype</b></td>\n";
103 echo " </tr>\n";
105 $rowid = $prow['id'];
106 $disptitle = trim($prow['title']) ? $prow['title'] : "[Missing Title]";
108 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
109 "pid = '$pid' AND list_id = '$rowid'");
111 echo " <tr class='text'>\n";
112 echo " <td valign='top'>&nbsp;</td>\n";
113 echo " <td valign='top'>";
114 echo "<input type='checkbox' name='issue_$rowid' onclick='issueClick(this)' value='/";
115 while ($ierow = sqlFetchArray($ieres)) {
116 echo $ierow['encounter'] . "/";
118 echo "' />$disptitle</td>\n";
119 echo " <td valign='top'>" . $prow['begdate'];
120 if ($prow['enddate']) {
121 echo " - " . $prow['enddate'];
122 } else {
123 echo " Active";
125 echo " &nbsp; &nbsp; </td>\n";
126 echo " </tr>\n";
129 </table>
130 <br>
131 </td>
133 <td valign='top' class='text'>
134 <span class='bold'>Encounter Forms to Include in this Report:</span>
135 <br><br>
137 $isfirst = 1;
139 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
140 "forms.formdir, forms.date AS fdate, form_encounter.date " .
141 "FROM forms, form_encounter WHERE " .
142 "forms.pid = '$pid' AND form_encounter.encounter = forms.encounter " .
143 "ORDER BY form_encounter.date DESC, fdate ASC");
145 while($result = sqlFetchArray($res)) {
146 if ($result{"form_name"} == "New Patient Encounter") {
147 if ($isfirst == 0) {
148 print "</blockquote>\n\n";
150 $isfirst = 0;
152 print "<input type=checkbox name='" . $result{"formdir"} . "_" .
153 $result{"form_id"} . "' value='" . $result{"encounter"} . "'";
154 print " >New Encounter" .
155 " (" . date("Y-m-d",strtotime($result{"date"})) .
156 ")<blockquote>\n";
157 } else {
158 print "<input type='checkbox' name='" . $result{"formdir"} . "_" .
159 $result{"form_id"} . "' value='" . $result{"encounter"} . "'";
160 print ">" . $result{"form_name"} . "<br>\n";
162 //call_user_func($result{"formdir"} . "_report", $pid, $result{"encounter"}, $cols, $result{"form_id"});
165 </blockquote>
167 </td>
168 </tr>
169 </table>
171 <span class="bold">Documents</span>:<br>
172 <ul>
174 //code lists available images
175 $db = $GLOBALS['adodb']['db'];
176 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
177 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
178 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
179 "d.foreign_id = " . $db->qstr($pid);
180 $result = $db->Execute($sql);
181 echo $db->ErrorMsg();
182 while ($result && !$result->EOF) {
183 echo '<span class="bold"><input type="checkbox" name="documents[]" value="' .
184 $result->fields['id'] . '">';
185 echo '&nbsp;&nbsp;<i>' . $result->fields['name'] . "</i>";
186 echo '&nbsp;&nbsp;Name: <i>' . basename($result->fields['url']) . "</i>";
187 echo '</span><br>';
188 $result->MoveNext();
191 </ul>
192 </form>
194 <a href='javascript:document.report_form.submit()' class='link_submit'>Generate Report</a>
196 </body>
197 </html>