3 * Administration Lists Module.
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.
28 if (empty($_REQUEST['list_id'])) {
29 $list_id = 'language';
30 $blank_list_id = true;
32 $list_id = $_REQUEST['list_id'];
35 // Check authorization.
36 $thisauth = acl_check('admin', 'super');
38 die(xlt('Not authorized'));
41 // If we are saving, then save.
43 if ($_POST['formaction'] == 'save' && $list_id) {
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) {
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 ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
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']),
123 formTrim($iter['ordering']),
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']),
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' &&
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') {
176 // Force Transaction Form names to start with LBT.
177 if ($list_id == 'transactions' && substr($id, 0, 3) != 'LBT') {
181 if ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
182 $notes = formTrim($iter['apptstat_color']) . '|' . formTrim($iter['apptstat_timealert']);
184 $notes = formTrim($iter['notes']);
186 // Insert the list item
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 ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
194 formTrim($iter['title']),
195 formTrim($iter['seq']),
196 formTrim($iter['default']),
198 formTrim($iter['mapping']),
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']));
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)
238 $arrcodes = explode('~', $codes);
240 foreach ($arrcodes as $codestring) {
241 if ($codestring === '') {
244 $arrcode = explode('|', $codestring);
245 $code_type = $arrcode[0];
247 $selector = $arrcode[2];
249 if ($code_type == 'PROD') {
250 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = ?", array($code));
251 $desc = "$code:$selector " . $row['name'];
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);
267 // Write one option line to the form.
269 function writeOptionLine(
284 global $opt_line_no, $list_id;
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" : "";
295 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][id]' value='" .
296 attr($option_id) . "' size='12' maxlength='63' class='optin' />";
299 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][title]' value='" .
300 attr($title) . "' size='20' maxlength='63' class='optin' />";
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";
308 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][seq]' value='" .
309 attr($seq) . "' size='4' maxlength='10' class='optin' />";
313 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][default]' value='1' " .
314 "onclick='defClicked(" . attr($opt_line_no) . ")' class='optin'$checked />";
317 if (preg_match('/Eye_QP_/', $list_id)) {
319 echo "<select name='opt[" . attr($opt_line_no) . "][activity]' class='optin'>";
323 ) as $key => $desc) {
324 echo "<option value='" . attr($key) . "'";
325 if ($key == $active) {
328 echo ">" . text($desc) . "</option>";
334 echo "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][activity]' value='1' " . " class='optin'$checked_active />";
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') {
341 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][value]' value='" .
342 attr($value) . "' size='8' maxlength='15' class='optin' />";
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') {
351 echo "<select name='opt[" . attr($opt_line_no) . "][value]' class='optin'>";
353 1 => xl('Charge adjustment'),
354 2 => xl('Coinsurance'),
355 3 => xl('Deductible'),
356 4 => xl('Other pt resp'),
358 ) as $key => $desc) {
359 echo "<option value='" . attr($key) . "'";
360 if ($key == $value) {
363 echo ">" . text($desc) . "</option>";
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') {
372 echo "<select name='opt[" . attr($opt_line_no) . "][value]' class='optin'>";
374 1 => xl('Unassigned'),
377 ) as $key => $desc) {
378 echo "<option value='" . attr($key) . "'";
379 if ($key == $value) {
382 echo ">" . text($desc) . "</option>";
386 } // Immunization categories use option_value to map list items
389 elseif ($list_id == 'immunizations') {
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') . "'/>";
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') {
402 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][mapping]' value='" .
403 attr($mapping) . "' size='12' maxlength='15' class='optin' />";
405 } elseif ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
406 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
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' />";
412 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][apptstat_timealert]' value='" .
413 attr($apptstat_timealert) . "' size='2' maxlength='2' class='optin' />";
417 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][notes]' value='" .
418 attr($notes) . "' size='25' maxlength='255' class='optin' ";
422 if ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
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 />";
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 />";
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' />";
438 if (preg_match('/_issue_list$/', $list_id)) {
440 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype', ' ', 'optin');
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) . "' />";
450 // Write a form line as above but for the special case of the Fee Sheet.
452 function writeFSLine($category, $option, $codes)
457 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
459 $descs = getCodeDescriptions($codes);
464 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][category]' value='" .
465 attr($category) . "' size='20' maxlength='63' class='optin' />";
469 echo "<input type='text' name='opt[" . attr($opt_line_no) . "][option]' value='" .
470 attr($option) . "' size='20' maxlength='63' class='optin' />";
473 echo " <td align='left' class='optcell'>";
474 echo " <div id='codelist_" . attr($opt_line_no) . "'>";
475 if (strlen($descs)) {
476 $arrdescs = explode('~', $descs);
478 foreach ($arrdescs as $desc) {
479 echo "<a href='' onclick='return delete_code(" . attr($opt_line_no) . ",$i)' title='" . xla('Delete') . "'>";
480 echo "[x] </a>" . text($desc) . "<br />";
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) . "' />";
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] : '';
506 $s .= " title='" . attr($title) . "'";
509 $s .= "<input type='text' name='opt[" . attr($opt_line_no) . "][" . attr($name) . "]' value='";
511 $s .= "' size='" . attr($size) . "' maxlength='" . attr($maxlength) . "' class='optin' />";
516 function ctGenCbox($opt_line_no, $data_array, $name, $title = '')
518 $checked = empty($data_array[$name]) ?
'' : 'checked ';
521 $s .= " title='" . attr($title) . "'";
524 $s .= "<input type='checkbox' name='opt[" . attr($opt_line_no) . "][" . attr($name) . "]' value='1' ";
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) {
540 $s .= ">" . text($desc) . "</option>";
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;
554 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
562 xl('Is this code type active?')
570 xl('Unique human-readable identifier for this type')
578 xl('Unique numeric identifier for this type')
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";
598 xl('Numeric display order')
606 xl('Length of modifier, 0 if none')
614 xl('If billing justification is used enter the name of the diagnosis code type.')
622 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.')
628 xl('Is this code type used in claims?')
634 xl('Are fees charged for this type?')
640 xl('Does this type allow related codes?')
646 xl('Is this type hidden in the fee sheet?')
652 xl('Is this a procedure/service type?')
658 xl('Is this a diagnosis type?')
664 xl('Is this a Clinical Term code type?')
670 xl('Is this a Medical Problem code type?')
676 xl('Is this a Medication type?')
682 $cd_external_options,
683 xl('Is this using external sql tables? If it is, then choose the format.')
689 * Special case of Issue Types
691 function writeITLine($it_array)
693 global $opt_line_no, $ISSUE_TYPE_CATEGORIES, $ISSUE_TYPE_STYLES;
695 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
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.'));
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']);
733 <?php
echo Header
::setupHeader(['select2', 'jscolor']); ?
>
734 <title
><?php
echo xlt('List Editor'); ?
></title
>
740 background
-color
: transparent
;
751 <script type
="text/javascript">
752 $
(document
).ready(function () {
753 $
(".select-dropdown").select2({
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
);
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];
783 var descs
= f
['opt[' + lino +
'][descs]'].value
;
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] </a>" + arrdescs
[i
] +
"<br />";
791 setDivContent('codelist_' + lino
, s
);
794 // Helper function to remove a Fee Sheet code.
795 function dc_substring(s
, i
) {
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);
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]'];
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
);
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
= '';
830 dlgopen('../patient_file/encounter/find_code_dynamic.php', '_blank', 900, 600);
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
];
858 if (s
.length
> 0) s +
= ';';
859 s +
= codetype +
':' + code
;
866 else if (current_sel_name
) {
867 // Coming from Immunizations edit
868 var e
= f
[current_sel_name
];
879 // Coming from Fee Sheet edit
880 var celem
= f
['opt[' + current_lino +
'][codes]'];
881 var delem
= f
['opt[' + current_lino +
'][descs]'];
883 while ((i
= codedesc
.indexOf('~')) >= 0) {
884 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
891 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
892 if (codetype
== 'PROD') {
893 delem
.value +
= code +
':' + selector +
' ' + codedesc
;
895 delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
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';
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(';');
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
);
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
);
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();
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
>
998 <a
class="navbar-brand"
999 href
="#"><?php
echo xlt('Manage Lists'); ?
></a
>
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
> 
;<?php
echo xlt('New List'); ?
>
1010 <a href
="#" class="deletelist" id
="<?php echo $list_id; ?>">
1011 <i
class="fa fa-trash"></i
> 
;<?php
echo xlt('Delete List'); ?
>
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"
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");
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 " .
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) {
1054 echo ">" . text($row['title']) . "</option>\n";
1061 </div
><!-- /.navbar
-collapse
-->
1065 <table
class="table table-striped table-condensed" style
="margin-top:55px;">
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>";
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'); ?
> 
; 
; 
; 
;</b
>
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>";
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>";
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>";
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
>
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>";
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') { ?
>
1154 <b
> 
; 
; 
; 
;<?php
echo xlt('CVX Code Mapping'); ?
></b
>
1157 if ($GLOBALS['ippf_specific']) { ?
>
1158 <th
><b
><?php
echo xlt('Global ID'); ?
></b
></th
>
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');
1193 <th
><b
><?php
echo xlt('Code(s)'); ?
></b
></th
>
1195 if (preg_match('/_issue_list$/', $list_id)) { ?
>
1196 <th
><b
><?php
echo xlt('Subtype'); ?
></b
></th
>
1199 endif; // end not fee sheet ?>
1204 // Get the selected list's elements.
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)) {
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)) {
1230 for ($i = 0; $i < 3; ++
$i) {
1231 writeITLine(array());
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)) {
1252 $row['option_value'],
1256 $row['toggle_setting_1'],
1257 $row['toggle_setting_2'],
1262 for ($i = 0; $i < 3; ++
$i) {
1263 writeOptionLine('', '', '', '', 0);
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'
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
>
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
1293 aria
-hidden
="true"></i
>
1295 <h4
class="modal-title"><?php
echo xlt('New List'); ?
></h4
>
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">
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
>
1312 </div
><!-- /.modal
-content
-->
1313 </div
><!-- /.modal
-dialog
-->
1314 </div
><!-- /.modal
#modal-new-list -->
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 () {
1324 $
("#list_id").change(function () {
1325 $
('#theform').submit();
1328 $
(".newlist").click(function () {
1331 $
(".savenewlist").click(function () {
1334 $
(".deletelist").click(function () {
1338 var SaveChanges
= function () {
1339 $
("#formaction").val("save");
1340 // $('#theform').submit();
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.'); ?>");
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?'); ?>")) {
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();