2 include_once("../../globals.php");
3 include_once("../../../library/api.inc");
4 include_once("../../../library/sql.inc");
5 formHeader("Form: CAMOS");
6 $returnurl = $GLOBALS['concurrent_layout'] ?
'encounter_top.php' : 'patient_encounter.php';
14 $out_of_encounter = false;
15 if (($_SESSION['encounter'] == '') ||
($_SESSION['pid'] == '')) {
16 $out_of_encounter = true;
25 $previous_encounter_data = '';
26 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
27 $previous_encounter_data = '<hr><p>'.xl('Previous Encounter CAMOS entries').'</p><hr>';
28 //get data from previous encounter to show at bottom of form for reference
29 $tmp = sqlQuery("SELECT max(encounter) AS max FROM forms WHERE " .
30 "form_name LIKE 'CAMOS%' AND encounter < '" . $_SESSION['encounter'] .
31 "' AND pid = '" . $_SESSION['pid'] . "'");
32 $last_encounter_id = $tmp['max'] ?
$tmp['max'] : 0;
33 $query = "SELECT t1.category, t1.subcategory, t1.item, t1.content " .
34 "FROM form_CAMOS as t1 JOIN forms as t2 on (t1.id = t2.form_id) where " .
35 "t2.encounter = '$last_encounter_id' and t1.pid = " . $_SESSION['pid'];
36 $statement = sqlStatement($query);
37 while ($result = sqlFetchArray($statement)) {
38 $previous_encounter_data .= $result['category']." | ".$result['subcategory'].
39 " | ".$result['item']."<p><pre>".$result['content']."</pre></p><hr>";
43 //end of get data from previous encounter
44 //variables for preselect section below (after handle database changes):
45 $preselect_category = '';
46 $preselect_subcategory = '';
48 $preselect_category_override = '';
49 $preselect_subcategory_override = '';
50 $preselect_item_override = '';
52 $quote_search = array("\r","\n");
53 $quote_replace = array("\\r","\\n");
54 $quote_search_content = array("\r","\n");
55 $quote_replace_content = array("\\r","\\n");
56 $category = str_replace($quote_search,$quote_replace,$_POST['change_category']);
57 $subcategory = str_replace($quote_search,$quote_replace,$_POST['change_subcategory']);
58 $item = str_replace($quote_search,$quote_replace,$_POST['change_item']);
59 $content = str_replace($quote_search_content,$quote_replace_content,$_POST['textarea_content']);
60 $category = fixquotes($category);
61 $subcategory = fixquotes($subcategory);
62 $item = fixquotes($item);
63 $content = fixquotes($content);
65 if ($_POST['hidden_category']) {$preselect_category = $_POST['hidden_category'];}
66 if ($_POST['hidden_subcategory']) {$preselect_subcategory = $_POST['hidden_subcategory'];}
67 if ($_POST['hidden_item']) {$preselect_item = $_POST['hidden_item'];}
68 //handle changes to database
69 if ($_POST['hidden_mode'] == 'add') {
70 if ($_POST['hidden_selection'] == 'change_category') {
71 $preselect_category_override = $_POST['change_category'];
72 $query = "INSERT INTO form_CAMOS_category (category) values ('";
73 $query .= $category."')";
76 else if ($_POST['hidden_selection'] == 'change_subcategory') {
77 $preselect_subcategory_override = $_POST['change_subcategory'];
78 $category_id = $_POST['hidden_category'];
79 if ($category_id >= 0 ) {
80 $query = "INSERT INTO form_CAMOS_subcategory (subcategory, category_id) values ('";
81 $query .= $subcategory."', '".$category_id."')";
85 else if ($_POST['hidden_selection'] == 'change_item') {
86 $preselect_item_override = $_POST['change_item'];
87 $category_id = $_POST['hidden_category'];
88 $subcategory_id = $_POST['hidden_subcategory'];
89 if (($category_id >= 0 ) && ($subcategory_id >=0)) {
90 $query = "INSERT INTO form_CAMOS_item (item, content, subcategory_id) values ('";
91 $query .= $item."', '".$content."', '".$subcategory_id."')";
96 else if ($_POST['hidden_selection'] == 'change_content') {
97 $item_id = $_POST['hidden_item'];
99 $query = "UPDATE form_CAMOS_item set content = '".$content."' where id = ".$item_id;
104 else if ($_POST['hidden_mode'] == 'delete') {
105 if ($_POST['hidden_selection'] == 'change_category') {
106 $to_delete_id = $_POST['hidden_category'];
107 $to_delete_from_table = 'form_CAMOS_category';
108 $to_delete_from_subtable = 'form_CAMOS_subcategory';
109 $tablename = 'category';
110 $subtablename = 'subcategory';
112 else if ($_POST['hidden_selection'] == 'change_subcategory') {
113 $to_delete_id = $_POST['hidden_subcategory'];
114 $to_delete_from_table = 'form_CAMOS_subcategory';
115 $to_delete_from_subtable = 'form_CAMOS_item';
116 $tablename = 'subcategory';
117 $subtablename = 'item';
119 else if ($_POST['hidden_selection'] == 'change_item') {
120 $to_delete_id = $_POST['hidden_item'];
121 $to_delete_from_table = 'form_CAMOS_item';
122 $to_delete_from_subtable = '';
127 if ($subtablename == '') {
128 $query = "DELETE FROM ".$to_delete_from_table." WHERE id like '".$to_delete_id."'";
132 $query = "SELECT count(id) FROM ".$to_delete_from_subtable." WHERE ".$tablename."_id like '".$to_delete_id."'";
133 $statement = sqlStatement($query);
134 if ($result = sqlFetchArray($statement)) {
135 if ($result['count(id)'] == 0) {
136 $query = "DELETE FROM ".$to_delete_from_table." WHERE id like '".$to_delete_id."'";
140 $error = $subtablename." not empty!";
145 else if ($_POST['hidden_mode'] == 'alter') {
146 $newval = $_POST[$_POST['hidden_selection']];
147 if ($_POST['hidden_selection'] == 'change_category') {
148 $to_alter_id = $_POST['hidden_category'];
149 $to_alter_table = 'form_CAMOS_category';
150 $to_alter_column = 'category';
152 else if ($_POST['hidden_selection'] == 'change_subcategory') {
153 $to_alter_id = $_POST['hidden_subcategory'];
154 $to_alter_table = 'form_CAMOS_subcategory';
155 $to_alter_column = 'subcategory';
157 else if ($_POST['hidden_selection'] == 'change_item') {
158 $to_alter_id = $_POST['hidden_item'];
159 $to_alter_table = 'form_CAMOS_item';
160 $to_alter_column = 'item';
162 $query = "UPDATE ".$to_alter_table." set ".$to_alter_column." = '".$newval."' where id = ".$to_alter_id;
165 // end handle changes to database
167 //preselect column items
168 //either a database change has been made, so the user should be made to feel that they never left the same CAMOS screen
169 //or, CAMOS has been started freshly, therefore the last entry of the current patient should be selected.
170 $preselect_mode = '';
171 if ($preselect_category == '' && !$out_of_encounter) {
172 $preselect_mode = 'by name';
173 //at this point, if this variable has not been set, CAMOS must have been start over
174 //so let's get the most recent values from form_CAMOS for this patient's pid
175 $tmp = sqlQuery("SELECT max(id) AS max FROM form_CAMOS WHERE " .
176 "pid = '" . $_SESSION['pid'] . "'");
177 $maxid = $tmp['max'] ?
$tmp['max'] : 0;
179 $query = "SELECT category, subcategory, item FROM form_CAMOS WHERE id = $maxid";
180 $statement = sqlStatement($query);
181 if ($result = sqlFetchArray($statement)) {
182 $preselect_category = $result['category'];
183 $preselect_subcategory = $result['subcategory'];
184 $preselect_item = $result['item'];
186 else {$preselect_mode = '';}
189 $preselect_mode = 'by number';
194 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
196 <script language
="javascript" type
="text/javascript">
198 var array1
= new Array();
199 var array2
= new Array();
200 var array3
= new Array();
201 var buffer
= new Array();
203 var preselect_off
= false;
204 var content_change_flag
= false;
205 var lock_override_flag
= false;
206 var switchbox_status
= 'main';
207 var columns_status
= 'show';
208 var clone_mode
= false;
209 var multibox_count
= 0;
212 if (substr($_POST['hidden_mode'],0,5) == 'clone') {
213 echo "clone_mode = true;\n";
217 function clear_box(obj
) {
218 var hold
= obj
.value
;
219 obj
.value
= buffer
[obj
] ? buffer
[obj
] : '';
225 var separator1
= '/*[begin: ' + multibox_count +
']*/';
226 var separator2
= '/*[end: ' + multibox_count +
']*/\n\n';
227 var multibox_function_name
= 'camos';
228 var outer_delim1
= '/* ';
229 var outer_delim2
= ' */';
230 var inner_delim
= ' :: ';
232 var active_content
= f2
.textarea_content
;
233 if (f2
.top_bottom_active
[1].checked
) {
234 active_content
= f2
.textarea_content02
;
236 f3
= active_content
.value
;
237 document
.CAMOS
.textarea_multibox
.value
=
239 document
.CAMOS
.textarea_multibox
.value +
241 outer_delim1 + multibox_function_name + inner_delim +
242 f2
.select_category
.options
[f2
.select_category
.selectedIndex
].text +
244 f2
.select_subcategory
.options
[f2
.select_subcategory
.selectedIndex
].text +
246 f2
.select_item
.options
[f2
.select_item
.selectedIndex
].text +
251 function switchbox() {
252 var mainbox
= document
.getElementById('id_mainbox');
253 var multibox
= document
.getElementById('id_multibox');
254 if (switchbox_status
== 'main') {
255 switchbox_status
= 'multi';
256 mainbox
.style
.display
= 'none';
257 multibox
.style
.display
= 'block';
258 document
.CAMOS
.switch_box
.value
= 'hide multibox';
261 switchbox_status
= 'main';
262 multibox
.style
.display
= 'none';
263 mainbox
.style
.display
= 'block';
264 document
.CAMOS
.switch_box
.value
= 'show multibox';
267 function hide_columns() {
268 var column01
= document
.getElementById('id_category_column');
269 var column02
= document
.getElementById('id_subcategory_column');
270 var column03
= document
.getElementById('id_item_column');
271 var columnheader01
= document
.getElementById('id_category_column_header');
272 var columnheader02
= document
.getElementById('id_subcategory_column_header');
273 var columnheader03
= document
.getElementById('id_item_column_header');
275 if (columns_status
== 'show') {
276 columns_status
= 'hide';
277 column01
.style
.display
= 'none';
278 column02
.style
.display
= 'none';
279 column03
.style
.display
= 'none';
280 columnheader01
.style
.display
= 'none';
281 columnheader02
.style
.display
= 'none';
282 columnheader03
.style
.display
= 'none';
285 columns_status
= 'show';
286 column01
.style
.display
= 'inline';
287 column02
.style
.display
= 'inline';
288 column03
.style
.display
= 'inline';
289 columnheader01
.style
.display
= 'inline';
290 columnheader02
.style
.display
= 'inline';
291 columnheader03
.style
.display
= 'inline';
294 //deal with locking of content = prevent accidental overwrite
296 function trimString (str
) {
297 str
= this
!= window? this
: str
;
298 return str
.replace(/^\s+
/g
, '').replace(/\s+$
/g
, '');
300 function isLocked() {
302 if (lock_override_flag
) {
303 lock_override_flag
= false;
306 return /\
/\
*\s
*lock\s
*\
:\
:\s
*\
*\
//.test(f2.textarea_content.value);
308 function lock_content() {
310 if ((trimString(f2
.textarea_content
.value
) != "") && (!isLocked())) {
311 f2
.textarea_content
.value
= f2
.textarea_content
.value +
"\n\n" +
"/*lock::*/";
312 lock_override_flag
= true;
313 js_button('add','change_content');
316 function allSelected() {
317 var f2
= document
.CAMOS
;
318 if ( (f2
.select_category
.selectedIndex
< 0) ||
(f2
.select_subcategory
.selectedIndex
< 0) ||
(f2
.select_item
.selectedIndex
< 0) ) {
319 return false; //one of the columns is not selected
322 return true; //all columns have a selection
326 function content_focus() {
327 if (content_change_flag
== false) {
328 if (!allSelected()) {
329 alert("If you add text to the 'content' box without a selection in each column (category, subcategory, item), you will likely lose your work.")
333 content_change_flag
= true;
335 function content_blur() {
336 if (content_change_flag
== true) {
337 content_change_flag
= false;
341 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
344 $query = "SELECT code_text, code FROM billing WHERE encounter=".$_SESSION['encounter'].
345 " AND pid=".$_SESSION['pid']." AND code_type like 'ICD9' AND activity=1";
346 $statement = sqlStatement($query);
347 if ($result = sqlFetchArray($statement)) {
349 echo "icd9_list = \"\\n\\n\\\n";
350 echo $result['code']." ".$result['code_text']."\\n\\\n";
352 while ($result = sqlFetchArray($statement)) {
353 echo $result['code']." ".$result['code_text']."\\n\\\n";
355 if ($icd9_flag) {echo "\";\n";}
358 $query = "SELECT id, category FROM form_CAMOS_category ORDER BY category";
359 $statement = sqlStatement($query);
361 while ($result = sqlFetchArray($statement)) {
362 echo "array1[".$i."] = new Array('".$result['category']."','".$result['id']."', new Array());\n";
366 $query = "SELECT id, subcategory, category_id FROM form_CAMOS_subcategory ORDER BY subcategory";
367 $statement = sqlStatement($query);
368 while ($result = sqlFetchArray($statement)) {
369 echo "array2[".$i."] = new Array('".$result['subcategory']."', '".$result['category_id']."', '".$result['id']."', new Array());\n";
373 $query = "SELECT id, item, content, subcategory_id FROM form_CAMOS_item ORDER BY item";
374 $statement = sqlStatement($query);
375 while ($result = sqlFetchArray($statement)) {
376 echo "array3[".$i."] = new Array('".$result['item']."', '".fixquotes(str_replace($quote_search_content,$quote_replace_content,strip_tags($result['content'],"<b>,<i>")))."', '".$result['subcategory_id'].
377 "','".$result['id']."');\n";
382 function append_icd9() {
383 var f2
= document
.CAMOS
;
384 f2
.textarea_content
.value
= f2
.textarea_content
.value + icd9_list
;
387 function select_word(mode
, mystring
, myselect
) { //take a string and select it in a select box if present
388 if (preselect_off
) return 0;
389 for (var i
=0;i
<myselect
.length
;i++
) {
391 if (mode
== 'by name') {
392 match
= myselect
.options
[i
].text
;
394 else if (mode
== 'by number') {
395 match
= myselect
.options
[i
].value
;
398 if (match
== mystring
) {
399 myselect
.selectedIndex
= i
;
405 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
406 //cloning - similar process to preselect set to first time starting CAMOS
408 $clone_category = '';
409 $clone_subcategory = '';
414 $clone_data_array = array();
415 if (substr($_POST['hidden_mode'],0,5) == 'clone') {
416 $clone_category = $_POST['category'];
417 $query = "SELECT subcategory, item, content FROM form_CAMOS WHERE category like '".$clone_category."' and pid=".$_SESSION['pid']." order by id";
418 // if ($_POST['hidden_mode'] == 'clone last visit') {
419 // $query = "SELECT category, subcategory, item, content FROM form_CAMOS WHERE date(date) like (SELECT
420 // date(MAX(date)) FROM form_CAMOS where date(date) < date(now()) and pid=".$_SESSION['pid'].") and pid=".$_SESSION['pid']." order by id";
423 if ($_POST['hidden_mode'] == 'clone last visit') {
424 $tmp = sqlQuery("SELECT max(encounter) as max FROM billing where encounter < " .
425 $_SESSION['encounter'] . " and pid= " . $_SESSION['pid']);
426 $last_encounter_id = $tmp['max'] ?
$tmp['max'] : 0;
427 // $tmp = sqlQuery("SELECT max(encounter) AS max FROM forms WHERE " .
428 // "form_name LIKE 'CAMOS%' AND encounter < '" . $_SESSION['encounter'] .
429 // "' AND pid = '" . $_SESSION['pid'] . "'");
430 $last_encounter_id = $tmp['max'] ?
$tmp['max'] : 0;
431 $query = "SELECT category, subcategory, item, content FROM form_CAMOS " .
432 "join forms on (form_CAMOS.id = forms.form_id) where " .
433 "forms.encounter = '$last_encounter_id' and form_CAMOS.pid=" .
434 $_SESSION['pid']." order by form_CAMOS.id";
436 $statement = sqlStatement($query);
437 while ($result = sqlFetchArray($statement)) {
438 if (preg_match('/^[\s\r\n]*$/',$result['content']) == 0) {
439 if ($_POST['hidden_mode'] == 'clone last visit') {
440 $clone_category = $result['category'];
442 $clone_subcategory = $result['subcategory'];
443 $clone_item = $result['item'];
444 $clone_content = $result['content'];
445 $clone_data1 = "/* camos :: $clone_category :: $clone_subcategory :: $clone_item :: ";
446 $clone_data2 = "$clone_content */";
447 $clone_data3 = $clone_data1 . $clone_data2;
448 if ($_POST['hidden_mode'] == 'clone last visit') {
449 $clone_data1 = $clone_data3; //make key include whole entry so all 'last visit' data gets recorded and shown
451 $clone_data_array[$clone_data1] = $clone_data3;
454 if ($_POST['hidden_mode'] == 'clone last visit') {
455 // $tmp = sqlQuery("SELECT max(encounter) as max FROM billing where encounter < " .
456 // $_SESSION['encounter'] . " and pid= " . $_SESSION['pid']);
457 // $last_encounter_id = $tmp['max'] ? $tmp['max'] : 0;
458 $query = "SELECT code_type, code, code_text, modifier, units, fee FROM billing WHERE encounter = '$last_encounter_id' and pid=".$_SESSION['pid']." and activity=1 order by id";
459 $statement = sqlStatement($query);
460 while ($result = sqlFetchArray($statement)) {
461 $clone_code_type = $result['code_type'];
462 $clone_code = $result['code'];
463 $clone_code_text = $result['code_text'];
464 $clone_modifier = $result['modifier'];
465 $clone_units = $result['units'];
466 $clone_fee = $result['fee'];
467 $clone_billing_data = "/* billing :: $clone_code_type :: $clone_code :: $clone_code_text :: $clone_modifier :: $clone_units :: $clone_fee */";
468 $clone_data_array[$clone_billing_data] = $clone_billing_data;
472 //end preselect column items
473 } //end of clone stuff
476 var f2
= document
.CAMOS
;
480 if (substr($_POST['hidden_mode'],0,5) == 'clone') {
481 foreach($clone_data_array as $key => $val) {
482 echo "f2.textarea_multibox.value = f2.textarea_multibox.value + \"".fixquotes(str_replace($quote_search,$quote_replace,$val))."\\n\"\n";
484 echo "switchbox();\n";
489 for (i1
=0;i1
<array1
.length
;i1++
) {
490 f2
.select_category
.options
[f2
.select_category
.length
] = new Option(array1
[i1
][0], array1
[i1
][1]);
493 $temp_preselect_mode = $preselect_mode;
494 if ($preselect_category_override != '') {
495 $temp_preselect_mode = "by name";
496 $preselect_category = $preselect_category_override;
499 if (select_word('<? echo $temp_preselect_mode."', '".$preselect_category; ?>' ,f2
.select_category
)) {
504 function click_category() {
505 var f2
= document
.CAMOS
;
506 var category_index
= f2
.select_category
.selectedIndex
;
507 if ((category_index
< 0) ||
(category_index
> f2
.select_category
.length
-1)) {return 0;}
508 var sel
= f2
.select_category
.options
[f2
.select_category
.selectedIndex
].value
;
509 for (var i1
=0;i1
<array1
.length
;i1++
) {
510 if (array1
[i1
][1] == sel
) {
511 f2
.select_subcategory
.length
= 0;
512 f2
.select_item
.length
= 0;
513 f2
.textarea_content
.value
= '';
514 for (var i2
=0;i2
<array2
.length
;i2++
) {
515 if (array1
[i1
][1] == array2
[i2
][1]) {
516 f2
.select_subcategory
.options
[f2
.select_subcategory
.length
] = new Option(array2
[i2
][0], array2
[i2
][2]);
522 $temp_preselect_mode = $preselect_mode;
523 if ($preselect_subcategory_override != '') {
524 $temp_preselect_mode = "by name";
525 $preselect_subcategory = $preselect_subcategory_override;
528 if (select_word('<? echo $temp_preselect_mode."', '".$preselect_subcategory; ?>' ,f2
.select_subcategory
)) {
532 function click_subcategory() {
533 var f2
= document
.CAMOS
;
534 var subcategory_index
= f2
.select_subcategory
.selectedIndex
;
535 if ((subcategory_index
< 0) ||
(subcategory_index
> f2
.select_subcategory
.length
-1)) {return 0;}
536 var sel
= f2
.select_subcategory
.options
[f2
.select_subcategory
.selectedIndex
].value
;
537 for (var i1
=0;i1
<array2
.length
;i1++
) {
538 if (array2
[i1
][2] == sel
) {
539 f2
.select_item
.length
= 0;
540 f2
.textarea_content
.value
= '';
541 for (var i2
=0;i2
<array3
.length
;i2++
) {
542 if (array2
[i1
][2] == array3
[i2
][2]) {
543 f2
.select_item
.options
[f2
.select_item
.length
] = new Option(array3
[i2
][0], array3
[i2
][3]);
549 $temp_preselect_mode = $preselect_mode;
550 if ($preselect_item_override != '') {
551 $temp_preselect_mode = "by name";
552 $preselect_item = $preselect_item_override;
555 if (select_word('<? echo $temp_preselect_mode."', '".$preselect_item; ?>' ,f2
.select_item
)) {
557 preselect_off
= true;
560 function click_item() {
561 var f2
= document
.CAMOS
;
562 var item_index
= f2
.select_item
.selectedIndex
;
563 if ((item_index
< 0) ||
(item_index
> f2
.select_item
.length
-1)) {return 0;}
564 var sel
= f2
.select_item
.options
[item_index
].value
;
565 for (var i1
=0;i1
<array3
.length
;i1++
) {
566 if (array3
[i1
][3] == sel
) {
567 f2
.textarea_content
.value
= array3
[i1
][1].replace(/\\/g
,'');
572 function selectContains(myselect
, str
) {
573 for (var i
=0;i
<myselect
.length
;i++
) {
574 if (myselect
.options
[i
].text
== trimString(str
)) {return true;}
578 function insert_content(direction
) {
579 var f2
= document
.CAMOS
;
580 var source_box
= f2
.textarea_content
;
581 var target_box
= f2
.textarea_content02
;
582 if (direction
== 'up') {
583 source_box
= f2
.textarea_content02
;
584 target_box
= f2
.textarea_content
;
586 var sba
= source_box
.selectionStart
;
587 var sbb
= source_box
.selectionEnd
;
588 var tba
= target_box
.selectionStart
;
589 var tbb
= target_box
.selectionEnd
;
592 sbb
= source_box
.value
.length
;
594 var insert_text
= (source_box
.value
).
596 target_box
.value
= (target_box
.value
).
597 substring(0,tba
) + insert_text +
598 (target_box
.value
).substring(tba
,target_box
.value
.length
);
601 function js_button(mode
,selection
) {
602 var f2
= document
.CAMOS
;
604 if ( (mode
== 'add') && (selection
== 'change_content') && (isLocked()) ) {
605 alert("You have attempted to alter content which is locked.\nRemove the lock if you want to do this.\nTo unlock, remove the line, '/*lock::*/'");
610 //check for blank or duplicate submissions
611 if ( (mode
== 'add') ||
(mode
== 'alter') ) {
612 if (selection
== 'change_category') {
613 if (trimString(f2
.change_category
.value
) == "") {
614 alert("You cannot add a blank value for a category!");
617 if (selectContains(f2
.select_category
, trimString(f2
.change_category
.value
))) {
618 alert("There is already a category named "+f2
.change_category
.value+
".");
622 if (selection
== 'change_subcategory') {
623 if (trimString(f2
.change_subcategory
.value
) == "") {
624 alert("You cannot add a blank value for a subcategory!");
627 if (selectContains(f2
.select_subcategory
, trimString(f2
.change_subcategory
.value
))) {
628 alert("There is already a subcategory named "+f2
.change_subcategory
.value+
".");
632 if (selection
== 'change_item') {
633 if (trimString(f2
.change_item
.value
) == "") {
634 alert("You cannot add a blank value for an item!");
637 if (selectContains(f2
.select_item
, trimString(f2
.change_item
.value
))) {
638 alert("There is already an item named "+f2
.change_item
.value+
".");
643 //end of check for blank or duplicate submissions
645 if (mode
== 'delete') {
646 if (!confirm("Are you sure you want to delete this item from the database?")) {
650 var f2
= document
.CAMOS
;
651 var category_index
= f2
.select_category
.selectedIndex
;
653 if (category_index
< 0) {
654 if ((selection
== 'change_subcategory') ||
(selection
== 'change_item') ||
655 (selection
== 'change_content')) {
656 alert ('You have not selected a category!');
662 category
= f2
.select_category
.options
[category_index
].value
;
664 var subcategory_index
= f2
.select_subcategory
.selectedIndex
;
666 if (subcategory_index
< 0) {
667 if ((selection
== 'change_item') ||
(selection
== 'change_content')) {
668 alert ('You have not selected a subcategory!');
674 subcategory
= f2
.select_subcategory
.options
[subcategory_index
].value
;
676 var item_index
= f2
.select_item
.selectedIndex
;
678 if (item_index
< 0) {
679 if (selection
== 'change_content') {
680 alert ('You have not selected an item!');
686 item
= f2
.select_item
.options
[item_index
].value
;
688 //deal with clone buttons
689 if ( (mode
.substr(0,5) == 'clone') ||
(mode
== 'add') ||
690 (mode
== 'alter') ||
(mode
=='delete') ) {
691 f2
.category
.value
= f2
.select_category
.options
[f2
.select_category
.selectedIndex
].text
;
692 f2
.hidden_mode
.value
= mode
;
693 f2
.hidden_selection
.value
= selection
;
694 f2
.hidden_category
.value
= category
;
695 f2
.hidden_subcategory
.value
= subcategory
;
696 f2
.hidden_item
.value
= item
;
697 f2
.action
= '<? print $GLOBALS['webroot
'] ?>/interface/patient_file/encounter/load_form.php?formname=CAMOS';
701 if (mode
== 'submit') {
702 var active_content
= f2
.textarea_content
;
703 if (f2
.top_bottom_active
[1].checked
) {
704 active_content
= f2
.textarea_content02
;
706 f2
.category
.value
= f2
.select_category
.options
[f2
.select_category
.selectedIndex
].text
;
707 f2
.subcategory
.value
= f2
.select_subcategory
.options
[f2
.select_subcategory
.selectedIndex
].text
;
708 f2
.item
.value
= f2
.select_item
.options
[f2
.select_item
.selectedIndex
].text
;
709 if (selection
== 'submit_selection') {
710 f2
.content
.value
= (active_content
.value
).substring(active_content
.selectionStart
, active_content
.selectionEnd
);
712 else if (selection
== 'multibox') {f2
.content
.value
= f2
.textarea_multibox
.value
;}
713 else {f2
.content
.value
= active_content
.value
;}
714 f2
.action
= '<?echo $rootdir;?>/forms/CAMOS/save.php?mode=new';
719 function selectItem () {
721 f2
.item
.value
=f2
.select_item
.options
[f2
.select_item
.selectedIndex
].text
;
722 f2
.content
.value
= f2
.textarea_content
.value
;
727 <body
<?
echo $top_bg_line;?
> topmargin
=0 rightmargin
=0 leftmargin
=2 bottommargin
=0 marginwidth
=2 marginheight
=0 onload
="init()">
728 <form method
=post action
="<?echo $rootdir;?>/forms/CAMOS/save.php?mode=new" name
="CAMOS">
729 <input type
=button name
='switch_box' value
='show multibox' onClick
="switchbox()">
730 <input type
=button name
='add_multibox' value
='add to multibox' onClick
="addbox()">
731 <input type
=button name
='submit_multibox' value
='submit multibox' onClick
="js_button('submit','multibox')">
732 <input type
=button name
=clone value
=clone onClick
="js_button('clone', 'clone')">
733 <input type
=button name
=clone_visit value
='clone last visit' onClick
="js_button('clone last visit', 'clone last visit')">
735 echo "<a href='".$GLOBALS['webroot'] . "/interface/patient_file/encounter/$returnurl' onclick='top.restoreSession()'>[".xl('do not save')."]</a>";
737 <div id
=id_mainbox style
="display:inline">
740 echo "<h1> error: ".$error."</h1>\n";
746 <div id
=id_category_column_header style
="display:inline">
747 <?php
xl('Category',e
)?
>
748 </div
> <!-- end of id_category_column_header
-->
751 <div id
=id_subcategory_column_header style
="display:inline">
752 <?php
xl('Subsubcategory',e
)?
>
753 </div
> <!-- end of id_subcategory_column_header
-->
756 <div id
=id_item_column_header style
="display:inline">
758 </div
> <!-- end of id_item_column_header
-->
761 <?php
xl('Content',e
)?
>
767 <div id
=id_category_column style
="display:inline">
768 <select name
=select_category size
=<?
echo $select_size ?
> onchange
="click_category()"></select
><br
>
770 if (myAuth() == 1) {//root user only can see administration option
772 <input type
=text name
=change_category
><br
>
773 <input type
=button name
=add1 value
=add onClick
="js_button('add','change_category')">
774 <input type
=button name
=alter1 value
=alter onClick
="js_button('alter','change_category')">
775 <input type
=button name
=del1 value
=del onClick
="js_button('delete','change_category')"><br
>
779 </div
> <!-- end of id_category_column
-->
782 <div id
=id_subcategory_column style
="display:inline">
783 <select name
=select_subcategory size
=<?
echo $select_size ?
> onchange
="click_subcategory()"></select
><br
>
785 if (myAuth() == 1) {//root user only can see administration option
787 <input type
=text name
=change_subcategory
><br
>
788 <input type
=button name
=add2 value
=add onClick
="js_button('add','change_subcategory')">
789 <input type
=button name
=alter1 value
=alter onClick
="js_button('alter','change_subcategory')">
790 <input type
=button name
=del2 value
=del onClick
="js_button('delete','change_subcategory')"><br
>
794 </div
> <!-- end of id_subcategory_column
-->
797 <div id
=id_item_column style
="display:inline">
798 <select name
=select_item size
=<?
echo $select_size ?
> onchange
="click_item()"
799 ondblclick
="addbox()"></select
><br
>
801 if (myAuth() == 1) {//root user only can see administration option
803 <input type
=text name
=change_item
><br
>
804 <input type
=button name
=add3 value
=add onClick
="js_button('add','change_item')">
805 <input type
=button name
=alter1 value
=alter onClick
="js_button('alter','change_item')">
806 <input type
=button name
=del3 value
=del onClick
="js_button('delete','change_item')"><br
>
810 </div
> <!-- end of id_item_column
-->
813 <div id
=id_textarea_content style
="display:inline">
814 <textarea name
=textarea_content cols
=<?
echo $textarea_cols ?
> rows
=<?
echo $textarea_rows ?
> onFocus
="content_focus()" onBlur
="content_blur()" ondblclick
="clear_box(this)"></textarea
>
816 <input type
=button name
=insert_down value
='insert down' onClick
="insert_content('down')">
817 <input type
=radio name
=top_bottom_active value
=top checked
>
818 </div
> <!-- end of id_textarea_content
-->
820 <div id
=id_textarea_content02 style
="display:inline">
821 <textarea name
=textarea_content02 cols
=<?
echo $textarea_cols ?
> rows
=<?
echo $textarea_rows ?
> onFocus
="content_focus()" onBlur
="content_blur()" ondblclick
="clear_box(this)"></textarea
>
823 <input type
=button name
=insert_up value
='insert up' onClick
="insert_content('up')">
824 <input type
=radio name
=top_bottom_active value
=bottom
>
825 </div
> <!-- end of id_textarea_content02
-->
828 if (myAuth() == 1) {//root user only can see administration option
830 <div id
=id_main_content_buttons style
="display:none">
831 <input type
=button name
=add4 value
=add onClick
="js_button('add','change_content')">
832 <input type
=button name
=lock value
=lock onClick
="lock_content()">
834 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
836 <input type
=button name
=icd9 value
=icd9 onClick
="append_icd9()">
837 </div
> <!-- end of id_main_content_buttons
-->
848 <input type
=hidden name
=hidden_mode
>
849 <input type
=hidden name
=hidden_selection
>
850 <input type
=hidden name
=hidden_category
>
851 <input type
=hidden name
=hidden_subcategory
>
852 <input type
=hidden name
=hidden_item
>
854 <input type
=hidden name
=category
>
855 <input type
=hidden name
=subcategory
>
856 <input type
=hidden name
=item
>
857 <input type
=hidden name
=content
>
859 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
861 <input type
=button name
='submit form' value
='submit all content' onClick
="js_button('submit','submit')">
862 <input type
=button name
='submit form' value
='submit selected content' onClick
="js_button('submit','submit_selection')">
867 if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter
868 echo "<a href='".$GLOBALS['webroot'] . "/interface/patient_file/encounter/$returnurl' onclick='top.restoreSession()'>[".xl('do not save')."]</a>";
869 echo "<a href='".$GLOBALS['webroot'] . "/interface/forms/CAMOS/help.html' target='new'> | [".xl('help')."]</a>";
870 echo $previous_encounter_data; //probably don't need anymore now that we have clone last visit
874 <div id
=id_multibox style
="display:none">
875 <textarea name
=textarea_multibox cols
=<?
echo $multibox_cols ?
> rows
=<?
echo $multibox_rows ?
> onFocus
="content_focus()" onBlur
="content_blur()"></textarea
>
876 </div
> <!-- end of id_multibox
-->
883 function fixquotes ($string) {
884 $string = preg_replace('/([\\\])*\'/', "\\\'", $string);
885 $string = preg_replace('/([\\\])*\"/', "\\\"", $string);