Added access controls for encounter categories
[openemr.git] / library / ippf_issues.inc.php
blob0bee04a27f745470626b7f962d82686a901a6b62
1 <?php
2 // Copyright (C) 2008-2009 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This module is invoked by add_edit_issue.php as an extension to
10 // add support for issue types that are specific to IPPF.
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/patient.inc");
15 $CPR = 4; // cells per row
17 $pprow = array();
19 function end_cell()
21 global $item_count, $cell_count;
22 if ($item_count > 0) {
23 echo "</td>";
24 $item_count = 0;
28 function end_row()
30 global $cell_count, $CPR;
31 end_cell();
32 if ($cell_count > 0) {
33 for (; $cell_count < $CPR;
34 ++$cell_count) echo "<td></td>";
35 echo "</tr>\n";
36 $cell_count = 0;
40 function end_group()
42 global $last_group;
43 if (strlen($last_group) > 0) {
44 end_row();
45 echo " </table>\n";
46 echo "</div>\n";
50 function issue_ippf_gcac_newtype()
52 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
53 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
56 function issue_ippf_gcac_save($issue)
58 $sets = "id = '" . add_escape_custom($issue) . "'";
59 $fres = sqlStatement("SELECT * FROM layout_options " .
60 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
61 "ORDER BY group_name, seq");
62 while ($frow = sqlFetchArray($fres)) {
63 $field_id = $frow['field_id'];
64 $value = get_layout_form_value($frow);
65 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
67 // This replaces the row if its id exists, otherwise inserts it.
68 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
71 function issue_ippf_gcac_form($issue, $thispid)
73 global $pprow, $item_count, $cell_count, $last_group;
75 $shrow = getHistoryData($thispid);
77 if ($issue) {
78 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
79 } else {
80 $pprow = array();
83 echo "<div id='ippf_gcac' style='display:none'>\n";
85 $fres = sqlStatement("SELECT * FROM layout_options " .
86 "WHERE form_id = 'GCA' AND uor > 0 " .
87 "ORDER BY group_name, seq");
88 $last_group = '';
89 $cell_count = 0;
90 $item_count = 0;
91 $display_style = 'block';
93 while ($frow = sqlFetchArray($fres)) {
94 $this_group = $frow['group_name'];
95 $titlecols = $frow['titlecols'];
96 $datacols = $frow['datacols'];
97 $data_type = $frow['data_type'];
98 $field_id = $frow['field_id'];
99 $list_id = $frow['list_id'];
101 $currvalue = '';
103 if ($frow['edit_options'] == 'H') {
104 // This data comes from static history
105 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
106 } else {
107 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
110 // Handle a data category (group) change.
111 if (strcmp($this_group, $last_group) != 0) {
112 end_group();
113 $group_seq = 'gca' . substr($this_group, 0, 1);
114 $group_name = substr($this_group, 1);
115 $last_group = $this_group;
116 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
117 "onclick='return divclick(this,\"div_$group_seq\");'";
118 if ($display_style == 'block') echo " checked";
119 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
120 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
121 echo " <table border='0' cellpadding='0' width='100%'>\n";
122 $display_style = 'none';
125 // Handle starting of a new row.
126 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
127 end_row();
128 echo " <tr>";
131 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
133 // Handle starting of a new label cell.
134 if ($titlecols > 0) {
135 end_cell();
136 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
137 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
138 if ($cell_count == 2) echo " style='padding-left:10pt'";
139 echo ">";
140 $cell_count += $titlecols;
142 ++$item_count;
144 echo "<b>";
145 if ($frow['title']) echo (xl_layout_label($frow['title']) . ":");
146 else echo "&nbsp;";
147 echo "</b>";
149 // Handle starting of a new data cell.
150 if ($datacols > 0) {
151 end_cell();
152 echo "<td valign='top' colspan='$datacols' class='text'";
153 if ($cell_count > 0) echo " style='padding-left:5pt'";
154 echo ">";
155 $cell_count += $datacols;
158 ++$item_count;
160 if ($frow['edit_options'] == 'H')
161 echo generate_display_field($frow, $currvalue);
162 else
163 generate_form_field($frow, $currvalue);
166 end_group();
167 echo "</div>\n";
170 function issue_ippf_con_newtype()
172 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
173 echo " document.getElementById('ippf_con').style.display = condisp;\n";
176 function issue_ippf_con_save($issue)
178 $sets = "id = '" . add_escape_custom($issue) . "'";
179 $fres = sqlStatement("SELECT * FROM layout_options " .
180 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
181 "ORDER BY group_name, seq");
182 while ($frow = sqlFetchArray($fres)) {
183 $field_id = $frow['field_id'];
184 $value = get_layout_form_value($frow);
185 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
187 // This replaces the row if its id exists, otherwise inserts it.
188 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
191 function issue_ippf_con_form($issue, $thispid)
193 global $pprow, $item_count, $cell_count, $last_group;
195 $shrow = getHistoryData($thispid);
197 if ($issue) {
198 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
199 } else {
200 $pprow = array();
203 echo "<div id='ippf_con' style='display:none'>\n";
205 $fres = sqlStatement("SELECT * FROM layout_options " .
206 "WHERE form_id = 'CON' AND uor > 0 " .
207 "ORDER BY group_name, seq");
208 $last_group = '';
209 $cell_count = 0;
210 $item_count = 0;
211 $display_style = 'block';
213 while ($frow = sqlFetchArray($fres)) {
214 $this_group = $frow['group_name'];
215 $titlecols = $frow['titlecols'];
216 $datacols = $frow['datacols'];
217 $data_type = $frow['data_type'];
218 $field_id = $frow['field_id'];
219 $list_id = $frow['list_id'];
221 $currvalue = '';
223 if ($frow['edit_options'] == 'H') {
224 // This data comes from static history
225 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
226 } else {
227 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
230 // Handle a data category (group) change.
231 if (strcmp($this_group, $last_group) != 0) {
232 end_group();
233 $group_seq = 'con' . substr($this_group, 0, 1);
234 $group_name = substr($this_group, 1);
235 $last_group = $this_group;
236 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
237 "onclick='return divclick(this,\"div_$group_seq\");'";
238 if ($display_style == 'block') echo " checked";
239 echo " /><b>$group_name</b></span>\n";
240 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
241 echo " <table border='0' cellpadding='0' width='100%'>\n";
242 $display_style = 'none';
245 // Handle starting of a new row.
246 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
247 end_row();
248 echo " <tr>";
251 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
253 // Handle starting of a new label cell.
254 if ($titlecols > 0) {
255 end_cell();
256 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
257 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
258 if ($cell_count == 2) echo " style='padding-left:10pt'";
259 echo ">";
260 $cell_count += $titlecols;
262 ++$item_count;
264 echo "<b>";
265 if ($frow['title']) echo $frow['title'] . ":";
266 else echo "&nbsp;";
267 echo "</b>";
269 // Handle starting of a new data cell.
270 if ($datacols > 0) {
271 end_cell();
272 echo "<td valign='top' colspan='$datacols' class='text'";
273 if ($cell_count > 0) echo " style='padding-left:5pt'";
274 echo ">";
275 $cell_count += $datacols;
278 ++$item_count;
280 if ($frow['edit_options'] == 'H')
281 echo generate_display_field($frow, $currvalue);
282 else
283 generate_form_field($frow, $currvalue);
286 end_group();
287 echo "</div>\n";
290 /*********************************************************************
292 function issue_ippf_srh_newtype() {
293 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
294 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
297 function issue_ippf_srh_save($issue) {
298 $sets = "id = '" add_escape_custom($issue) . "'";
299 $fres = sqlStatement("SELECT * FROM layout_options " .
300 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
301 "ORDER BY group_name, seq");
302 while ($frow = sqlFetchArray($fres)) {
303 $field_id = $frow['field_id'];
304 $value = get_layout_form_value($frow);
305 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
307 // This replaces the row if its id exists, otherwise inserts it.
308 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
311 function issue_ippf_srh_form($issue, $thispid) {
312 global $pprow, $item_count, $cell_count, $last_group;
314 $shrow = getHistoryData($thispid);
316 if ($issue) {
317 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
318 } else {
319 $pprow = array();
322 echo "<div id='ippf_srh' style='display:none'>\n";
324 $fres = sqlStatement("SELECT * FROM layout_options " .
325 "WHERE form_id = 'SRH' AND uor > 0 " .
326 "ORDER BY group_name, seq");
327 $last_group = '';
328 $cell_count = 0;
329 $item_count = 0;
330 $display_style = 'block';
332 while ($frow = sqlFetchArray($fres)) {
333 $this_group = $frow['group_name'];
334 $titlecols = $frow['titlecols'];
335 $datacols = $frow['datacols'];
336 $data_type = $frow['data_type'];
337 $field_id = $frow['field_id'];
338 $list_id = $frow['list_id'];
340 $currvalue = '';
342 if ($frow['edit_options'] == 'H') {
343 // This data comes from static history
344 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
345 } else {
346 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
349 // Handle a data category (group) change.
350 if (strcmp($this_group, $last_group) != 0) {
351 end_group();
352 $group_seq = 'srh' . substr($this_group, 0, 1);
353 $group_name = substr($this_group, 1);
354 $last_group = $this_group;
355 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
356 "onclick='return divclick(this,\"div_$group_seq\");'";
357 if ($display_style == 'block') echo " checked";
358 echo " /><b>$group_name</b></span>\n";
359 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
360 echo " <table border='0' cellpadding='0' width='100%'>\n";
361 $display_style = 'none';
364 // Handle starting of a new row.
365 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
366 end_row();
367 echo " <tr>";
370 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
372 // Handle starting of a new label cell.
373 if ($titlecols > 0) {
374 end_cell();
375 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
376 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
377 if ($cell_count == 2) echo " style='padding-left:10pt'";
378 echo ">";
379 $cell_count += $titlecols;
381 ++$item_count;
383 echo "<b>";
384 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
385 echo "</b>";
387 // Handle starting of a new data cell.
388 if ($datacols > 0) {
389 end_cell();
390 echo "<td valign='top' colspan='$datacols' class='text'";
391 if ($cell_count > 0) echo " style='padding-left:5pt'";
392 echo ">";
393 $cell_count += $datacols;
396 ++$item_count;
398 if ($frow['edit_options'] == 'H')
399 echo generate_display_field($frow, $currvalue);
400 else
401 generate_form_field($frow, $currvalue);
404 end_group();
405 echo "</div>\n";
407 *********************************************************************/