dev ldap fixes (#3914)
[openemr.git] / library / ippf_issues.inc.php
blob8d74daf15bc5a4bbcb6f1fcdd33fb0b313e98dae
1 <?php
3 /**
4 * This module is invoked by add_edit_issue.php as an extension to
5 * add support for issue types that are specific to IPPF.
7 * @package OpenEMR
8 * @link https://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2008-2009 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
13 * @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; ++$cell_count) {
38 echo "<td></td>";
41 echo "</tr>\n";
42 $cell_count = 0;
46 function end_group()
48 global $last_group;
49 if (strlen($last_group) > 0) {
50 end_row();
51 echo " </table>\n";
52 echo "</div>\n";
56 function issue_ippf_gcac_newtype()
58 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
59 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
62 function issue_ippf_gcac_save($issue)
64 $sets = "id = '" . add_escape_custom($issue) . "'";
65 $fres = sqlStatement("SELECT * FROM layout_options " .
66 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
67 "ORDER BY group_id, seq");
68 while ($frow = sqlFetchArray($fres)) {
69 $field_id = $frow['field_id'];
70 $value = get_layout_form_value($frow);
71 $sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
74 // This replaces the row if its id exists, otherwise inserts it.
75 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
78 function issue_ippf_gcac_form($issue, $thispid)
80 global $pprow, $item_count, $cell_count, $last_group;
82 $shrow = getHistoryData($thispid);
84 if ($issue) {
85 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = ?", array($issue));
86 } else {
87 $pprow = array();
90 echo "<div id='ippf_gcac' style='display:none'>\n";
92 // Load array of properties for this layout and its groups.
93 $grparr = array();
94 getLayoutProperties('GCA', $grparr);
96 $fres = sqlStatement("SELECT * FROM layout_options " .
97 "WHERE form_id = 'GCA' AND uor > 0 " .
98 "ORDER BY group_id, seq");
99 $last_group = '';
100 $cell_count = 0;
101 $item_count = 0;
102 $display_style = 'block';
104 while ($frow = sqlFetchArray($fres)) {
105 $this_group = $frow['group_id'];
106 $titlecols = $frow['titlecols'];
107 $datacols = $frow['datacols'];
108 $data_type = $frow['data_type'];
109 $field_id = $frow['field_id'];
110 $list_id = $frow['list_id'];
112 $currvalue = '';
114 if ($frow['edit_options'] == 'H') {
115 // This data comes from static history
116 if (isset($shrow[$field_id])) {
117 $currvalue = $shrow[$field_id];
119 } else {
120 if (isset($pprow[$field_id])) {
121 $currvalue = $pprow[$field_id];
125 // Handle a data category (group) change.
126 if (strcmp($this_group, $last_group) != 0) {
127 end_group();
128 $group_seq = 'gca' . substr($this_group, 0, 1);
129 $group_name = $grparr[$this_group]['grp_title'];
130 $last_group = $this_group;
131 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
132 "onclick='return divclick(this," . attr_js('div_' . $group_seq) . ");'";
133 if ($display_style == 'block') {
134 echo " checked";
137 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
138 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
139 echo " <table border='0' cellpadding='0' width='100%'>\n";
140 $display_style = 'none';
143 // Handle starting of a new row.
144 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
145 end_row();
146 echo " <tr>";
149 if ($item_count == 0 && $titlecols == 0) {
150 $titlecols = 1;
153 // Handle starting of a new label cell.
154 if ($titlecols > 0) {
155 end_cell();
156 echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
157 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
158 if ($cell_count == 2) {
159 echo " style='padding-left:10pt'";
162 echo ">";
163 $cell_count += $titlecols;
166 ++$item_count;
168 echo "<b>";
169 if ($frow['title']) {
170 echo (text(xl_layout_label($frow['title'])) . ":");
171 } else {
172 echo "&nbsp;";
175 echo "</b>";
177 // Handle starting of a new data cell.
178 if ($datacols > 0) {
179 end_cell();
180 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
181 if ($cell_count > 0) {
182 echo " style='padding-left:5pt'";
185 echo ">";
186 $cell_count += $datacols;
189 ++$item_count;
191 if ($frow['edit_options'] == 'H') {
192 echo generate_display_field($frow, $currvalue);
193 } else {
194 generate_form_field($frow, $currvalue);
198 end_group();
199 echo "</div>\n";
202 function issue_ippf_con_newtype()
204 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
205 echo " document.getElementById('ippf_con').style.display = condisp;\n";
208 function issue_ippf_con_save($issue)
210 $sets = "id = '" . add_escape_custom($issue) . "'";
211 $fres = sqlStatement("SELECT * FROM layout_options " .
212 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
213 "ORDER BY group_id, seq");
214 while ($frow = sqlFetchArray($fres)) {
215 $field_id = $frow['field_id'];
216 $value = get_layout_form_value($frow);
217 $sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
220 // This replaces the row if its id exists, otherwise inserts it.
221 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
224 function issue_ippf_con_form($issue, $thispid)
226 global $pprow, $item_count, $cell_count, $last_group;
228 $shrow = getHistoryData($thispid);
230 if ($issue) {
231 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = ?", array($issue));
232 } else {
233 $pprow = array();
236 echo "<div id='ippf_con' style='display:none'>\n";
238 // Load array of properties for this layout and its groups.
239 $grparr = array();
240 getLayoutProperties('CON', $grparr);
242 $fres = sqlStatement("SELECT * FROM layout_options " .
243 "WHERE form_id = 'CON' AND uor > 0 " .
244 "ORDER BY group_id, seq");
245 $last_group = '';
246 $cell_count = 0;
247 $item_count = 0;
248 $display_style = 'block';
250 while ($frow = sqlFetchArray($fres)) {
251 $this_group = $frow['group_id'];
252 $titlecols = $frow['titlecols'];
253 $datacols = $frow['datacols'];
254 $data_type = $frow['data_type'];
255 $field_id = $frow['field_id'];
256 $list_id = $frow['list_id'];
258 $currvalue = '';
260 if ($frow['edit_options'] == 'H') {
261 // This data comes from static history
262 if (isset($shrow[$field_id])) {
263 $currvalue = $shrow[$field_id];
265 } else {
266 if (isset($pprow[$field_id])) {
267 $currvalue = $pprow[$field_id];
271 // Handle a data category (group) change.
272 if (strcmp($this_group, $last_group) != 0) {
273 end_group();
274 $group_seq = 'con' . substr($this_group, 0, 1);
275 $group_name = $grparr[$this_group]['grp_title'];
276 $last_group = $this_group;
277 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
278 "onclick='return divclick(this," . attr_js('div_' . $group_seq) . ");'";
279 if ($display_style == 'block') {
280 echo " checked";
283 echo " /><b>" . text($group_name) . "</b></span>\n";
284 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
285 echo " <table border='0' cellpadding='0' width='100%'>\n";
286 $display_style = 'none';
289 // Handle starting of a new row.
290 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
291 end_row();
292 echo " <tr>";
295 if ($item_count == 0 && $titlecols == 0) {
296 $titlecols = 1;
299 // Handle starting of a new label cell.
300 if ($titlecols > 0) {
301 end_cell();
302 echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
303 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
304 if ($cell_count == 2) {
305 echo " style='padding-left:10pt'";
308 echo ">";
309 $cell_count += $titlecols;
312 ++$item_count;
314 echo "<b>";
315 if ($frow['title']) {
316 echo text($frow['title']) . ":";
317 } else {
318 echo "&nbsp;";
321 echo "</b>";
323 // Handle starting of a new data cell.
324 if ($datacols > 0) {
325 end_cell();
326 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
327 if ($cell_count > 0) {
328 echo " style='padding-left:5pt'";
331 echo ">";
332 $cell_count += $datacols;
335 ++$item_count;
337 if ($frow['edit_options'] == 'H') {
338 echo generate_display_field($frow, $currvalue);
339 } else {
340 generate_form_field($frow, $currvalue);
344 end_group();
345 echo "</div>\n";