minor improvement to the fee sheet search code drop down
[openemr.git] / interface / forms / CAMOS / ajax_save.php
blobfe9c54df1318bd2bc796d616a96be1bbcf1a9176
1 <?php
2 //------------This file inserts your field data into the MySQL database
3 include_once("../../globals.php");
4 include_once("../../../library/api.inc");
5 include_once("../../../library/forms.inc");
6 include_once("../../../library/sql.inc");
7 include_once("content_parser.php");
8 include_once("../../../library/formdata.inc.php");
10 $field_names = array('category' => formData("category"), 'subcategory' => formData("subcategory"), 'item' => formData("item"), 'content' => strip_escape_custom($_POST['content']));
11 $camos_array = array();
12 process_commands($field_names['content'],$camos_array);
14 $CAMOS_form_name = "CAMOS-".$field_names['category'].'-'.$field_names['subcategory'].'-'.$field_names['item'];
16 if ($encounter == "") {
17 $encounter = date("Ymd");
20 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/",$field_names['content']) == 0) { //make sure blanks do not get submitted
21 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
22 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
23 // before being submitted to the database. Will also continue to support placeholder conversion on report
24 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
25 // version 4.0).
26 $field_names['content'] = add_escape_custom( replace($pid,$encounter,$field_names['content']) );
27 reset($field_names);
28 $newid = formSubmit("form_CAMOS", $field_names, $_GET["id"], $userauthorized);
29 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
31 //deal with embedded camos submissions here
32 foreach($camos_array as $val) {
33 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/",$val['content']) == 0) { //make sure blanks not submitted
34 foreach($val as $k => $v) {
35 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
36 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
37 // before being submitted to the database. Will also continue to support placeholder conversion on report
38 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
39 // version 4.0).
40 $val[$k] = trim( add_escape_custom( replace($pid,$encounter,$v) ) );
42 $CAMOS_form_name = "CAMOS-".$val['category'].'-'.$val['subcategory'].'-'.$val['item'];
43 reset($val);
44 $newid = formSubmit("form_CAMOS", $val, $_GET["id"], $userauthorized);
45 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
48 echo "<font color=red><b>" . xl('submitted') . ": " . time() . "</b></font>";