minor fhir code updates (#1425)
[openemr.git] / phpfhir / libs / controller / ClientAppController.php
blob0144d81612fe21bd7cbc7f11e6f2ca1a15881b5a
1 <?php
2 /**
3 * clientController class
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Jerry Padgett <sjpadgett@gmail.com>
8 * @copyright Copyright (c) 2018 Jerry Padgett <sjpadgett@gmail.com>
9 * @license https://www.gnu.org/licenses/agpl-3.0.en.html GNU Affero General Public License 3
12 require_once("oeDispatcher.php");
14 use oeFHIR\oeFHIRHttpClient;
15 use oeFHIR\oeFHIRResource;
17 class clientController extends oeDispatchController
19 public function __construct()
21 parent::__construct();
24 public function indexAction()
26 if (!$this->getSession('pid', '')) {
27 $pid = $this->getRequest('patient_id');
28 $this->setSession('pid', $pid);
29 } else {
30 $pid = $this->getSession('pid', '');
33 return null;
36 public function createAction()
38 $pid = $this->getRequest(pid);
39 $type = $this->getRequest(type);
40 $client = new oeFHIRHttpClient();
41 $id = 'oe-' . $pid;
42 $rs = new oeFHIRResource();
43 $r = $rs->createPatientResource($pid);
44 $pt = $client->sendResource($type, $id, $r);
46 return $pt;
49 public function historyAction()
51 $pid = $this->getRequest(pid);
52 $type = $this->getRequest(type);
53 $client = new oeFHIRHttpClient();
54 $id = 'oe-' . $pid;
55 $pt = $client->requestResource($type, $id, 'history');
56 return $pt;
59 public function readAction()
61 $pid = $this->getRequest(pid);
62 $type = $this->getRequest(type);
63 $client = new oeFHIRHttpClient();
64 $id = 'oe-' . $pid;
65 $pt = $client->requestResource($type, $id, ''); // gets latest version.
66 return $pt;
69 public function searchAction()
71 $pid = $this->getRequest(pid);
72 $type = $this->getRequest(type);
73 $client = new oeFHIRHttpClient();
74 $id = 'oe-' . $pid;
75 $pt = $client->requestResource($type, $id, 'search'); // gets latest version.
76 return $pt;