2 // Copyright (C) 2009 Rod Roark <rod@sunsetsystems.com>
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";
25 if (!($thisenc && $thispid)) {
26 echo "alert('" . xl('Internal error: pid or encounter is missing.') . ".');\n";
30 $msg = xl('Internal error!');
33 $msg = xl('Issue') . " $issue " . xl('has been linked to visit') .
34 " $thispid.$thisenc.";
37 $issue = sqlInsert("INSERT INTO lists ( " .
38 "date, pid, type, title, activity, comments, begdate, user, groupname " .
43 "'" . xl('Auto-generated') . "', " .
46 "'" . date('Y-m-d') . "', " .
47 "'" . $_SESSION['authUser'] . "', " .
48 "'" . $_SESSION['authProvider'] . "' " .
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.');
58 $query = "INSERT INTO issue_encounter ( " .
59 "pid, list_id, encounter " .
61 "'$thispid', '$issue', '$thisenc'" .
66 echo "alert('$msg');\n";