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>;.
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.
37 if (empty($_REQUEST['list_id'])) {
38 $list_id = 'language';
39 $blank_list_id = true;
41 $list_id = $_REQUEST['list_id'];
44 // Check authorization.
45 $thisauth = acl_check('admin', 'super');
47 die(xl('Not authorized'));
50 // If we are saving, then save.
52 if ($_POST['formaction'] == 'save' && $list_id) {
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 " .
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 " .
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']),
133 formTrim($iter['ordering']),
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']),
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' &&
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') {
186 // Force Transaction Form names to start with LBT.
187 if ($list_id == 'transactions' && substr($id, 0, 3) != 'LBT') {
191 if ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
192 $notes = formTrim($iter['apptstat_color']) . '|' . formTrim($iter['apptstat_timealert']);
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 " .
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']) . "' " .
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 " .
229 "'lists'," . // the master list-of-lists
230 "'" . $newlistID . "'," .
231 "'" . $_POST['newlistname'] . "', " .
232 "'" . ($row['maxseq'] +
1) . "'," .
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'] . "'");
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)
250 $arrcodes = explode('~', $codes);
252 foreach ($arrcodes as $codestring) {
253 if ($codestring === '') {
256 $arrcode = explode('|', $codestring);
257 $code_type = $arrcode[0];
259 $selector = $arrcode[2];
261 if ($code_type == 'PROD') {
262 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
263 $desc = "$code:$selector " . $row['name'];
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);
279 // Write one option line to the form.
281 function writeOptionLine(
296 global $opt_line_no, $list_id;
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" : "";
307 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
308 htmlspecialchars($option_id, ENT_QUOTES
) . "' size='12' maxlength='63' class='optin' />";
311 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
312 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
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";
320 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
321 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
325 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
326 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
330 echo "<input type='checkbox' name='opt[$opt_line_no][activity]' value='1' " .
331 " class='optin'$checked_active />";
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') {
338 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
339 htmlspecialchars($value, ENT_QUOTES
) . "' size='8' maxlength='15' class='optin' />";
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') {
348 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
350 1 => xl('Charge adjustment'),
351 2 => xl('Coinsurance'),
352 3 => xl('Deductible'),
353 4 => xl('Other pt resp'),
355 ) as $key => $desc) {
356 echo "<option value='$key'";
357 if ($key == $value) {
360 echo ">" . htmlspecialchars($desc) . "</option>";
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') {
369 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
371 1 => xl('Unassigned'),
374 ) as $key => $desc) {
375 echo "<option value='$key'";
376 if ($key == $value) {
379 echo ">" . htmlspecialchars($desc) . "</option>";
383 } // Immunization categories use option_value to map list items
386 elseif ($list_id == 'immunizations') {
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
) . "'/>";
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') {
399 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
400 htmlspecialchars($mapping, ENT_QUOTES
) . "' size='12' maxlength='15' class='optin' />";
402 } elseif ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
403 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
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' />";
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' />";
414 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
415 attr($notes) . "' size='25' maxlength='255' class='optin' ";
419 if ($list_id == 'apptstat' ||
$list_id == 'groupstat') {
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 />";
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 />";
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' />";
435 if (preg_match('/_issue_list$/', $list_id)) {
437 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype', ' ', 'optin');
443 // Write a form line as above but for the special case of the Fee Sheet.
445 function writeFSLine($category, $option, $codes)
450 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
452 $descs = getCodeDescriptions($codes);
457 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
458 htmlspecialchars($category, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
462 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
463 htmlspecialchars($option, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
466 echo " <td align='left' class='optcell'>";
467 echo " <div id='codelist_$opt_line_no'>";
468 if (strlen($descs)) {
469 $arrdescs = explode('~', $descs);
471 foreach ($arrdescs as $desc) {
472 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
473 echo "[x] </a>$desc<br />";
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
) . "' />";
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] : '';
499 $s .= " title='" . attr($title) . "'";
502 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
504 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
509 function ctGenCbox($opt_line_no, $data_array, $name, $title = '')
511 $checked = empty($data_array[$name]) ?
'' : 'checked ';
514 $s .= " title='" . attr($title) . "'";
517 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
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) {
533 $s .= ">" . text($desc) . "</option>";
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;
547 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
555 xl('Is this code type active?')
563 xl('Unique human-readable identifier for this type')
571 xl('Unique numeric identifier for this type')
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";
591 xl('Numeric display order')
599 xl('Length of modifier, 0 if none')
607 xl('If billing justification is used enter the name of the diagnosis code type.')
615 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.')
621 xl('Is this code type used in claims?')
627 xl('Are fees charged for this type?')
633 xl('Does this type allow related codes?')
639 xl('Is this type hidden in the fee sheet?')
645 xl('Is this a procedure/service type?')
651 xl('Is this a diagnosis type?')
657 xl('Is this a Clinical Term code type?')
663 xl('Is this a Medical Problem code type?')
669 xl('Is this a Medication type?')
675 $cd_external_options,
676 xl('Is this using external sql tables? If it is, then choose the format.')
682 * Special case of Issue Types
684 function writeITLine($it_array)
686 global $opt_line_no, $ISSUE_TYPE_CATEGORIES, $ISSUE_TYPE_STYLES;
688 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
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.'));
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']);
726 <?php
echo Header
::setupHeader(['select2', 'jscolor']); ?
>
727 <title
><?php
xl('List Editor', 'e'); ?
></title
>
733 background
-color
: transparent
;
744 <script type
="text/javascript">
745 $
(document
).ready(function () {
746 $
(".select-dropdown").select2({
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
);
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];
775 var descs
= f
['opt[' + lino +
'][descs]'].value
;
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] </a>" + arrdescs
[i
] +
"<br />";
783 setDivContent('codelist_' + lino
, s
);
786 // Helper function to remove a Fee Sheet code.
787 function dc_substring(s
, i
) {
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);
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]'];
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
);
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
= '';
822 dlgopen('../patient_file/encounter/find_code_dynamic.php', '_blank', 900, 600);
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
];
850 if (s
.length
> 0) s +
= ';';
851 s +
= codetype +
':' + code
;
858 else if (current_sel_name
) {
859 // Coming from Immunizations edit
860 var e
= f
[current_sel_name
];
871 // Coming from Fee Sheet edit
872 var celem
= f
['opt[' + current_lino +
'][codes]'];
873 var delem
= f
['opt[' + current_lino +
'][descs]'];
875 while ((i
= codedesc
.indexOf('~')) >= 0) {
876 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
883 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
884 if (codetype
== 'PROD') {
885 delem
.value +
= code +
':' + selector +
' ' + codedesc
;
887 delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
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';
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(';');
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
);
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
);
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();
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
>
989 <a
class="navbar-brand"
990 href
="#"><?php
xl('Manage Lists', 'e'); ?
></a
>
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
> 
;<?php
xl('New List', 'e'); ?
>
1001 <a href
="#" class="deletelist" id
="<?php echo $list_id; ?>">
1002 <i
class="fa fa-trash"></i
> 
;<?php
xl('Delete List', 'e'); ?
>
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"
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");
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) {
1047 echo ">" . $row['title'] . "</option>\n";
1054 </div
><!-- /.navbar
-collapse
-->
1058 <table
class="table table-striped table-condensed" style
="margin-top:55px;">
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>";
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'); ?
> 
; 
; 
; 
;</b
>
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>";
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>";
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>";
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
>
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>";
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') { ?
>
1147 <b
> 
; 
; 
; 
;<?php
xl('CVX Code Mapping', 'e'); ?
></b
>
1150 if ($GLOBALS['ippf_specific']) { ?
>
1151 <th
><b
><?php
xl('Global ID', 'e'); ?
></b
></th
>
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');
1186 <th
><b
><?php
xl('Code(s)', 'e'); ?
></b
></th
>
1188 if (preg_match('/_issue_list$/', $list_id)) { ?
>
1189 <th
><b
><?php
echo xlt('Subtype'); ?
></b
></th
>
1192 endif; // end not fee sheet ?>
1197 // Get the selected list's elements.
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)) {
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)) {
1223 for ($i = 0; $i < 3; ++
$i) {
1224 writeITLine(array());
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)) {
1245 $row['option_value'],
1249 $row['toggle_setting_1'],
1250 $row['toggle_setting_2'],
1255 for ($i = 0; $i < 3; ++
$i) {
1256 writeOptionLine('', '', '', '', 0);
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'
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
>
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
1286 aria
-hidden
="true"></i
>
1288 <h4
class="modal-title"><?php
xl('New List', 'e'); ?
></h4
>
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">
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
>
1305 </div
><!-- /.modal
-content
-->
1306 </div
><!-- /.modal
-dialog
-->
1307 </div
><!-- /.modal
#modal-new-list -->
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 () {
1317 $
("#list_id").change(function () {
1318 $
('#theform').submit();
1321 $
(".newlist").click(function () {
1324 $
(".savenewlist").click(function () {
1327 $
(".deletelist").click(function () {
1331 var SaveChanges
= function () {
1332 $
("#formaction").val("save");
1333 // $('#theform').submit();
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'); ?>");
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', ''); ?>")) {
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();