bug fixes in contrib
[openemr.git] / library / ippf_issues.inc.php
blob328f7b003e12ebb58ad530474081d9b9e07118a4
1 <?php
2 /**
3 * This module is invoked by add_edit_issue.php as an extension to
4 * add support for issue types that are specific to IPPF.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2008-2009 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("$srcdir/options.inc.php");
17 require_once("$srcdir/patient.inc");
19 $CPR = 4; // cells per row
21 $pprow = array();
23 function end_cell()
25 global $item_count, $cell_count;
26 if ($item_count > 0) {
27 echo "</td>";
28 $item_count = 0;
32 function end_row()
34 global $cell_count, $CPR;
35 end_cell();
36 if ($cell_count > 0) {
37 for (; $cell_count < $CPR;
38 ++$cell_count) {
39 echo "<td></td>";
42 echo "</tr>\n";
43 $cell_count = 0;
47 function end_group()
49 global $last_group;
50 if (strlen($last_group) > 0) {
51 end_row();
52 echo " </table>\n";
53 echo "</div>\n";
57 function issue_ippf_gcac_newtype()
59 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
60 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
63 function issue_ippf_gcac_save($issue)
65 $sets = "id = '" . add_escape_custom($issue) . "'";
66 $fres = sqlStatement("SELECT * FROM layout_options " .
67 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
68 "ORDER BY group_id, seq");
69 while ($frow = sqlFetchArray($fres)) {
70 $field_id = $frow['field_id'];
71 $value = get_layout_form_value($frow);
72 $sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
75 // This replaces the row if its id exists, otherwise inserts it.
76 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
79 function issue_ippf_gcac_form($issue, $thispid)
81 global $pprow, $item_count, $cell_count, $last_group;
83 $shrow = getHistoryData($thispid);
85 if ($issue) {
86 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = ?", array($issue));
87 } else {
88 $pprow = array();
91 echo "<div id='ippf_gcac' style='display:none'>\n";
93 // Load array of properties for this layout and its groups.
94 $grparr = array();
95 getLayoutProperties('GCA', $grparr);
97 $fres = sqlStatement("SELECT * FROM layout_options " .
98 "WHERE form_id = 'GCA' AND uor > 0 " .
99 "ORDER BY group_id, seq");
100 $last_group = '';
101 $cell_count = 0;
102 $item_count = 0;
103 $display_style = 'block';
105 while ($frow = sqlFetchArray($fres)) {
106 $this_group = $frow['group_id'];
107 $titlecols = $frow['titlecols'];
108 $datacols = $frow['datacols'];
109 $data_type = $frow['data_type'];
110 $field_id = $frow['field_id'];
111 $list_id = $frow['list_id'];
113 $currvalue = '';
115 if ($frow['edit_options'] == 'H') {
116 // This data comes from static history
117 if (isset($shrow[$field_id])) {
118 $currvalue = $shrow[$field_id];
120 } else {
121 if (isset($pprow[$field_id])) {
122 $currvalue = $pprow[$field_id];
126 // Handle a data category (group) change.
127 if (strcmp($this_group, $last_group) != 0) {
128 end_group();
129 $group_seq = 'gca' . substr($this_group, 0, 1);
130 $group_name = $grparr[$this_group]['grp_title'];
131 $last_group = $this_group;
132 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
133 "onclick='return divclick(this," . attr_js('div_'.$group_seq) . ");'";
134 if ($display_style == 'block') {
135 echo " checked";
138 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
139 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
140 echo " <table border='0' cellpadding='0' width='100%'>\n";
141 $display_style = 'none';
144 // Handle starting of a new row.
145 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
146 end_row();
147 echo " <tr>";
150 if ($item_count == 0 && $titlecols == 0) {
151 $titlecols = 1;
154 // Handle starting of a new label cell.
155 if ($titlecols > 0) {
156 end_cell();
157 echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
158 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
159 if ($cell_count == 2) {
160 echo " style='padding-left:10pt'";
163 echo ">";
164 $cell_count += $titlecols;
167 ++$item_count;
169 echo "<b>";
170 if ($frow['title']) {
171 echo (text(xl_layout_label($frow['title'])) . ":");
172 } else {
173 echo "&nbsp;";
176 echo "</b>";
178 // Handle starting of a new data cell.
179 if ($datacols > 0) {
180 end_cell();
181 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
182 if ($cell_count > 0) {
183 echo " style='padding-left:5pt'";
186 echo ">";
187 $cell_count += $datacols;
190 ++$item_count;
192 if ($frow['edit_options'] == 'H') {
193 echo generate_display_field($frow, $currvalue);
194 } else {
195 generate_form_field($frow, $currvalue);
199 end_group();
200 echo "</div>\n";
203 function issue_ippf_con_newtype()
205 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
206 echo " document.getElementById('ippf_con').style.display = condisp;\n";
209 function issue_ippf_con_save($issue)
211 $sets = "id = '" . add_escape_custom($issue) . "'";
212 $fres = sqlStatement("SELECT * FROM layout_options " .
213 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
214 "ORDER BY group_id, seq");
215 while ($frow = sqlFetchArray($fres)) {
216 $field_id = $frow['field_id'];
217 $value = get_layout_form_value($frow);
218 $sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
221 // This replaces the row if its id exists, otherwise inserts it.
222 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
225 function issue_ippf_con_form($issue, $thispid)
227 global $pprow, $item_count, $cell_count, $last_group;
229 $shrow = getHistoryData($thispid);
231 if ($issue) {
232 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = ?", array($issue));
233 } else {
234 $pprow = array();
237 echo "<div id='ippf_con' style='display:none'>\n";
239 // Load array of properties for this layout and its groups.
240 $grparr = array();
241 getLayoutProperties('CON', $grparr);
243 $fres = sqlStatement("SELECT * FROM layout_options " .
244 "WHERE form_id = 'CON' AND uor > 0 " .
245 "ORDER BY group_id, seq");
246 $last_group = '';
247 $cell_count = 0;
248 $item_count = 0;
249 $display_style = 'block';
251 while ($frow = sqlFetchArray($fres)) {
252 $this_group = $frow['group_id'];
253 $titlecols = $frow['titlecols'];
254 $datacols = $frow['datacols'];
255 $data_type = $frow['data_type'];
256 $field_id = $frow['field_id'];
257 $list_id = $frow['list_id'];
259 $currvalue = '';
261 if ($frow['edit_options'] == 'H') {
262 // This data comes from static history
263 if (isset($shrow[$field_id])) {
264 $currvalue = $shrow[$field_id];
266 } else {
267 if (isset($pprow[$field_id])) {
268 $currvalue = $pprow[$field_id];
272 // Handle a data category (group) change.
273 if (strcmp($this_group, $last_group) != 0) {
274 end_group();
275 $group_seq = 'con' . substr($this_group, 0, 1);
276 $group_name = $grparr[$this_group]['grp_title'];
277 $last_group = $this_group;
278 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
279 "onclick='return divclick(this," . attr_js('div_'.$group_seq) . ");'";
280 if ($display_style == 'block') {
281 echo " checked";
284 echo " /><b>" . text($group_name) . "</b></span>\n";
285 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
286 echo " <table border='0' cellpadding='0' width='100%'>\n";
287 $display_style = 'none';
290 // Handle starting of a new row.
291 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
292 end_row();
293 echo " <tr>";
296 if ($item_count == 0 && $titlecols == 0) {
297 $titlecols = 1;
300 // Handle starting of a new label cell.
301 if ($titlecols > 0) {
302 end_cell();
303 echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
304 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
305 if ($cell_count == 2) {
306 echo " style='padding-left:10pt'";
309 echo ">";
310 $cell_count += $titlecols;
313 ++$item_count;
315 echo "<b>";
316 if ($frow['title']) {
317 echo text($frow['title']) . ":";
318 } else {
319 echo "&nbsp;";
322 echo "</b>";
324 // Handle starting of a new data cell.
325 if ($datacols > 0) {
326 end_cell();
327 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
328 if ($cell_count > 0) {
329 echo " style='padding-left:5pt'";
332 echo ">";
333 $cell_count += $datacols;
336 ++$item_count;
338 if ($frow['edit_options'] == 'H') {
339 echo generate_display_field($frow, $currvalue);
340 } else {
341 generate_form_field($frow, $currvalue);
345 end_group();
346 echo "</div>\n";