Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / forms / functional_cognitive_status / save.php
blob2ce35c250487c15d4be1469c3bbb8abdcccca57f
1 <?php
2 /**
3 * Functional cognitive status form save.php.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Jacob T Paul <jacob@zhservices.com>
8 * @author Vinish K <vinish@zhservices.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2015 Z&H Consultancy Services Private Limited <sam@zhservices.com>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../../globals.php");
17 require_once("$srcdir/api.inc");
18 require_once("$srcdir/forms.inc");
20 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
21 csrfNotVerified();
24 if (!$encounter) { // comes from globals.php
25 die(xlt("Internal error: we do not seem to be in an encounter!"));
28 $id = 0 + (isset($_GET['id']) ? $_GET['id'] : '');
29 $code = $_POST["code"];
30 $code_text = $_POST["codetext"];
31 $code_date = $_POST["code_date"];
32 $code_des = $_POST["description"];
33 $code_activity = $_POST["activity1"];
35 if ($id && $id != 0) {
36 sqlStatement("DELETE FROM `form_functional_cognitive_status` WHERE id=? AND pid = ? AND encounter = ?", array($id, $_SESSION["pid"], $_SESSION["encounter"]));
37 $newid = $id;
38 } else {
39 $res2 = sqlStatement("SELECT MAX(id) as largestId FROM `form_functional_cognitive_status`");
40 $getMaxid = sqlFetchArray($res2);
41 if ($getMaxid['largestId']) {
42 $newid = $getMaxid['largestId'] + 1;
43 } else {
44 $newid = 1;
47 addForm($encounter, "Functional and Cognitive Status Form", $newid, "functional_cognitive_status", $_SESSION["pid"], $userauthorized);
50 $code_text = array_filter($code_text);
52 if (!empty($code_text)) {
53 foreach ($code_text as $key => $codeval) :
54 $sets = "id = ?,
55 pid = ?,
56 groupname = ?,
57 user = ?,
58 encounter = ?,
59 authorized = ?,
60 activity = '?,
61 code = ?,
62 codetext = ?,
63 description= ?,
64 date = ?";
65 sqlStatement(
66 "INSERT INTO form_functional_cognitive_status SET $sets",
68 $newid,
69 $_SESSION["pid"],
70 $_SESSION["authProvider"],
71 $_SESSION["authUser"],
72 $_SESSION["encounter"],
73 $userauthorized,
74 $code_activity[$key],
75 $code[$key],
76 $code_text[$key],
77 $code_des[$key],
78 $code_date[$key]
81 endforeach;
84 $_SESSION["encounter"] = $encounter;
85 formHeader("Redirecting....");
86 formJump();
87 formFooter();