3 * clientController class
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\FetchLiveData
;
15 use oeFHIR\oeFHIRHttpClient
;
16 use oeFHIR\oeFHIRResource
;
18 class clientController
extends oeDispatchController
20 public function __construct()
22 parent
::__construct();
25 public function indexAction()
27 if (!$this->getSession('pid', '')) {
28 $pid = $this->getRequest('patient_id');
29 $this->setSession('pid', $pid);
31 $pid = $this->getSession('pid', '');
37 public function createEncounterAllAction()
39 $pid = $this->getRequest(pid
);
40 $oeid = $this->getRequest(oeid
);
41 $type = $this->getRequest(type
);
42 $fs = new FetchLiveData();
43 $oept = $fs->getEncounterIdList($pid);
45 foreach ($oept as $e) {
46 $client = new oeFHIRHttpClient();
47 $id = 'encounter-' . $e['encounter'];
48 $rs = new oeFHIRResource();
49 $r = $rs->createEncounterResource($pid, $id, $e['encounter']);
50 $pt = $client->sendResource($type, $id, $r);
51 $notify .= '<strong>Sent:</strong></br>' . $r . '</br>' . $pt;
56 public function createAction()
58 $pid = $this->getRequest(pid
);
59 $oeid = $this->getRequest(oeid
);
60 $type = $this->getRequest(type
);
61 $client = new oeFHIRHttpClient();
62 $id = strtolower($type) . '-' . $oeid;
63 $method = 'create' . $type . 'Resource';
64 $rs = new oeFHIRResource();
65 $r = $rs->$method($pid, $id);
66 $pt = $client->sendResource($type, $id, $r);
68 return '<strong>Sent:</strong></br>' . $r . '</br>' . $pt;
71 public function historyAction()
73 $pid = $this->getRequest(pid
);
74 $oeid = $this->getRequest(oeid
);
75 $type = $this->getRequest(type
);
76 $client = new oeFHIRHttpClient();
77 $id = strtolower($type) . '-' . $oeid;
78 $pt = $client->requestResource($type, $id, 'history');
82 public function readAction()
84 $pid = $this->getRequest(pid
);
85 $oeid = $this->getRequest(oeid
);
86 $type = $this->getRequest(type
);
87 $client = new oeFHIRHttpClient();
88 $id = strtolower($type) . '-' . $oeid;
89 $pt = $client->requestResource($type, $id, ''); // gets latest version.
93 public function searchAction()
95 $pid = $this->getRequest(pid
);
96 $type = $this->getRequest(type
);
97 if ($type === 'Patient') {
98 return xlt('Search Not Available');
100 $client = new oeFHIRHttpClient();
101 $id = 'patient-' . $pid;
102 $pt = $client->searchResource($type, $id, 'search');