Housekeeping stuff:
[openemr.git] / interface / patient_file / link_issue_to_encounter.php
blobd0c611bbcfa375004f310bd23507897ea65a73a9
1 <?php
2 // Copyright (C) 2009 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This links a specified or newly created GCAC issue to a specified
10 // encounter. It is invoked from pos_checkout.php via a jquery getScript().
12 require_once("../globals.php");
13 require_once("$srcdir/lists.inc");
14 require_once("$srcdir/acl.inc");
16 $issue = 0 + (empty($_REQUEST['issue']) ? 0 : $_REQUEST['issue']);
17 $thispid = 0 + (empty($_REQUEST['thispid']) ? $pid : $_REQUEST['thispid']);
18 $thisenc = 0 + (empty($_REQUEST['thisenc']) ? 0 : $_REQUEST['thisenc']);
20 if (!acl_check('patients', 'med')) {
21 echo "alert('" . xl('Not authorized') . ".');\n";
22 exit();
25 if (!($thisenc && $thispid)) {
26 echo "alert('" . xl('Internal error: pid or encounter is missing.') . ".');\n";
27 exit();
30 $msg = xl('Internal error!');
32 if ($issue) {
33 $msg = xl('Issue') . " $issue " . xl('has been linked to visit') .
34 " $thispid.$thisenc.";
36 else {
37 $issue = sqlInsert("INSERT INTO lists ( " .
38 "date, pid, type, title, activity, comments, begdate, user, groupname " .
39 ") VALUES ( " .
40 "NOW(), " .
41 "'$thispid', " .
42 "'ippf_gcac', " .
43 "'" . xl('Auto-generated') . "', " .
44 "1, " .
45 "'', " .
46 "'" . date('Y-m-d') . "', " .
47 "'" . $_SESSION['authUser'] . "', " .
48 "'" . $_SESSION['authProvider'] . "' " .
49 ")");
51 if ($issue) {
52 sqlStatement("INSERT INTO lists_ippf_gcac ( id ) VALUES ( $issue )");
53 $msg = xl('An incomplete GCAC issue has been created and linked. Someone will need to complete it later.');
57 if ($issue) {
58 $query = "INSERT INTO issue_encounter ( " .
59 "pid, list_id, encounter " .
60 ") VALUES ( " .
61 "'$thispid', '$issue', '$thisenc'" .
62 ")";
63 sqlStatement($query);
66 echo "alert('$msg');\n";