Display fix: width in manila for demographics (#1909)
[openemr.git] / library / ippf_issues.inc.php
blob049b073e22265c5cdc3d4ed98cce3ba280ee3c6e
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_id, 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 // Load array of properties for this layout and its groups.
90 $grparr = array();
91 getLayoutProperties('GCA', $grparr);
93 $fres = sqlStatement("SELECT * FROM layout_options " .
94 "WHERE form_id = 'GCA' AND uor > 0 " .
95 "ORDER BY group_id, seq");
96 $last_group = '';
97 $cell_count = 0;
98 $item_count = 0;
99 $display_style = 'block';
101 while ($frow = sqlFetchArray($fres)) {
102 $this_group = $frow['group_id'];
103 $titlecols = $frow['titlecols'];
104 $datacols = $frow['datacols'];
105 $data_type = $frow['data_type'];
106 $field_id = $frow['field_id'];
107 $list_id = $frow['list_id'];
109 $currvalue = '';
111 if ($frow['edit_options'] == 'H') {
112 // This data comes from static history
113 if (isset($shrow[$field_id])) {
114 $currvalue = $shrow[$field_id];
116 } else {
117 if (isset($pprow[$field_id])) {
118 $currvalue = $pprow[$field_id];
122 // Handle a data category (group) change.
123 if (strcmp($this_group, $last_group) != 0) {
124 end_group();
125 $group_seq = 'gca' . substr($this_group, 0, 1);
126 $group_name = $grparr[$this_group]['grp_title'];
127 $last_group = $this_group;
128 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
129 "onclick='return divclick(this,\"div_$group_seq\");'";
130 if ($display_style == 'block') {
131 echo " checked";
134 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
135 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
136 echo " <table border='0' cellpadding='0' width='100%'>\n";
137 $display_style = 'none';
140 // Handle starting of a new row.
141 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
142 end_row();
143 echo " <tr>";
146 if ($item_count == 0 && $titlecols == 0) {
147 $titlecols = 1;
150 // Handle starting of a new label cell.
151 if ($titlecols > 0) {
152 end_cell();
153 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
154 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
155 if ($cell_count == 2) {
156 echo " style='padding-left:10pt'";
159 echo ">";
160 $cell_count += $titlecols;
163 ++$item_count;
165 echo "<b>";
166 if ($frow['title']) {
167 echo (xl_layout_label($frow['title']) . ":");
168 } else {
169 echo "&nbsp;";
172 echo "</b>";
174 // Handle starting of a new data cell.
175 if ($datacols > 0) {
176 end_cell();
177 echo "<td valign='top' colspan='$datacols' class='text'";
178 if ($cell_count > 0) {
179 echo " style='padding-left:5pt'";
182 echo ">";
183 $cell_count += $datacols;
186 ++$item_count;
188 if ($frow['edit_options'] == 'H') {
189 echo generate_display_field($frow, $currvalue);
190 } else {
191 generate_form_field($frow, $currvalue);
195 end_group();
196 echo "</div>\n";
199 function issue_ippf_con_newtype()
201 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
202 echo " document.getElementById('ippf_con').style.display = condisp;\n";
205 function issue_ippf_con_save($issue)
207 $sets = "id = '" . add_escape_custom($issue) . "'";
208 $fres = sqlStatement("SELECT * FROM layout_options " .
209 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
210 "ORDER BY group_id, seq");
211 while ($frow = sqlFetchArray($fres)) {
212 $field_id = $frow['field_id'];
213 $value = get_layout_form_value($frow);
214 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
217 // This replaces the row if its id exists, otherwise inserts it.
218 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
221 function issue_ippf_con_form($issue, $thispid)
223 global $pprow, $item_count, $cell_count, $last_group;
225 $shrow = getHistoryData($thispid);
227 if ($issue) {
228 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
229 } else {
230 $pprow = array();
233 echo "<div id='ippf_con' style='display:none'>\n";
235 // Load array of properties for this layout and its groups.
236 $grparr = array();
237 getLayoutProperties('CON', $grparr);
239 $fres = sqlStatement("SELECT * FROM layout_options " .
240 "WHERE form_id = 'CON' AND uor > 0 " .
241 "ORDER BY group_id, seq");
242 $last_group = '';
243 $cell_count = 0;
244 $item_count = 0;
245 $display_style = 'block';
247 while ($frow = sqlFetchArray($fres)) {
248 $this_group = $frow['group_id'];
249 $titlecols = $frow['titlecols'];
250 $datacols = $frow['datacols'];
251 $data_type = $frow['data_type'];
252 $field_id = $frow['field_id'];
253 $list_id = $frow['list_id'];
255 $currvalue = '';
257 if ($frow['edit_options'] == 'H') {
258 // This data comes from static history
259 if (isset($shrow[$field_id])) {
260 $currvalue = $shrow[$field_id];
262 } else {
263 if (isset($pprow[$field_id])) {
264 $currvalue = $pprow[$field_id];
268 // Handle a data category (group) change.
269 if (strcmp($this_group, $last_group) != 0) {
270 end_group();
271 $group_seq = 'con' . substr($this_group, 0, 1);
272 $group_name = $grparr[$this_group]['grp_title'];
273 $last_group = $this_group;
274 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
275 "onclick='return divclick(this,\"div_$group_seq\");'";
276 if ($display_style == 'block') {
277 echo " checked";
280 echo " /><b>$group_name</b></span>\n";
281 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
282 echo " <table border='0' cellpadding='0' width='100%'>\n";
283 $display_style = 'none';
286 // Handle starting of a new row.
287 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
288 end_row();
289 echo " <tr>";
292 if ($item_count == 0 && $titlecols == 0) {
293 $titlecols = 1;
296 // Handle starting of a new label cell.
297 if ($titlecols > 0) {
298 end_cell();
299 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
300 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
301 if ($cell_count == 2) {
302 echo " style='padding-left:10pt'";
305 echo ">";
306 $cell_count += $titlecols;
309 ++$item_count;
311 echo "<b>";
312 if ($frow['title']) {
313 echo $frow['title'] . ":";
314 } else {
315 echo "&nbsp;";
318 echo "</b>";
320 // Handle starting of a new data cell.
321 if ($datacols > 0) {
322 end_cell();
323 echo "<td valign='top' colspan='$datacols' class='text'";
324 if ($cell_count > 0) {
325 echo " style='padding-left:5pt'";
328 echo ">";
329 $cell_count += $datacols;
332 ++$item_count;
334 if ($frow['edit_options'] == 'H') {
335 echo generate_display_field($frow, $currvalue);
336 } else {
337 generate_form_field($frow, $currvalue);
341 end_group();
342 echo "</div>\n";
345 /*********************************************************************
347 function issue_ippf_srh_newtype() {
348 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
349 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
352 function issue_ippf_srh_save($issue) {
353 $sets = "id = '" add_escape_custom($issue) . "'";
354 $fres = sqlStatement("SELECT * FROM layout_options " .
355 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
356 "ORDER BY group_name, seq");
357 while ($frow = sqlFetchArray($fres)) {
358 $field_id = $frow['field_id'];
359 $value = get_layout_form_value($frow);
360 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
362 // This replaces the row if its id exists, otherwise inserts it.
363 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
366 function issue_ippf_srh_form($issue, $thispid) {
367 global $pprow, $item_count, $cell_count, $last_group;
369 $shrow = getHistoryData($thispid);
371 if ($issue) {
372 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
373 } else {
374 $pprow = array();
377 echo "<div id='ippf_srh' style='display:none'>\n";
379 $fres = sqlStatement("SELECT * FROM layout_options " .
380 "WHERE form_id = 'SRH' AND uor > 0 " .
381 "ORDER BY group_name, seq");
382 $last_group = '';
383 $cell_count = 0;
384 $item_count = 0;
385 $display_style = 'block';
387 while ($frow = sqlFetchArray($fres)) {
388 $this_group = $frow['group_name'];
389 $titlecols = $frow['titlecols'];
390 $datacols = $frow['datacols'];
391 $data_type = $frow['data_type'];
392 $field_id = $frow['field_id'];
393 $list_id = $frow['list_id'];
395 $currvalue = '';
397 if ($frow['edit_options'] == 'H') {
398 // This data comes from static history
399 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
400 } else {
401 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
404 // Handle a data category (group) change.
405 if (strcmp($this_group, $last_group) != 0) {
406 end_group();
407 $group_seq = 'srh' . substr($this_group, 0, 1);
408 $group_name = substr($this_group, 1);
409 $last_group = $this_group;
410 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
411 "onclick='return divclick(this,\"div_$group_seq\");'";
412 if ($display_style == 'block') echo " checked";
413 echo " /><b>$group_name</b></span>\n";
414 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
415 echo " <table border='0' cellpadding='0' width='100%'>\n";
416 $display_style = 'none';
419 // Handle starting of a new row.
420 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
421 end_row();
422 echo " <tr>";
425 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
427 // Handle starting of a new label cell.
428 if ($titlecols > 0) {
429 end_cell();
430 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
431 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
432 if ($cell_count == 2) echo " style='padding-left:10pt'";
433 echo ">";
434 $cell_count += $titlecols;
436 ++$item_count;
438 echo "<b>";
439 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
440 echo "</b>";
442 // Handle starting of a new data cell.
443 if ($datacols > 0) {
444 end_cell();
445 echo "<td valign='top' colspan='$datacols' class='text'";
446 if ($cell_count > 0) echo " style='padding-left:5pt'";
447 echo ">";
448 $cell_count += $datacols;
451 ++$item_count;
453 if ($frow['edit_options'] == 'H')
454 echo generate_display_field($frow, $currvalue);
455 else
456 generate_form_field($frow, $currvalue);
459 end_group();
460 echo "</div>\n";
462 *********************************************************************/