Some Module Updates (#7732)
[openemr.git] / interface / smart / ehr-launch-client.php
blobd13e302a92645183964bf2dd7f5534bcedbf7d45
1 <?php
3 /**
4 * ehr-launch-client.php Main entry point for the OpenEMR OAUTH2 / SMART client in ehr launch
5 * Allows a smart app to launch into the OpenEMR EHR in a seamless interaction
6 * @package openemr
7 * @link http://www.open-emr.org
8 * @author Stephen Nielson <snielson@discoverandchange.com>
9 * @copyright Copyright (c) 2023 Discover and Change, Inc. <snielson@discoverandchange.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
15 use OpenEMR\Common\Acl\AccessDeniedException;
16 use OpenEMR\Common\Csrf\CsrfInvalidException;
17 use OpenEMR\Common\Csrf\CsrfUtils;
18 use OpenEMR\Common\Logging\SystemLogger;
19 use OpenEMR\FHIR\SMART\SmartLaunchController;
21 $controller = new SmartLaunchController();
23 $intentData = [];
24 try {
25 $intentData['appointment_id'] = $_REQUEST['appointment_id'] ?? null;
26 $controller->redirectAndLaunchSmartApp(
27 $_REQUEST['intent'] ?? null,
28 $_REQUEST['client_id'] ?? null,
29 $_REQUEST['csrf_token'] ?? null,
30 $intentData
32 } catch (CsrfInvalidException $exception) {
33 CsrfUtils::csrfNotVerified();
34 } catch (AccessDeniedException $exception) {
35 (new SystemLogger())->critical($exception->getMessage(), ["trace" => $exception->getTraceAsString()]);
36 die();
37 } catch (Exception $exception) {
38 (new SystemLogger())->error($exception->getMessage(), ["trace" => $exception->getTraceAsString()]);
39 die("Unknown system error occurred");