3 * Functional cognitive status form save.php.
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"])) {
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"]));
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;
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) :
66 "INSERT INTO form_functional_cognitive_status SET $sets",
70 $_SESSION["authProvider"],
71 $_SESSION["authUser"],
72 $_SESSION["encounter"],
84 $_SESSION["encounter"] = $encounter;
85 formHeader("Redirecting....");