Merge pull request #1154 for user interface improvements of left nav and main title
[openemr.git] / interface / super / edit_list.php
blob48db4d8d6cbe4bbb7695faf59942491589ec5bfe
1 <?php
2 /**
3 * Administration Lists Module.
5 * Copyright (C) 2007-2017 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Rod Roark <rod@sunsetsystems.com>
21 * @author Brady Miller <brady.g.miller@gmail.com>
22 * @author Teny <teny@zhservices.com>
23 * @link http://www.open-emr.org
26 require_once("../globals.php");
27 require_once("$srcdir/acl.inc");
28 require_once("$phpgacl_location/gacl_api.class.php");
29 require_once("$srcdir/lists.inc");
30 require_once("../../custom/code_types.inc.php");
31 require_once("$srcdir/options.inc.php");
32 use OpenEMR\Core\Header;
34 // Below allows the list to default to the first item on the list
35 // when list_id is blank.
36 $blank_list_id = '';
37 if (empty($_REQUEST['list_id'])) {
38 $list_id = 'language';
39 $blank_list_id = true;
40 } else {
41 $list_id = $_REQUEST['list_id'];
44 // Check authorization.
45 $thisauth = acl_check('admin', 'super');
46 if (!$thisauth) {
47 die(xl('Not authorized'));
50 // If we are saving, then save.
52 if ($_POST['formaction'] == 'save' && $list_id) {
53 $opt = $_POST['opt'];
54 if ($list_id == 'feesheet') {
55 // special case for the feesheet list
56 sqlStatement("DELETE FROM fee_sheet_options");
57 for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
58 $iter = $opt["$lino"];
59 $category = formTrim($iter['category']);
60 $option = formTrim($iter['option']);
61 $codes = formTrim($iter['codes']);
62 if (strlen($category) > 0 && strlen($option) > 0) {
63 sqlInsert("INSERT INTO fee_sheet_options ( " .
64 "fs_category, fs_option, fs_codes " .
65 ") VALUES ( " .
66 "'$category', " .
67 "'$option', " .
68 "'$codes' " .
69 ")");
72 } elseif ($list_id == 'code_types') {
73 // special case for code types
74 sqlStatement("DELETE FROM code_types");
75 for ($lino = 1; isset($opt["$lino"]['ct_key']); ++$lino) {
76 $iter = $opt["$lino"];
77 $ct_key = formTrim($iter['ct_key']);
78 $ct_id = formTrim($iter['ct_id']) + 0;
79 $ct_seq = formTrim($iter['ct_seq']) + 0;
80 $ct_mod = formTrim($iter['ct_mod']) + 0;
81 $ct_just = formTrim($iter['ct_just']);
82 $ct_mask = formTrim($iter['ct_mask']);
83 $ct_fee = empty($iter['ct_fee']) ? 0 : 1;
84 $ct_rel = empty($iter['ct_rel']) ? 0 : 1;
85 $ct_nofs = empty($iter['ct_nofs']) ? 0 : 1;
86 $ct_diag = empty($iter['ct_diag']) ? 0 : 1;
87 $ct_active = empty($iter['ct_active']) ? 0 : 1;
88 $ct_label = formTrim($iter['ct_label']);
89 $ct_external = formTrim($iter['ct_external']) + 0;
90 $ct_claim = empty($iter['ct_claim']) ? 0 : 1;
91 $ct_proc = empty($iter['ct_proc']) ? 0 : 1;
92 $ct_term = empty($iter['ct_term']) ? 0 : 1;
93 $ct_problem = empty($iter['ct_problem']) ? 0 : 1;
94 $ct_drug = empty($iter['ct_drug']) ? 0 : 1;
95 if (strlen($ct_key) > 0 && $ct_id > 0) {
96 sqlInsert("INSERT INTO code_types ( " .
97 "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 " .
98 ") VALUES ( " .
99 "'$ct_key' , " .
100 "'$ct_id' , " .
101 "'$ct_seq' , " .
102 "'$ct_mod' , " .
103 "'$ct_just', " .
104 "'$ct_mask', " .
105 "'$ct_fee' , " .
106 "'$ct_rel' , " .
107 "'$ct_nofs', " .
108 "'$ct_diag', " .
109 "'$ct_active', " .
110 "'$ct_label', " .
111 "'$ct_external', " .
112 "'$ct_claim', " .
113 "'$ct_proc', " .
114 "'$ct_term', " .
115 "'$ct_problem', " .
116 "'$ct_drug' " .
117 ")");
120 } elseif ($list_id == 'issue_types') {
121 // special case for issue_types
122 sqlStatement("DELETE FROM issue_types");
123 for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
124 $iter = $opt["$lino"];
125 $it_category = formTrim($iter['category']);
126 $it_type = formTrim($iter['type']);
127 if ((strlen($it_category) > 0) && (strlen($it_type) > 0)) {
128 sqlInsert("INSERT INTO issue_types (" .
129 "`active`,`category`,`ordering`, `type`, `plural`, `singular`, `abbreviation`, `style`, " .
130 "`force_show`, `aco_spec`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array(
131 formTrim($iter['active']),
132 $it_category,
133 formTrim($iter['ordering']),
134 $it_type,
135 formTrim($iter['plural']),
136 formTrim($iter['singular']),
137 formTrim($iter['abbreviation']),
138 formTrim($iter['style']),
139 formTrim($iter['force_show']),
140 formTrim($iter['aco_spec']),
144 } else {
145 // all other lists
147 // collect the option toggle if using the 'immunizations' list
148 if ($list_id == 'immunizations') {
149 $ok_map_cvx_codes = isset($_POST['ok_map_cvx_codes']) ? $_POST['ok_map_cvx_codes'] : 0;
151 // erase lists options and recreate them from the submitted form data
152 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
153 for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
154 $iter = $opt["$lino"];
155 $value = empty($iter['value']) ? 0 : (formTrim($iter['value']) + 0);
156 $id = formTrim($iter['id']);
157 if (strlen($id) > 0) {
158 // Special processing for the immunizations list
159 // Map the entered cvx codes into the immunizations table cvx_code
160 // Ensure the following conditions are met to do this:
161 // $list_id == 'immunizations'
162 // $value is an integer and greater than 0
163 // $id is set, not empty and not equal to 0
164 // (note that all these filters are important. Not allowing $id
165 // of zero here is extremely important; never remove this conditional
166 // or you risk corrupting your current immunizations database entries)
167 // $ok_map_cvx_codes is equal to 1
168 if ($list_id == 'immunizations' &&
169 is_int($value) &&
170 $value > 0 &&
171 isset($id) &&
172 !empty($id) &&
173 $id != 0 &&
174 $ok_map_cvx_codes == 1
176 sqlStatement("UPDATE `immunizations` " .
177 "SET `cvx_code`='" . $value . "' " .
178 "WHERE `immunization_id`='" . $id . "'");
181 // Force List Based Form names to start with LBF.
182 if ($list_id == 'lbfnames' && substr($id, 0, 3) != 'LBF') {
183 $id = "LBF$id";
186 // Force Transaction Form names to start with LBT.
187 if ($list_id == 'transactions' && substr($id, 0, 3) != 'LBT') {
188 $id = "LBT$id";
191 if ($list_id == 'apptstat' || $list_id == 'groupstat') {
192 $notes = formTrim($iter['apptstat_color']) . '|' . formTrim($iter['apptstat_timealert']);
193 } else {
194 $notes = formTrim($iter['notes']);
196 // Insert the list item
197 sqlInsert("INSERT INTO list_options ( " .
198 "list_id, option_id, title, seq, is_default, option_value, mapping, notes, codes, toggle_setting_1, toggle_setting_2, activity, subtype " .
199 ") VALUES ( " .
200 "'$list_id', " .
201 "'" . $id . "', " .
202 "'" . formTrim($iter['title']) . "', " .
203 "'" . formTrim($iter['seq']) . "', " .
204 "'" . formTrim($iter['default']) . "', " .
205 "'" . $value . "', " .
206 "'" . formTrim($iter['mapping']) . "', " .
207 "'" . $notes . "', " .
208 "'" . formTrim($iter['codes']) . "', " .
209 "'" . formTrim($iter['toggle_setting_1']) . "', " .
210 "'" . formTrim($iter['toggle_setting_2']) . "', " .
211 "'" . formTrim($iter['activity']) . "', " .
212 "'" . formTrim($iter['subtype']) . "' " .
213 ")");
217 } elseif ($_POST['formaction'] == 'addlist') {
218 // make a new list ID from the new list name
219 $newlistID = $_POST['newlistname'];
220 $newlistID = preg_replace("/\W/", "_", $newlistID);
222 // determine the position of this new list
223 $row = sqlQuery("SELECT max(seq) AS maxseq FROM list_options WHERE list_id= 'lists'");
225 // add the new list to the list-of-lists
226 sqlInsert("INSERT INTO list_options ( " .
227 "list_id, option_id, title, seq, is_default, option_value " .
228 ") VALUES ( " .
229 "'lists'," . // the master list-of-lists
230 "'" . $newlistID . "'," .
231 "'" . $_POST['newlistname'] . "', " .
232 "'" . ($row['maxseq'] + 1) . "'," .
233 "'1', '0')");
234 $list_id = $newlistID;
235 } elseif ($_POST['formaction'] == 'deletelist') {
236 // delete the lists options
237 sqlStatement("DELETE FROM list_options WHERE list_id = '" . $_POST['list_id'] . "'");
238 // delete the list from the master list-of-lists
239 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' AND option_id='" . $_POST['list_id'] . "'");
242 $opt_line_no = 0;
244 // Given a string of multiple instances of code_type|code|selector,
245 // make a description for each.
246 // @TODO Instead should use a function from custom/code_types.inc.php and need to remove casing functions
247 function getCodeDescriptions($codes)
249 global $code_types;
250 $arrcodes = explode('~', $codes);
251 $s = '';
252 foreach ($arrcodes as $codestring) {
253 if ($codestring === '') {
254 continue;
256 $arrcode = explode('|', $codestring);
257 $code_type = $arrcode[0];
258 $code = $arrcode[1];
259 $selector = $arrcode[2];
260 $desc = '';
261 if ($code_type == 'PROD') {
262 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
263 $desc = "$code:$selector " . $row['name'];
264 } else {
265 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
266 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
267 "code = '$code' ORDER BY modifier LIMIT 1");
268 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
270 $desc = str_replace('~', ' ', $desc);
271 if ($s) {
272 $s .= '~';
274 $s .= $desc;
276 return $s;
279 // Write one option line to the form.
281 function writeOptionLine(
282 $option_id,
283 $title,
284 $seq,
285 $default,
286 $value,
287 $mapping = '',
288 $notes = '',
289 $codes = '',
290 $tog1 = '',
291 $tog2 = '',
292 $active = '1',
293 $subtype = ''
296 global $opt_line_no, $list_id;
297 ++$opt_line_no;
298 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
299 $checked = $default ? " checked" : "";
300 $checked_tog1 = $tog1 ? " checked" : "";
301 $checked_tog2 = $tog2 ? " checked" : "";
302 $checked_active = $active ? " checked" : "";
304 echo " <tr>\n";
306 echo " <td>";
307 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
308 htmlspecialchars($option_id, ENT_QUOTES) . "' size='12' maxlength='63' class='optin' />";
309 echo "</td>\n";
310 echo " <td>";
311 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
312 htmlspecialchars($title, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
313 echo "</td>\n";
315 // if not english and translating lists then show the translation
316 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
317 echo " <td align='center' class='translation'>" . (htmlspecialchars(xl($title), ENT_QUOTES)) . "</td>\n";
319 echo " <td>";
320 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
321 htmlspecialchars($seq, ENT_QUOTES) . "' size='4' maxlength='10' class='optin' />";
322 echo "</td>\n";
324 echo " <td>";
325 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
326 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
327 echo "</td>\n";
329 echo " <td>";
330 echo "<input type='checkbox' name='opt[$opt_line_no][activity]' value='1' " .
331 " class='optin'$checked_active />";
332 echo "</td>\n";
334 // Tax rates, contraceptive methods and LBF names have an additional attribute.
336 if ($list_id == 'taxrate' || $list_id == 'contrameth' || $list_id == 'lbfnames' || $list_id == 'transactions') {
337 echo " <td>";
338 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
339 htmlspecialchars($value, ENT_QUOTES) . "' size='8' maxlength='15' class='optin' />";
340 echo "</td>\n";
341 } // Adjustment reasons use option_value as a reason category. This is
342 // needed to distinguish between adjustments that change the invoice
343 // balance and those that just shift responsibility of payment or
344 // are used as comments.
346 elseif ($list_id == 'adjreason') {
347 echo " <td>";
348 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
349 foreach (array(
350 1 => xl('Charge adjustment'),
351 2 => xl('Coinsurance'),
352 3 => xl('Deductible'),
353 4 => xl('Other pt resp'),
354 5 => xl('Comment'),
355 ) as $key => $desc) {
356 echo "<option value='$key'";
357 if ($key == $value) {
358 echo " selected";
360 echo ">" . htmlspecialchars($desc) . "</option>";
362 echo "</select>";
363 echo "</td>\n";
364 } // Address book categories use option_value to flag category as a
365 // person-centric vs company-centric vs indifferent.
367 elseif ($list_id == 'abook_type') {
368 echo " <td>";
369 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
370 foreach (array(
371 1 => xl('Unassigned'),
372 2 => xl('Person'),
373 3 => xl('Company'),
374 ) as $key => $desc) {
375 echo "<option value='$key'";
376 if ($key == $value) {
377 echo " selected";
379 echo ">" . htmlspecialchars($desc) . "</option>";
381 echo "</select>";
382 echo "</td>\n";
383 } // Immunization categories use option_value to map list items
384 // to CVX codes.
386 elseif ($list_id == 'immunizations') {
387 echo " <td>";
388 echo "<input type='text' size='10' name='opt[$opt_line_no][value]' " .
389 "value='" . htmlspecialchars($value, ENT_QUOTES) . "' onclick='sel_cvxcode(this)' " .
390 "title='" . htmlspecialchars(xl('Click to select or change CVX code'), ENT_QUOTES) . "'/>";
391 echo "</td>\n";
394 // IPPF includes the ability to map each list item to a "master" identifier.
395 // Sports teams use this for some extra info for fitness levels.
397 if ($GLOBALS['ippf_specific'] || $list_id == 'fitness') {
398 echo " <td>";
399 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
400 htmlspecialchars($mapping, ENT_QUOTES) . "' size='12' maxlength='15' class='optin' />";
401 echo "</td>\n";
402 } elseif ($list_id == 'apptstat' || $list_id == 'groupstat') {
403 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
404 echo " <td>";
405 echo "<input type='text' class='jscolor' name='opt[$opt_line_no][apptstat_color]' value='" .
406 htmlspecialchars($apptstat_color, ENT_QUOTES) . "' size='6' maxlength='6' class='optin' />";
407 echo "</td>\n";
408 echo " <td>";
409 echo "<input type='text' name='opt[$opt_line_no][apptstat_timealert]' value='" .
410 htmlspecialchars($apptstat_timealert, ENT_QUOTES) . "' size='2' maxlength='2' class='optin' />";
411 echo "</td>\n";
412 } else {
413 echo " <td>";
414 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
415 attr($notes) . "' size='25' maxlength='255' class='optin' ";
416 echo "/>";
417 echo "</td>\n";
419 if ($list_id == 'apptstat' || $list_id == 'groupstat') {
420 echo " <td>";
421 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_1]' value='1' " .
422 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog1 />";
423 echo "</td>\n";
424 echo " <td>";
425 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_2]' value='1' " .
426 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog2 />";
427 echo "</td>\n";
429 echo " <td>";
430 echo "<input type='text' name='opt[$opt_line_no][codes]' title='" .
431 xla('Clinical Term Code(s)') . "' value='" .
432 htmlspecialchars($codes, ENT_QUOTES) . "' onclick='select_clin_term_code(this)' size='25' maxlength='255' class='optin' />";
433 echo "</td>\n";
435 if (preg_match('/_issue_list$/', $list_id)) {
436 echo " <td>";
437 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype', ' ', 'optin');
438 echo "</td>\n";
440 echo " </tr>\n";
443 // Write a form line as above but for the special case of the Fee Sheet.
445 function writeFSLine($category, $option, $codes)
447 global $opt_line_no;
449 ++$opt_line_no;
450 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
452 $descs = getCodeDescriptions($codes);
454 echo " <tr>\n";
456 echo " <td>";
457 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
458 htmlspecialchars($category, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
459 echo "</td>\n";
461 echo " <td>";
462 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
463 htmlspecialchars($option, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
464 echo "</td>\n";
466 echo " <td align='left' class='optcell'>";
467 echo " <div id='codelist_$opt_line_no'>";
468 if (strlen($descs)) {
469 $arrdescs = explode('~', $descs);
470 $i = 0;
471 foreach ($arrdescs as $desc) {
472 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
473 echo "[x]&nbsp;</a>$desc<br />";
474 ++$i;
477 echo "</div>";
478 echo "<a href='' onclick='return select_code($opt_line_no)'>";
479 echo "[" . xl('Add') . "]</a>";
481 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
482 htmlspecialchars($codes, ENT_QUOTES) . "' />";
483 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
484 htmlspecialchars($descs, ENT_QUOTES) . "' />";
485 echo "</td>\n";
487 echo " </tr>\n";
492 * Helper functions for writeITLine() and writeCTLine().
494 function ctGenCell($opt_line_no, $data_array, $name, $size, $maxlength, $title = '')
496 $value = isset($data_array[$name]) ? $data_array[$name] : '';
497 $s = " <td";
498 if ($title) {
499 $s .= " title='" . attr($title) . "'";
501 $s .= ">";
502 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
503 $s .= attr($value);
504 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
505 $s .= "</td>\n";
506 return $s;
509 function ctGenCbox($opt_line_no, $data_array, $name, $title = '')
511 $checked = empty($data_array[$name]) ? '' : 'checked ';
512 $s = " <td";
513 if ($title) {
514 $s .= " title='" . attr($title) . "'";
516 $s .= ">";
517 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
518 $s .= "$checked/>";
519 $s .= "</td>\n";
520 return $s;
523 function ctSelector($opt_line_no, $data_array, $name, $option_array, $title = '')
525 $value = isset($data_array[$name]) ? $data_array[$name] : '';
526 $s = " <td title='" . attr($title) . "'>";
527 $s .= "<select name='opt[$opt_line_no][$name]' class='optin'>";
528 foreach ($option_array as $key => $desc) {
529 $s .= "<option value='" . attr($key) . "'";
530 if ($key == $value) {
531 $s .= " selected";
533 $s .= ">" . text($desc) . "</option>";
535 $s .= "</select>";
536 $s .= "</td>\n";
537 return $s;
540 // Write a form line as above but for the special case of Code Types.
542 function writeCTLine($ct_array)
544 global $opt_line_no, $cd_external_options;
546 ++$opt_line_no;
547 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
549 echo " <tr>\n";
551 echo ctGenCBox(
552 $opt_line_no,
553 $ct_array,
554 'ct_active',
555 xl('Is this code type active?')
557 echo ctGenCell(
558 $opt_line_no,
559 $ct_array,
560 'ct_key',
563 xl('Unique human-readable identifier for this type')
565 echo ctGenCell(
566 $opt_line_no,
567 $ct_array,
568 'ct_id',
571 xl('Unique numeric identifier for this type')
573 echo ctGenCell(
574 $opt_line_no,
575 $ct_array,
576 'ct_label',
579 xl('Label for this type')
581 // if not english and translating lists then show the translation
582 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
583 echo " <td align='center' class='translation'>" . xlt($ct_array['ct_label']) . "</td>\n";
585 echo ctGenCell(
586 $opt_line_no,
587 $ct_array,
588 'ct_seq',
591 xl('Numeric display order')
593 echo ctGenCell(
594 $opt_line_no,
595 $ct_array,
596 'ct_mod',
599 xl('Length of modifier, 0 if none')
601 echo ctGenCell(
602 $opt_line_no,
603 $ct_array,
604 'ct_just',
607 xl('If billing justification is used enter the name of the diagnosis code type.')
609 echo ctGenCell(
610 $opt_line_no,
611 $ct_array,
612 'ct_mask',
615 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.')
617 echo ctGenCBox(
618 $opt_line_no,
619 $ct_array,
620 'ct_claim',
621 xl('Is this code type used in claims?')
623 echo ctGenCBox(
624 $opt_line_no,
625 $ct_array,
626 'ct_fee',
627 xl('Are fees charged for this type?')
629 echo ctGenCBox(
630 $opt_line_no,
631 $ct_array,
632 'ct_rel',
633 xl('Does this type allow related codes?')
635 echo ctGenCBox(
636 $opt_line_no,
637 $ct_array,
638 'ct_nofs',
639 xl('Is this type hidden in the fee sheet?')
641 echo ctGenCBox(
642 $opt_line_no,
643 $ct_array,
644 'ct_proc',
645 xl('Is this a procedure/service type?')
647 echo ctGenCBox(
648 $opt_line_no,
649 $ct_array,
650 'ct_diag',
651 xl('Is this a diagnosis type?')
653 echo ctGenCBox(
654 $opt_line_no,
655 $ct_array,
656 'ct_term',
657 xl('Is this a Clinical Term code type?')
659 echo ctGenCBox(
660 $opt_line_no,
661 $ct_array,
662 'ct_problem',
663 xl('Is this a Medical Problem code type?')
665 echo ctGenCBox(
666 $opt_line_no,
667 $ct_array,
668 'ct_drug',
669 xl('Is this a Medication type?')
671 echo ctSelector(
672 $opt_line_no,
673 $ct_array,
674 'ct_external',
675 $cd_external_options,
676 xl('Is this using external sql tables? If it is, then choose the format.')
678 echo " </tr>\n";
682 * Special case of Issue Types
684 function writeITLine($it_array)
686 global $opt_line_no, $ISSUE_TYPE_CATEGORIES, $ISSUE_TYPE_STYLES;
687 ++$opt_line_no;
688 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
689 echo " <tr>\n";
690 echo ctSelector($opt_line_no, $it_array, 'category', $ISSUE_TYPE_CATEGORIES, xl('OpenEMR Application Category'));
691 echo ctGenCBox($opt_line_no, $it_array, 'active', xl('Is this active?'));
692 echo ctGenCell($opt_line_no, $it_array, 'ordering', 4, 10, xl('Order'));
693 echo ctGenCell($opt_line_no, $it_array, 'type', 15, 75, xl('Issue Type'));
694 echo ctGenCell($opt_line_no, $it_array, 'plural', 15, 75, xl('Plural'));
695 // if not english and translating lists then show the translation
696 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
697 echo " <td align='center' class='translation'>" . xlt($it_array['plural']) . "</td>\n";
699 echo ctGenCell($opt_line_no, $it_array, 'singular', 15, 75, xl('Singular'));
700 // if not english and translating lists then show the translation
701 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
702 echo " <td align='center' class='translation'>" . xlt($it_array['singular']) . "</td>\n";
704 echo ctGenCell($opt_line_no, $it_array, 'abbreviation', 5, 10, xl('Abbreviation'));
705 // if not english and translating lists then show the translation
706 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
707 echo " <td align='center' class='translation'>" . xlt($it_array['abbreviation']) . "</td>\n";
709 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'));
710 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.'));
712 echo "<td>";
713 echo "<select name='opt[$opt_line_no][aco_spec]' class='optin'>";
714 echo "<option value=''></option>";
715 echo gen_aco_html_options($it_array['aco_spec']);
716 echo "</select>";
717 echo "</td>";
719 echo " </tr>\n";
723 <html>
725 <head>
726 <?php echo Header::setupHeader(['select2', 'jscolor']); ?>
727 <title><?php xl('List Editor', 'e'); ?></title>
728 <style>
729 .optcell {
732 .optin {
733 background-color: transparent;
736 .help {
737 cursor: help;
740 .translation {
741 color: green;
743 </style>
744 <script type="text/javascript">
745 $(document).ready(function () {
746 $(".select-dropdown").select2({
747 theme: "bootstrap"
751 // Keeping track of code picker requests.
752 var current_lino = 0;
753 var current_sel_name = '';
754 var current_sel_clin_term = '';
756 // Helper function to set the contents of a div.
757 // This is for Fee Sheet administration.
758 function setDivContent(id, content) {
759 if (document.getElementById) {
760 var x = document.getElementById(id);
761 x.innerHTML = '';
762 x.innerHTML = content;
764 else if (document.all) {
765 var x = document.all[id];
766 x.innerHTML = content;
770 // Given a line number, redisplay its descriptive list of codes.
771 // This is for Fee Sheet administration.
772 function displayCodes(lino) {
773 var f = document.forms[0];
774 var s = '';
775 var descs = f['opt[' + lino + '][descs]'].value;
776 if (descs.length) {
777 var arrdescs = descs.split('~');
778 for (var i = 0; i < arrdescs.length; ++i) {
779 s += "<a href='' onclick='return delete_code(" + lino + "," + i + ")' title='<?php xl('Delete', 'e'); ?>'>";
780 s += "[x]&nbsp;</a>" + arrdescs[i] + "<br />";
783 setDivContent('codelist_' + lino, s);
786 // Helper function to remove a Fee Sheet code.
787 function dc_substring(s, i) {
788 var r = '';
789 var j = s.indexOf('~', i);
790 if (j < 0) { // deleting last segment
791 if (i > 0) r = s.substring(0, i - 1); // omits trailing ~
793 else { // not last segment
794 r = s.substring(0, i) + s.substring(j + 1);
796 return r;
799 // Remove a generated Fee Sheet code.
800 function delete_code(lino, seqno) {
801 var f = document.forms[0];
802 var celem = f['opt[' + lino + '][codes]'];
803 var delem = f['opt[' + lino + '][descs]'];
804 var ci = 0;
805 var di = 0;
806 for (var i = 0; i < seqno; ++i) {
807 ci = celem.value.indexOf('~', ci) + 1;
808 di = delem.value.indexOf('~', di) + 1;
810 celem.value = dc_substring(celem.value, ci);
811 delem.value = dc_substring(delem.value, di);
812 displayCodes(lino);
813 return false;
816 // This invokes the find-code popup.
817 // For Fee Sheet administration.
818 function select_code(lino) {
819 current_sel_name = '';
820 current_sel_clin_term = '';
821 current_lino = lino;
822 dlgopen('../patient_file/encounter/find_code_dynamic.php', '_blank', 900, 600);
823 return false;
826 // This invokes the find-code popup.
827 // For CVX/immunization code administration.
828 function sel_cvxcode(e) {
829 current_sel_clin_term = '';
830 current_sel_name = e.name;
831 dlgopen('../patient_file/encounter/find_code_dynamic.php?codetype=CVX', '_blank', 900, 600);
834 // This invokes the find-code popup.
835 // For CVX/immunization code administration.
836 function select_clin_term_code(e) {
837 current_sel_name = '';
838 current_sel_clin_term = e.name;
839 dlgopen('../patient_file/encounter/find_code_dynamic.php?codetype=<?php echo attr(collect_codetypes("clinical_term", "csv")); ?>', '_blank', 900, 600);
842 // This is for callback by the find-code popup.
843 function set_related(codetype, code, selector, codedesc) {
844 var f = document.forms[0];
845 if (current_sel_clin_term) {
846 // Coming from the Clinical Terms Code(s) edit
847 var e = f[current_sel_clin_term];
848 var s = e.value;
849 if (code) {
850 if (s.length > 0) s += ';';
851 s += codetype + ':' + code;
853 else {
854 s = '';
856 e.value = s;
858 else if (current_sel_name) {
859 // Coming from Immunizations edit
860 var e = f[current_sel_name];
861 var s = e.value;
862 if (code) {
863 s = code;
865 else {
866 s = '0';
868 e.value = s;
870 else {
871 // Coming from Fee Sheet edit
872 var celem = f['opt[' + current_lino + '][codes]'];
873 var delem = f['opt[' + current_lino + '][descs]'];
874 var i = 0;
875 while ((i = codedesc.indexOf('~')) >= 0) {
876 codedesc = codedesc.substring(0, i) + ' ' + codedesc.substring(i+1);
878 if (code) {
879 if (celem.value) {
880 celem.value += '~';
881 delem.value += '~';
883 celem.value += codetype + '|' + code + '|' + selector;
884 if (codetype == 'PROD') {
885 delem.value += code + ':' + selector + ' ' + codedesc;
886 } else {
887 delem.value += codetype + ':' + code + ' ' + codedesc;
889 } else {
890 celem.value = '';
891 delem.value = '';
893 displayCodes(current_lino);
897 // This is for callback by the find-code popup.
898 // Deletes the specified codetype:code from the currently selected list.
899 function del_related(s) {
900 var f = document.forms[0];
901 if (current_sel_clin_term) {
902 // Coming from the Clinical Terms Code(s) edit
903 my_del_related(s, f[current_sel_clin_term], false);
905 else if (current_sel_name) {
906 // Coming from Immunizations edit
907 f[current_sel_name].value = '0';
909 else {
910 // Coming from Fee Sheet edit
911 f['opt[' + current_lino + '][codes]'].value = '';
912 f['opt[' + current_lino + '][descs]'].value = '';
913 displayCodes(current_lino);
917 // This is for callback by the find-code popup.
918 // Returns the array of currently selected codes with each element in codetype:code format.
919 function get_related() {
920 var f = document.forms[0];
921 if (current_sel_clin_term) {
922 return f[current_sel_clin_term].value.split(';');
924 return new Array();
927 // Called when a "default" checkbox is clicked. Clears all the others.
928 function defClicked(lino) {
929 var f = document.forms[0];
930 for (var i = 1; f['opt[' + i + '][default]']; ++i) {
931 if (i != lino) f['opt[' + i + '][default]'].checked = false;
935 // Form validation and submission.
936 // This needs more validation.
937 function mysubmit() {
938 var f = document.forms[0];
939 if (f.list_id.value == 'code_types') {
940 for (var i = 1; f['opt[' + i + '][ct_key]'].value; ++i) {
941 var ikey = 'opt[' + i + ']';
942 for (var j = i + 1; f['opt[' + j + '][ct_key]'].value; ++j) {
943 var jkey = 'opt[' + j + ']';
944 if (f[ikey + '[ct_key]'].value == f[jkey + '[ct_key]'].value) {
945 alert('<?php echo xl('Error: duplicated name on line') ?>' + ' ' + j);
946 return;
948 if (parseInt(f[ikey + '[ct_id]'].value) == parseInt(f[jkey + '[ct_id]'].value)) {
949 alert('<?php echo xl('Error: duplicated ID on line') ?>' + ' ' + j);
950 return;
955 else if (f['opt[1][id]']) {
956 // Check for duplicate IDs.
957 for (var i = 1; f['opt[' + i + '][id]']; ++i) {
958 var ikey = 'opt[' + i + '][id]';
959 if (f[ikey].value == '') continue;
960 for (var j = i+1; f['opt[' + j + '][id]']; ++j) {
961 var jkey = 'opt[' + j + '][id]';
962 if (f[ikey].value.toUpperCase() == f[jkey].value.toUpperCase()) {
963 alert('<?php echo xls('Error: duplicated ID') ?>' + ': ' + f[jkey].value);
964 f[jkey].scrollIntoView();
965 f[jkey].focus();
966 f[jkey].select();
967 return;
972 f.submit();
975 </script>
977 </head>
979 <body class="body_top">
980 <nav class="navbar navbar-default navbar-fixed-top">
981 <div class="container-fluid">
982 <div class="navbar-header">
983 <button type="button" class="navbar-toggle collapsed"
984 data-toggle="collapse" data-target="#navbar-list"
985 aria-expanded="false">
986 <span class="sr-only"><?php xl('Toggle navigation', 'e'); ?></span>
987 <i class="fa fa-bars"></i>
988 </button>
989 <a class="navbar-brand"
990 href="#"><?php xl('Manage Lists', 'e'); ?></a>
991 </div>
993 <!-- Collect the nav links, forms, and other content for toggling -->
994 <div class="collapse navbar-collapse" id="navbar-list">
995 <ul class="nav navbar-nav">
996 <li><a href="#" data-toggle="modal"
997 data-target="#modal-new-list"><i class="fa fa-plus"></i>&nbsp;<?php xl('New List', 'e'); ?>
998 </a>
999 </li>
1000 <li>
1001 <a href="#" class="deletelist" id="<?php echo $list_id; ?>">
1002 <i class="fa fa-trash"></i>&nbsp;<?php xl('Delete List', 'e'); ?>
1003 </a>
1004 </li>
1005 </ul>
1006 <form method='post' name='theform' id='theform'
1007 action='edit_list.php' class="navbar-form navbar-left">
1008 <input type="hidden" name="formaction" id="formaction">
1009 <div class="form-group">
1010 <select name='list_id' class="form-control select-dropdown"
1011 id="list_id">
1012 <?php
1014 // List order depends on language translation options.
1015 $lang_id = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
1017 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
1018 !$GLOBALS['translate_lists']
1020 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1021 "list_id = 'lists' ORDER BY title, seq");
1022 } else {
1023 // Use and sort by the translated list name.
1024 $res = sqlStatement("SELECT lo.option_id, " .
1025 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
1026 "FROM list_options AS lo " .
1027 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
1028 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
1029 "ld.lang_id = '$lang_id' " .
1030 "WHERE lo.list_id = 'lists' AND lo.edit_options = 1 " .
1031 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
1034 while ($row = sqlFetchArray($res)) {
1035 // This allows the list to default to the first item on the list
1036 // when the list_id request parameter is blank.
1037 if (($blank_list_id) && ($list_id == 'language')) {
1038 $list_id = $row['option_id'];
1039 $blank_list_id = false;
1042 $key = $row['option_id'];
1043 echo "<option value='$key'";
1044 if ($key == $list_id) {
1045 echo " selected";
1047 echo ">" . $row['title'] . "</option>\n";
1051 </select>
1052 </div>
1054 </div><!-- /.navbar-collapse -->
1055 </div>
1056 </nav>
1058 <table class="table table-striped table-condensed" style="margin-top:55px;">
1059 <thead>
1060 <tr>
1061 <?php if ($list_id == 'feesheet') : ?>
1062 <td><b><?php xl('Group', 'e'); ?></b></td>
1063 <td><b><?php xl('Option', 'e'); ?></b></td>
1064 <td><b><?php xl('Generates', 'e'); ?></b></td>
1065 <?php elseif ($list_id == 'code_types') : ?>
1066 <th><b><?php xl('Active', 'e'); ?></b></th>
1067 <th><b><?php xl('Key', 'e'); ?></b></th>
1068 <th><b><?php xl('ID', 'e'); ?></b></th>
1069 <th><b><?php xl('Label', 'e'); ?></b></th>
1070 <?php //show translation column if not english and the translation lists flag is set
1071 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1072 echo "<th><b>" . xl('Translation') . "</b><span class='help' title='" . xl('The translated Title that will appear in current language') . "'> (?)</span></th>";
1073 } ?>
1074 <th><b><?php xl('Seq', 'e'); ?></b></th>
1075 <th><b><?php xl('ModLength', 'e'); ?></b></th>
1076 <th><b><?php xl('Justify', 'e'); ?></b></th>
1077 <th><b><?php xl('Mask', 'e'); ?></b></th>
1078 <th><b><?php xl('Claims', 'e'); ?></b></th>
1079 <th><b><?php xl('Fees', 'e'); ?></b></th>
1080 <th><b><?php xl('Relations', 'e'); ?></b></th>
1081 <th><b><?php xl('Hide', 'e'); ?></b></th>
1082 <th><b><?php xl('Procedure', 'e'); ?></b></th>
1083 <th><b><?php xl('Diagnosis', 'e'); ?></b></th>
1084 <th><b><?php xl('Clinical Term', 'e'); ?></b></th>
1085 <th><b><?php xl('Medical Problem', 'e'); ?></b></th>
1086 <th><b><?php xl('Drug', 'e'); ?></b></th>
1087 <th><b><?php xl('External', 'e'); ?></b></th>
1088 <?php elseif ($list_id == 'apptstat' || $list_id == 'groupstat') : ?>
1089 <th><b><?php xl('ID', 'e'); ?></b></th>
1090 <th><b><?php xl('Title', 'e'); ?></b></th>
1091 <th><b><?php xl('Order', 'e'); ?></b></th>
1092 <th><b><?php xl('Default', 'e'); ?></b></th>
1093 <th><b><?php xl('Active', 'e'); ?></b></th>
1094 <th><b><?php xl('Color', 'e'); ?></b></th>
1095 <th><b><?php xl('Alert Time', 'e'); ?></b></th>
1096 <th><b><?php xl('Check In', 'e'); ?>&nbsp;&nbsp;&nbsp;&nbsp;</b>
1097 </th>
1098 <th><b><?php xl('Check Out', 'e'); ?></b></th>
1099 <th><b><?php xl('Code(s)', 'e'); ?></b></th>
1100 <?php elseif ($list_id == 'issue_types') : ?>
1101 <th><b><?php echo xlt('OpenEMR Application Category'); ?></b></th>
1102 <th><b><?php echo xlt('Active'); ?></b></th>
1103 <th><b><?php echo xlt('Order'); ?></b></th>
1104 <th><b><?php echo xlt('Type'); ?></b></th>
1105 <th><b><?php echo xlt('Plural'); ?></b></th>
1106 <?php //show translation column if not english and the translation lists flag is set
1107 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1108 echo "<th><b>" . xl('Translation') . "</b><span class='help' title='" . xl('The translated Title that will appear in current language') . "'> (?)</span></th>";
1109 } ?>
1110 <th><b><?php echo xlt('Singular'); ?></b></th>
1111 <?php //show translation column if not english and the translation lists flag is set
1112 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1113 echo "<th><b>" . xl('Translation') . "</b><span class='help' title='" . xl('The translated Title that will appear in current language') . "'> (?)</span></th>";
1114 } ?>
1115 <th><b><?php echo xlt('Mini'); ?></b></th>
1116 <?php //show translation column if not english and the translation lists flag is set
1117 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1118 echo "<th><b>" . xl('Translation') . "</b><span class='help' title='" . xl('The translated Title that will appear in current language') . "'> (?)</span></th>";
1119 } ?>
1120 <th><b><?php echo xlt('Style'); ?></b></th>
1121 <th><b><?php echo xlt('Force Show'); ?></b></th>
1122 <th><b><?php echo xlt('Access Control'); ?></b></th>
1123 <?php else : ?>
1124 <th title=<?php xl('Click to edit', 'e', '\'', '\''); ?>>
1125 <b><?php xl('ID', 'e'); ?></b></th>
1126 <th><b><?php xl('Title', 'e'); ?></b></th>
1127 <?php //show translation column if not english and the translation lists flag is set
1128 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
1129 echo "<th><b>" . xl('Translation') . "</b><span class='help' title='" . xl('The translated Title that will appear in current language') . "'> (?)</span></th>";
1130 } ?>
1131 <th><b><?php xl('Order', 'e'); ?></b></th>
1132 <th><b><?php xl('Default', 'e'); ?></b></th>
1133 <th><b><?php xl('Active', 'e'); ?></b></th>
1134 <?php if ($list_id == 'taxrate') { ?>
1135 <th><b><?php xl('Rate', 'e'); ?></b></th>
1136 <?php } elseif ($list_id == 'contrameth') { ?>
1137 <th><b><?php xl('Effectiveness', 'e'); ?></b></th>
1138 <?php } elseif ($list_id == 'lbfnames' || $list_id == 'transactions') { ?>
1139 <th title='<?php xl('Number of past history columns', 'e'); ?>'>
1140 <b><?php xl('Repeats', 'e'); ?></b></th>
1141 <?php } elseif ($list_id == 'fitness') { ?>
1142 <th><b><?php xl('Color:Abbr', 'e'); ?></b></th>
1143 <?php } elseif ($list_id == 'adjreason' || $list_id == 'abook_type') { ?>
1144 <th><b><?php xl('Type', 'e'); ?></b></th>
1145 <?php } elseif ($list_id == 'immunizations') { ?>
1146 <th>
1147 <b>&nbsp;&nbsp;&nbsp;&nbsp;<?php xl('CVX Code Mapping', 'e'); ?></b>
1148 </th>
1149 <?php }
1150 if ($GLOBALS['ippf_specific']) { ?>
1151 <th><b><?php xl('Global ID', 'e'); ?></b></th>
1152 <?php } ?>
1153 <th><b><?php
1154 if ($list_id == 'language') {
1155 echo xlt('ISO 639-2 Code');
1156 } elseif ($list_id == 'personal_relationship' || $list_id == 'religious_affiliation' || $list_id == 'ethnicity' || $list_id == 'race' || $list_id == 'drug_route') {
1157 echo xlt('HL7-V3 Concept Code');
1158 } elseif ($list_id == 'Immunization_Completion_Status') {
1159 echo xlt('Treatment Completion Status');
1160 } elseif ($list_id == 'race') {
1161 echo xlt('CDC Code');
1162 } elseif ($list_id == 'Immunization_Manufacturer') {
1163 echo xlt('MVX Code');
1164 } elseif ($list_id == 'marital') {
1165 echo xlt('Marital Status');
1166 } elseif ($list_id == 'county') {
1167 echo xlt('INCITS Code'); //International Committee for Information Technology Standards
1168 } elseif ($list_id == 'immunization_registry_status' || $list_id == 'imm_vac_eligibility_results') {
1169 echo xlt('IIS Code');
1170 } elseif ($list_id == 'publicity_code') {
1171 echo xlt('CDC Code');
1172 } elseif ($list_id == 'immunization_refusal_reason' || $list_id == 'immunization_informationsource') {
1173 echo xlt('CDC-NIP Code');
1174 } elseif ($list_id == 'next_of_kin_relationship' || $list_id == 'immunization_administered_site') {
1175 echo xlt('HL7 Code');
1176 } elseif ($list_id == 'immunization_observation') {
1177 echo xlt('LOINC Code');
1178 } elseif ($list_id == 'page_validation') {
1179 echo xlt('Page Validation');
1180 } elseif ($list_id == 'lbfnames') {
1181 echo xlt('Attributes');
1182 } else {
1183 echo xlt('Notes');
1184 } ?></b></th>
1186 <th><b><?php xl('Code(s)', 'e'); ?></b></th>
1187 <?php
1188 if (preg_match('/_issue_list$/', $list_id)) { ?>
1189 <th><b><?php echo xlt('Subtype'); ?></b></th>
1190 <?php
1192 endif; // end not fee sheet ?>
1193 </tr>
1194 </thead>
1195 <tbody>
1196 <?php
1197 // Get the selected list's elements.
1198 if ($list_id) {
1199 if ($list_id == 'feesheet') {
1200 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
1201 "ORDER BY fs_category, fs_option");
1202 while ($row = sqlFetchArray($res)) {
1203 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
1205 for ($i = 0; $i < 3; ++$i) {
1206 writeFSLine('', '', '');
1208 } elseif ($list_id == 'code_types') {
1209 $res = sqlStatement("SELECT * FROM code_types " .
1210 "ORDER BY ct_seq, ct_key");
1211 while ($row = sqlFetchArray($res)) {
1212 writeCTLine($row);
1214 for ($i = 0; $i < 3; ++$i) {
1215 writeCTLine(array());
1217 } elseif ($list_id == 'issue_types') {
1218 $res = sqlStatement("SELECT * FROM issue_types " .
1219 "ORDER BY category, ordering ASC");
1220 while ($row = sqlFetchArray($res)) {
1221 writeITLine($row);
1223 for ($i = 0; $i < 3; ++$i) {
1224 writeITLine(array());
1226 } else {
1228 * Add edit options to show or hide in list management
1229 * If the edit_options setting of the main list entry is set to 0,
1230 * then none of the list items will show.
1231 * If the edit_options setting of the main list entry is set to 1,
1232 * then the list items with edit_options set to 1 will show.
1234 $res = sqlStatement("SELECT lo.*
1235 FROM list_options as lo
1236 right join list_options as lo2 on lo2.option_id = lo.list_id AND lo2.edit_options = 1
1237 WHERE lo.list_id = '{$list_id}' AND lo.edit_options = 1
1238 ORDER BY seq,title");
1239 while ($row = sqlFetchArray($res)) {
1240 writeOptionLine(
1241 $row['option_id'],
1242 $row['title'],
1243 $row['seq'],
1244 $row['is_default'],
1245 $row['option_value'],
1246 $row['mapping'],
1247 $row['notes'],
1248 $row['codes'],
1249 $row['toggle_setting_1'],
1250 $row['toggle_setting_2'],
1251 $row['activity'],
1252 $row['subtype']
1255 for ($i = 0; $i < 3; ++$i) {
1256 writeOptionLine('', '', '', '', 0);
1261 </tbody>
1262 </table>
1264 <?php if ($list_id == 'immunizations') { ?>
1265 <p> <?php echo xlt('Is it ok to map these CVX codes to already existent immunizations?') ?>
1266 <input type='checkbox' name='ok_map_cvx_codes' id='ok_map_cvx_codes'
1267 value='1'/>
1268 </p>
1269 <?php } // end if($list_id == 'immunizations') ?>
1272 <button type="submit" name='form_save' id='form_save'
1273 class="btn btn-default btn-save"><?php xl('Save', 'e'); ?></button>
1274 </p>
1276 </form>
1278 <div class="modal fade" id="modal-new-list" tabindex="-1" role="dialog">
1279 <div class="modal-dialog" role="document">
1280 <div class="modal-content">
1281 <form action="edit_list.php" method="post" class="form">
1282 <div class="modal-header">
1283 <button type="button" class="close" data-dismiss="modal"
1284 aria-label="<?php echo xl('Close'); ?>"><i
1285 class="fa fa-times"
1286 aria-hidden="true"></i>
1287 </button>
1288 <h4 class="modal-title"><?php xl('New List', 'e'); ?></h4>
1289 </div>
1290 <div class="modal-body">
1291 <label for="newlistname"
1292 class="control-label"><?php xl('List Name', 'e'); ?></label>
1293 <input type="text" size="20" class="form-control"
1294 maxlength="100" name="newlistname" id="newlistname">
1295 <input type="hidden" name="formaction" value="addlist">
1297 </div>
1298 <div class="modal-footer text-right">
1299 <button type="submit"
1300 class="btn btn-default btn-save"><?php xl('Save', 'e'); ?></button>
1301 <button type="button" class="btn btn-link btn-cancel"
1302 data-dismiss="modal"><?php xl('Cancel', 'e'); ?></button>
1303 </div>
1304 </form>
1305 </div><!-- /.modal-content -->
1306 </div><!-- /.modal-dialog -->
1307 </div><!-- /.modal #modal-new-list -->
1309 </body>
1310 <script type="text/javascript">
1311 // jQuery stuff to make the page a little easier to use
1313 $(document).ready(function () {
1314 $("#form_save").click(function () {
1315 SaveChanges();
1317 $("#list_id").change(function () {
1318 $('#theform').submit();
1321 $(".newlist").click(function () {
1322 NewList(this);
1324 $(".savenewlist").click(function () {
1325 SaveNewList(this);
1327 $(".deletelist").click(function () {
1328 DeleteList(this);
1331 var SaveChanges = function () {
1332 $("#formaction").val("save");
1333 // $('#theform').submit();
1334 mysubmit();
1337 // show the DIV to create a new list
1338 var NewList = function (btnObj) {
1339 // show the field details DIV
1340 $('#newlistdetail').css('visibility', 'visible');
1341 $('#newlistdetail').css('display', 'block');
1342 $(btnObj).parent().append($("#newlistdetail"));
1343 $('#newlistdetail > #newlistname').focus();
1345 // save the new list
1346 var SaveNewList = function () {
1347 // the list name can only have letters, numbers, spaces and underscores
1348 // AND it cannot start with a number
1349 if ($("#newlistname").val().match(/^\d+/)) {
1350 alert("<?php xl('List names cannot start with numbers.', 'e'); ?>");
1351 return false;
1353 var validname = $("#newlistname").val().replace(/[^A-za-z0-9 -]/g, "_"); // match any non-word characters and replace them
1354 if (validname != $("#newlistname").val()) {
1355 if (!confirm("<?php xl('Your list name has been changed to meet naming requirements.', 'e', '', '\n') . xl('Please compare the new name', 'e', '', ', \''); ?>" + validname + "<?php xl('with the old name', 'e', '\' ', ', \''); ?>" + $("#newlistname").val() + "<?php xl('Do you wish to continue with the new name?', 'e', '\'.\n', ''); ?>")) {
1356 return false;
1359 $("#newlistname").val(validname);
1361 // submit the form to add a new field to a specific group
1362 $("#formaction").val("addlist");
1363 $("#theform").submit();
1365 // actually delete an entire list from the database
1366 var DeleteList = function (btnObj) {
1367 var listid = $(btnObj).attr("id");
1368 if (confirm("<?php xl('WARNING', 'e', '', ' - ') . xl('This action cannot be undone.', 'e', '', '\n') . xl('Are you sure you wish to delete the entire list', 'e', ' ', '('); ?>" + listid + ")?")) {
1369 // submit the form to add a new field to a specific group
1370 $("#formaction").val("deletelist");
1371 $("#deletelistname").val(listid);
1372 $("#theform").submit();
1377 </script>
1378 </html>