This is a new form for generating orders.
[openemr.git] / interface / forms / CAMOS / save.php
blobdf9d2c722194daac562af742926c6a4bddd91ab4
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");
8 $field_names = array('category' => $_POST['category'], 'subcategory' => $_POST['subcategory'], 'item' => $_POST['item'], 'content' => $_POST['content']);
10 //to add codes to billing from CAMOS content field
11 //addBilling($encounter, $type, $code, $text, $pid, $userauthorized,$_SESSION['authUserID'],$modifier,$units,$fee);
14 foreach ($field_names as $k => $var) {
15 $field_names[$k] = mysql_real_escape_string($var);
16 echo "$var\n";
19 //The following little section is to sift out data to be entered into the billing table
20 //or, in the future, wherever...
21 //as it is written write now, it just removes all but the list and rewrites the string with '-'
22 //in between. It uses '::' as a delimeter. you will have to put a :: before each piece of data
23 //with no spaces between. Since we will probably want to allow for multiple table entries,
24 //I guess we will need another delimiter to split first...well, at least this is proof that
25 //it can be done and basically demonstrates how to do it.
26 $content_value = $field_names['content'];
27 $content_array = split('::',$field_names['content']);
28 if (count($content_array) > 1) {
29 $content_value = '';
30 $i = 0;
31 foreach ($content_array as $k => $var) {
32 if ($i > 0) {
33 $content_value .= $var."-";
35 $i++;
38 $field_names['content'] = $content_value;
39 //end of experimental '::' section :)
41 if ($encounter == "")
42 $encounter = date("Ymd");
43 if ($_GET["mode"] == "new"){
44 $newid = formSubmit("form_CAMOS", $field_names, $_GET["id"], $userauthorized);
45 addForm($encounter, "CAMOS", $newid, "CAMOS", $pid, $userauthorized);
46 }elseif ($_GET["mode"] == "update") {
47 sqlInsert("update form_CAMOS set pid = {$_SESSION["pid"]},groupname='".$_SESSION["authProvider"]."',user='".$_SESSION["authUser"]."',authorized=$userauthorized,activity=1, date = NOW(), category='".$field_names["category"]."',subcategory='".$field_names["subcategory"]."',item='".$field_names["item"]."',content='".$content_value."' where id=$id");
48 }elseif ($_GET["mode"] == "delete") {
49 sqlInsert("delete from form_CAMOS where id=$id and date(date) = date(now())");
50 sqlInsert("delete from forms where form_name='CAMOS' and form_id=$id and pid='".$_SESSION["pid"]."' and date(date) = date(now())");
52 $_SESSION["encounter"] = $encounter;
53 formHeader("Redirecting....");
54 formJump();
55 formFooter();