couple more minor adjustment to prior commit
[openemr.git] / library / ippf_issues.inc.php
blob5f1aad75e7ab5aaea5a3e5ffb9d0101c61f8abca
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) {
35 echo "<td></td>";
38 echo "</tr>\n";
39 $cell_count = 0;
43 function end_group()
45 global $last_group;
46 if (strlen($last_group) > 0) {
47 end_row();
48 echo " </table>\n";
49 echo "</div>\n";
53 function issue_ippf_gcac_newtype()
55 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
56 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
59 function issue_ippf_gcac_save($issue)
61 $sets = "id = '" . add_escape_custom($issue) . "'";
62 $fres = sqlStatement("SELECT * FROM layout_options " .
63 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
64 "ORDER BY group_name, seq");
65 while ($frow = sqlFetchArray($fres)) {
66 $field_id = $frow['field_id'];
67 $value = get_layout_form_value($frow);
68 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
71 // This replaces the row if its id exists, otherwise inserts it.
72 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
75 function issue_ippf_gcac_form($issue, $thispid)
77 global $pprow, $item_count, $cell_count, $last_group;
79 $shrow = getHistoryData($thispid);
81 if ($issue) {
82 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
83 } else {
84 $pprow = array();
87 echo "<div id='ippf_gcac' style='display:none'>\n";
89 $fres = sqlStatement("SELECT * FROM layout_options " .
90 "WHERE form_id = 'GCA' AND uor > 0 " .
91 "ORDER BY group_name, seq");
92 $last_group = '';
93 $cell_count = 0;
94 $item_count = 0;
95 $display_style = 'block';
97 while ($frow = sqlFetchArray($fres)) {
98 $this_group = $frow['group_name'];
99 $titlecols = $frow['titlecols'];
100 $datacols = $frow['datacols'];
101 $data_type = $frow['data_type'];
102 $field_id = $frow['field_id'];
103 $list_id = $frow['list_id'];
105 $currvalue = '';
107 if ($frow['edit_options'] == 'H') {
108 // This data comes from static history
109 if (isset($shrow[$field_id])) {
110 $currvalue = $shrow[$field_id];
112 } else {
113 if (isset($pprow[$field_id])) {
114 $currvalue = $pprow[$field_id];
118 // Handle a data category (group) change.
119 if (strcmp($this_group, $last_group) != 0) {
120 end_group();
121 $group_seq = 'gca' . substr($this_group, 0, 1);
122 $group_name = substr($this_group, 1);
123 $last_group = $this_group;
124 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
125 "onclick='return divclick(this,\"div_$group_seq\");'";
126 if ($display_style == 'block') {
127 echo " checked";
130 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
131 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
132 echo " <table border='0' cellpadding='0' width='100%'>\n";
133 $display_style = 'none';
136 // Handle starting of a new row.
137 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
138 end_row();
139 echo " <tr>";
142 if ($item_count == 0 && $titlecols == 0) {
143 $titlecols = 1;
146 // Handle starting of a new label cell.
147 if ($titlecols > 0) {
148 end_cell();
149 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
150 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
151 if ($cell_count == 2) {
152 echo " style='padding-left:10pt'";
155 echo ">";
156 $cell_count += $titlecols;
159 ++$item_count;
161 echo "<b>";
162 if ($frow['title']) {
163 echo (xl_layout_label($frow['title']) . ":");
164 } else {
165 echo "&nbsp;";
168 echo "</b>";
170 // Handle starting of a new data cell.
171 if ($datacols > 0) {
172 end_cell();
173 echo "<td valign='top' colspan='$datacols' class='text'";
174 if ($cell_count > 0) {
175 echo " style='padding-left:5pt'";
178 echo ">";
179 $cell_count += $datacols;
182 ++$item_count;
184 if ($frow['edit_options'] == 'H') {
185 echo generate_display_field($frow, $currvalue);
186 } else {
187 generate_form_field($frow, $currvalue);
191 end_group();
192 echo "</div>\n";
195 function issue_ippf_con_newtype()
197 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
198 echo " document.getElementById('ippf_con').style.display = condisp;\n";
201 function issue_ippf_con_save($issue)
203 $sets = "id = '" . add_escape_custom($issue) . "'";
204 $fres = sqlStatement("SELECT * FROM layout_options " .
205 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
206 "ORDER BY group_name, seq");
207 while ($frow = sqlFetchArray($fres)) {
208 $field_id = $frow['field_id'];
209 $value = get_layout_form_value($frow);
210 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
213 // This replaces the row if its id exists, otherwise inserts it.
214 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
217 function issue_ippf_con_form($issue, $thispid)
219 global $pprow, $item_count, $cell_count, $last_group;
221 $shrow = getHistoryData($thispid);
223 if ($issue) {
224 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
225 } else {
226 $pprow = array();
229 echo "<div id='ippf_con' style='display:none'>\n";
231 $fres = sqlStatement("SELECT * FROM layout_options " .
232 "WHERE form_id = 'CON' AND uor > 0 " .
233 "ORDER BY group_name, seq");
234 $last_group = '';
235 $cell_count = 0;
236 $item_count = 0;
237 $display_style = 'block';
239 while ($frow = sqlFetchArray($fres)) {
240 $this_group = $frow['group_name'];
241 $titlecols = $frow['titlecols'];
242 $datacols = $frow['datacols'];
243 $data_type = $frow['data_type'];
244 $field_id = $frow['field_id'];
245 $list_id = $frow['list_id'];
247 $currvalue = '';
249 if ($frow['edit_options'] == 'H') {
250 // This data comes from static history
251 if (isset($shrow[$field_id])) {
252 $currvalue = $shrow[$field_id];
254 } else {
255 if (isset($pprow[$field_id])) {
256 $currvalue = $pprow[$field_id];
260 // Handle a data category (group) change.
261 if (strcmp($this_group, $last_group) != 0) {
262 end_group();
263 $group_seq = 'con' . substr($this_group, 0, 1);
264 $group_name = substr($this_group, 1);
265 $last_group = $this_group;
266 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
267 "onclick='return divclick(this,\"div_$group_seq\");'";
268 if ($display_style == 'block') {
269 echo " checked";
272 echo " /><b>$group_name</b></span>\n";
273 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
274 echo " <table border='0' cellpadding='0' width='100%'>\n";
275 $display_style = 'none';
278 // Handle starting of a new row.
279 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
280 end_row();
281 echo " <tr>";
284 if ($item_count == 0 && $titlecols == 0) {
285 $titlecols = 1;
288 // Handle starting of a new label cell.
289 if ($titlecols > 0) {
290 end_cell();
291 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
292 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
293 if ($cell_count == 2) {
294 echo " style='padding-left:10pt'";
297 echo ">";
298 $cell_count += $titlecols;
301 ++$item_count;
303 echo "<b>";
304 if ($frow['title']) {
305 echo $frow['title'] . ":";
306 } else {
307 echo "&nbsp;";
310 echo "</b>";
312 // Handle starting of a new data cell.
313 if ($datacols > 0) {
314 end_cell();
315 echo "<td valign='top' colspan='$datacols' class='text'";
316 if ($cell_count > 0) {
317 echo " style='padding-left:5pt'";
320 echo ">";
321 $cell_count += $datacols;
324 ++$item_count;
326 if ($frow['edit_options'] == 'H') {
327 echo generate_display_field($frow, $currvalue);
328 } else {
329 generate_form_field($frow, $currvalue);
333 end_group();
334 echo "</div>\n";
337 /*********************************************************************
339 function issue_ippf_srh_newtype() {
340 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
341 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
344 function issue_ippf_srh_save($issue) {
345 $sets = "id = '" add_escape_custom($issue) . "'";
346 $fres = sqlStatement("SELECT * FROM layout_options " .
347 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
348 "ORDER BY group_name, seq");
349 while ($frow = sqlFetchArray($fres)) {
350 $field_id = $frow['field_id'];
351 $value = get_layout_form_value($frow);
352 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
354 // This replaces the row if its id exists, otherwise inserts it.
355 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
358 function issue_ippf_srh_form($issue, $thispid) {
359 global $pprow, $item_count, $cell_count, $last_group;
361 $shrow = getHistoryData($thispid);
363 if ($issue) {
364 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
365 } else {
366 $pprow = array();
369 echo "<div id='ippf_srh' style='display:none'>\n";
371 $fres = sqlStatement("SELECT * FROM layout_options " .
372 "WHERE form_id = 'SRH' AND uor > 0 " .
373 "ORDER BY group_name, seq");
374 $last_group = '';
375 $cell_count = 0;
376 $item_count = 0;
377 $display_style = 'block';
379 while ($frow = sqlFetchArray($fres)) {
380 $this_group = $frow['group_name'];
381 $titlecols = $frow['titlecols'];
382 $datacols = $frow['datacols'];
383 $data_type = $frow['data_type'];
384 $field_id = $frow['field_id'];
385 $list_id = $frow['list_id'];
387 $currvalue = '';
389 if ($frow['edit_options'] == 'H') {
390 // This data comes from static history
391 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
392 } else {
393 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
396 // Handle a data category (group) change.
397 if (strcmp($this_group, $last_group) != 0) {
398 end_group();
399 $group_seq = 'srh' . substr($this_group, 0, 1);
400 $group_name = substr($this_group, 1);
401 $last_group = $this_group;
402 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
403 "onclick='return divclick(this,\"div_$group_seq\");'";
404 if ($display_style == 'block') echo " checked";
405 echo " /><b>$group_name</b></span>\n";
406 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
407 echo " <table border='0' cellpadding='0' width='100%'>\n";
408 $display_style = 'none';
411 // Handle starting of a new row.
412 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
413 end_row();
414 echo " <tr>";
417 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
419 // Handle starting of a new label cell.
420 if ($titlecols > 0) {
421 end_cell();
422 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
423 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
424 if ($cell_count == 2) echo " style='padding-left:10pt'";
425 echo ">";
426 $cell_count += $titlecols;
428 ++$item_count;
430 echo "<b>";
431 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
432 echo "</b>";
434 // Handle starting of a new data cell.
435 if ($datacols > 0) {
436 end_cell();
437 echo "<td valign='top' colspan='$datacols' class='text'";
438 if ($cell_count > 0) echo " style='padding-left:5pt'";
439 echo ">";
440 $cell_count += $datacols;
443 ++$item_count;
445 if ($frow['edit_options'] == 'H')
446 echo generate_display_field($frow, $currvalue);
447 else
448 generate_form_field($frow, $currvalue);
451 end_group();
452 echo "</div>\n";
454 *********************************************************************/