more organization of autoloaded files (#424)
[openemr.git] / interface / forms / CAMOS / ajax_save.php
blob453a34af05862815ba645d12f1e39383e4065911
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("content_parser.php");
8 $field_names = array('category' => formData("category"), 'subcategory' => formData("subcategory"), 'item' => formData("item"), 'content' => strip_escape_custom($_POST['content']));
9 $camos_array = array();
10 process_commands($field_names['content'],$camos_array);
12 $CAMOS_form_name = "CAMOS-".$field_names['category'].'-'.$field_names['subcategory'].'-'.$field_names['item'];
14 if ($encounter == "") {
15 $encounter = date("Ymd");
18 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/",$field_names['content']) == 0) { //make sure blanks do not get submitted
19 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
20 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
21 // before being submitted to the database. Will also continue to support placeholder conversion on report
22 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
23 // version 4.0).
24 $field_names['content'] = add_escape_custom( replace($pid,$encounter,$field_names['content']) );
25 reset($field_names);
26 $newid = formSubmit("form_CAMOS", $field_names, $_GET["id"], $userauthorized);
27 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
29 //deal with embedded camos submissions here
30 foreach($camos_array as $val) {
31 if (preg_match("/^[\s\\r\\n\\\\r\\\\n]*$/",$val['content']) == 0) { //make sure blanks not submitted
32 foreach($val as $k => $v) {
33 // Replace the placeholders before saving the form. This was changed in version 4.0. Previous to this, placeholders
34 // were submitted into the database and converted when viewing. All new notes will now have placeholders converted
35 // before being submitted to the database. Will also continue to support placeholder conversion on report
36 // views to support notes within database that still contain placeholders (ie. notes that were created previous to
37 // version 4.0).
38 $val[$k] = trim( add_escape_custom( replace($pid,$encounter,$v) ) );
40 $CAMOS_form_name = "CAMOS-".$val['category'].'-'.$val['subcategory'].'-'.$val['item'];
41 reset($val);
42 $newid = formSubmit("form_CAMOS", $val, $_GET["id"], $userauthorized);
43 addForm($encounter, $CAMOS_form_name, $newid, "CAMOS", $pid, $userauthorized);
46 echo "<font color=red><b>" . xl('submitted') . ": " . time() . "</b></font>";