removed new acceptors from ma stats
[openemr.git] / library / ippf_issues.inc.php
blobcf07dce736de655b47bf48030ee7eee7e4d44f01
1 <?php
2 // Copyright (C) 2008 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() {
20 global $item_count, $cell_count;
21 if ($item_count > 0) {
22 echo "</td>";
23 $item_count = 0;
27 function end_row() {
28 global $cell_count, $CPR;
29 end_cell();
30 if ($cell_count > 0) {
31 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
32 echo "</tr>\n";
33 $cell_count = 0;
37 function end_group() {
38 global $last_group;
39 if (strlen($last_group) > 0) {
40 end_row();
41 echo " </table>\n";
42 echo "</div>\n";
46 function issue_ippf_gcac_newtype() {
47 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
48 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
51 function issue_ippf_gcac_save($issue) {
52 $sets = "id = '$issue'";
53 $fres = sqlStatement("SELECT * FROM layout_options " .
54 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
55 "ORDER BY group_name, seq");
56 while ($frow = sqlFetchArray($fres)) {
57 $field_id = $frow['field_id'];
58 $value = get_layout_form_value($frow);
59 $sets .= ", $field_id = '$value'";
61 // This replaces the row if its id exists, otherwise inserts it.
62 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
65 function issue_ippf_gcac_form($issue, $thispid) {
66 global $pprow, $item_count, $cell_count, $last_group;
68 $shrow = getHistoryData($thispid);
70 if ($issue) {
71 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
72 } else {
73 $pprow = array();
76 echo "<div id='ippf_gcac' style='display:none'>\n";
78 $fres = sqlStatement("SELECT * FROM layout_options " .
79 "WHERE form_id = 'GCA' AND uor > 0 " .
80 "ORDER BY group_name, seq");
81 $last_group = '';
82 $cell_count = 0;
83 $item_count = 0;
84 $display_style = 'block';
86 while ($frow = sqlFetchArray($fres)) {
87 $this_group = $frow['group_name'];
88 $titlecols = $frow['titlecols'];
89 $datacols = $frow['datacols'];
90 $data_type = $frow['data_type'];
91 $field_id = $frow['field_id'];
92 $list_id = $frow['list_id'];
94 $currvalue = '';
96 if ($frow['edit_options'] == 'H') {
97 // This data comes from static history
98 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
99 } else {
100 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
103 // Handle a data category (group) change.
104 if (strcmp($this_group, $last_group) != 0) {
105 end_group();
106 $group_seq = 'gca' . substr($this_group, 0, 1);
107 $group_name = substr($this_group, 1);
108 $last_group = $this_group;
109 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
110 "onclick='return divclick(this,\"div_$group_seq\");'";
111 if ($display_style == 'block') echo " checked";
112 echo " /><b>$group_name</b></span>\n";
113 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
114 echo " <table border='0' cellpadding='0' width='100%'>\n";
115 $display_style = 'none';
118 // Handle starting of a new row.
119 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
120 end_row();
121 echo " <tr>";
124 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
126 // Handle starting of a new label cell.
127 if ($titlecols > 0) {
128 end_cell();
129 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
130 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
131 if ($cell_count == 2) echo " style='padding-left:10pt'";
132 echo ">";
133 $cell_count += $titlecols;
135 ++$item_count;
137 echo "<b>";
138 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
139 echo "</b>";
141 // Handle starting of a new data cell.
142 if ($datacols > 0) {
143 end_cell();
144 echo "<td valign='top' colspan='$datacols' class='text'";
145 if ($cell_count > 0) echo " style='padding-left:5pt'";
146 echo ">";
147 $cell_count += $datacols;
150 ++$item_count;
152 if ($frow['edit_options'] == 'H')
153 echo generate_display_field($frow, $currvalue);
154 else
155 generate_form_field($frow, $currvalue);
158 end_group();
159 echo "</div>\n";
162 function issue_ippf_con_newtype() {
163 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
164 echo " document.getElementById('ippf_con').style.display = condisp;\n";
167 function issue_ippf_con_save($issue) {
168 $sets = "id = '$issue'";
169 $fres = sqlStatement("SELECT * FROM layout_options " .
170 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
171 "ORDER BY group_name, seq");
172 while ($frow = sqlFetchArray($fres)) {
173 $field_id = $frow['field_id'];
174 $value = get_layout_form_value($frow);
175 $sets .= ", $field_id = '$value'";
177 // This replaces the row if its id exists, otherwise inserts it.
178 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
181 function issue_ippf_con_form($issue, $thispid) {
182 global $pprow, $item_count, $cell_count, $last_group;
184 $shrow = getHistoryData($thispid);
186 if ($issue) {
187 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
188 } else {
189 $pprow = array();
192 echo "<div id='ippf_con' style='display:none'>\n";
194 $fres = sqlStatement("SELECT * FROM layout_options " .
195 "WHERE form_id = 'CON' AND uor > 0 " .
196 "ORDER BY group_name, seq");
197 $last_group = '';
198 $cell_count = 0;
199 $item_count = 0;
200 $display_style = 'block';
202 while ($frow = sqlFetchArray($fres)) {
203 $this_group = $frow['group_name'];
204 $titlecols = $frow['titlecols'];
205 $datacols = $frow['datacols'];
206 $data_type = $frow['data_type'];
207 $field_id = $frow['field_id'];
208 $list_id = $frow['list_id'];
210 $currvalue = '';
212 if ($frow['edit_options'] == 'H') {
213 // This data comes from static history
214 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
215 } else {
216 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
219 // Handle a data category (group) change.
220 if (strcmp($this_group, $last_group) != 0) {
221 end_group();
222 $group_seq = 'con' . substr($this_group, 0, 1);
223 $group_name = substr($this_group, 1);
224 $last_group = $this_group;
225 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
226 "onclick='return divclick(this,\"div_$group_seq\");'";
227 if ($display_style == 'block') echo " checked";
228 echo " /><b>$group_name</b></span>\n";
229 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
230 echo " <table border='0' cellpadding='0' width='100%'>\n";
231 $display_style = 'none';
234 // Handle starting of a new row.
235 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
236 end_row();
237 echo " <tr>";
240 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
242 // Handle starting of a new label cell.
243 if ($titlecols > 0) {
244 end_cell();
245 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
246 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
247 if ($cell_count == 2) echo " style='padding-left:10pt'";
248 echo ">";
249 $cell_count += $titlecols;
251 ++$item_count;
253 echo "<b>";
254 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
255 echo "</b>";
257 // Handle starting of a new data cell.
258 if ($datacols > 0) {
259 end_cell();
260 echo "<td valign='top' colspan='$datacols' class='text'";
261 if ($cell_count > 0) echo " style='padding-left:5pt'";
262 echo ">";
263 $cell_count += $datacols;
266 ++$item_count;
268 if ($frow['edit_options'] == 'H')
269 echo generate_display_field($frow, $currvalue);
270 else
271 generate_form_field($frow, $currvalue);
274 end_group();
275 echo "</div>\n";
278 /*********************************************************************
280 function issue_ippf_srh_newtype() {
281 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
282 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
285 function issue_ippf_srh_save($issue) {
286 $sets = "id = '$issue'";
287 $fres = sqlStatement("SELECT * FROM layout_options " .
288 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
289 "ORDER BY group_name, seq");
290 while ($frow = sqlFetchArray($fres)) {
291 $field_id = $frow['field_id'];
292 $value = get_layout_form_value($frow);
293 $sets .= ", $field_id = '$value'";
295 // This replaces the row if its id exists, otherwise inserts it.
296 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
299 function issue_ippf_srh_form($issue, $thispid) {
300 global $pprow, $item_count, $cell_count, $last_group;
302 $shrow = getHistoryData($thispid);
304 if ($issue) {
305 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
306 } else {
307 $pprow = array();
310 echo "<div id='ippf_srh' style='display:none'>\n";
312 $fres = sqlStatement("SELECT * FROM layout_options " .
313 "WHERE form_id = 'SRH' AND uor > 0 " .
314 "ORDER BY group_name, seq");
315 $last_group = '';
316 $cell_count = 0;
317 $item_count = 0;
318 $display_style = 'block';
320 while ($frow = sqlFetchArray($fres)) {
321 $this_group = $frow['group_name'];
322 $titlecols = $frow['titlecols'];
323 $datacols = $frow['datacols'];
324 $data_type = $frow['data_type'];
325 $field_id = $frow['field_id'];
326 $list_id = $frow['list_id'];
328 $currvalue = '';
330 if ($frow['edit_options'] == 'H') {
331 // This data comes from static history
332 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
333 } else {
334 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
337 // Handle a data category (group) change.
338 if (strcmp($this_group, $last_group) != 0) {
339 end_group();
340 $group_seq = 'srh' . substr($this_group, 0, 1);
341 $group_name = substr($this_group, 1);
342 $last_group = $this_group;
343 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
344 "onclick='return divclick(this,\"div_$group_seq\");'";
345 if ($display_style == 'block') echo " checked";
346 echo " /><b>$group_name</b></span>\n";
347 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
348 echo " <table border='0' cellpadding='0' width='100%'>\n";
349 $display_style = 'none';
352 // Handle starting of a new row.
353 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
354 end_row();
355 echo " <tr>";
358 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
360 // Handle starting of a new label cell.
361 if ($titlecols > 0) {
362 end_cell();
363 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
364 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
365 if ($cell_count == 2) echo " style='padding-left:10pt'";
366 echo ">";
367 $cell_count += $titlecols;
369 ++$item_count;
371 echo "<b>";
372 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
373 echo "</b>";
375 // Handle starting of a new data cell.
376 if ($datacols > 0) {
377 end_cell();
378 echo "<td valign='top' colspan='$datacols' class='text'";
379 if ($cell_count > 0) echo " style='padding-left:5pt'";
380 echo ">";
381 $cell_count += $datacols;
384 ++$item_count;
386 if ($frow['edit_options'] == 'H')
387 echo generate_display_field($frow, $currvalue);
388 else
389 generate_form_field($frow, $currvalue);
392 end_group();
393 echo "</div>\n";
395 *********************************************************************/