forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathippf_issues.inc.php
346 lines (286 loc) · 10.2 KB
/
ippf_issues.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<?php
/**
* This module is invoked by add_edit_issue.php as an extension to
* add support for issue types that are specific to IPPF.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Rod Roark <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2008-2009 Rod Roark <[email protected]>
* @copyright Copyright (c) 2017-2018 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("$srcdir/options.inc.php");
require_once("$srcdir/patient.inc.php");
$CPR = 4; // cells per row
$pprow = array();
function end_cell()
{
global $item_count, $cell_count;
if ($item_count > 0) {
echo "</td>";
$item_count = 0;
}
}
function end_row()
{
global $cell_count, $CPR;
end_cell();
if ($cell_count > 0) {
for (; $cell_count < $CPR; ++$cell_count) {
echo "<td></td>";
}
echo "</tr>\n";
$cell_count = 0;
}
}
function end_group()
{
global $last_group;
if (strlen($last_group) > 0) {
end_row();
echo " </table>\n";
echo "</div>\n";
}
}
function issue_ippf_gcac_newtype()
{
echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
}
function issue_ippf_gcac_save($issue)
{
$sets = "id = '" . add_escape_custom($issue) . "'";
$fres = sqlStatement("SELECT * FROM layout_options " .
"WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
"ORDER BY group_id, seq");
while ($frow = sqlFetchArray($fres)) {
$field_id = $frow['field_id'];
$value = get_layout_form_value($frow);
$sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
}
// This replaces the row if its id exists, otherwise inserts it.
sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
}
function issue_ippf_gcac_form($issue, $thispid)
{
global $pprow, $item_count, $cell_count, $last_group;
$shrow = getHistoryData($thispid);
if ($issue) {
$pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = ?", array($issue));
} else {
$pprow = array();
}
echo "<div id='ippf_gcac' style='display:none'>\n";
// Load array of properties for this layout and its groups.
$grparr = array();
getLayoutProperties('GCA', $grparr);
$fres = sqlStatement("SELECT * FROM layout_options " .
"WHERE form_id = 'GCA' AND uor > 0 " .
"ORDER BY group_id, seq");
$last_group = '';
$cell_count = 0;
$item_count = 0;
$display_style = 'block';
while ($frow = sqlFetchArray($fres)) {
$this_group = $frow['group_id'];
$titlecols = $frow['titlecols'];
$datacols = $frow['datacols'];
$data_type = $frow['data_type'];
$field_id = $frow['field_id'];
$list_id = $frow['list_id'];
$currvalue = '';
if ($frow['edit_options'] == 'H') {
// This data comes from static history
if (isset($shrow[$field_id])) {
$currvalue = $shrow[$field_id];
}
} else {
if (isset($pprow[$field_id])) {
$currvalue = $pprow[$field_id];
}
}
// Handle a data category (group) change.
if (strcmp($this_group, $last_group) != 0) {
end_group();
$group_seq = 'gca' . substr($this_group, 0, 1);
$group_name = $grparr[$this_group]['grp_title'];
$last_group = $this_group;
echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
"onclick='return divclick(this," . attr_js('div_' . $group_seq) . ");'";
if ($display_style == 'block') {
echo " checked";
}
echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
echo " <table border='0' cellpadding='0' width='100%'>\n";
$display_style = 'none';
}
// Handle starting of a new row.
if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
end_row();
echo " <tr>";
}
if ($item_count == 0 && $titlecols == 0) {
$titlecols = 1;
}
// Handle starting of a new label cell.
if ($titlecols > 0) {
end_cell();
echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
if ($cell_count == 2) {
echo " style='padding-left:10pt'";
}
echo ">";
$cell_count += $titlecols;
}
++$item_count;
echo "<b>";
if ($frow['title']) {
echo (text(xl_layout_label($frow['title'])) . ":");
} else {
echo " ";
}
echo "</b>";
// Handle starting of a new data cell.
if ($datacols > 0) {
end_cell();
echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
if ($cell_count > 0) {
echo " style='padding-left:5pt'";
}
echo ">";
$cell_count += $datacols;
}
++$item_count;
if ($frow['edit_options'] == 'H') {
echo generate_display_field($frow, $currvalue);
} else {
generate_form_field($frow, $currvalue);
}
}
end_group();
echo "</div>\n";
}
function issue_ippf_con_newtype()
{
echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
echo " document.getElementById('ippf_con').style.display = condisp;\n";
}
function issue_ippf_con_save($issue)
{
$sets = "id = '" . add_escape_custom($issue) . "'";
$fres = sqlStatement("SELECT * FROM layout_options " .
"WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
"ORDER BY group_id, seq");
while ($frow = sqlFetchArray($fres)) {
$field_id = $frow['field_id'];
$value = get_layout_form_value($frow);
$sets .= ", " . add_escape_custom($field_id) . " = '" . add_escape_custom($value) . "'";
}
// This replaces the row if its id exists, otherwise inserts it.
sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
}
function issue_ippf_con_form($issue, $thispid)
{
global $pprow, $item_count, $cell_count, $last_group;
$shrow = getHistoryData($thispid);
if ($issue) {
$pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = ?", array($issue));
} else {
$pprow = array();
}
echo "<div id='ippf_con' style='display:none'>\n";
// Load array of properties for this layout and its groups.
$grparr = array();
getLayoutProperties('CON', $grparr);
$fres = sqlStatement("SELECT * FROM layout_options " .
"WHERE form_id = 'CON' AND uor > 0 " .
"ORDER BY group_id, seq");
$last_group = '';
$cell_count = 0;
$item_count = 0;
$display_style = 'block';
while ($frow = sqlFetchArray($fres)) {
$this_group = $frow['group_id'];
$titlecols = $frow['titlecols'];
$datacols = $frow['datacols'];
$data_type = $frow['data_type'];
$field_id = $frow['field_id'];
$list_id = $frow['list_id'];
$currvalue = '';
if ($frow['edit_options'] == 'H') {
// This data comes from static history
if (isset($shrow[$field_id])) {
$currvalue = $shrow[$field_id];
}
} else {
if (isset($pprow[$field_id])) {
$currvalue = $pprow[$field_id];
}
}
// Handle a data category (group) change.
if (strcmp($this_group, $last_group) != 0) {
end_group();
$group_seq = 'con' . substr($this_group, 0, 1);
$group_name = $grparr[$this_group]['grp_title'];
$last_group = $this_group;
echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
"onclick='return divclick(this," . attr_js('div_' . $group_seq) . ");'";
if ($display_style == 'block') {
echo " checked";
}
echo " /><b>" . text($group_name) . "</b></span>\n";
echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
echo " <table border='0' cellpadding='0' width='100%'>\n";
$display_style = 'none';
}
// Handle starting of a new row.
if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
end_row();
echo " <tr>";
}
if ($item_count == 0 && $titlecols == 0) {
$titlecols = 1;
}
// Handle starting of a new label cell.
if ($titlecols > 0) {
end_cell();
echo "<td valign='top' colspan='" . attr($titlecols) . "' width='1%' nowrap";
echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
if ($cell_count == 2) {
echo " style='padding-left:10pt'";
}
echo ">";
$cell_count += $titlecols;
}
++$item_count;
echo "<b>";
if ($frow['title']) {
echo text($frow['title']) . ":";
} else {
echo " ";
}
echo "</b>";
// Handle starting of a new data cell.
if ($datacols > 0) {
end_cell();
echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
if ($cell_count > 0) {
echo " style='padding-left:5pt'";
}
echo ">";
$cell_count += $datacols;
}
++$item_count;
if ($frow['edit_options'] == 'H') {
echo generate_display_field($frow, $currvalue);
} else {
generate_form_field($frow, $currvalue);
}
}
end_group();
echo "</div>\n";
}