Refactor previous name into dedicated service (#7571)
[openemr.git] / interface / forms / aftercare_plan / save.php
blob9edc3868ce3f1c5285ced982444eb9bebd54625a
1 <?php
3 /**
4 * aftercare_plan save.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Naina Mohamed <naina@capminds.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2012-2013 Naina Mohamed <naina@capminds.com> CapMinds Technologies
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
15 require_once(__DIR__ . "/../../globals.php");
16 require_once("$srcdir/api.inc.php");
17 require_once("$srcdir/forms.inc.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
21 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
22 CsrfUtils::csrfNotVerified();
25 if (! $encounter) { // comes from globals.php
26 die(xlt("Internal error: we do not seem to be in an encounter!"));
29 $id = (int) (isset($_GET['id']) ? $_GET['id'] : '');
31 $sets = "pid = ?,
32 groupname = ?,
33 user = ?,
34 authorized = ?,
35 activity = 1,
36 date = NOW(),
37 provider = ?,
38 client_name = ?,
39 admit_date = ?,
40 discharged = ?,
41 goal_a_acute_intoxication = ?,
42 goal_a_acute_intoxication_I = ?,
43 goal_a_acute_intoxication_II = ?,
44 goal_b_emotional_behavioral_conditions = ?,
45 goal_b_emotional_behavioral_conditions_I = ?,
46 goal_c_relapse_potential = ?,
47 goal_c_relapse_potential_I = ?";
50 if (empty($id)) {
51 $newid = sqlInsert(
52 "INSERT INTO form_aftercare_plan SET $sets",
54 $_SESSION["pid"],
55 $_SESSION["authProvider"],
56 $_SESSION["authUser"],
57 $userauthorized,
58 $_POST["provider"],
59 $_POST["client_name"],
60 $_POST["admit_date"],
61 $_POST["discharged"],
62 $_POST["goal_a_acute_intoxication"],
63 $_POST["goal_a_acute_intoxication_I"],
64 $_POST["goal_a_acute_intoxication_II"],
65 $_POST["goal_b_emotional_behavioral_conditions"],
66 $_POST["goal_b_emotional_behavioral_conditions_I"],
67 $_POST["goal_c_relapse_potential"],
68 $_POST["goal_c_relapse_potential_I"]
72 addForm($encounter, "Aftercare Plan", $newid, "aftercare_plan", $pid, $userauthorized);
73 } else {
74 sqlStatement(
75 "UPDATE form_aftercare_plan SET $sets WHERE id = ?;",
77 $_SESSION["pid"],
78 $_SESSION["authProvider"],
79 $_SESSION["authUser"],
80 $userauthorized,
81 $_POST["provider"],
82 $_POST["client_name"],
83 $_POST["admit_date"],
84 $_POST["discharged"],
85 $_POST["goal_a_acute_intoxication"],
86 $_POST["goal_a_acute_intoxication_I"],
87 $_POST["goal_a_acute_intoxication_II"],
88 $_POST["goal_b_emotional_behavioral_conditions"],
89 $_POST["goal_b_emotional_behavioral_conditions_I"],
90 $_POST["goal_c_relapse_potential"],
91 $_POST["goal_c_relapse_potential_I"],
92 $id
97 formHeader("Redirecting....");
98 formJump();
99 formFooter();