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/formdata.inc.php");
28 require_once("$srcdir/lists.inc");
29 require_once("../../custom/code_types.inc.php");
30 require_once("$srcdir/options.inc.php");
32 $list_id = empty($_REQUEST['list_id']) ?
'language' : $_REQUEST['list_id'];
34 // Check authorization.
35 $thisauth = acl_check('admin', 'super');
36 if (!$thisauth) die(xl('Not authorized'));
38 // If we are saving, then save.
40 if ($_POST['formaction']=='save' && $list_id) {
42 if ($list_id == 'feesheet') {
43 // special case for the feesheet list
44 sqlStatement("DELETE FROM fee_sheet_options");
45 for ($lino = 1; isset($opt["$lino"]['category']); ++
$lino) {
46 $iter = $opt["$lino"];
47 $category = formTrim($iter['category']);
48 $option = formTrim($iter['option']);
49 $codes = formTrim($iter['codes']);
50 if (strlen($category) > 0 && strlen($option) > 0) {
51 sqlInsert("INSERT INTO fee_sheet_options ( " .
52 "fs_category, fs_option, fs_codes " .
61 else if ($list_id == 'code_types') {
62 // special case for code types
63 sqlStatement("DELETE FROM code_types");
64 for ($lino = 1; isset($opt["$lino"]['ct_key']); ++
$lino) {
65 $iter = $opt["$lino"];
66 $ct_key = formTrim($iter['ct_key']);
67 $ct_id = formTrim($iter['ct_id']) +
0;
68 $ct_seq = formTrim($iter['ct_seq']) +
0;
69 $ct_mod = formTrim($iter['ct_mod']) +
0;
70 $ct_just = formTrim($iter['ct_just']);
71 $ct_mask = formTrim($iter['ct_mask']);
72 $ct_fee = empty($iter['ct_fee' ]) ?
0 : 1;
73 $ct_rel = empty($iter['ct_rel' ]) ?
0 : 1;
74 $ct_nofs = empty($iter['ct_nofs']) ?
0 : 1;
75 $ct_diag = empty($iter['ct_diag']) ?
0 : 1;
76 $ct_active = empty($iter['ct_active' ]) ?
0 : 1;
77 $ct_label = formTrim($iter['ct_label']);
78 $ct_external = formTrim($iter['ct_external']) +
0;
79 $ct_claim = empty($iter['ct_claim']) ?
0 : 1;
80 $ct_proc = empty($iter['ct_proc']) ?
0 : 1;
81 $ct_term = empty($iter['ct_term']) ?
0 : 1;
82 $ct_problem = empty($iter['ct_problem']) ?
0 : 1;
83 $ct_drug = empty($iter['ct_drug']) ?
0 : 1;
84 if (strlen($ct_key) > 0 && $ct_id > 0) {
85 sqlInsert("INSERT INTO code_types ( " .
86 "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 " .
110 else if ($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_active = formTrim($iter['active']);
116 $it_category = formTrim($iter['category']);
117 $it_ordering = formTrim($iter['ordering']);
118 $it_type = formTrim($iter['type']);
119 $it_plural = formTrim($iter['plural']);
120 $it_singular = formTrim($iter['singular']);
121 $it_abbr = formTrim($iter['abbreviation']);
122 $it_style = formTrim($iter['style']);
123 $it_fshow = formTrim($iter['force_show']);
125 if ( (strlen($it_category) > 0) && (strlen($it_type) > 0) ) {
126 sqlInsert("INSERT INTO issue_types ( " .
127 "`active`,`category`,`ordering`, `type`, `plural`, `singular`, `abbreviation`, `style`, `force_show` " .
130 "'$it_category' , " .
131 "'$it_ordering' , " .
134 "'$it_singular' , " .
145 // collect the option toggle if using the 'immunizations' list
146 if ($list_id == 'immunizations') {
147 $ok_map_cvx_codes = isset($_POST['ok_map_cvx_codes']) ?
$_POST['ok_map_cvx_codes'] : 0;
149 // erase lists options and recreate them from the submitted form data
150 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
151 for ($lino = 1; isset($opt["$lino"]['id']); ++
$lino) {
152 $iter = $opt["$lino"];
153 $value = empty($iter['value']) ?
0 : (formTrim($iter['value']) +
0);
154 $id = formTrim($iter['id']);
155 if (strlen($id) > 0) {
157 // Special processing for the immunizations list
158 // Map the entered cvx codes into the immunizations table cvx_code
159 // Ensure the following conditions are met to do this:
160 // $list_id == 'immunizations'
161 // $value is an integer and greater than 0
162 // $id is set, not empty and not equal to 0
163 // (note that all these filters are important. Not allowing $id
164 // of zero here is extremely important; never remove this conditional
165 // or you risk corrupting your current immunizations database entries)
166 // $ok_map_cvx_codes is equal to 1
167 if ($list_id == 'immunizations' &&
173 $ok_map_cvx_codes == 1 ) {
174 sqlStatement ("UPDATE `immunizations` " .
175 "SET `cvx_code`='".$value."' " .
176 "WHERE `immunization_id`='".$id."'");
179 // Force List Based Form names to start with LBF.
180 if ($list_id == 'lbfnames' && substr($id,0,3) != 'LBF')
183 // Force Transaction Form names to start with LBT.
184 if ($list_id == 'transactions' && substr($id,0,3) != 'LBT')
187 if ($list_id == 'apptstat') {
188 $notes = formTrim($iter['apptstat_color']) .'|'. formTrim($iter['apptstat_timealert']);
192 $notes = formTrim($iter['notes']);
194 // Insert the list item
195 sqlInsert("INSERT INTO list_options ( " .
196 "list_id, option_id, title, seq, is_default, option_value, mapping, notes, codes, toggle_setting_1, toggle_setting_2, activity, subtype " .
200 "'" . formTrim($iter['title']) . "', " .
201 "'" . formTrim($iter['seq']) . "', " .
202 "'" . formTrim($iter['default']) . "', " .
203 "'" . $value . "', " .
204 "'" . formTrim($iter['mapping']) . "', " .
205 "'" . $notes . "', " .
206 "'" . formTrim($iter['codes']) . "', " .
207 "'" . formTrim($iter['toggle_setting_1']) . "', " .
208 "'" . formTrim($iter['toggle_setting_2']) . "', " .
209 "'" . formTrim($iter['activity']) . "', " .
210 "'" . formTrim($iter['subtype']) . "' " .
216 else if ($_POST['formaction']=='addlist') {
217 // make a new list ID from the new list name
218 $newlistID = $_POST['newlistname'];
219 $newlistID = preg_replace("/\W/", "_", $newlistID);
221 // determine the position of this new list
222 $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
224 // add the new list to the list-of-lists
225 sqlInsert("INSERT INTO list_options ( " .
226 "list_id, option_id, title, seq, is_default, option_value " .
228 "'lists',". // the master list-of-lists
230 "'".$_POST['newlistname']."', ".
231 "'".($row['maxseq']+
1)."',".
235 else if ($_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) {
249 $arrcodes = explode('~', $codes);
251 foreach ($arrcodes as $codestring) {
252 if ($codestring === '') continue;
253 $arrcode = explode('|', $codestring);
254 $code_type = $arrcode[0];
256 $selector = $arrcode[2];
258 if ($code_type == 'PROD') {
259 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
260 $desc = "$code:$selector " . $row['name'];
263 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
264 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
265 "code = '$code' ORDER BY modifier LIMIT 1");
266 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
268 $desc = str_replace('~', ' ', $desc);
275 // Write one option line to the form.
277 function writeOptionLine($option_id, $title, $seq, $default, $value, $mapping='', $notes='', $codes='',$tog1='', $tog2='', $active='',$subtype='') {
278 global $opt_line_no, $list_id;
280 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
281 $checked = $default ?
" checked" : "";
282 $checked_tog1 = $tog1 ?
" checked" : "";
283 $checked_tog2 = $tog2 ?
" checked" : "";
284 $checked_active = $active ?
" checked" : "";
286 echo " <tr bgcolor='$bgcolor'>\n";
288 echo " <td align='center' class='optcell'>";
289 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
290 htmlspecialchars($option_id, ENT_QUOTES
) . "' size='12' maxlength='63' class='optin' />";
292 echo " <td align='center' class='optcell'>";
293 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
294 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
297 // if not english and translating lists then show the translation
298 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
299 echo " <td align='center' class='translation'>" . (htmlspecialchars( xl($title), ENT_QUOTES
)) . "</td>\n";
301 echo " <td align='center' class='optcell'>";
302 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
303 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
306 echo " <td align='center' class='optcell'>";
307 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
308 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
311 echo " <td align='center' class='optcell'>";
312 echo "<input type='checkbox' name='opt[$opt_line_no][activity]' value='1' " .
313 " class='optin'$checked_active />";
316 // Tax rates, contraceptive methods and LBF names have an additional attribute.
318 if ($list_id == 'taxrate' ||
$list_id == 'contrameth' ||
$list_id == 'lbfnames' ||
$list_id == 'transactions') {
319 echo " <td align='center' class='optcell'>";
320 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
321 htmlspecialchars($value, ENT_QUOTES
) . "' size='8' maxlength='15' class='optin' />";
325 // Adjustment reasons use option_value as a reason category. This is
326 // needed to distinguish between adjustments that change the invoice
327 // balance and those that just shift responsibility of payment or
328 // are used as comments.
330 else if ($list_id == 'adjreason') {
331 echo " <td align='center' class='optcell'>";
332 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
334 1 => xl('Charge adjustment'),
335 2 => xl('Coinsurance'),
336 3 => xl('Deductible'),
337 4 => xl('Other pt resp'),
339 ) as $key => $desc) {
340 echo "<option value='$key'";
341 if ($key == $value) echo " selected";
342 echo ">" . htmlspecialchars($desc) . "</option>";
348 // Address book categories use option_value to flag category as a
349 // person-centric vs company-centric vs indifferent.
351 else if ($list_id == 'abook_type') {
352 echo " <td align='center' class='optcell'>";
353 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
355 1 => xl('Unassigned'),
358 ) as $key => $desc) {
359 echo "<option value='$key'";
360 if ($key == $value) echo " selected";
361 echo ">" . htmlspecialchars($desc) . "</option>";
367 // Immunization categories use option_value to map list items
370 else if ($list_id == 'immunizations') {
371 echo " <td align='center' class='optcell'>";
372 echo "<input type='text' size='10' name='opt[$opt_line_no][value]' " .
373 "value='" . htmlspecialchars($value,ENT_QUOTES
) . "' onclick='sel_cvxcode(this)' " .
374 "title='" . htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES
) . "'/>";
378 // IPPF includes the ability to map each list item to a "master" identifier.
379 // Sports teams use this for some extra info for fitness levels.
381 if ($GLOBALS['ippf_specific'] ||
$list_id == 'fitness') {
382 echo " <td align='center' class='optcell'>";
383 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
384 htmlspecialchars($mapping, ENT_QUOTES
) . "' size='12' maxlength='15' class='optin' />";
387 else if($list_id == 'apptstat') {
388 list($apptstat_color, $apptstat_timealert) = explode("|", $notes);
389 echo " <td align='center' class='optcell'>";
390 echo "<input type='text' class='color' name='opt[$opt_line_no][apptstat_color]' value='" .
391 htmlspecialchars($apptstat_color, ENT_QUOTES
) . "' size='6' maxlength='6' class='optin' />";
393 echo " <td align='center' class='optcell'>";
394 echo "<input type='text' name='opt[$opt_line_no][apptstat_timealert]' value='" .
395 htmlspecialchars($apptstat_timealert, ENT_QUOTES
) . "' size='2' maxlength='2' class='optin' />";
398 echo " <td align='center' class='optcell'>";
399 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
400 htmlspecialchars($notes, ENT_QUOTES
) . "' size='25' class='optin' />";
403 if($list_id == 'apptstat') {
404 echo " <td align='center' class='optcell'>";
405 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_1]' value='1' " .
406 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog1 />";
408 echo " <td align='center' class='optcell'>";
409 echo "<input type='checkbox' name='opt[$opt_line_no][toggle_setting_2]' value='1' " .
410 "onclick='defClicked($opt_line_no)' class='optin'$checked_tog2 />";
413 echo " <td align='center' class='optcell'>";
414 echo "<input type='text' name='opt[$opt_line_no][codes]' title='" .
415 xla('Clinical Term Code(s)') ."' value='" .
416 htmlspecialchars($codes, ENT_QUOTES
) . "' onclick='select_clin_term_code(this)' size='25' maxlength='255' class='optin' />";
419 if (preg_match('/_issue_list$/',$list_id)) {
420 echo " <td align='center' class='optcell'>";
421 echo generate_select_list("opt[$opt_line_no][subtype]", 'issue_subtypes', $subtype, 'Subtype',' ', 'optin');
427 // Write a form line as above but for the special case of the Fee Sheet.
429 function writeFSLine($category, $option, $codes) {
433 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
435 $descs = getCodeDescriptions($codes);
437 echo " <tr bgcolor='$bgcolor'>\n";
439 echo " <td align='center' class='optcell'>";
440 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
441 htmlspecialchars($category, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
444 echo " <td align='center' class='optcell'>";
445 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
446 htmlspecialchars($option, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
449 echo " <td align='left' class='optcell'>";
450 echo " <div id='codelist_$opt_line_no'>";
451 if (strlen($descs)) {
452 $arrdescs = explode('~', $descs);
454 foreach ($arrdescs as $desc) {
455 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
456 echo "[x] </a>$desc<br />";
461 echo "<a href='' onclick='return select_code($opt_line_no)'>";
462 echo "[" . xl('Add') . "]</a>";
464 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
465 htmlspecialchars($codes, ENT_QUOTES
) . "' />";
466 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
467 htmlspecialchars($descs, ENT_QUOTES
) . "' />";
475 * Helper functions for writeITLine() and writeCTLine().
477 function ctGenCell($opt_line_no, $data_array, $name, $size, $maxlength, $title='') {
478 $value = isset($data_array[$name]) ?
$data_array[$name] : '';
479 $s = " <td align='center' class='optcell'";
480 if ($title) $s .= " title='" . attr($title) . "'";
482 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
484 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
489 function ctGenCbox($opt_line_no, $data_array, $name, $title='') {
490 $checked = empty($data_array[$name]) ?
'' : 'checked ';
491 $s = " <td align='center' class='optcell'";
492 if ($title) $s .= " title='" . attr($title) . "'";
494 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
500 function ctSelector($opt_line_no, $data_array, $name, $option_array, $title='') {
501 $value = isset($data_array[$name]) ?
$data_array[$name] : '';
502 $s = " <td title='" . attr($title) . "' align='center' class='optcell'>";
503 $s .= "<select name='opt[$opt_line_no][$name]' class='optin'>";
504 foreach ( $option_array as $key => $desc) {
505 $s .= "<option value='" . attr($key) . "'";
506 if ($key == $value) $s .= " selected";
507 $s .= ">" . text($desc) . "</option>";
514 // Write a form line as above but for the special case of Code Types.
516 function writeCTLine($ct_array) {
517 global $opt_line_no,$cd_external_options;
520 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
522 echo " <tr bgcolor='$bgcolor'>\n";
524 echo ctGenCBox($opt_line_no, $ct_array, 'ct_active',
525 xl('Is this code type active?'));
526 echo ctGenCell($opt_line_no, $ct_array, 'ct_key' , 6, 15,
527 xl('Unique human-readable identifier for this type'));
528 echo ctGenCell($opt_line_no, $ct_array, 'ct_id' , 2, 11,
529 xl('Unique numeric identifier for this type'));
530 echo ctGenCell($opt_line_no, $ct_array, 'ct_label' , 6, 30,
531 xl('Label for this type'));
532 // if not english and translating lists then show the translation
533 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
534 echo " <td align='center' class='translation'>" . xlt($ct_array['ct_label']) . "</td>\n";
536 echo ctGenCell($opt_line_no, $ct_array, 'ct_seq' , 2, 3,
537 xl('Numeric display order'));
538 echo ctGenCell($opt_line_no, $ct_array, 'ct_mod' , 1, 2,
539 xl('Length of modifier, 0 if none'));
540 echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15,
541 xl('If billing justification is used enter the name of the diagnosis code type.'));
542 echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9,
543 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.'));
544 echo ctGenCBox($opt_line_no, $ct_array, 'ct_claim',
545 xl('Is this code type used in claims?'));
546 echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee',
547 xl('Are fees charged for this type?'));
548 echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel',
549 xl('Does this type allow related codes?'));
550 echo ctGenCBox($opt_line_no, $ct_array, 'ct_nofs',
551 xl('Is this type hidden in the fee sheet?'));
552 echo ctGenCBox($opt_line_no, $ct_array, 'ct_proc',
553 xl('Is this a procedure/service type?'));
554 echo ctGenCBox($opt_line_no, $ct_array, 'ct_diag',
555 xl('Is this a diagnosis type?'));
556 echo ctGenCBox($opt_line_no, $ct_array, 'ct_term',
557 xl('Is this a Clinical Term code type?'));
558 echo ctGenCBox($opt_line_no, $ct_array, 'ct_problem',
559 xl('Is this a Medical Problem code type?'));
560 echo ctGenCBox($opt_line_no, $ct_array, 'ct_drug',
561 xl('Is this a Medication type?'));
562 echo ctSelector($opt_line_no, $ct_array, 'ct_external',
563 $cd_external_options, xl('Is this using external sql tables? If it is, then choose the format.'));
568 * Special case of Issue Types
570 function writeITLine($it_array) {
571 global $opt_line_no,$ISSUE_TYPE_CATEGORIES,$ISSUE_TYPE_STYLES;
573 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
574 echo " <tr bgcolor='$bgcolor'>\n";
575 echo ctSelector($opt_line_no, $it_array, 'category', $ISSUE_TYPE_CATEGORIES, xl('OpenEMR Application Category'));
576 echo ctGenCBox($opt_line_no, $it_array, 'active', xl('Is this active?'));
577 echo ctGenCell($opt_line_no, $it_array, 'ordering' , 10, 10, xl('Order'));
578 echo ctGenCell($opt_line_no, $it_array, 'type' , 20, 75, xl('Issue Type'));
579 echo ctGenCell($opt_line_no, $it_array, 'plural' , 20, 75, xl('Plural'));
580 // if not english and translating lists then show the translation
581 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
582 echo " <td align='center' class='translation'>" . xlt($it_array['plural']) . "</td>\n";
584 echo ctGenCell($opt_line_no, $it_array, 'singular' , 20, 75, xl('Singular'));
585 // if not english and translating lists then show the translation
586 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
587 echo " <td align='center' class='translation'>" . xlt($it_array['singular']) . "</td>\n";
589 echo ctGenCell($opt_line_no, $it_array, 'abbreviation' , 10, 10, xl('Abbreviation'));
590 // if not english and translating lists then show the translation
591 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
592 echo " <td align='center' class='translation'>" . xlt($it_array['abbreviation']) . "</td>\n";
594 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'));
595 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.'));
603 <?php
html_header_show();?
>
605 <!-- supporting javascript code
-->
606 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script
>
608 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
609 <title
><?php
xl('List Editor','e'); ?
></title
>
612 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
613 tr
.detail
{ font
-size
:10pt
; }
614 td
{ font
-size
:10pt
; }
615 input
{ font
-size
:10pt
; }
616 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
618 .optin
{ background
-color
:transparent
; }
619 .help
{ cursor
:help
; }
620 .translation
{ color
:green
; }
623 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
624 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script
>
626 <script language
="JavaScript">
628 var current_lino
= 0;
630 // Helper function to set the contents of a div.
631 // This is for Fee Sheet administration.
632 function setDivContent(id
, content
) {
633 if (document
.getElementById
) {
634 var x
= document
.getElementById(id
);
636 x
.innerHTML
= content
;
638 else if (document
.all
) {
639 var x
= document
.all
[id
];
640 x
.innerHTML
= content
;
644 // Given a line number, redisplay its descriptive list of codes.
645 // This is for Fee Sheet administration.
646 function displayCodes(lino
) {
647 var f
= document
.forms
[0];
649 var descs
= f
['opt[' + lino +
'][descs]'].value
;
651 var arrdescs
= descs
.split('~');
652 for (var i
= 0; i
< arrdescs
.length
; ++i
) {
653 s +
= "<a href='' onclick='return delete_code(" + lino +
"," + i +
")' title='<?php xl('Delete','e'); ?>'>";
654 s +
= "[x] </a>" + arrdescs
[i
] +
"<br />";
657 setDivContent('codelist_' + lino
, s
);
660 // Helper function to remove a Fee Sheet code.
661 function dc_substring(s
, i
) {
663 var j
= s
.indexOf('~', i
);
664 if (j
< 0) { // deleting last segment
665 if (i
> 0) r
= s
.substring(0, i
-1); // omits trailing ~
667 else { // not last segment
668 r
= s
.substring(0, i
) + s
.substring(j +
1);
673 // Remove a generated Fee Sheet code.
674 function delete_code(lino
, seqno
) {
675 var f
= document
.forms
[0];
676 var celem
= f
['opt[' + lino +
'][codes]'];
677 var delem
= f
['opt[' + lino +
'][descs]'];
680 for (var i
= 0; i
< seqno
; ++i
) {
681 ci
= celem
.value
.indexOf('~', ci
) +
1;
682 di
= delem
.value
.indexOf('~', di
) +
1;
684 celem
.value
= dc_substring(celem
.value
, ci
);
685 delem
.value
= dc_substring(delem
.value
, di
);
690 // This invokes the find-code popup.
691 // For Fee Sheet administration.
692 function select_code(lino
) {
694 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 700, 400);
698 // This invokes the find-code popup.
699 // For CVX/immunization code administration.
700 function sel_cvxcode(e
) {
701 current_sel_name
= e
.name
;
702 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
705 // This invokes the find-code popup.
706 // For CVX/immunization code administration.
707 function select_clin_term_code(e
) {
708 current_sel_clin_term
= e
.name
;
709 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=<?php echo attr(collect_codetypes("clinical_term","csv")) ?>', '_blank', 500, 400);
712 // This is for callback by the find-code popup.
713 function set_related(codetype
, code
, selector
, codedesc
) {
714 if (typeof(current_sel_name
) == 'undefined' && typeof(current_sel_clin_term
) == 'undefined')
716 // Coming from Fee Sheet edit
717 var f
= document
.forms
[0];
718 var celem
= f
['opt[' + current_lino +
'][codes]'];
719 var delem
= f
['opt[' + current_lino +
'][descs]'];
721 while ((i
= codedesc
.indexOf('~')) >= 0) {
722 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
729 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
730 if (codetype
== 'PROD') delem
.value +
= code +
':' + selector +
' ' + codedesc
;
731 else delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
736 displayCodes(current_lino
);
738 else if (typeof(current_sel_name
) == 'undefined') {
739 // Coming from the Clinical Terms Code(s) edit
740 var f
= document
.forms
[0][current_sel_clin_term
];
743 if (s
.length
> 0) s +
= ';';
744 s +
= codetype +
':' + code
;
752 // Coming from Immunizations edit
753 var f
= document
.forms
[0][current_sel_name
];
765 // Called when a "default" checkbox is clicked. Clears all the others.
766 function defClicked(lino
) {
767 var f
= document
.forms
[0];
768 for (var i
= 1; f
['opt[' + i +
'][default]']; ++i
) {
769 if (i
!= lino
) f
['opt[' + i +
'][default]'].checked
= false;
773 // Form validation and submission.
774 // This needs more validation.
775 function mysubmit() {
776 var f
= document
.forms
[0];
777 if (f
.list_id
.value
== 'code_types') {
778 for (var i
= 1; f
['opt[' + i +
'][ct_key]'].value
; ++i
) {
779 var ikey
= 'opt[' + i +
']';
780 for (var j
= i+
1; f
['opt[' + j +
'][ct_key]'].value
; ++j
) {
781 var jkey
= 'opt[' + j +
']';
782 if (f
[ikey+
'[ct_key]'].value
== f
[jkey+
'[ct_key]'].value
) {
783 alert('<?php echo xl('Error
: duplicated name on line
') ?>' +
' ' + j
);
786 if (parseInt(f
[ikey+
'[ct_id]'].value
) == parseInt(f
[jkey+
'[ct_id]'].value
)) {
787 alert('<?php echo xl('Error
: duplicated ID on line
') ?>' +
' ' + j
);
800 <body
class="body_top">
802 <form method
='post' name
='theform' id
='theform' action
='edit_list.php'>
803 <input type
="hidden" name
="formaction" id
="formaction">
805 <p
><b
><?php
xl('Edit list','e'); ?
>:</b
> 
;
806 <select name
='list_id' id
="list_id">
809 // List order depends on language translation options.
810 $lang_id = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
812 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
813 !$GLOBALS['translate_lists'])
815 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
816 "list_id = 'lists' ORDER BY title, seq");
819 // Use and sort by the translated list name.
820 $res = sqlStatement("SELECT lo.option_id, " .
821 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
822 "FROM list_options AS lo " .
823 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
824 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
825 "ld.lang_id = '$lang_id' " .
826 "WHERE lo.list_id = 'lists' " .
827 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
830 while ($row = sqlFetchArray($res)) {
831 $key = $row['option_id'];
832 echo "<option value='$key'";
833 if ($key == $list_id) echo " selected";
834 echo ">" . $row['title'] . "</option>\n";
839 <input type
="button" id
="<?php echo $list_id; ?>" class="deletelist" value
=<?php
xl('Delete List','e','\'','\''); ?
>>
840 <input type
="button" id
="newlist" class="newlist" value
=<?php
xl('New List','e','\'','\''); ?
>>
845 <table cellpadding
='2' cellspacing
='0'>
847 <?php
if ($list_id == 'feesheet') { ?
>
848 <td
><b
><?php
xl('Group' ,'e'); ?
></b
></td
>
849 <td
><b
><?php
xl('Option' ,'e'); ?
></b
></td
>
850 <td
><b
><?php
xl('Generates','e'); ?
></b
></td
>
851 <?php
} else if ($list_id == 'code_types') { ?
>
852 <td
><b
><?php
xl('Active' ,'e'); ?
></b
></td
>
853 <td
><b
><?php
xl('Key' ,'e'); ?
></b
></td
>
854 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
855 <td
><b
><?php
xl('Label' ,'e'); ?
></b
></td
>
856 <?php
//show translation column if not english and the translation lists flag is set
857 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
858 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
860 <td
><b
><?php
xl('Seq' ,'e'); ?
></b
></td
>
861 <td
><b
><?php
xl('ModLength' ,'e'); ?
></b
></td
>
862 <td
><b
><?php
xl('Justify' ,'e'); ?
></b
></td
>
863 <td
><b
><?php
xl('Mask' ,'e'); ?
></b
></td
>
864 <td
><b
><?php
xl('Claims' ,'e'); ?
></b
></td
>
865 <td
><b
><?php
xl('Fees' ,'e'); ?
></b
></td
>
866 <td
><b
><?php
xl('Relations' ,'e'); ?
></b
></td
>
867 <td
><b
><?php
xl('Hide' ,'e'); ?
></b
></td
>
868 <td
><b
><?php
xl('Procedure' ,'e'); ?
></b
></td
>
869 <td
><b
><?php
xl('Diagnosis' ,'e'); ?
></b
></td
>
870 <td
><b
><?php
xl('Clinical Term','e'); ?
></b
></td
>
871 <td
><b
><?php
xl('Medical Problem','e'); ?
></b
></td
>
872 <td
><b
><?php
xl('Drug' ,'e'); ?
></b
></td
>
873 <td
><b
><?php
xl('External' ,'e'); ?
></b
></td
>
874 <?php
} else if ($list_id == 'apptstat') { ?
>
875 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
876 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
877 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
878 <td
><b
><?php
xl('Default' ,'e'); ?
></b
></td
>
879 <td
><b
><?php
xl('Active','e'); ?
></b
></td
>
880 <td
><b
><?php
xl('Color' ,'e'); ?
></b
></td
>
881 <td
><b
><?php
xl('Alert Time','e'); ?
></b
></td
>
882 <td
><b
><?php
xl('Check In' ,'e');?
> 
; 
; 
; 
;</b
></td
>
883 <td
><b
><?php
xl('Check Out' ,'e'); ?
></b
></td
>
884 <td
><b
><?php
xl('Code(s)' ,'e');?
></b
></td
>
885 <?php
} else if ($list_id == 'issue_types') { ?
>
886 <td
><b
><?php
echo xlt('OpenEMR Application Category'); ?
></b
></td
>
887 <td
><b
><?php
echo xlt('Active'); ?
></b
></td
>
888 <td
><b
><?php
echo xlt('Order'); ?
></b
></td
>
889 <td
><b
><?php
echo xlt('Type'); ?
></b
></td
>
890 <td
><b
><?php
echo xlt('Plural'); ?
></b
></td
>
891 <?php
//show translation column if not english and the translation lists flag is set
892 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
893 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
895 <td
><b
><?php
echo xlt('Singular'); ?
></b
></td
>
896 <?php
//show translation column if not english and the translation lists flag is set
897 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
898 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
900 <td
><b
><?php
echo xlt('Abbreviation'); ?
></b
></td
>
901 <?php
//show translation column if not english and the translation lists flag is set
902 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
903 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
905 <td
><b
><?php
echo xlt('Style'); ?
></b
></td
>
906 <td
><b
><?php
echo xlt('Force Show'); ?
></b
></td
>
908 <td title
=<?php
xl('Click to edit','e','\'','\''); ?
>><b
><?php
xl('ID','e'); ?
></b
></td
>
909 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
910 <?php
//show translation column if not english and the translation lists flag is set
911 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
912 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
914 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
915 <td
><b
><?php
xl('Default','e'); ?
></b
></td
>
916 <td
><b
><?php
xl('Active','e'); ?
></b
></td
>
917 <?php
if ($list_id == 'taxrate') { ?
>
918 <td
><b
><?php
xl('Rate' ,'e'); ?
></b
></td
>
919 <?php
} else if ($list_id == 'contrameth') { ?
>
920 <td
><b
><?php
xl('Effectiveness','e'); ?
></b
></td
>
921 <?php
} else if ($list_id == 'lbfnames' ||
$list_id == 'transactions') { ?
>
922 <td title
='<?php xl('Number of past history columns
','e
'); ?>'><b
><?php
xl('Repeats','e'); ?
></b
></td
>
923 <?php
} else if ($list_id == 'fitness') { ?
>
924 <td
><b
><?php
xl('Color:Abbr','e'); ?
></b
></td
>
925 <?php
} else if ($list_id == 'adjreason' ||
$list_id == 'abook_type') { ?
>
926 <td
><b
><?php
xl('Type','e'); ?
></b
></td
>
927 <?php
} else if ($list_id == 'immunizations') { ?
>
928 <td
><b
> 
; 
; 
; 
;<?php
xl('CVX Code Mapping','e'); ?
></b
></td
>
929 <?php
} if ($GLOBALS['ippf_specific']) { ?
>
930 <td
><b
><?php
xl('Global ID','e'); ?
></b
></td
>
933 if ($list_id == 'language') {
934 xl('ISO 639-2 Code','e');
935 } else if ($list_id == 'personal_relationship' ||
$list_id == 'religious_affiliation' ||
$list_id == 'ethnicity' ||
$list_id == 'race' ||
$list_id == 'drug_route'){
936 xl('HL7-V3 Concept Code','e');
937 } else if ($list_id == 'Immunization_Completion_Status'){
938 xl('Treatment Completion Status','e');
939 } else if ($list_id == 'race') {
941 } else if ($list_id == 'Immunization_Manufacturer') {
943 } else if ($list_id == 'marital') {
944 xl('Marital Status','e');
945 } else if ( $list_id == 'county' ) {
946 xl('INCITS Code','e'); //International Committee for Information Technology Standards
947 }else if ( $list_id == 'immunization_registry_status' ||
$list_id == 'imm_vac_eligibility_results' ) {
949 }else if ( $list_id == 'publicity_code' ) {
951 }else if ( $list_id == 'immunization_refusal_reason' ||
$list_id == 'immunization_informationsource' ) {
952 xl('CDC-NIP Code','e');
953 }else if ( $list_id == 'next_of_kin_relationship' ||
$list_id == 'immunization_administered_site') {
955 }else if ( $list_id == 'immunization_observation' ) {
956 xl('LOINC Code','e');
957 }else if ( $list_id == 'page_validation' ) {
958 xl('Page Validation','e');
964 <td
><b
><?php
xl('Code(s)','e'); ?
></b
></td
>
966 if (preg_match('/_issue_list$/',$list_id)) { ?
>
967 <td
><b
><?php
echo xlt('Subtype'); ?
></b
></td
>
969 } // end not fee sheet ?>
973 // Get the selected list's elements.
975 if ($list_id == 'feesheet') {
976 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
977 "ORDER BY fs_category, fs_option");
978 while ($row = sqlFetchArray($res)) {
979 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
981 for ($i = 0; $i < 3; ++
$i) {
982 writeFSLine('', '', '');
985 else if ($list_id == 'code_types') {
986 $res = sqlStatement("SELECT * FROM code_types " .
987 "ORDER BY ct_seq, ct_key");
988 while ($row = sqlFetchArray($res)) {
991 for ($i = 0; $i < 3; ++
$i) {
992 writeCTLine(array());
995 else if ($list_id == 'issue_types') {
996 $res = sqlStatement("SELECT * FROM issue_types " .
997 "ORDER BY category, ordering ASC");
998 while ($row = sqlFetchArray($res)) {
1001 for ($i = 0; $i < 3; ++
$i) {
1002 writeITLine(array());
1006 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1007 "list_id = '$list_id' ORDER BY seq,title");
1008 while ($row = sqlFetchArray($res)) {
1009 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
1010 $row['is_default'], $row['option_value'], $row['mapping'],
1011 $row['notes'],$row['codes'],$row['toggle_setting_1'],$row['toggle_setting_2'],
1012 $row['activity'],$row['subtype']);
1014 for ($i = 0; $i < 3; ++
$i) {
1015 writeOptionLine('', '', '', '', 0);
1023 <?php
if ($list_id == 'immunizations') { ?
>
1024 <p
> <?php
echo xlt('Is it ok to map these CVX codes to already existent immunizations?') ?
>
1025 <input type
='checkbox' name
='ok_map_cvx_codes' id
='ok_map_cvx_codes' value
='1' />
1027 <?php
} // end if($list_id == 'immunizations') ?>
1030 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
'); ?>' />
1036 <!-- template DIV that appears when user chooses to make a
new list -->
1037 <div id
="newlistdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
1038 <?php
xl('List Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newlistname" id
="newlistname">
1040 <input type
="button" class="savenewlist" value
=<?php
xl('Save New List','e','\'','\''); ?
>>
1041 <input type
="button" class="cancelnewlist" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
1044 <script language
="javascript">
1045 // jQuery stuff to make the page a little easier to use
1047 $
(document
).ready(function(){
1048 $
("#form_save").click(function() { SaveChanges(); });
1049 $
("#list_id").change(function() { $
('#theform').submit(); });
1051 $
(".newlist").click(function() { NewList(this
); });
1052 $
(".savenewlist").click(function() { SaveNewList(this
); });
1053 $
(".deletelist").click(function() { DeleteList(this
); });
1054 $
(".cancelnewlist").click(function() { CancelNewList(this
); });
1056 var SaveChanges
= function() {
1057 $
("#formaction").val("save");
1058 // $('#theform').submit();
1062 // show the DIV to create a new list
1063 var NewList
= function(btnObj
) {
1064 // show the field details DIV
1065 $
('#newlistdetail').css('visibility', 'visible');
1066 $
('#newlistdetail').css('display', 'block');
1067 $
(btnObj
).parent().append($
("#newlistdetail"));
1068 $
('#newlistdetail > #newlistname').focus();
1070 // save the new list
1071 var SaveNewList
= function() {
1072 // the list name can only have letters, numbers, spaces and underscores
1073 // AND it cannot start with a number
1074 if ($
("#newlistname").val().match(/^\d+
/)) {
1075 alert("<?php xl('List names cannot start with numbers.','e'); ?>");
1078 var validname
= $
("#newlistname").val().replace(/[^A
-za
-z0
-9 -]/g
, "_"); // match any non-word characters and replace them
1079 if (validname
!= $
("#newlistname").val()) {
1080 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',''); ?>"))
1085 $
("#newlistname").val(validname
);
1087 // submit the form to add a new field to a specific group
1088 $
("#formaction").val("addlist");
1089 $
("#theform").submit();
1091 // actually delete an entire list from the database
1092 var DeleteList
= function(btnObj
) {
1093 var listid
= $
(btnObj
).attr("id");
1094 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+
")?")) {
1095 // submit the form to add a new field to a specific group
1096 $
("#formaction").val("deletelist");
1097 $
("#deletelistname").val(listid
);
1098 $
("#theform").submit();
1102 // just hide the new list DIV
1103 var CancelNewList
= function(btnObj
) {
1104 // hide the list details DIV
1105 $
('#newlistdetail').css('visibility', 'hidden');
1106 $
('#newlistdetail').css('display', 'none');
1107 // reset the new group values to a default
1108 $
('#newlistdetail > #newlistname').val("");