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