added support for the scanned_notes encounter form
[openemr.git] / library / ippf_issues.inc.php
blobfcb1bc47bf8cb574744f071bf693ff2e79fda332
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 to add support
10 // for issue types that are specific to IPPF.
12 require_once("$srcdir/options.inc.php");
14 $CPR = 4; // cells per row
16 $pprow = array();
18 function end_cell() {
19 global $item_count, $cell_count;
20 if ($item_count > 0) {
21 echo "</td>";
22 $item_count = 0;
26 function end_row() {
27 global $cell_count, $CPR;
28 end_cell();
29 if ($cell_count > 0) {
30 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
31 echo "</tr>\n";
32 $cell_count = 0;
36 function end_group() {
37 global $last_group;
38 if (strlen($last_group) > 0) {
39 end_row();
40 echo " </table>\n";
41 echo "</div>\n";
45 function issue_ippf_gcac_newtype() {
46 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
47 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
50 function issue_ippf_gcac_save($issue) {
51 $sets = "id = '$issue'";
52 $fres = sqlStatement("SELECT * FROM layout_options " .
53 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' " .
54 "ORDER BY group_name, seq");
55 while ($frow = sqlFetchArray($fres)) {
56 $field_id = $frow['field_id'];
57 $value = get_layout_form_value($frow);
58 $sets .= ", $field_id = '$value'";
60 // This replaces the row if its id exists, otherwise inserts it.
61 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
64 function issue_ippf_gcac_form($issue) {
65 global $pprow, $item_count, $cell_count, $last_group;
67 if ($issue) {
68 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
69 } else {
70 $pprow = array();
73 echo "<div id='ippf_gcac' style='display:none'>\n";
75 $fres = sqlStatement("SELECT * FROM layout_options " .
76 "WHERE form_id = 'GCA' AND uor > 0 " .
77 "ORDER BY group_name, seq");
78 $last_group = '';
79 $cell_count = 0;
80 $item_count = 0;
81 $display_style = 'block';
83 while ($frow = sqlFetchArray($fres)) {
84 $this_group = $frow['group_name'];
85 $titlecols = $frow['titlecols'];
86 $datacols = $frow['datacols'];
87 $data_type = $frow['data_type'];
88 $field_id = $frow['field_id'];
89 $list_id = $frow['list_id'];
91 $currvalue = '';
92 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
94 // Handle a data category (group) change.
95 if (strcmp($this_group, $last_group) != 0) {
96 end_group();
97 $group_seq = 'gca' . substr($this_group, 0, 1);
98 $group_name = substr($this_group, 1);
99 $last_group = $this_group;
100 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
101 "onclick='return divclick(this,\"div_$group_seq\");'";
102 if ($display_style == 'block') echo " checked";
103 echo " /><b>$group_name</b></span>\n";
104 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
105 echo " <table border='0' cellpadding='0' width='100%'>\n";
106 $display_style = 'none';
109 // Handle starting of a new row.
110 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
111 end_row();
112 echo " <tr>";
115 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
117 // Handle starting of a new label cell.
118 if ($titlecols > 0) {
119 end_cell();
120 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
121 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
122 if ($cell_count == 2) echo " style='padding-left:10pt'";
123 echo ">";
124 $cell_count += $titlecols;
126 ++$item_count;
128 echo "<b>";
129 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
130 echo "</b>";
132 // Handle starting of a new data cell.
133 if ($datacols > 0) {
134 end_cell();
135 echo "<td valign='top' colspan='$datacols' class='text'";
136 if ($cell_count > 0) echo " style='padding-left:5pt'";
137 echo ">";
138 $cell_count += $datacols;
141 ++$item_count;
142 generate_form_field($frow, $currvalue);
145 end_group();
146 echo "</div>\n";
149 function issue_ippf_con_newtype() {
150 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
151 echo " document.getElementById('ippf_con').style.display = condisp;\n";
154 function issue_ippf_con_save($issue) {
155 $sets = "id = '$issue'";
156 $fres = sqlStatement("SELECT * FROM layout_options " .
157 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' " .
158 "ORDER BY group_name, seq");
159 while ($frow = sqlFetchArray($fres)) {
160 $field_id = $frow['field_id'];
161 $value = get_layout_form_value($frow);
162 $sets .= ", $field_id = '$value'";
164 // This replaces the row if its id exists, otherwise inserts it.
165 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
168 function issue_ippf_con_form($issue) {
169 global $pprow, $item_count, $cell_count, $last_group;
171 if ($issue) {
172 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
173 } else {
174 $pprow = array();
177 echo "<div id='ippf_con' style='display:none'>\n";
179 $fres = sqlStatement("SELECT * FROM layout_options " .
180 "WHERE form_id = 'CON' AND uor > 0 " .
181 "ORDER BY group_name, seq");
182 $last_group = '';
183 $cell_count = 0;
184 $item_count = 0;
185 $display_style = 'block';
187 while ($frow = sqlFetchArray($fres)) {
188 $this_group = $frow['group_name'];
189 $titlecols = $frow['titlecols'];
190 $datacols = $frow['datacols'];
191 $data_type = $frow['data_type'];
192 $field_id = $frow['field_id'];
193 $list_id = $frow['list_id'];
195 $currvalue = '';
196 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
198 // Handle a data category (group) change.
199 if (strcmp($this_group, $last_group) != 0) {
200 end_group();
201 $group_seq = 'con' . substr($this_group, 0, 1);
202 $group_name = substr($this_group, 1);
203 $last_group = $this_group;
204 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
205 "onclick='return divclick(this,\"div_$group_seq\");'";
206 if ($display_style == 'block') echo " checked";
207 echo " /><b>$group_name</b></span>\n";
208 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
209 echo " <table border='0' cellpadding='0' width='100%'>\n";
210 $display_style = 'none';
213 // Handle starting of a new row.
214 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
215 end_row();
216 echo " <tr>";
219 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
221 // Handle starting of a new label cell.
222 if ($titlecols > 0) {
223 end_cell();
224 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
225 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
226 if ($cell_count == 2) echo " style='padding-left:10pt'";
227 echo ">";
228 $cell_count += $titlecols;
230 ++$item_count;
232 echo "<b>";
233 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
234 echo "</b>";
236 // Handle starting of a new data cell.
237 if ($datacols > 0) {
238 end_cell();
239 echo "<td valign='top' colspan='$datacols' class='text'";
240 if ($cell_count > 0) echo " style='padding-left:5pt'";
241 echo ">";
242 $cell_count += $datacols;
245 ++$item_count;
246 generate_form_field($frow, $currvalue);
249 end_group();
250 echo "</div>\n";