3 * Administration Lists Module.
5 * Copyright (C) 2007-2016 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author Rod Roark <rod@sunsetsystems.com>
20 * @author Brady Miller <brady@sparmy.com>
21 * @author Teny <teny@zhservices.com>
22 * @link http://www.open-emr.org
25 require_once("../globals.php");
26 require_once("$srcdir/acl.inc");
27 require_once("$srcdir/lists.inc");
28 require_once("../../custom/code_types.inc.php");
29 require_once("$srcdir/options.inc.php");
31 $list_id = empty($_REQUEST['list_id']) ?
'language' : $_REQUEST['list_id'];
33 // Check authorization.
34 $thisauth = acl_check('admin', 'super');
35 if (!$thisauth) die(xl('Not authorized'));
37 // If we are saving, then save.
39 if ($_POST['formaction']=='save' && $list_id) {
41 if ($list_id == 'feesheet') {
42 // special case for the feesheet list
43 sqlStatement("DELETE FROM fee_sheet_options");
44 for ($lino = 1; isset($opt["$lino"]['category']); ++
$lino) {
45 $iter = $opt["$lino"];
46 $category = formTrim($iter['category']);
47 $option = formTrim($iter['option']);
48 $codes = formTrim($iter['codes']);
49 if (strlen($category) > 0 && strlen($option) > 0) {
50 sqlInsert("INSERT INTO fee_sheet_options ( " .
51 "fs_category, fs_option, fs_codes " .
60 else if ($list_id == 'code_types') {
61 // special case for code types
62 sqlStatement("DELETE FROM code_types");
63 for ($lino = 1; isset($opt["$lino"]['ct_key']); ++
$lino) {
64 $iter = $opt["$lino"];
65 $ct_key = formTrim($iter['ct_key']);
66 $ct_id = formTrim($iter['ct_id']) +
0;
67 $ct_seq = formTrim($iter['ct_seq']) +
0;
68 $ct_mod = formTrim($iter['ct_mod']) +
0;
69 $ct_just = formTrim($iter['ct_just']);
70 $ct_mask = formTrim($iter['ct_mask']);
71 $ct_fee = empty($iter['ct_fee' ]) ?
0 : 1;
72 $ct_rel = empty($iter['ct_rel' ]) ?
0 : 1;
73 $ct_nofs = empty($iter['ct_nofs']) ?
0 : 1;
74 $ct_diag = empty($iter['ct_diag']) ?
0 : 1;
75 $ct_active = empty($iter['ct_active' ]) ?
0 : 1;
76 $ct_label = formTrim($iter['ct_label']);
77 $ct_external = formTrim($iter['ct_external']) +
0;
78 $ct_claim = empty($iter['ct_claim']) ?
0 : 1;
79 $ct_proc = empty($iter['ct_proc']) ?
0 : 1;
80 $ct_term = empty($iter['ct_term']) ?
0 : 1;
81 $ct_problem = empty($iter['ct_problem']) ?
0 : 1;
82 $ct_drug = empty($iter['ct_drug']) ?
0 : 1;
83 if (strlen($ct_key) > 0 && $ct_id > 0) {
84 sqlInsert("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 " .
109 else if ($list_id == 'issue_types') {
110 // special case for issue_types
111 sqlStatement("DELETE FROM issue_types");
112 for ($lino = 1; isset($opt["$lino"]['category']); ++
$lino) {
113 $iter = $opt["$lino"];
114 $it_active = formTrim($iter['active']);
115 $it_category = formTrim($iter['category']);
116 $it_ordering = formTrim($iter['ordering']);
117 $it_type = formTrim($iter['type']);
118 $it_plural = formTrim($iter['plural']);
119 $it_singular = formTrim($iter['singular']);
120 $it_abbr = formTrim($iter['abbreviation']);
121 $it_style = formTrim($iter['style']);
122 $it_fshow = formTrim($iter['force_show']);
124 if ( (strlen($it_category) > 0) && (strlen($it_type) > 0) ) {
125 sqlInsert("INSERT INTO issue_types ( " .
126 "`active`,`category`,`ordering`, `type`, `plural`, `singular`, `abbreviation`, `style`, `force_show` " .
129 "'$it_category' , " .
130 "'$it_ordering' , " .
133 "'$it_singular' , " .
144 // collect the option toggle if using the 'immunizations' list
145 if ($list_id == 'immunizations') {
146 $ok_map_cvx_codes = isset($_POST['ok_map_cvx_codes']) ?
$_POST['ok_map_cvx_codes'] : 0;
148 // erase lists options and recreate them from the submitted form data
149 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
150 for ($lino = 1; isset($opt["$lino"]['id']); ++
$lino) {
151 $iter = $opt["$lino"];
152 $value = empty($iter['value']) ?
0 : (formTrim($iter['value']) +
0);
153 $id = formTrim($iter['id']);
154 if (strlen($id) > 0) {
156 // Special processing for the immunizations list
157 // Map the entered cvx codes into the immunizations table cvx_code
158 // Ensure the following conditions are met to do this:
159 // $list_id == 'immunizations'
160 // $value is an integer and greater than 0
161 // $id is set, not empty and not equal to 0
162 // (note that all these filters are important. Not allowing $id
163 // of zero here is extremely important; never remove this conditional
164 // or you risk corrupting your current immunizations database entries)
165 // $ok_map_cvx_codes is equal to 1
166 if ($list_id == 'immunizations' &&
172 $ok_map_cvx_codes == 1 ) {
173 sqlStatement ("UPDATE `immunizations` " .
174 "SET `cvx_code`='".$value."' " .
175 "WHERE `immunization_id`='".$id."'");
178 // Force List Based Form names to start with LBF.
179 if ($list_id == 'lbfnames' && substr($id,0,3) != 'LBF')
182 // Force Transaction Form names to start with LBT.
183 if ($list_id == 'transactions' && substr($id,0,3) != 'LBT')
186 if ($list_id == 'apptstat') {
187 $notes = formTrim($iter['apptstat_color']) .'|'. formTrim($iter['apptstat_timealert']);
191 $notes = formTrim($iter['notes']);
193 // Insert the list item
194 sqlInsert("INSERT INTO list_options ( " .
195 "list_id, option_id, title, seq, is_default, option_value, mapping, notes, codes, toggle_setting_1, toggle_setting_2, activity, subtype " .
199 "'" . formTrim($iter['title']) . "', " .
200 "'" . formTrim($iter['seq']) . "', " .
201 "'" . formTrim($iter['default']) . "', " .
202 "'" . $value . "', " .
203 "'" . formTrim($iter['mapping']) . "', " .
204 "'" . $notes . "', " .
205 "'" . formTrim($iter['codes']) . "', " .
206 "'" . formTrim($iter['toggle_setting_1']) . "', " .
207 "'" . formTrim($iter['toggle_setting_2']) . "', " .
208 "'" . formTrim($iter['activity']) . "', " .
209 "'" . formTrim($iter['subtype']) . "' " .
215 else if ($_POST['formaction']=='addlist') {
216 // make a new list ID from the new list name
217 $newlistID = $_POST['newlistname'];
218 $newlistID = preg_replace("/\W/", "_", $newlistID);
220 // determine the position of this new list
221 $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
223 // add the new list to the list-of-lists
224 sqlInsert("INSERT INTO list_options ( " .
225 "list_id, option_id, title, seq, is_default, option_value " .
227 "'lists',". // the master list-of-lists
229 "'".$_POST['newlistname']."', ".
230 "'".($row['maxseq']+
1)."',".
234 else if ($_POST['formaction']=='deletelist') {
235 // delete the lists options
236 sqlStatement("DELETE FROM list_options WHERE list_id = '".$_POST['list_id']."'");
237 // delete the list from the master list-of-lists
238 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' and option_id='".$_POST['list_id']."'");
243 // Given a string of multiple instances of code_type|code|selector,
244 // make a description for each.
245 // @TODO Instead should use a function from custom/code_types.inc.php and need to remove casing functions
246 function getCodeDescriptions($codes) {
248 $arrcodes = explode('~', $codes);
250 foreach ($arrcodes as $codestring) {
251 if ($codestring === '') continue;
252 $arrcode = explode('|', $codestring);
253 $code_type = $arrcode[0];
255 $selector = $arrcode[2];
257 if ($code_type == 'PROD') {
258 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
259 $desc = "$code:$selector " . $row['name'];
262 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
263 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
264 "code = '$code' ORDER BY modifier LIMIT 1");
265 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
267 $desc = str_replace('~', ' ', $desc);
274 // Write one option line to the form.
276 function writeOptionLine($option_id, $title, $seq, $default, $value, $mapping='', $notes='', $codes='',$tog1='', $tog2='', $active='',$subtype='') {
277 global $opt_line_no, $list_id;
279 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
280 $checked = $default ?
" checked" : "";
281 $checked_tog1 = $tog1 ?
" checked" : "";
282 $checked_tog2 = $tog2 ?
" checked" : "";
283 $checked_active = $active ?
" checked" : "";
285 echo " <tr bgcolor='$bgcolor'>\n";
287 echo " <td align='center' class='optcell'>";
288 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
289 htmlspecialchars($option_id, ENT_QUOTES
) . "' size='12' maxlength='63' class='optin' />";
291 echo " <td align='center' class='optcell'>";
292 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
293 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
296 // if not english and translating lists then show the translation
297 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
298 echo " <td align='center' class='translation'>" . (htmlspecialchars( xl($title), ENT_QUOTES
)) . "</td>\n";
300 echo " <td align='center' class='optcell'>";
301 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
302 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
305 echo " <td align='center' class='optcell'>";
306 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
307 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
310 echo " <td align='center' class='optcell'>";
311 echo "<input type='checkbox' name='opt[$opt_line_no][activity]' value='1' " .
312 " class='optin'$checked_active />";
315 // Tax rates, contraceptive methods and LBF names have an additional attribute.
317 if ($list_id == 'taxrate' ||
$list_id == 'contrameth' ||
$list_id == 'lbfnames' ||
$list_id == 'transactions') {
318 echo " <td align='center' class='optcell'>";
319 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
320 htmlspecialchars($value, ENT_QUOTES
) . "' size='8' maxlength='15' class='optin' />";
324 // Adjustment reasons use option_value as a reason category. This is
325 // needed to distinguish between adjustments that change the invoice
326 // balance and those that just shift responsibility of payment or
327 // are used as comments.
329 else if ($list_id == 'adjreason') {
330 echo " <td align='center' class='optcell'>";
331 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
333 1 => xl('Charge adjustment'),
334 2 => xl('Coinsurance'),
335 3 => xl('Deductible'),
336 4 => xl('Other pt resp'),
338 ) as $key => $desc) {
339 echo "<option value='$key'";
340 if ($key == $value) echo " selected";
341 echo ">" . htmlspecialchars($desc) . "</option>";
347 // Address book categories use option_value to flag category as a
348 // person-centric vs company-centric vs indifferent.
350 else if ($list_id == 'abook_type') {
351 echo " <td align='center' class='optcell'>";
352 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
354 1 => xl('Unassigned'),
357 ) as $key => $desc) {
358 echo "<option value='$key'";
359 if ($key == $value) echo " selected";
360 echo ">" . htmlspecialchars($desc) . "</option>";
366 // Immunization categories use option_value to map list items
369 else if ($list_id == 'immunizations') {
370 echo " <td align='center' class='optcell'>";
371 echo "<input type='text' size='10' name='opt[$opt_line_no][value]' " .
372 "value='" . htmlspecialchars($value,ENT_QUOTES
) . "' onclick='sel_cvxcode(this)' " .
373 "title='" . htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES
) . "'/>";
377 // IPPF includes the ability to map each list item to a "master" identifier.
378 // Sports teams use this for some extra info for fitness levels.
380 if ($GLOBALS['ippf_specific'] ||
$list_id == 'fitness') {
381 echo " <td align='center' class='optcell'>";
382 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
383 htmlspecialchars($mapping, ENT_QUOTES
) . "' size='12' maxlength='15' class='optin' />";
386 else if($list_id == 'apptstat') {
387 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
388 echo " <td align='center' class='optcell'>";
389 echo "<input type='text' class='color' name='opt[$opt_line_no][apptstat_color]' value='" .
390 htmlspecialchars($apptstat_color, ENT_QUOTES
) . "' size='6' maxlength='6' class='optin' />";
392 echo " <td align='center' class='optcell'>";
393 echo "<input type='text' name='opt[$opt_line_no][apptstat_timealert]' value='" .
394 htmlspecialchars($apptstat_timealert, ENT_QUOTES
) . "' size='2' maxlength='2' class='optin' />";
397 echo " <td align='center' class='optcell'>";
398 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
399 htmlspecialchars($notes, ENT_QUOTES
) . "' size='25' class='optin' />";
402 if($list_id == 'apptstat') {
403 echo " <td align='center' class='optcell'>";
404 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_1]' value='1' " .
405 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog1 />";
407 echo " <td align='center' class='optcell'>";
408 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_2]' value='1' " .
409 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog2 />";
412 echo " <td align='center' class='optcell'>";
413 echo "<input type='text' name='opt[$opt_line_no][codes]' title='" .
414 xla('Clinical Term Code(s)') ."' value='" .
415 htmlspecialchars($codes, ENT_QUOTES
) . "' onclick='select_clin_term_code(this)' size='25' maxlength='255' class='optin' />";
418 if (preg_match('/_issue_list$/',$list_id)) {
419 echo " <td align='center' class='optcell'>";
420 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype',' ', 'optin');
426 // Write a form line as above but for the special case of the Fee Sheet.
428 function writeFSLine($category, $option, $codes) {
432 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
434 $descs = getCodeDescriptions($codes);
436 echo " <tr bgcolor='$bgcolor'>\n";
438 echo " <td align='center' class='optcell'>";
439 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
440 htmlspecialchars($category, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
443 echo " <td align='center' class='optcell'>";
444 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
445 htmlspecialchars($option, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
448 echo " <td align='left' class='optcell'>";
449 echo " <div id='codelist_$opt_line_no'>";
450 if (strlen($descs)) {
451 $arrdescs = explode('~', $descs);
453 foreach ($arrdescs as $desc) {
454 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
455 echo "[x] </a>$desc<br />";
460 echo "<a href='' onclick='return select_code($opt_line_no)'>";
461 echo "[" . xl('Add') . "]</a>";
463 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
464 htmlspecialchars($codes, ENT_QUOTES
) . "' />";
465 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
466 htmlspecialchars($descs, ENT_QUOTES
) . "' />";
474 * Helper functions for writeITLine() and writeCTLine().
476 function ctGenCell($opt_line_no, $data_array, $name, $size, $maxlength, $title='') {
477 $value = isset($data_array[$name]) ?
$data_array[$name] : '';
478 $s = " <td align='center' class='optcell'";
479 if ($title) $s .= " title='" . attr($title) . "'";
481 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
483 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
488 function ctGenCbox($opt_line_no, $data_array, $name, $title='') {
489 $checked = empty($data_array[$name]) ?
'' : 'checked ';
490 $s = " <td align='center' class='optcell'";
491 if ($title) $s .= " title='" . attr($title) . "'";
493 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
499 function ctSelector($opt_line_no, $data_array, $name, $option_array, $title='') {
500 $value = isset($data_array[$name]) ?
$data_array[$name] : '';
501 $s = " <td title='" . attr($title) . "' align='center' class='optcell'>";
502 $s .= "<select name='opt[$opt_line_no][$name]' class='optin'>";
503 foreach ( $option_array as $key => $desc) {
504 $s .= "<option value='" . attr($key) . "'";
505 if ($key == $value) $s .= " selected";
506 $s .= ">" . text($desc) . "</option>";
513 // Write a form line as above but for the special case of Code Types.
515 function writeCTLine($ct_array) {
516 global $opt_line_no,$cd_external_options;
519 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
521 echo " <tr bgcolor='$bgcolor'>\n";
523 echo ctGenCBox($opt_line_no, $ct_array, 'ct_active',
524 xl('Is this code type active?'));
525 echo ctGenCell($opt_line_no, $ct_array, 'ct_key' , 6, 15,
526 xl('Unique human-readable identifier for this type'));
527 echo ctGenCell($opt_line_no, $ct_array, 'ct_id' , 2, 11,
528 xl('Unique numeric identifier for this type'));
529 echo ctGenCell($opt_line_no, $ct_array, 'ct_label' , 6, 30,
530 xl('Label for this type'));
531 // if not english and translating lists then show the translation
532 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
533 echo " <td align='center' class='translation'>" . xlt($ct_array['ct_label']) . "</td>\n";
535 echo ctGenCell($opt_line_no, $ct_array, 'ct_seq' , 2, 3,
536 xl('Numeric display order'));
537 echo ctGenCell($opt_line_no, $ct_array, 'ct_mod' , 1, 2,
538 xl('Length of modifier, 0 if none'));
539 echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15,
540 xl('If billing justification is used enter the name of the diagnosis code type.'));
541 echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9,
542 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.'));
543 echo ctGenCBox($opt_line_no, $ct_array, 'ct_claim',
544 xl('Is this code type used in claims?'));
545 echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee',
546 xl('Are fees charged for this type?'));
547 echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel',
548 xl('Does this type allow related codes?'));
549 echo ctGenCBox($opt_line_no, $ct_array, 'ct_nofs',
550 xl('Is this type hidden in the fee sheet?'));
551 echo ctGenCBox($opt_line_no, $ct_array, 'ct_proc',
552 xl('Is this a procedure/service type?'));
553 echo ctGenCBox($opt_line_no, $ct_array, 'ct_diag',
554 xl('Is this a diagnosis type?'));
555 echo ctGenCBox($opt_line_no, $ct_array, 'ct_term',
556 xl('Is this a Clinical Term code type?'));
557 echo ctGenCBox($opt_line_no, $ct_array, 'ct_problem',
558 xl('Is this a Medical Problem code type?'));
559 echo ctGenCBox($opt_line_no, $ct_array, 'ct_drug',
560 xl('Is this a Medication type?'));
561 echo ctSelector($opt_line_no, $ct_array, 'ct_external',
562 $cd_external_options, xl('Is this using external sql tables? If it is, then choose the format.'));
567 * Special case of Issue Types
569 function writeITLine($it_array) {
570 global $opt_line_no,$ISSUE_TYPE_CATEGORIES,$ISSUE_TYPE_STYLES;
572 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
573 echo " <tr bgcolor='$bgcolor'>\n";
574 echo ctSelector($opt_line_no, $it_array, 'category', $ISSUE_TYPE_CATEGORIES, xl('OpenEMR Application Category'));
575 echo ctGenCBox($opt_line_no, $it_array, 'active', xl('Is this active?'));
576 echo ctGenCell($opt_line_no, $it_array, 'ordering' , 10, 10, xl('Order'));
577 echo ctGenCell($opt_line_no, $it_array, 'type' , 20, 75, xl('Issue Type'));
578 echo ctGenCell($opt_line_no, $it_array, 'plural' , 20, 75, xl('Plural'));
579 // if not english and translating lists then show the translation
580 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
581 echo " <td align='center' class='translation'>" . xlt($it_array['plural']) . "</td>\n";
583 echo ctGenCell($opt_line_no, $it_array, 'singular' , 20, 75, xl('Singular'));
584 // if not english and translating lists then show the translation
585 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
586 echo " <td align='center' class='translation'>" . xlt($it_array['singular']) . "</td>\n";
588 echo ctGenCell($opt_line_no, $it_array, 'abbreviation' , 10, 10, xl('Abbreviation'));
589 // if not english and translating lists then show the translation
590 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
591 echo " <td align='center' class='translation'>" . xlt($it_array['abbreviation']) . "</td>\n";
593 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'));
594 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.'));
602 <?php
html_header_show();?
>
604 <!-- supporting javascript code
-->
605 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script
>
607 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
608 <title
><?php
xl('List Editor','e'); ?
></title
>
611 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
612 tr
.detail
{ font
-size
:10pt
; }
613 td
{ font
-size
:10pt
; }
614 input
{ font
-size
:10pt
; }
615 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
617 .optin
{ background
-color
:transparent
; }
618 .help
{ cursor
:help
; }
619 .translation
{ color
:green
; }
622 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
623 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script
>
625 <script language
="JavaScript">
627 var current_lino
= 0;
629 // Helper function to set the contents of a div.
630 // This is for Fee Sheet administration.
631 function setDivContent(id
, content
) {
632 if (document
.getElementById
) {
633 var x
= document
.getElementById(id
);
635 x
.innerHTML
= content
;
637 else if (document
.all
) {
638 var x
= document
.all
[id
];
639 x
.innerHTML
= content
;
643 // Given a line number, redisplay its descriptive list of codes.
644 // This is for Fee Sheet administration.
645 function displayCodes(lino
) {
646 var f
= document
.forms
[0];
648 var descs
= f
['opt[' + lino +
'][descs]'].value
;
650 var arrdescs
= descs
.split('~');
651 for (var i
= 0; i
< arrdescs
.length
; ++i
) {
652 s +
= "<a href='' onclick='return delete_code(" + lino +
"," + i +
")' title='<?php xl('Delete','e'); ?>'>";
653 s +
= "[x] </a>" + arrdescs
[i
] +
"<br />";
656 setDivContent('codelist_' + lino
, s
);
659 // Helper function to remove a Fee Sheet code.
660 function dc_substring(s
, i
) {
662 var j
= s
.indexOf('~', i
);
663 if (j
< 0) { // deleting last segment
664 if (i
> 0) r
= s
.substring(0, i
-1); // omits trailing ~
666 else { // not last segment
667 r
= s
.substring(0, i
) + s
.substring(j +
1);
672 // Remove a generated Fee Sheet code.
673 function delete_code(lino
, seqno
) {
674 var f
= document
.forms
[0];
675 var celem
= f
['opt[' + lino +
'][codes]'];
676 var delem
= f
['opt[' + lino +
'][descs]'];
679 for (var i
= 0; i
< seqno
; ++i
) {
680 ci
= celem
.value
.indexOf('~', ci
) +
1;
681 di
= delem
.value
.indexOf('~', di
) +
1;
683 celem
.value
= dc_substring(celem
.value
, ci
);
684 delem
.value
= dc_substring(delem
.value
, di
);
689 // This invokes the find-code popup.
690 // For Fee Sheet administration.
691 function select_code(lino
) {
693 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 700, 400);
697 // This invokes the find-code popup.
698 // For CVX/immunization code administration.
699 function sel_cvxcode(e
) {
700 current_sel_name
= e
.name
;
701 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
704 // This invokes the find-code popup.
705 // For CVX/immunization code administration.
706 function select_clin_term_code(e
) {
707 current_sel_clin_term
= e
.name
;
708 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo attr(collect_codetypes("clinical_term","csv")) ?>', '_blank', 500, 400);
711 // This is for callback by the find-code popup.
712 function set_related(codetype
, code
, selector
, codedesc
) {
713 if (typeof(current_sel_name
) == 'undefined' && typeof(current_sel_clin_term
) == 'undefined')
715 // Coming from Fee Sheet edit
716 var f
= document
.forms
[0];
717 var celem
= f
['opt[' + current_lino +
'][codes]'];
718 var delem
= f
['opt[' + current_lino +
'][descs]'];
720 while ((i
= codedesc
.indexOf('~')) >= 0) {
721 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
728 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
729 if (codetype
== 'PROD') delem
.value +
= code +
':' + selector +
' ' + codedesc
;
730 else delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
735 displayCodes(current_lino
);
737 else if (typeof(current_sel_name
) == 'undefined') {
738 // Coming from the Clinical Terms Code(s) edit
739 var f
= document
.forms
[0][current_sel_clin_term
];
742 if (s
.length
> 0) s +
= ';';
743 s +
= codetype +
':' + code
;
751 // Coming from Immunizations edit
752 var f
= document
.forms
[0][current_sel_name
];
764 // Called when a "default" checkbox is clicked. Clears all the others.
765 function defClicked(lino
) {
766 var f
= document
.forms
[0];
767 for (var i
= 1; f
['opt[' + i +
'][default]']; ++i
) {
768 if (i
!= lino
) f
['opt[' + i +
'][default]'].checked
= false;
772 // Form validation and submission.
773 // This needs more validation.
774 function mysubmit() {
775 var f
= document
.forms
[0];
776 if (f
.list_id
.value
== 'code_types') {
777 for (var i
= 1; f
['opt[' + i +
'][ct_key]'].value
; ++i
) {
778 var ikey
= 'opt[' + i +
']';
779 for (var j
= i+
1; f
['opt[' + j +
'][ct_key]'].value
; ++j
) {
780 var jkey
= 'opt[' + j +
']';
781 if (f
[ikey+
'[ct_key]'].value
== f
[jkey+
'[ct_key]'].value
) {
782 alert('<?php echo xl('Error
: duplicated name on line
') ?>' +
' ' + j
);
785 if (parseInt(f
[ikey+
'[ct_id]'].value
) == parseInt(f
[jkey+
'[ct_id]'].value
)) {
786 alert('<?php echo xl('Error
: duplicated ID on line
') ?>' +
' ' + j
);
799 <body
class="body_top">
801 <form method
='post' name
='theform' id
='theform' action
='edit_list.php'>
802 <input type
="hidden" name
="formaction" id
="formaction">
804 <p
><b
><?php
xl('Edit list','e'); ?
>:</b
> 
;
805 <select name
='list_id' id
="list_id">
808 // List order depends on language translation options.
809 $lang_id = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
811 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
812 !$GLOBALS['translate_lists'])
814 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
815 "list_id = 'lists' ORDER BY title, seq");
818 // Use and sort by the translated list name.
819 $res = sqlStatement("SELECT lo.option_id, " .
820 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
821 "FROM list_options AS lo " .
822 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
823 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
824 "ld.lang_id = '$lang_id' " .
825 "WHERE lo.list_id = 'lists' AND lo.edit_options = 1 " .
826 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
829 while ($row = sqlFetchArray($res)) {
830 $key = $row['option_id'];
831 echo "<option value='$key'";
832 if ($key == $list_id) echo " selected";
833 echo ">" . $row['title'] . "</option>\n";
838 <input type
="button" id
="<?php echo $list_id; ?>" class="deletelist" value
=<?php
xl('Delete List','e','\'','\''); ?
>>
839 <input type
="button" id
="newlist" class="newlist" value
=<?php
xl('New List','e','\'','\''); ?
>>
844 <table cellpadding
='2' cellspacing
='0'>
846 <?php
if ($list_id == 'feesheet') { ?
>
847 <td
><b
><?php
xl('Group' ,'e'); ?
></b
></td
>
848 <td
><b
><?php
xl('Option' ,'e'); ?
></b
></td
>
849 <td
><b
><?php
xl('Generates','e'); ?
></b
></td
>
850 <?php
} else if ($list_id == 'code_types') { ?
>
851 <td
><b
><?php
xl('Active' ,'e'); ?
></b
></td
>
852 <td
><b
><?php
xl('Key' ,'e'); ?
></b
></td
>
853 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
854 <td
><b
><?php
xl('Label' ,'e'); ?
></b
></td
>
855 <?php
//show translation column if not english and the translation lists flag is set
856 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
857 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
859 <td
><b
><?php
xl('Seq' ,'e'); ?
></b
></td
>
860 <td
><b
><?php
xl('ModLength' ,'e'); ?
></b
></td
>
861 <td
><b
><?php
xl('Justify' ,'e'); ?
></b
></td
>
862 <td
><b
><?php
xl('Mask' ,'e'); ?
></b
></td
>
863 <td
><b
><?php
xl('Claims' ,'e'); ?
></b
></td
>
864 <td
><b
><?php
xl('Fees' ,'e'); ?
></b
></td
>
865 <td
><b
><?php
xl('Relations' ,'e'); ?
></b
></td
>
866 <td
><b
><?php
xl('Hide' ,'e'); ?
></b
></td
>
867 <td
><b
><?php
xl('Procedure' ,'e'); ?
></b
></td
>
868 <td
><b
><?php
xl('Diagnosis' ,'e'); ?
></b
></td
>
869 <td
><b
><?php
xl('Clinical Term','e'); ?
></b
></td
>
870 <td
><b
><?php
xl('Medical Problem','e'); ?
></b
></td
>
871 <td
><b
><?php
xl('Drug' ,'e'); ?
></b
></td
>
872 <td
><b
><?php
xl('External' ,'e'); ?
></b
></td
>
873 <?php
} else if ($list_id == 'apptstat') { ?
>
874 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
875 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
876 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
877 <td
><b
><?php
xl('Default' ,'e'); ?
></b
></td
>
878 <td
><b
><?php
xl('Active','e'); ?
></b
></td
>
879 <td
><b
><?php
xl('Color' ,'e'); ?
></b
></td
>
880 <td
><b
><?php
xl('Alert Time','e'); ?
></b
></td
>
881 <td
><b
><?php
xl('Check In' ,'e');?
> 
; 
; 
; 
;</b
></td
>
882 <td
><b
><?php
xl('Check Out' ,'e'); ?
></b
></td
>
883 <td
><b
><?php
xl('Code(s)' ,'e');?
></b
></td
>
884 <?php
} else if ($list_id == 'issue_types') { ?
>
885 <td
><b
><?php
echo xlt('OpenEMR Application Category'); ?
></b
></td
>
886 <td
><b
><?php
echo xlt('Active'); ?
></b
></td
>
887 <td
><b
><?php
echo xlt('Order'); ?
></b
></td
>
888 <td
><b
><?php
echo xlt('Type'); ?
></b
></td
>
889 <td
><b
><?php
echo xlt('Plural'); ?
></b
></td
>
890 <?php
//show translation column if not english and the translation lists flag is set
891 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
892 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
894 <td
><b
><?php
echo xlt('Singular'); ?
></b
></td
>
895 <?php
//show translation column if not english and the translation lists flag is set
896 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
897 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
899 <td
><b
><?php
echo xlt('Abbreviation'); ?
></b
></td
>
900 <?php
//show translation column if not english and the translation lists flag is set
901 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
902 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
904 <td
><b
><?php
echo xlt('Style'); ?
></b
></td
>
905 <td
><b
><?php
echo xlt('Force Show'); ?
></b
></td
>
907 <td title
=<?php
xl('Click to edit','e','\'','\''); ?
>><b
><?php
xl('ID','e'); ?
></b
></td
>
908 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
909 <?php
//show translation column if not english and the translation lists flag is set
910 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
911 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
913 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
914 <td
><b
><?php
xl('Default','e'); ?
></b
></td
>
915 <td
><b
><?php
xl('Active','e'); ?
></b
></td
>
916 <?php
if ($list_id == 'taxrate') { ?
>
917 <td
><b
><?php
xl('Rate' ,'e'); ?
></b
></td
>
918 <?php
} else if ($list_id == 'contrameth') { ?
>
919 <td
><b
><?php
xl('Effectiveness','e'); ?
></b
></td
>
920 <?php
} else if ($list_id == 'lbfnames' ||
$list_id == 'transactions') { ?
>
921 <td title
='<?php xl('Number of past history columns
','e
'); ?>'><b
><?php
xl('Repeats','e'); ?
></b
></td
>
922 <?php
} else if ($list_id == 'fitness') { ?
>
923 <td
><b
><?php
xl('Color:Abbr','e'); ?
></b
></td
>
924 <?php
} else if ($list_id == 'adjreason' ||
$list_id == 'abook_type') { ?
>
925 <td
><b
><?php
xl('Type','e'); ?
></b
></td
>
926 <?php
} else if ($list_id == 'immunizations') { ?
>
927 <td
><b
> 
; 
; 
; 
;<?php
xl('CVX Code Mapping','e'); ?
></b
></td
>
928 <?php
} if ($GLOBALS['ippf_specific']) { ?
>
929 <td
><b
><?php
xl('Global ID','e'); ?
></b
></td
>
932 if ($list_id == 'language') {
933 xl('ISO 639-2 Code','e');
934 } else if ($list_id == 'personal_relationship' ||
$list_id == 'religious_affiliation' ||
$list_id == 'ethnicity' ||
$list_id == 'race' ||
$list_id == 'drug_route'){
935 xl('HL7-V3 Concept Code','e');
936 } else if ($list_id == 'Immunization_Completion_Status'){
937 xl('Treatment Completion Status','e');
938 } else if ($list_id == 'race') {
940 } else if ($list_id == 'Immunization_Manufacturer') {
942 } else if ($list_id == 'marital') {
943 xl('Marital Status','e');
944 } else if ( $list_id == 'county' ) {
945 xl('INCITS Code','e'); //International Committee for Information Technology Standards
946 }else if ( $list_id == 'immunization_registry_status' ||
$list_id == 'imm_vac_eligibility_results' ) {
948 }else if ( $list_id == 'publicity_code' ) {
950 }else if ( $list_id == 'immunization_refusal_reason' ||
$list_id == 'immunization_informationsource' ) {
951 xl('CDC-NIP Code','e');
952 }else if ( $list_id == 'next_of_kin_relationship' ||
$list_id == 'immunization_administered_site') {
954 }else if ( $list_id == 'immunization_observation' ) {
955 xl('LOINC Code','e');
956 }else if ( $list_id == 'page_validation' ) {
957 xl('Page Validation','e');
963 <td
><b
><?php
xl('Code(s)','e'); ?
></b
></td
>
965 if (preg_match('/_issue_list$/',$list_id)) { ?
>
966 <td
><b
><?php
echo xlt('Subtype'); ?
></b
></td
>
968 } // end not fee sheet ?>
972 // Get the selected list's elements.
974 if ($list_id == 'feesheet') {
975 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
976 "ORDER BY fs_category, fs_option");
977 while ($row = sqlFetchArray($res)) {
978 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
980 for ($i = 0; $i < 3; ++
$i) {
981 writeFSLine('', '', '');
984 else if ($list_id == 'code_types') {
985 $res = sqlStatement("SELECT * FROM code_types " .
986 "ORDER BY ct_seq, ct_key");
987 while ($row = sqlFetchArray($res)) {
990 for ($i = 0; $i < 3; ++
$i) {
991 writeCTLine(array());
994 else if ($list_id == 'issue_types') {
995 $res = sqlStatement("SELECT * FROM issue_types " .
996 "ORDER BY category, ordering ASC");
997 while ($row = sqlFetchArray($res)) {
1000 for ($i = 0; $i < 3; ++
$i) {
1001 writeITLine(array());
1006 * Add edit options to show or hide in list management
1007 * If the edit_options setting of the main list entry is set to 0,
1008 * then none of the list items will show.
1009 * If the edit_options setting of the main list entry is set to 1,
1010 * then the list items with edit_options set to 1 will show.
1012 $res = sqlStatement("SELECT lo.*
1013 FROM list_options as lo
1014 right join list_options as lo2 on lo2.option_id = lo.list_id AND lo2.edit_options = 1
1015 WHERE lo.list_id = '{$list_id}' AND lo.edit_options = 1
1016 ORDER BY seq,title");
1017 while ($row = sqlFetchArray($res)) {
1018 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
1019 $row['is_default'], $row['option_value'], $row['mapping'],
1020 $row['notes'],$row['codes'],$row['toggle_setting_1'],$row['toggle_setting_2'],
1021 $row['activity'],$row['subtype']);
1023 for ($i = 0; $i < 3; ++
$i) {
1024 writeOptionLine('', '', '', '', 0);
1032 <?php
if ($list_id == 'immunizations') { ?
>
1033 <p
> <?php
echo xlt('Is it ok to map these CVX codes to already existent immunizations?') ?
>
1034 <input type
='checkbox' name
='ok_map_cvx_codes' id
='ok_map_cvx_codes' value
='1' />
1036 <?php
} // end if($list_id == 'immunizations') ?>
1039 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
'); ?>' />
1045 <!-- template DIV that appears when user chooses to make a
new list -->
1046 <div id
="newlistdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
1047 <?php
xl('List Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newlistname" id
="newlistname">
1049 <input type
="button" class="savenewlist" value
=<?php
xl('Save New List','e','\'','\''); ?
>>
1050 <input type
="button" class="cancelnewlist" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
1053 <script language
="javascript">
1054 // jQuery stuff to make the page a little easier to use
1056 $
(document
).ready(function(){
1057 $
("#form_save").click(function() { SaveChanges(); });
1058 $
("#list_id").change(function() { $
('#theform').submit(); });
1060 $
(".newlist").click(function() { NewList(this
); });
1061 $
(".savenewlist").click(function() { SaveNewList(this
); });
1062 $
(".deletelist").click(function() { DeleteList(this
); });
1063 $
(".cancelnewlist").click(function() { CancelNewList(this
); });
1065 var SaveChanges
= function() {
1066 $
("#formaction").val("save");
1067 // $('#theform').submit();
1071 // show the DIV to create a new list
1072 var NewList
= function(btnObj
) {
1073 // show the field details DIV
1074 $
('#newlistdetail').css('visibility', 'visible');
1075 $
('#newlistdetail').css('display', 'block');
1076 $
(btnObj
).parent().append($
("#newlistdetail"));
1077 $
('#newlistdetail > #newlistname').focus();
1079 // save the new list
1080 var SaveNewList
= function() {
1081 // the list name can only have letters, numbers, spaces and underscores
1082 // AND it cannot start with a number
1083 if ($
("#newlistname").val().match(/^\d+
/)) {
1084 alert("<?php xl('List names cannot start with numbers.','e'); ?>");
1087 var validname
= $
("#newlistname").val().replace(/[^A
-za
-z0
-9 -]/g
, "_"); // match any non-word characters and replace them
1088 if (validname
!= $
("#newlistname").val()) {
1089 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',''); ?>"))
1094 $
("#newlistname").val(validname
);
1096 // submit the form to add a new field to a specific group
1097 $
("#formaction").val("addlist");
1098 $
("#theform").submit();
1100 // actually delete an entire list from the database
1101 var DeleteList
= function(btnObj
) {
1102 var listid
= $
(btnObj
).attr("id");
1103 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+
")?")) {
1104 // submit the form to add a new field to a specific group
1105 $
("#formaction").val("deletelist");
1106 $
("#deletelistname").val(listid
);
1107 $
("#theform").submit();
1111 // just hide the new list DIV
1112 var CancelNewList
= function(btnObj
) {
1113 // hide the list details DIV
1114 $
('#newlistdetail').css('visibility', 'hidden');
1115 $
('#newlistdetail').css('display', 'none');
1116 // reset the new group values to a default
1117 $
('#newlistdetail > #newlistname').val("");