some more updates to edit_list script
[openemr.git] / interface / super / edit_list.php
blob0cbde04f4e1d8e44991dcf6b76f10e274c76a3ba
1 <?php
2 /**
3 * Administration Lists Module.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Dan Ehrlich <daniel.ehrlich1@gmail.com>
10 * @author Teny <teny@zhservices.com>
11 * @copyright Copyright (c) 2007-2017 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("../globals.php");
17 require_once("$srcdir/acl.inc");
18 require_once("$phpgacl_location/gacl_api.class.php");
19 require_once("$srcdir/lists.inc");
20 require_once("../../custom/code_types.inc.php");
21 require_once("$srcdir/options.inc.php");
23 use OpenEMR\Core\Header;
25 // Below allows the list to default to the first item on the list
26 // when list_id is blank.
27 $blank_list_id = '';
28 if (empty($_REQUEST['list_id'])) {
29 $list_id = 'language';
30 $blank_list_id = true;
31 } else {
32 $list_id = $_REQUEST['list_id'];
35 // Check authorization.
36 $thisauth = acl_check('admin', 'super');
37 if (!$thisauth) {
38 die(xlt('Not authorized'));
41 // If we are saving, then save.
43 if ($_POST['formaction'] == 'save' && $list_id) {
44 $opt = $_POST['opt'];
45 if ($list_id == 'feesheet') {
46 // special case for the feesheet list
47 sqlStatement("DELETE FROM fee_sheet_options");
48 for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
49 $iter = $opt["$lino"];
50 $category = formTrim($iter['category']);
51 $option = formTrim($iter['option']);
52 $codes = formTrim($iter['codes']);
53 if (strlen($category) > 0 && strlen($option) > 0) {
54 sqlInsert("INSERT INTO fee_sheet_options ( " .
55 "fs_category, fs_option, fs_codes " .
56 ") VALUES ( ?,?,? )", array($category, $option, $codes));
59 } elseif ($list_id == 'code_types') {
60 // special case for code types
61 sqlStatement("DELETE FROM code_types");
62 for ($lino = 1; isset($opt["$lino"]['ct_key']); ++$lino) {
63 $iter = $opt["$lino"];
64 $ct_key = formTrim($iter['ct_key']);
65 $ct_id = formTrim($iter['ct_id']) + 0;
66 $ct_seq = formTrim($iter['ct_seq']) + 0;
67 $ct_mod = formTrim($iter['ct_mod']) + 0;
68 $ct_just = formTrim($iter['ct_just']);
69 $ct_mask = formTrim($iter['ct_mask']);
70 $ct_fee = empty($iter['ct_fee']) ? 0 : 1;
71 $ct_rel = empty($iter['ct_rel']) ? 0 : 1;
72 $ct_nofs = empty($iter['ct_nofs']) ? 0 : 1;
73 $ct_diag = empty($iter['ct_diag']) ? 0 : 1;
74 $ct_active = empty($iter['ct_active']) ? 0 : 1;
75 $ct_label = formTrim($iter['ct_label']);
76 $ct_external = formTrim($iter['ct_external']) + 0;
77 $ct_claim = empty($iter['ct_claim']) ? 0 : 1;
78 $ct_proc = empty($iter['ct_proc']) ? 0 : 1;
79 $ct_term = empty($iter['ct_term']) ? 0 : 1;
80 $ct_problem = empty($iter['ct_problem']) ? 0 : 1;
81 $ct_drug = empty($iter['ct_drug']) ? 0 : 1;
82 if (strlen($ct_key) > 0 && $ct_id > 0) {
83 sqlInsert(
84 "INSERT INTO code_types ( " .
85 "ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_mask, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term, ct_problem, ct_drug " .
86 ") VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
87 array(
88 $ct_key,
89 $ct_id,
90 $ct_seq,
91 $ct_mod,
92 $ct_just,
93 $ct_mask,
94 $ct_fee,
95 $ct_rel,
96 $ct_nofs,
97 $ct_diag,
98 $ct_active,
99 $ct_label,
100 $ct_external,
101 $ct_claim,
102 $ct_proc,
103 $ct_term,
104 $ct_problem,
105 $ct_drug
110 } elseif ($list_id == 'issue_types') {
111 // special case for issue_types
112 sqlStatement("DELETE FROM issue_types");
113 for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
114 $iter = $opt["$lino"];
115 $it_category = formTrim($iter['category']);
116 $it_type = formTrim($iter['type']);
117 if ((strlen($it_category) > 0) && (strlen($it_type) > 0)) {
118 sqlInsert("INSERT INTO issue_types (" .
119 "`active`,`category`,`ordering`, `type`, `plural`, `singular`, `abbreviation`, `style`, " .
120 "`force_show`, `aco_spec`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(
121 formTrim($iter['active']),
122 $it_category,
123 formTrim($iter['ordering']),
124 $it_type,
125 formTrim($iter['plural']),
126 formTrim($iter['singular']),
127 formTrim($iter['abbreviation']),
128 formTrim($iter['style']),
129 formTrim($iter['force_show']),
130 formTrim($iter['aco_spec']),
134 } else {
135 // all other lists
137 // collect the option toggle if using the 'immunizations' list
138 if ($list_id == 'immunizations') {
139 $ok_map_cvx_codes = isset($_POST['ok_map_cvx_codes']) ? $_POST['ok_map_cvx_codes'] : 0;
141 // erase lists options and recreate them from the submitted form data
142 sqlStatement("DELETE FROM list_options WHERE list_id = ?", array($list_id));
143 for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
144 $iter = $opt["$lino"];
145 $value = empty($iter['value']) ? 0 : (formTrim($iter['value']) + 0);
146 $id = formTrim($iter['id']);
147 if (strlen($id) > 0) {
148 // Special processing for the immunizations list
149 // Map the entered cvx codes into the immunizations table cvx_code
150 // Ensure the following conditions are met to do this:
151 // $list_id == 'immunizations'
152 // $value is an integer and greater than 0
153 // $id is set, not empty and not equal to 0
154 // (note that all these filters are important. Not allowing $id
155 // of zero here is extremely important; never remove this conditional
156 // or you risk corrupting your current immunizations database entries)
157 // $ok_map_cvx_codes is equal to 1
158 if ($list_id == 'immunizations' &&
159 is_int($value) &&
160 $value > 0 &&
161 isset($id) &&
162 !empty($id) &&
163 $id != 0 &&
164 $ok_map_cvx_codes == 1
166 sqlStatement("UPDATE `immunizations` " .
167 "SET `cvx_code`= ? " .
168 "WHERE `immunization_id`= ? ", array($value, $id));
171 // Force List Based Form names to start with LBF.
172 if ($list_id == 'lbfnames' && substr($id, 0, 3) != 'LBF') {
173 $id = "LBF$id";
176 // Force Transaction Form names to start with LBT.
177 if ($list_id == 'transactions' && substr($id, 0, 3) != 'LBT') {
178 $id = "LBT$id";
181 if ($list_id == 'apptstat' || $list_id == 'groupstat') {
182 $notes = formTrim($iter['apptstat_color']) . '|' . formTrim($iter['apptstat_timealert']);
183 } else {
184 $notes = formTrim($iter['notes']);
186 // Insert the list item
187 sqlInsert(
188 "INSERT INTO list_options ( " .
189 "list_id, option_id, title, seq, is_default, option_value, mapping, notes, codes, toggle_setting_1, toggle_setting_2, activity, subtype " .
190 ") VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
191 array(
192 $list_id,
193 $id,
194 formTrim($iter['title']),
195 formTrim($iter['seq']),
196 formTrim($iter['default']),
197 $value,
198 formTrim($iter['mapping']),
199 $notes,
200 formTrim($iter['codes']),
201 formTrim($iter['toggle_setting_1']),
202 formTrim($iter['toggle_setting_2']),
203 formTrim($iter['activity']),
204 formTrim($iter['subtype'])
210 } elseif ($_POST['formaction'] == 'addlist') {
211 // make a new list ID from the new list name
212 $newlistID = $_POST['newlistname'];
213 $newlistID = preg_replace("/\W/", "_", $newlistID);
215 // determine the position of this new list
216 $row = sqlQuery("SELECT max(seq) AS maxseq FROM list_options WHERE list_id= 'lists'");
218 // add the new list to the list-of-lists
219 sqlInsert("INSERT INTO list_options ( " .
220 "list_id, option_id, title, seq, is_default, option_value " .
221 ") VALUES ( 'lists', ?, ?, ?, '1', '0')", array($newlistID, $_POST['newlistname'], ($row['maxseq'] + 1)));
222 $list_id = $newlistID;
223 } elseif ($_POST['formaction'] == 'deletelist') {
224 // delete the lists options
225 sqlStatement("DELETE FROM list_options WHERE list_id = ?", array($_POST['list_id']));
226 // delete the list from the master list-of-lists
227 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' AND option_id='?", array($_POST['list_id']));
230 $opt_line_no = 0;
232 // Given a string of multiple instances of code_type|code|selector,
233 // make a description for each.
234 // @TODO Instead should use a function from custom/code_types.inc.php and need to remove casing functions
235 function getCodeDescriptions($codes)
237 global $code_types;
238 $arrcodes = explode('~', $codes);
239 $s = '';
240 foreach ($arrcodes as $codestring) {
241 if ($codestring === '') {
242 continue;
244 $arrcode = explode('|', $codestring);
245 $code_type = $arrcode[0];
246 $code = $arrcode[1];
247 $selector = $arrcode[2];
248 $desc = '';
249 if ($code_type == 'PROD') {
250 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = ?", array($code));
251 $desc = "$code:$selector " . $row['name'];
252 } else {
253 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
254 "code_type = ? AND " .
255 "code = ? ORDER BY modifier LIMIT 1", array($code_types[$code_type]['id'], $code ));
256 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
258 $desc = str_replace('~', ' ', $desc);
259 if ($s) {
260 $s .= '~';
262 $s .= $desc;
264 return $s;
267 // Write one option line to the form.
269 function writeOptionLine(
270 $option_id,
271 $title,
272 $seq,
273 $default,
274 $value,
275 $mapping = '',
276 $notes = '',
277 $codes = '',
278 $tog1 = '',
279 $tog2 = '',
280 $active = '1',
281 $subtype = ''
284 global $opt_line_no, $list_id;
285 ++$opt_line_no;
286 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
287 $checked = $default ? " checked" : "";
288 $checked_tog1 = $tog1 ? " checked" : "";
289 $checked_tog2 = $tog2 ? " checked" : "";
290 $checked_active = $active ? " checked" : "";
292 echo " <tr>\n";
294 echo " <td>";
295 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][id]' value='" .
296 attr($option_id) . "' size='12' maxlength='63' class='optin' />";
297 echo "</td>\n";
298 echo " <td>";
299 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][title]' value='" .
300 attr($title) . "' size='20' maxlength='63' class='optin' />";
301 echo "</td>\n";
303 // if not english and translating lists then show the translation
304 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
305 echo " <td align='center' class='translation'>" . xlt($title) . "</td>\n";
307 echo " <td>";
308 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][seq]' value='" .
309 attr($seq) . "' size='4' maxlength='10' class='optin' />";
310 echo "</td>\n";
312 echo " <td>";
313 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][default]' value='1' " .
314 "onclick='defClicked(" . attr($opt_line_no) . ")' class='optin'$checked />";
315 echo "</td>\n";
317 if (preg_match('/Eye_QP_/', $list_id)) {
318 echo " <td>";
319 echo "<select name='opt[" . attr($opt_line_no) . "][activity]' class='optin'>";
320 foreach (array(
321 1 => xl('Replace'),
322 2 => xl('Append')
323 ) as $key => $desc) {
324 echo "<option value='" . attr($key) . "'";
325 if ($key == $active) {
326 echo " selected";
328 echo ">" . text($desc) . "</option>";
330 echo "</select>";
331 echo "</td>";
332 } else {
333 echo " <td>";
334 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][activity]' value='1' " . " class='optin'$checked_active />";
335 echo "</td>\n";
337 // Tax rates, contraceptive methods and LBF names have an additional attribute.
339 if ($list_id == 'taxrate' || $list_id == 'contrameth' || $list_id == 'lbfnames' || $list_id == 'transactions') {
340 echo " <td>";
341 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][value]' value='" .
342 attr($value) . "' size='8' maxlength='15' class='optin' />";
343 echo "</td>\n";
344 } // Adjustment reasons use option_value as a reason category. This is
345 // needed to distinguish between adjustments that change the invoice
346 // balance and those that just shift responsibility of payment or
347 // are used as comments.
349 elseif ($list_id == 'adjreason') {
350 echo " <td>";
351 echo "<select name='opt[" . attr($opt_line_no) . "][value]' class='optin'>";
352 foreach (array(
353 1 => xl('Charge adjustment'),
354 2 => xl('Coinsurance'),
355 3 => xl('Deductible'),
356 4 => xl('Other pt resp'),
357 5 => xl('Comment'),
358 ) as $key => $desc) {
359 echo "<option value='" . attr($key) . "'";
360 if ($key == $value) {
361 echo " selected";
363 echo ">" . text($desc) . "</option>";
365 echo "</select>";
366 echo "</td>\n";
367 } // Address book categories use option_value to flag category as a
368 // person-centric vs company-centric vs indifferent.
370 elseif ($list_id == 'abook_type') {
371 echo " <td>";
372 echo "<select name='opt[" . attr($opt_line_no) . "][value]' class='optin'>";
373 foreach (array(
374 1 => xl('Unassigned'),
375 2 => xl('Person'),
376 3 => xl('Company'),
377 ) as $key => $desc) {
378 echo "<option value='" . attr($key) . "'";
379 if ($key == $value) {
380 echo " selected";
382 echo ">" . text($desc) . "</option>";
384 echo "</select>";
385 echo "</td>\n";
386 } // Immunization categories use option_value to map list items
387 // to CVX codes.
389 elseif ($list_id == 'immunizations') {
390 echo " <td>";
391 echo "<input type='text' size='10' name='opt[" . attr($opt_line_no) . "][value]' " .
392 "value='" . attr($value) . "' onclick='sel_cvxcode(this)' " .
393 "title='" . xla('Click to select or change CVX code') . "'/>";
394 echo "</td>\n";
397 // IPPF includes the ability to map each list item to a "master" identifier.
398 // Sports teams use this for some extra info for fitness levels.
400 if ($GLOBALS['ippf_specific'] || $list_id == 'fitness') {
401 echo " <td>";
402 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][mapping]' value='" .
403 attr($mapping) . "' size='12' maxlength='15' class='optin' />";
404 echo "</td>\n";
405 } elseif ($list_id == 'apptstat' || $list_id == 'groupstat') {
406 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
407 echo " <td>";
408 echo "<input type='text' class='jscolor' name='opt[" . attr($opt_line_no) . "][apptstat_color]' value='" .
409 attr($apptstat_color) . "' size='6' maxlength='6' class='optin' />";
410 echo "</td>\n";
411 echo " <td>";
412 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][apptstat_timealert]' value='" .
413 attr($apptstat_timealert) . "' size='2' maxlength='2' class='optin' />";
414 echo "</td>\n";
415 } else {
416 echo " <td>";
417 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][notes]' value='" .
418 attr($notes) . "' size='25' maxlength='255' class='optin' ";
419 echo "/>";
420 echo "</td>\n";
422 if ($list_id == 'apptstat' || $list_id == 'groupstat') {
423 echo " <td>";
424 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) ."][toggle_setting_1]' value='1' " .
425 "onclick='defClicked(" . attr($opt_line_no) . ")' class='optin'$checked_tog1 />";
426 echo "</td>\n";
427 echo " <td>";
428 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) ."][toggle_setting_2]' value='1' " .
429 "onclick='defClicked(" . attr($opt_line_no) . ")' class='optin'$checked_tog2 />";
430 echo "</td>\n";
432 echo " <td>";
433 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][codes]' title='" .
434 xla('Clinical Term Code(s)') . "' value='" .
435 attr($codes) . "' onclick='select_clin_term_code(this)' size='25' maxlength='255' class='optin' />";
436 echo "</td>\n";
438 if (preg_match('/_issue_list$/', $list_id)) {
439 echo " <td>";
440 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype', ' ', 'optin');
441 echo "</td>\n";
443 if (preg_match('/Eye_QP_/', $list_id)) {
444 echo "<input type='hidden' name='opt[" . attr($opt_line_no) . "][subtype]' value='" . attr($subtype) . "' />";
445 echo "<input type='hidden' name='opt[" . attr($opt_line_no) . "][mapping]' value='" . attr($mapping) . "' />";
447 echo " </tr>\n";
450 // Write a form line as above but for the special case of the Fee Sheet.
452 function writeFSLine($category, $option, $codes)
454 global $opt_line_no;
456 ++$opt_line_no;
457 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
459 $descs = getCodeDescriptions($codes);
461 echo " <tr>\n";
463 echo " <td>";
464 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][category]' value='" .
465 attr($category) . "' size='20' maxlength='63' class='optin' />";
466 echo "</td>\n";
468 echo " <td>";
469 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][option]' value='" .
470 attr($option) . "' size='20' maxlength='63' class='optin' />";
471 echo "</td>\n";
473 echo " <td align='left' class='optcell'>";
474 echo " <div id='codelist_" . attr($opt_line_no) . "'>";
475 if (strlen($descs)) {
476 $arrdescs = explode('~', $descs);
477 $i = 0;
478 foreach ($arrdescs as $desc) {
479 echo "<a href='' onclick='return delete_code(" . attr($opt_line_no) . ",$i)' title='" . xla('Delete') . "'>";
480 echo "[x]&nbsp;</a>" . text($desc) . "<br />";
481 ++$i;
484 echo "</div>";
485 echo "<a href='' onclick='return select_code(" . attr($opt_line_no) . ")'>";
486 echo "[" . xlt('Add') . "]</a>";
488 echo "<input type='hidden' name='opt[" . attr($opt_line_no) . "][codes]' value='" .
489 attr($codes) . "' />";
490 echo "<input type='hidden' name='opt[" . attr($opt_line_no) . "][descs]' value='" .
491 attr($descs) . "' />";
492 echo "</td>\n";
494 echo " </tr>\n";
499 * Helper functions for writeITLine() and writeCTLine().
501 function ctGenCell($opt_line_no, $data_array, $name, $size, $maxlength, $title = '')
503 $value = isset($data_array[$name]) ? $data_array[$name] : '';
504 $s = " <td";
505 if ($title) {
506 $s .= " title='" . attr($title) . "'";
508 $s .= ">";
509 $s .= "<input type='text' name='opt[" . attr($opt_line_no) . "][" . attr($name) . "]' value='";
510 $s .= attr($value);
511 $s .= "' size='" . attr($size) . "' maxlength='" . attr($maxlength) . "' class='optin' />";
512 $s .= "</td>\n";
513 return $s;
516 function ctGenCbox($opt_line_no, $data_array, $name, $title = '')
518 $checked = empty($data_array[$name]) ? '' : 'checked ';
519 $s = " <td";
520 if ($title) {
521 $s .= " title='" . attr($title) . "'";
523 $s .= ">";
524 $s .= "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][" . attr($name) . "]' value='1' ";
525 $s .= "$checked/>";
526 $s .= "</td>\n";
527 return $s;
530 function ctSelector($opt_line_no, $data_array, $name, $option_array, $title = '')
532 $value = isset($data_array[$name]) ? $data_array[$name] : '';
533 $s = " <td title='" . attr($title) . "'>";
534 $s .= "<select name='opt[" . attr($opt_line_no) . "][" . attr($name) . "]' class='optin'>";
535 foreach ($option_array as $key => $desc) {
536 $s .= "<option value='" . attr($key) . "'";
537 if ($key == $value) {
538 $s .= " selected";
540 $s .= ">" . text($desc) . "</option>";
542 $s .= "</select>";
543 $s .= "</td>\n";
544 return $s;
547 // Write a form line as above but for the special case of Code Types.
549 function writeCTLine($ct_array)
551 global $opt_line_no, $cd_external_options;
553 ++$opt_line_no;
554 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
556 echo " <tr>\n";
558 echo ctGenCBox(
559 $opt_line_no,
560 $ct_array,
561 'ct_active',
562 xl('Is this code type active?')
564 echo ctGenCell(
565 $opt_line_no,
566 $ct_array,
567 'ct_key',
570 xl('Unique human-readable identifier for this type')
572 echo ctGenCell(
573 $opt_line_no,
574 $ct_array,
575 'ct_id',
578 xl('Unique numeric identifier for this type')
580 echo ctGenCell(
581 $opt_line_no,
582 $ct_array,
583 'ct_label',
586 xl('Label for this type')
588 // if not english and translating lists then show the translation
589 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
590 echo " <td align='center' class='translation'>" . xlt($ct_array['ct_label']) . "</td>\n";
592 echo ctGenCell(
593 $opt_line_no,
594 $ct_array,
595 'ct_seq',
598 xl('Numeric display order')
600 echo ctGenCell(
601 $opt_line_no,
602 $ct_array,
603 'ct_mod',
606 xl('Length of modifier, 0 if none')
608 echo ctGenCell(
609 $opt_line_no,
610 $ct_array,
611 'ct_just',
614 xl('If billing justification is used enter the name of the diagnosis code type.')
616 echo ctGenCell(
617 $opt_line_no,
618 $ct_array,
619 'ct_mask',
622 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.')
624 echo ctGenCBox(
625 $opt_line_no,
626 $ct_array,
627 'ct_claim',
628 xl('Is this code type used in claims?')
630 echo ctGenCBox(
631 $opt_line_no,
632 $ct_array,
633 'ct_fee',
634 xl('Are fees charged for this type?')
636 echo ctGenCBox(
637 $opt_line_no,
638 $ct_array,
639 'ct_rel',
640 xl('Does this type allow related codes?')
642 echo ctGenCBox(
643 $opt_line_no,
644 $ct_array,
645 'ct_nofs',
646 xl('Is this type hidden in the fee sheet?')
648 echo ctGenCBox(
649 $opt_line_no,
650 $ct_array,
651 'ct_proc',
652 xl('Is this a procedure/service type?')
654 echo ctGenCBox(
655 $opt_line_no,
656 $ct_array,
657 'ct_diag',
658 xl('Is this a diagnosis type?')
660 echo ctGenCBox(
661 $opt_line_no,
662 $ct_array,
663 'ct_term',
664 xl('Is this a Clinical Term code type?')
666 echo ctGenCBox(
667 $opt_line_no,
668 $ct_array,
669 'ct_problem',
670 xl('Is this a Medical Problem code type?')
672 echo ctGenCBox(
673 $opt_line_no,
674 $ct_array,
675 'ct_drug',
676 xl('Is this a Medication type?')
678 echo ctSelector(
679 $opt_line_no,
680 $ct_array,
681 'ct_external',
682 $cd_external_options,
683 xl('Is this using external sql tables? If it is, then choose the format.')
685 echo " </tr>\n";
689 * Special case of Issue Types
691 function writeITLine($it_array)
693 global $opt_line_no, $ISSUE_TYPE_CATEGORIES, $ISSUE_TYPE_STYLES;
694 ++$opt_line_no;
695 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
696 echo " <tr>\n";
697 echo ctSelector($opt_line_no, $it_array, 'category', $ISSUE_TYPE_CATEGORIES, xl('OpenEMR Application Category'));
698 echo ctGenCBox($opt_line_no, $it_array, 'active', xl('Is this active?'));
699 echo ctGenCell($opt_line_no, $it_array, 'ordering', 4, 10, xl('Order'));
700 echo ctGenCell($opt_line_no, $it_array, 'type', 15, 75, xl('Issue Type'));
701 echo ctGenCell($opt_line_no, $it_array, 'plural', 15, 75, xl('Plural'));
702 // if not english and translating lists then show the translation
703 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
704 echo " <td align='center' class='translation'>" . xlt($it_array['plural']) . "</td>\n";
706 echo ctGenCell($opt_line_no, $it_array, 'singular', 15, 75, xl('Singular'));
707 // if not english and translating lists then show the translation
708 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
709 echo " <td align='center' class='translation'>" . xlt($it_array['singular']) . "</td>\n";
711 echo ctGenCell($opt_line_no, $it_array, 'abbreviation', 5, 10, xl('Abbreviation'));
712 // if not english and translating lists then show the translation
713 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
714 echo " <td align='center' class='translation'>" . xlt($it_array['abbreviation']) . "</td>\n";
716 echo ctSelector($opt_line_no, $it_array, 'style', $ISSUE_TYPE_STYLES, xl('Standard; Simplified: only title, start date, comments and an Active checkbox;no diagnosis, occurrence, end date, referred-by or sports fields. ; Football Injury'));
717 echo ctGenCBox($opt_line_no, $it_array, 'force_show', xl('Show this category on the patient summary screen even if no issues have been entered for this category.'));
719 echo "<td>";
720 echo "<select name='opt[" . attr($opt_line_no) . "][aco_spec]' class='optin'>";
721 echo "<option value=''></option>";
722 echo gen_aco_html_options($it_array['aco_spec']);
723 echo "</select>";
724 echo "</td>";
726 echo " </tr>\n";
730 <html>
732 <head>
733 <?php echo Header::setupHeader(['select2', 'jscolor']); ?>
734 <title><?php echo xlt('List Editor'); ?></title>
735 <style>
736 .optcell {
739 .optin {
740 background-color: transparent;
743 .help {
744 cursor: help;
747 .translation {
748 color: green;
750 </style>
751 <script type="text/javascript">
752 $(document).ready(function () {
753 $(".select-dropdown").select2({
754 theme: "bootstrap",
755 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
759 // Keeping track of code picker requests.
760 var current_lino = 0;
761 var current_sel_name = '';
762 var current_sel_clin_term = '';
764 // Helper function to set the contents of a div.
765 // This is for Fee Sheet administration.
766 function setDivContent(id, content) {
767 if (document.getElementById) {
768 var x = document.getElementById(id);
769 x.innerHTML = '';
770 x.innerHTML = content;
772 else if (document.all) {
773 var x = document.all[id];
774 x.innerHTML = content;
778 // Given a line number, redisplay its descriptive list of codes.
779 // This is for Fee Sheet administration.
780 function displayCodes(lino) {
781 var f = document.forms[0];
782 var s = '';
783 var descs = f['opt[' + lino + '][descs]'].value;
784 if (descs.length) {
785 var arrdescs = descs.split('~');
786 for (var i = 0; i < arrdescs.length; ++i) {
787 s += "<a href='' onclick='return delete_code(" + lino + "," + i + ")' title='<?php echo xla('Delete'); ?>'>";
788 s += "[x]&nbsp;</a>" + arrdescs[i] + "<br />";
791 setDivContent('codelist_' + lino, s);
794 // Helper function to remove a Fee Sheet code.
795 function dc_substring(s, i) {
796 var r = '';
797 var j = s.indexOf('~', i);
798 if (j < 0) { // deleting last segment
799 if (i > 0) r = s.substring(0, i - 1); // omits trailing ~
801 else { // not last segment
802 r = s.substring(0, i) + s.substring(j + 1);
804 return r;
807 // Remove a generated Fee Sheet code.
808 function delete_code(lino, seqno) {
809 var f = document.forms[0];
810 var celem = f['opt[' + lino + '][codes]'];
811 var delem = f['opt[' + lino + '][descs]'];
812 var ci = 0;
813 var di = 0;
814 for (var i = 0; i < seqno; ++i) {
815 ci = celem.value.indexOf('~', ci) + 1;
816 di = delem.value.indexOf('~', di) + 1;
818 celem.value = dc_substring(celem.value, ci);
819 delem.value = dc_substring(delem.value, di);
820 displayCodes(lino);
821 return false;
824 // This invokes the find-code popup.
825 // For Fee Sheet administration.
826 function select_code(lino) {
827 current_sel_name = '';
828 current_sel_clin_term = '';
829 current_lino = lino;
830 dlgopen('../patient_file/encounter/find_code_dynamic.php', '_blank', 900, 600);
831 return false;
834 // This invokes the find-code popup.
835 // For CVX/immunization code administration.
836 function sel_cvxcode(e) {
837 current_sel_clin_term = '';
838 current_sel_name = e.name;
839 dlgopen('../patient_file/encounter/find_code_dynamic.php?codetype=CVX', '_blank', 900, 600);
842 // This invokes the find-code popup.
843 // For CVX/immunization code administration.
844 function select_clin_term_code(e) {
845 current_sel_name = '';
846 current_sel_clin_term = e.name;
847 dlgopen('../patient_file/encounter/find_code_dynamic.php?codetype=<?php echo attr(collect_codetypes("clinical_term", "csv")); ?>', '_blank', 900, 600);
850 // This is for callback by the find-code popup.
851 function set_related(codetype, code, selector, codedesc) {
852 var f = document.forms[0];
853 if (current_sel_clin_term) {
854 // Coming from the Clinical Terms Code(s) edit
855 var e = f[current_sel_clin_term];
856 var s = e.value;
857 if (code) {
858 if (s.length > 0) s += ';';
859 s += codetype + ':' + code;
861 else {
862 s = '';
864 e.value = s;
866 else if (current_sel_name) {
867 // Coming from Immunizations edit
868 var e = f[current_sel_name];
869 var s = e.value;
870 if (code) {
871 s = code;
873 else {
874 s = '0';
876 e.value = s;
878 else {
879 // Coming from Fee Sheet edit
880 var celem = f['opt[' + current_lino + '][codes]'];
881 var delem = f['opt[' + current_lino + '][descs]'];
882 var i = 0;
883 while ((i = codedesc.indexOf('~')) >= 0) {
884 codedesc = codedesc.substring(0, i) + ' ' + codedesc.substring(i+1);
886 if (code) {
887 if (celem.value) {
888 celem.value += '~';
889 delem.value += '~';
891 celem.value += codetype + '|' + code + '|' + selector;
892 if (codetype == 'PROD') {
893 delem.value += code + ':' + selector + ' ' + codedesc;
894 } else {
895 delem.value += codetype + ':' + code + ' ' + codedesc;
897 } else {
898 celem.value = '';
899 delem.value = '';
901 displayCodes(current_lino);
905 // This is for callback by the find-code popup.
906 // Deletes the specified codetype:code from the currently selected list.
907 function del_related(s) {
908 var f = document.forms[0];
909 if (current_sel_clin_term) {
910 // Coming from the Clinical Terms Code(s) edit
911 my_del_related(s, f[current_sel_clin_term], false);
913 else if (current_sel_name) {
914 // Coming from Immunizations edit
915 f[current_sel_name].value = '0';
917 else {
918 // Coming from Fee Sheet edit
919 f['opt[' + current_lino + '][codes]'].value = '';
920 f['opt[' + current_lino + '][descs]'].value = '';
921 displayCodes(current_lino);
925 // This is for callback by the find-code popup.
926 // Returns the array of currently selected codes with each element in codetype:code format.
927 function get_related() {
928 var f = document.forms[0];
929 if (current_sel_clin_term) {
930 return f[current_sel_clin_term].value.split(';');
932 return new Array();
935 // Called when a "default" checkbox is clicked. Clears all the others.
936 function defClicked(lino) {
937 var f = document.forms[0];
938 for (var i = 1; f['opt[' + i + '][default]']; ++i) {
939 if (i != lino) f['opt[' + i + '][default]'].checked = false;
943 // Form validation and submission.
944 // This needs more validation.
945 function mysubmit() {
946 var f = document.forms[0];
947 if (f.list_id.value == 'code_types') {
948 for (var i = 1; f['opt[' + i + '][ct_key]'].value; ++i) {
949 var ikey = 'opt[' + i + ']';
950 for (var j = i + 1; f['opt[' + j + '][ct_key]'].value; ++j) {
951 var jkey = 'opt[' + j + ']';
952 if (f[ikey + '[ct_key]'].value == f[jkey + '[ct_key]'].value) {
953 alert('<?php echo xls('Error: duplicated name on line') ?>' + ' ' + j);
954 return;
956 if (parseInt(f[ikey + '[ct_id]'].value) == parseInt(f[jkey + '[ct_id]'].value)) {
957 alert('<?php echo xls('Error: duplicated ID on line') ?>' + ' ' + j);
958 return;
963 else if (f['opt[1][id]']) {
964 // Check for duplicate IDs.
965 for (var i = 1; f['opt[' + i + '][id]']; ++i) {
966 var ikey = 'opt[' + i + '][id]';
967 if (f[ikey].value == '') continue;
968 for (var j = i+1; f['opt[' + j + '][id]']; ++j) {
969 var jkey = 'opt[' + j + '][id]';
970 if (f[ikey].value.toUpperCase() == f[jkey].value.toUpperCase()) {
971 alert('<?php echo xls('Error: duplicated ID') ?>' + ': ' + f[jkey].value);
972 f[jkey].scrollIntoView();
973 f[jkey].focus();
974 f[jkey].select();
975 return;
980 f.submit();
983 </script>
985 </head>
987 <body class="body_top">
988 <form method='post' name='theform' id='theform' action='edit_list.php'>
989 <nav class="navbar navbar-default navbar-fixed-top">
990 <div class="container-fluid">
991 <div class="navbar-header">
992 <button type="button" class="navbar-toggle collapsed"
993 data-toggle="collapse" data-target="#navbar-list"
994 aria-expanded="false">
995 <span class="sr-only"><?php echo xlt('Toggle navigation'); ?></span>
996 <i class="fa fa-bars"></i>
997 </button>
998 <a class="navbar-brand"
999 href="#"><?php echo xlt('Manage Lists'); ?></a>
1000 </div>
1002 <!-- Collect the nav links, forms, and other content for toggling -->
1003 <div class="collapse navbar-collapse" id="navbar-list">
1004 <ul class="nav navbar-nav">
1005 <li><a href="#" data-toggle="modal"
1006 data-target="#modal-new-list"><i class="fa fa-plus"></i>&nbsp;<?php echo xlt('New List'); ?>
1007 </a>
1008 </li>
1009 <li>
1010 <a href="#" class="deletelist" id="<?php echo $list_id; ?>">
1011 <i class="fa fa-trash"></i>&nbsp;<?php echo xlt('Delete List'); ?>
1012 </a>
1013 </li>
1014 </ul>
1015 <input type="hidden" name="formaction" id="formaction">
1016 <div class="form-group navbar-left">
1017 <select name='list_id' class="form-control select-dropdown"
1018 id="list_id">
1019 <?php
1021 // List order depends on language translation options.
1022 $lang_id = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
1024 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
1025 !$GLOBALS['translate_lists']
1027 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1028 "list_id = 'lists' ORDER BY title, seq");
1029 } else {
1030 // Use and sort by the translated list name.
1031 $res = sqlStatement("SELECT lo.option_id, " .
1032 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
1033 "FROM list_options AS lo " .
1034 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
1035 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
1036 "ld.lang_id = ? " .
1037 "WHERE lo.list_id = 'lists' AND lo.edit_options = 1 " .
1038 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq", array($lang_id));
1041 while ($row = sqlFetchArray($res)) {
1042 // This allows the list to default to the first item on the list
1043 // when the list_id request parameter is blank.
1044 if (($blank_list_id) && ($list_id == 'language')) {
1045 $list_id = $row['option_id'];
1046 $blank_list_id = false;
1049 $key = $row['option_id'];
1050 echo "<option value='" . attr($key) . "'";
1051 if ($key == $list_id) {
1052 echo " selected";
1054 echo ">" . text($row['title']) . "</option>\n";
1058 </select>
1059 </div>
1061 </div><!-- /.navbar-collapse -->
1062 </div>
1063 </nav>
1065 <table class="table table-striped table-condensed" style="margin-top:55px;">
1066 <thead>
1067 <tr>
1068 <?php if ($list_id == 'feesheet') : ?>
1069 <td><b><?php echo xlt('Group'); ?></b></td>
1070 <td><b><?php echo xlt('Option'); ?></b></td>
1071 <td><b><?php echo xlt('Generates'); ?></b></td>
1072 <?php elseif ($list_id == 'code_types') : ?>
1073 <th><b><?php echo xlt('Active'); ?></b></th>
1074 <th><b><?php echo xlt('Key'); ?></b></th>
1075 <th><b><?php echo xlt('ID'); ?></b></th>
1076 <th><b><?php echo xlt('Label'); ?></b></th>
1077 <?php //show translation column if not english and the translation lists flag is set
1078 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1079 echo "<th><b>" . xlt('Translation') . "</b><span class='help' title='" . xla('The translated Title that will appear in current language') . "'> (?)</span></th>";
1080 } ?>
1081 <th><b><?php echo xlt('Seq'); ?></b></th>
1082 <th><b><?php echo xlt('ModLength'); ?></b></th>
1083 <th><b><?php echo xlt('Justify'); ?></b></th>
1084 <th><b><?php echo xlt('Mask'); ?></b></th>
1085 <th><b><?php echo xlt('Claims'); ?></b></th>
1086 <th><b><?php echo xlt('Fees'); ?></b></th>
1087 <th><b><?php echo xlt('Relations'); ?></b></th>
1088 <th><b><?php echo xlt('Hide'); ?></b></th>
1089 <th><b><?php echo xlt('Procedure'); ?></b></th>
1090 <th><b><?php echo xlt('Diagnosis'); ?></b></th>
1091 <th><b><?php echo xlt('Clinical Term'); ?></b></th>
1092 <th><b><?php echo xlt('Medical Problem'); ?></b></th>
1093 <th><b><?php echo xlt('Drug'); ?></b></th>
1094 <th><b><?php echo xlt('External'); ?></b></th>
1095 <?php elseif ($list_id == 'apptstat' || $list_id == 'groupstat') : ?>
1096 <th><b><?php echo xlt('ID'); ?></b></th>
1097 <th><b><?php echo xlt('Title'); ?></b></th>
1098 <th><b><?php echo xlt('Order'); ?></b></th>
1099 <th><b><?php echo xlt('Default'); ?></b></th>
1100 <th><b><?php echo xlt('Active'); ?></b></th>
1101 <th><b><?php echo xlt('Color'); ?></b></th>
1102 <th><b><?php echo xlt('Alert Time'); ?></b></th>
1103 <th><b><?php echo xlt('Check In'); ?>&nbsp;&nbsp;&nbsp;&nbsp;</b>
1104 </th>
1105 <th><b><?php echo xlt('Check Out'); ?></b></th>
1106 <th><b><?php echo xlt('Code(s)'); ?></b></th>
1107 <?php elseif ($list_id == 'issue_types') : ?>
1108 <th><b><?php echo xlt('OpenEMR Application Category'); ?></b></th>
1109 <th><b><?php echo xlt('Active'); ?></b></th>
1110 <th><b><?php echo xlt('Order'); ?></b></th>
1111 <th><b><?php echo xlt('Type'); ?></b></th>
1112 <th><b><?php echo xlt('Plural'); ?></b></th>
1113 <?php //show translation column if not english and the translation lists flag is set
1114 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1115 echo "<th><b>" . xlt('Translation') . "</b><span class='help' title='" . xla('The translated Title that will appear in current language') . "'> (?)</span></th>";
1116 } ?>
1117 <th><b><?php echo xlt('Singular'); ?></b></th>
1118 <?php //show translation column if not english and the translation lists flag is set
1119 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1120 echo "<th><b>" . xlt('Translation') . "</b><span class='help' title='" . xla('The translated Title that will appear in current language') . "'> (?)</span></th>";
1121 } ?>
1122 <th><b><?php echo xlt('Mini'); ?></b></th>
1123 <?php //show translation column if not english and the translation lists flag is set
1124 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1125 echo "<th><b>" . xlt('Translation') . "</b><span class='help' title='" . xla('The translated Title that will appear in current language') . "'> (?)</span></th>";
1126 } ?>
1127 <th><b><?php echo xlt('Style'); ?></b></th>
1128 <th><b><?php echo xlt('Force Show'); ?></b></th>
1129 <th><b><?php echo xlt('Access Control'); ?></b></th>
1130 <?php else : ?>
1131 <th title='<?php echo xla('Click to edit'); ?>'>
1132 <b><?php echo xlt('ID'); ?></b></th>
1133 <th><b><?php echo xlt('Title'); ?></b></th>
1134 <?php //show translation column if not english and the translation lists flag is set
1135 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1136 echo "<th><b>" . xlt('Translation') . "</b><span class='help' title='" . xla('The translated Title that will appear in current language') . "'> (?)</span></th>";
1137 } ?>
1138 <th><b><?php echo xlt('Order'); ?></b></th>
1139 <th><b><?php echo xlt('Default'); ?></b></th>
1140 <th><b><?php echo xlt('Active'); ?></b></th>
1141 <?php if ($list_id == 'taxrate') { ?>
1142 <th><b><?php echo xlt('Rate'); ?></b></th>
1143 <?php } elseif ($list_id == 'contrameth') { ?>
1144 <th><b><?php echo xlt('Effectiveness'); ?></b></th>
1145 <?php } elseif ($list_id == 'lbfnames' || $list_id == 'transactions') { ?>
1146 <th title='<?php echo xla('Number of past history columns'); ?>'>
1147 <b><?php echo xlt('Repeats'); ?></b></th>
1148 <?php } elseif ($list_id == 'fitness') { ?>
1149 <th><b><?php echo xlt('Color:Abbr'); ?></b></th>
1150 <?php } elseif ($list_id == 'adjreason' || $list_id == 'abook_type') { ?>
1151 <th><b><?php echo xlt('Type'); ?></b></th>
1152 <?php } elseif ($list_id == 'immunizations') { ?>
1153 <th>
1154 <b>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo xlt('CVX Code Mapping'); ?></b>
1155 </th>
1156 <?php }
1157 if ($GLOBALS['ippf_specific']) { ?>
1158 <th><b><?php echo xlt('Global ID'); ?></b></th>
1159 <?php } ?>
1160 <th><b><?php
1161 if ($list_id == 'language') {
1162 echo xlt('ISO 639-2 Code');
1163 } elseif ($list_id == 'personal_relationship' || $list_id == 'religious_affiliation' || $list_id == 'ethnicity' || $list_id == 'race' || $list_id == 'drug_route') {
1164 echo xlt('HL7-V3 Concept Code');
1165 } elseif ($list_id == 'Immunization_Completion_Status') {
1166 echo xlt('Treatment Completion Status');
1167 } elseif ($list_id == 'race') {
1168 echo xlt('CDC Code');
1169 } elseif ($list_id == 'Immunization_Manufacturer') {
1170 echo xlt('MVX Code');
1171 } elseif ($list_id == 'marital') {
1172 echo xlt('Marital Status');
1173 } elseif ($list_id == 'county') {
1174 echo xlt('INCITS Code'); //International Committee for Information Technology Standards
1175 } elseif ($list_id == 'immunization_registry_status' || $list_id == 'imm_vac_eligibility_results') {
1176 echo xlt('IIS Code');
1177 } elseif ($list_id == 'publicity_code') {
1178 echo xlt('CDC Code');
1179 } elseif ($list_id == 'immunization_refusal_reason' || $list_id == 'immunization_informationsource') {
1180 echo xlt('CDC-NIP Code');
1181 } elseif ($list_id == 'next_of_kin_relationship' || $list_id == 'immunization_administered_site') {
1182 echo xlt('HL7 Code');
1183 } elseif ($list_id == 'immunization_observation') {
1184 echo xlt('LOINC Code');
1185 } elseif ($list_id == 'page_validation') {
1186 echo xlt('Page Validation');
1187 } elseif ($list_id == 'lbfnames') {
1188 echo xlt('Attributes');
1189 } else {
1190 echo xlt('Notes');
1191 } ?></b></th>
1193 <th><b><?php echo xlt('Code(s)'); ?></b></th>
1194 <?php
1195 if (preg_match('/_issue_list$/', $list_id)) { ?>
1196 <th><b><?php echo xlt('Subtype'); ?></b></th>
1197 <?php
1199 endif; // end not fee sheet ?>
1200 </tr>
1201 </thead>
1202 <tbody>
1203 <?php
1204 // Get the selected list's elements.
1205 if ($list_id) {
1206 if ($list_id == 'feesheet') {
1207 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
1208 "ORDER BY fs_category, fs_option");
1209 while ($row = sqlFetchArray($res)) {
1210 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
1212 for ($i = 0; $i < 3; ++$i) {
1213 writeFSLine('', '', '');
1215 } elseif ($list_id == 'code_types') {
1216 $res = sqlStatement("SELECT * FROM code_types " .
1217 "ORDER BY ct_seq, ct_key");
1218 while ($row = sqlFetchArray($res)) {
1219 writeCTLine($row);
1221 for ($i = 0; $i < 3; ++$i) {
1222 writeCTLine(array());
1224 } elseif ($list_id == 'issue_types') {
1225 $res = sqlStatement("SELECT * FROM issue_types " .
1226 "ORDER BY category, ordering ASC");
1227 while ($row = sqlFetchArray($res)) {
1228 writeITLine($row);
1230 for ($i = 0; $i < 3; ++$i) {
1231 writeITLine(array());
1233 } else {
1235 * Add edit options to show or hide in list management
1236 * If the edit_options setting of the main list entry is set to 0,
1237 * then none of the list items will show.
1238 * If the edit_options setting of the main list entry is set to 1,
1239 * then the list items with edit_options set to 1 will show.
1241 $res = sqlStatement("SELECT lo.*
1242 FROM list_options as lo
1243 right join list_options as lo2 on lo2.option_id = lo.list_id AND lo2.edit_options = 1
1244 WHERE lo.list_id = ? AND lo.edit_options = 1
1245 ORDER BY seq,title", array($list_id));
1246 while ($row = sqlFetchArray($res)) {
1247 writeOptionLine(
1248 $row['option_id'],
1249 $row['title'],
1250 $row['seq'],
1251 $row['is_default'],
1252 $row['option_value'],
1253 $row['mapping'],
1254 $row['notes'],
1255 $row['codes'],
1256 $row['toggle_setting_1'],
1257 $row['toggle_setting_2'],
1258 $row['activity'],
1259 $row['subtype']
1262 for ($i = 0; $i < 3; ++$i) {
1263 writeOptionLine('', '', '', '', 0);
1268 </tbody>
1269 </table>
1271 <?php if ($list_id == 'immunizations') { ?>
1272 <p> <?php echo xlt('Is it ok to map these CVX codes to already existent immunizations?') ?>
1273 <input type='checkbox' name='ok_map_cvx_codes' id='ok_map_cvx_codes'
1274 value='1'/>
1275 </p>
1276 <?php } // end if($list_id == 'immunizations') ?>
1279 <button type="submit" name='form_save' id='form_save'
1280 class="btn btn-default btn-save"><?php echo xlt('Save'); ?></button>
1281 </p>
1283 </form>
1285 <div class="modal fade" id="modal-new-list" tabindex="-1" role="dialog">
1286 <div class="modal-dialog" role="document">
1287 <div class="modal-content">
1288 <form action="edit_list.php" method="post" class="form">
1289 <div class="modal-header">
1290 <button type="button" class="close" data-dismiss="modal"
1291 aria-label="<?php echo xla('Close'); ?>"><i
1292 class="fa fa-times"
1293 aria-hidden="true"></i>
1294 </button>
1295 <h4 class="modal-title"><?php echo xlt('New List'); ?></h4>
1296 </div>
1297 <div class="modal-body">
1298 <label for="newlistname"
1299 class="control-label"><?php echo xlt('List Name'); ?></label>
1300 <input type="text" size="20" class="form-control"
1301 maxlength="100" name="newlistname" id="newlistname">
1302 <input type="hidden" name="formaction" value="addlist">
1304 </div>
1305 <div class="modal-footer text-right">
1306 <button type="submit"
1307 class="btn btn-default btn-save"><?php echo xlt('Save'); ?></button>
1308 <button type="button" class="btn btn-link btn-cancel"
1309 data-dismiss="modal"><?php echo xlt('Cancel'); ?></button>
1310 </div>
1311 </form>
1312 </div><!-- /.modal-content -->
1313 </div><!-- /.modal-dialog -->
1314 </div><!-- /.modal #modal-new-list -->
1316 </body>
1317 <script type="text/javascript">
1318 // jQuery stuff to make the page a little easier to use
1320 $(document).ready(function () {
1321 $("#form_save").click(function () {
1322 SaveChanges();
1324 $("#list_id").change(function () {
1325 $('#theform').submit();
1328 $(".newlist").click(function () {
1329 NewList(this);
1331 $(".savenewlist").click(function () {
1332 SaveNewList(this);
1334 $(".deletelist").click(function () {
1335 DeleteList(this);
1338 var SaveChanges = function () {
1339 $("#formaction").val("save");
1340 // $('#theform').submit();
1341 mysubmit();
1344 // show the DIV to create a new list
1345 var NewList = function (btnObj) {
1346 // show the field details DIV
1347 $('#newlistdetail').css('visibility', 'visible');
1348 $('#newlistdetail').css('display', 'block');
1349 $(btnObj).parent().append($("#newlistdetail"));
1350 $('#newlistdetail > #newlistname').focus();
1352 // save the new list
1353 var SaveNewList = function () {
1354 // the list name can only have letters, numbers, spaces and underscores
1355 // AND it cannot start with a number
1356 if ($("#newlistname").val().match(/^\d+/)) {
1357 alert("<?php echo xls('List names cannot start with numbers.'); ?>");
1358 return false;
1360 var validname = $("#newlistname").val().replace(/[^A-za-z0-9 -]/g, "_"); // match any non-word characters and replace them
1361 if (validname != $("#newlistname").val()) {
1362 if (!confirm("<?php echo xls('Your list name has been changed to meet naming requirements.') . '\n' . xls('Please compare the new name') . ', \''; ?>" + validname + "<?php echo '\' ' . xls('with the old name') . ', \''; ?>" + $("#newlistname").val() + "<?php echo '\'.\n' . xls('Do you wish to continue with the new name?'); ?>")) {
1363 return false;
1366 $("#newlistname").val(validname);
1368 // submit the form to add a new field to a specific group
1369 $("#formaction").val("addlist");
1370 $("#theform").submit();
1372 // actually delete an entire list from the database
1373 var DeleteList = function (btnObj) {
1374 var listid = $(btnObj).attr("id");
1375 if (confirm("<?php echo xls('WARNING') . ' - ' . xls('This action cannot be undone.') . '\n' . xls('Are you sure you wish to delete the entire list') . '('; ?>" + listid + ")?")) {
1376 // submit the form to add a new field to a specific group
1377 $("#formaction").val("deletelist");
1378 $("#deletelistname").val(listid);
1379 $("#theform").submit();
1384 </script>
1385 </html>