6 * @link http://www.open-emr.org
7 * @author Jerry Padgett <sjpadgett@gmail.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2016-2019 Jerry Padgett <sjpadgett@gmail.com>
10 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 //Need to unwrap data to ensure user/patient is authorized
15 $data = (array)(json_decode(file_get_contents("php://input")));
17 $user = $data['user'];
18 $signer = !empty($data['signer']) ?
$data['signer'] : '';
19 $type = $data['type'];
20 $isPortal = $data['is_portal'];
21 $output = urldecode($data['output']);
24 // this script is used by both the patient portal and main openemr; below does authorization.
26 require_once(dirname(__FILE__
) . "/../../../src/Common/Session/SessionUtil.php");
27 OpenEMR\Common\Session\SessionUtil
::portalSessionStart();
29 if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
30 // authorized by patient portal
31 $pid = $_SESSION['pid'];
34 OpenEMR\Common\Session\SessionUtil
::portalSessionCookieDestroy();
35 echo js_escape("error");
39 require_once("../../../interface/globals.php");
41 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
42 if ($type == 'admin-signature') {
45 $sig_hash = sha1($output);
47 $ip = $_SERVER['REMOTE_ADDR'];
49 $lastmod = date('Y-m-d H:i:s');
50 $r = sqlStatement("SELECT COUNT( DISTINCT TYPE ) x FROM onsite_signatures where pid = ? and user = ? ", array($pid, $user));
51 $c = sqlFetchArray($r);
54 $qstr = "UPDATE onsite_signatures SET pid=?,lastmod=?,status=?, user=?, signature=?, sig_hash=?, ip=?,sig_image=? WHERE pid=? && user=?";
55 $rcnt = sqlStatement($qstr, array($pid, $lastmod, $status, $user, null, $sig_hash, $ip, $output, $pid, $user));
57 $qstr = "INSERT INTO onsite_signatures (pid,lastmod,status,type,user,signator, signature, sig_hash, ip, created, sig_image) VALUES (?,?,?,?,?,?,?,?,?,?,?) ";
58 sqlStatement($qstr, array($pid, $lastmod, $status, $type, $user, $signer, null, $sig_hash, $ip, $created, $output));
61 echo json_encode('Done');