Fixes for restoreSession logic. (#4378)
[openemr.git] / library / MedEx / MedEx.php
blob50d2d235ee664eb56fb3659e4ad50eff58284bdd
1 <?php
3 /**
4 * /library/MedEx/MedEx.php
6 * This file is the callback service for MedEx to update local DB with new responses in real-time.
7 * It must be accessible remotely to receive data synchronously.
9 * It is not required if a practice is happy syncing using background services only.
11 * The advantages using this file are:
12 * 1. Real time updates of patient responses == synchronous receiver
13 * 2. Reduced need to run the MedEx_background service
14 * - MedEx_background syncs DB responses asynchronously, ie only when run (default = every 29 minutes)
15 * - It consumes resources and may affecting performance of the server if run too often.
16 * (see MedEx_background.php for configuration examples)
18 * Uses multiple authentication steps for security:
19 * - local API_key
20 * - MedEx username
21 * - session token
22 * - MedEx generated token
24 * @package MedEx
25 * @author MedEx <support@MedExBank.com>
26 * @link http://www.MedExBank.com
27 * @copyright Copyright (c) 2017 MedEx <support@MedExBank.com>
28 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
31 $ignoreAuth = true;
32 $_SERVER['HTTP_HOST'] = 'default'; //change for multi-site
34 require_once(dirname(__FILE__) . "/../../interface/globals.php");
35 require_once(dirname(__FILE__) . "/../patient.inc");
36 require_once(dirname(__FILE__) . "/API.php");
38 if (!empty($_POST['callback_key'])) {
39 $MedEx = new MedExApi\MedEx('MedExBank.com');
40 $response = $MedEx->login('2');
41 header('Content-type: application/json');
42 echo json_encode($response);
43 exit;
45 echo "Not logged in: ";
46 echo $MedEx->getLastError();
47 exit;