Highway to PSR2
[openemr.git] / interface / forms / functional_cognitive_status / save.php
blob67b42240e011246bd5b8fd4e907bc8fc1eb8c7e2
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2015 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 //
23 // Author: Jacob T Paul <jacob@zhservices.com>
24 // Vinish K <vinish@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 include_once("../../globals.php");
29 include_once("$srcdir/api.inc");
30 include_once("$srcdir/forms.inc");
32 if (!$encounter) { // comes from globals.php
33 die(xlt("Internal error: we do not seem to be in an encounter!"));
36 $id = 0 + (isset($_GET['id']) ? $_GET['id'] : '');
37 $code = $_POST["code"];
38 $code_text = $_POST["codetext"];
39 $code_date = $_POST["code_date"];
40 $code_des = $_POST["description"];
41 $code_activity = $_POST["activity1"];
43 if ($id && $id != 0) {
44 sqlStatement("DELETE FROM `form_functional_cognitive_status` WHERE id=? AND pid = ? AND encounter = ?", array($id, $_SESSION["pid"], $_SESSION["encounter"]));
45 $newid = $id;
46 } else {
47 $res2 = sqlStatement("SELECT MAX(id) as largestId FROM `form_functional_cognitive_status`");
48 $getMaxid = sqlFetchArray($res2);
49 if ($getMaxid['largestId']) {
50 $newid = $getMaxid['largestId'] + 1;
51 } else {
52 $newid = 1;
55 addForm($encounter, "Functional and Cognitive Status Form", $newid, "functional_cognitive_status", $_SESSION["pid"], $userauthorized);
58 $code_text = array_filter($code_text);
60 if (!empty($code_text)) {
61 foreach ($code_text as $key => $codeval) :
62 $sets = "id = ". add_escape_custom($newid) .",
63 pid = ". add_escape_custom($_SESSION["pid"]) .",
64 groupname = '" . add_escape_custom($_SESSION["authProvider"]) . "',
65 user = '" . add_escape_custom($_SESSION["authUser"]) . "',
66 encounter = '" . add_escape_custom($_SESSION["encounter"]) . "',
67 authorized = ". add_escape_custom($userauthorized) .",
68 activity = '" . add_escape_custom($code_activity[$key]) . "',
69 code = '" . add_escape_custom($code[$key]) . "',
70 codetext = '" . add_escape_custom($code_text[$key]) . "',
71 description= '" . add_escape_custom($code_des[$key]) . "',
72 date = '" . add_escape_custom($code_date[$key]) . "'";
73 sqlInsert("INSERT INTO form_functional_cognitive_status SET $sets");
74 endforeach;
77 $_SESSION["encounter"] = $encounter;
78 formHeader("Redirecting....");
79 formJump();
80 formFooter();