Demographics pnote completed button doesn't work (#4484)
[openemr.git] / _rest_routes.inc.php
blob0e0a565659198dc34ca23e70beb23386650c1791
1 <?php
3 /**
4 * Routes
5 * (All REST routes)
7 * @package OpenEMR
8 * @link http://www.open-emr.org
9 * @author Matthew Vita <matthewvita48@gmail.com>
10 * @author Jerry Padgett <sjpadgett@gmail.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @author Yash Raj Bothra <yashrajbothra786@gmail.com>
13 * @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
14 * @copyright Copyright (c) 2018-2020 Jerry Padgett <sjpadgett@gmail.com>
15 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
16 * @copyright Copyright (c) 2020 Yash Raj Bothra <yashrajbothra786@gmail.com>
17 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 // Lets keep our controller classes with the routes.
22 use OpenEMR\Common\Acl\AccessDeniedException;
23 use OpenEMR\Common\Http\HttpRestRequest;
24 use OpenEMR\RestControllers\AllergyIntoleranceRestController;
25 use OpenEMR\RestControllers\FacilityRestController;
26 use OpenEMR\RestControllers\VersionRestController;
27 use OpenEMR\RestControllers\ProductRegistrationRestController;
28 use OpenEMR\RestControllers\PatientRestController;
29 use OpenEMR\RestControllers\EncounterRestController;
30 use OpenEMR\RestControllers\PractitionerRestController;
31 use OpenEMR\RestControllers\ListRestController;
32 use OpenEMR\RestControllers\InsuranceCompanyRestController;
33 use OpenEMR\RestControllers\AppointmentRestController;
34 use OpenEMR\RestControllers\ConditionRestController;
35 use OpenEMR\RestControllers\ONoteRestController;
36 use OpenEMR\RestControllers\DocumentRestController;
37 use OpenEMR\RestControllers\DrugRestController;
38 use OpenEMR\RestControllers\ImmunizationRestController;
39 use OpenEMR\RestControllers\InsuranceRestController;
40 use OpenEMR\RestControllers\MessageRestController;
41 use OpenEMR\RestControllers\PrescriptionRestController;
42 use OpenEMR\RestControllers\ProcedureRestController;
44 // Note some Http clients may not send auth as json so a function
45 // is implemented to determine and parse encoding on auth route's.
47 // Note that the api route is only for users role
48 // (there is a mechanism in place to ensure only user role can access the api route)
49 RestConfig::$ROUTE_MAP = array(
50 "GET /api/facility" => function () {
51 RestConfig::authorization_check("admin", "users");
52 $return = (new FacilityRestController())->getAll($_GET);
53 RestConfig::apiLog($return);
54 return $return;
56 "GET /api/facility/:fuuid" => function ($fuuid) {
57 RestConfig::authorization_check("admin", "users");
58 $return = (new FacilityRestController())->getOne($fuuid);
59 RestConfig::apiLog($return);
60 return $return;
62 "POST /api/facility" => function () {
63 RestConfig::authorization_check("admin", "super");
64 $data = (array) (json_decode(file_get_contents("php://input")));
65 $return = (new FacilityRestController())->post($data);
66 RestConfig::apiLog($return, $data);
67 return $return;
69 "PUT /api/facility/:fuuid" => function ($fuuid) {
70 RestConfig::authorization_check("admin", "super");
71 $data = (array) (json_decode(file_get_contents("php://input")));
72 $return = (new FacilityRestController())->patch($fuuid, $data);
73 RestConfig::apiLog($return, $data);
74 return $return;
76 "GET /api/patient" => function () {
77 RestConfig::authorization_check("patients", "demo");
78 $return = (new PatientRestController())->getAll($_GET);
79 RestConfig::apiLog($return);
80 return $return;
82 "POST /api/patient" => function () {
83 RestConfig::authorization_check("patients", "demo");
84 $data = (array) (json_decode(file_get_contents("php://input")));
85 $return = (new PatientRestController())->post($data);
86 RestConfig::apiLog($return, $data);
87 return $return;
89 "PUT /api/patient/:puuid" => function ($puuid) {
90 RestConfig::authorization_check("patients", "demo");
91 $data = (array) (json_decode(file_get_contents("php://input")));
92 $return = (new PatientRestController())->put($puuid, $data);
93 RestConfig::apiLog($return, $data);
94 return $return;
96 "GET /api/patient/:puuid" => function ($puuid) {
97 RestConfig::authorization_check("patients", "demo");
98 $return = (new PatientRestController())->getOne($puuid);
99 RestConfig::apiLog($return);
100 return $return;
102 "GET /api/patient/:puuid/encounter" => function ($puuid) {
103 RestConfig::authorization_check("encounters", "auth_a");
104 $return = (new EncounterRestController())->getAll($puuid);
105 RestConfig::apiLog($return);
106 return $return;
108 "POST /api/patient/:puuid/encounter" => function ($puuid) {
109 RestConfig::authorization_check("encounters", "auth_a");
110 $data = (array) (json_decode(file_get_contents("php://input")));
111 $return = (new EncounterRestController())->post($puuid, $data);
112 RestConfig::apiLog($return, $data);
113 return $return;
115 "PUT /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
116 RestConfig::authorization_check("encounters", "auth_a");
117 $data = (array) (json_decode(file_get_contents("php://input")));
118 $return = (new EncounterRestController())->put($puuid, $euuid, $data);
119 RestConfig::apiLog($return, $data);
120 return $return;
122 "GET /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
123 RestConfig::authorization_check("encounters", "auth_a");
124 $return = (new EncounterRestController())->getOne($puuid, $euuid);
125 RestConfig::apiLog($return);
126 return $return;
128 "GET /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
129 RestConfig::authorization_check("encounters", "notes");
130 $return = (new EncounterRestController())->getSoapNotes($pid, $eid);
131 RestConfig::apiLog($return);
132 return $return;
134 "POST /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
135 RestConfig::authorization_check("encounters", "notes");
136 $data = (array) (json_decode(file_get_contents("php://input")));
137 $return = (new EncounterRestController())->postVital($pid, $eid, $data);
138 RestConfig::apiLog($return, $data);
139 return $return;
141 "PUT /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
142 RestConfig::authorization_check("encounters", "notes");
143 $data = (array) (json_decode(file_get_contents("php://input")));
144 $return = (new EncounterRestController())->putVital($pid, $eid, $vid, $data);
145 RestConfig::apiLog($return, $data);
146 return $return;
148 "GET /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
149 RestConfig::authorization_check("encounters", "notes");
150 $return = (new EncounterRestController())->getVitals($pid, $eid);
151 RestConfig::apiLog($return);
152 return $return;
154 "GET /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
155 RestConfig::authorization_check("encounters", "notes");
156 $return = (new EncounterRestController())->getVital($pid, $eid, $vid);
157 RestConfig::apiLog($return);
158 return $return;
160 "GET /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
161 RestConfig::authorization_check("encounters", "notes");
162 $return = (new EncounterRestController())->getSoapNote($pid, $eid, $sid);
163 RestConfig::apiLog($return);
164 return $return;
166 "POST /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
167 RestConfig::authorization_check("encounters", "notes");
168 $data = (array) (json_decode(file_get_contents("php://input")));
169 $return = (new EncounterRestController())->postSoapNote($pid, $eid, $data);
170 RestConfig::apiLog($return, $data);
171 return $return;
173 "PUT /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
174 RestConfig::authorization_check("encounters", "notes");
175 $data = (array) (json_decode(file_get_contents("php://input")));
176 $return = (new EncounterRestController())->putSoapNote($pid, $eid, $sid, $data);
177 RestConfig::apiLog($return, $data);
178 return $return;
180 "GET /api/practitioner" => function () {
181 RestConfig::authorization_check("admin", "users");
182 $return = (new PractitionerRestController())->getAll($_GET);
183 RestConfig::apiLog($return);
184 return $return;
186 "GET /api/practitioner/:prid" => function ($prid) {
187 RestConfig::authorization_check("admin", "users");
188 $return = (new PractitionerRestController())->getOne($prid);
189 RestConfig::apiLog($return);
190 return $return;
192 "POST /api/practitioner" => function () {
193 RestConfig::authorization_check("admin", "users");
194 $data = (array) (json_decode(file_get_contents("php://input")));
195 $return = (new PractitionerRestController())->post($data);
196 RestConfig::apiLog($return, $data);
197 return $return;
199 "PUT /api/practitioner/:prid" => function ($prid) {
200 RestConfig::authorization_check("admin", "users");
201 $data = (array) (json_decode(file_get_contents("php://input")));
202 $return = (new PractitionerRestController())->patch($prid, $data);
203 RestConfig::apiLog($return, $data);
204 return $return;
206 "GET /api/medical_problem" => function () {
207 RestConfig::authorization_check("encounters", "notes");
208 $return = (new ConditionRestController())->getAll();
209 RestConfig::apiLog($return);
210 return $return;
212 "GET /api/medical_problem/:muuid" => function ($muuid) {
213 RestConfig::authorization_check("encounters", "notes");
214 $return = (new ConditionRestController())->getOne($muuid);
215 RestConfig::apiLog($return);
216 return $return;
218 "GET /api/patient/:puuid/medical_problem" => function ($puuid) {
219 RestConfig::authorization_check("encounters", "notes");
220 $return = (new ConditionRestController())->getAll($puuid, "medical_problem");
221 RestConfig::apiLog($return);
222 return $return;
224 "GET /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
225 RestConfig::authorization_check("patients", "med");
226 $return = (new ConditionRestController())->getAll(['puuid' => $puuid, 'condition_uuid' => $muuid]);
227 RestConfig::apiLog($return);
228 return $return;
230 "POST /api/patient/:puuid/medical_problem" => function ($puuid) {
231 RestConfig::authorization_check("patients", "med");
232 $data = (array) (json_decode(file_get_contents("php://input")));
233 $return = (new ConditionRestController())->post($puuid, $data);
234 RestConfig::apiLog($return, $data);
235 return $return;
237 "PUT /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
238 RestConfig::authorization_check("patients", "med");
239 $data = (array) (json_decode(file_get_contents("php://input")));
240 $return = (new ConditionRestController())->put($puuid, $muuid, $data);
241 RestConfig::apiLog($return, $data);
242 return $return;
244 "DELETE /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
245 RestConfig::authorization_check("patients", "med");
246 $return = (new ConditionRestController())->delete($puuid, $muuid);
247 RestConfig::apiLog($return);
248 return $return;
250 "GET /api/allergy" => function () {
251 RestConfig::authorization_check("patients", "med");
252 $return = (new AllergyIntoleranceRestController())->getAll();
253 RestConfig::apiLog($return);
254 return $return;
256 "GET /api/allergy/:auuid" => function ($auuid) {
257 RestConfig::authorization_check("patients", "med");
258 $return = (new AllergyIntoleranceRestController())->getOne($auuid);
259 RestConfig::apiLog($return);
260 return $return;
262 "GET /api/patient/:puuid/allergy" => function ($puuid) {
263 RestConfig::authorization_check("patients", "med");
264 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid]);
265 RestConfig::apiLog($return);
266 return $return;
268 "GET /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
269 RestConfig::authorization_check("patients", "med");
270 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid, 'lists.id' => $auuid]);
271 RestConfig::apiLog($return);
272 return $return;
274 "POST /api/patient/:puuid/allergy" => function ($puuid) {
275 RestConfig::authorization_check("patients", "med");
276 $data = (array) (json_decode(file_get_contents("php://input")));
277 $return = (new AllergyIntoleranceRestController())->post($puuid, $data);
278 RestConfig::apiLog($return, $data);
279 return $return;
281 "PUT /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
282 RestConfig::authorization_check("patients", "med");
283 $data = (array) (json_decode(file_get_contents("php://input")));
284 $return = (new AllergyIntoleranceRestController())->put($puuid, $auuid, $data);
285 RestConfig::apiLog($return, $data);
286 return $return;
288 "DELETE /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
289 RestConfig::authorization_check("patients", "med");
290 $return = (new AllergyIntoleranceRestController())->delete($puuid, $auuid);
291 RestConfig::apiLog($return);
292 return $return;
294 "GET /api/patient/:pid/medication" => function ($pid) {
295 RestConfig::authorization_check("patients", "med");
296 $return = (new ListRestController())->getAll($pid, "medication");
297 RestConfig::apiLog($return);
298 return $return;
300 "POST /api/patient/:pid/medication" => function ($pid) {
301 RestConfig::authorization_check("patients", "med");
302 $data = (array) (json_decode(file_get_contents("php://input")));
303 $return = (new ListRestController())->post($pid, "medication", $data);
304 RestConfig::apiLog($return, $data);
305 return $return;
307 "PUT /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
308 RestConfig::authorization_check("patients", "med");
309 $data = (array) (json_decode(file_get_contents("php://input")));
310 $return = (new ListRestController())->put($pid, $mid, "medication", $data);
311 RestConfig::apiLog($return, $data);
312 return $return;
314 "GET /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
315 RestConfig::authorization_check("patients", "med");
316 $return = (new ListRestController())->getOne($pid, "medication", $mid);
317 RestConfig::apiLog($return);
318 return $return;
320 "DELETE /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
321 RestConfig::authorization_check("patients", "med");
322 $return = (new ListRestController())->delete($pid, $mid, "medication");
323 RestConfig::apiLog($return);
324 return $return;
326 "GET /api/patient/:pid/surgery" => function ($pid) {
327 RestConfig::authorization_check("patients", "med");
328 $return = (new ListRestController())->getAll($pid, "surgery");
329 RestConfig::apiLog($return);
330 return $return;
332 "GET /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
333 RestConfig::authorization_check("patients", "med");
334 $return = (new ListRestController())->getOne($pid, "surgery", $sid);
335 RestConfig::apiLog($return);
336 return $return;
338 "DELETE /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
339 RestConfig::authorization_check("patients", "med");
340 $return = (new ListRestController())->delete($pid, $sid, "surgery");
341 RestConfig::apiLog($return);
342 return $return;
344 "POST /api/patient/:pid/surgery" => function ($pid) {
345 RestConfig::authorization_check("patients", "med");
346 $data = (array) (json_decode(file_get_contents("php://input")));
347 $return = (new ListRestController())->post($pid, "surgery", $data);
348 RestConfig::apiLog($return, $data);
349 return $return;
351 "PUT /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
352 RestConfig::authorization_check("patients", "med");
353 $data = (array) (json_decode(file_get_contents("php://input")));
354 $return = (new ListRestController())->put($pid, $sid, "surgery", $data);
355 RestConfig::apiLog($return, $data);
356 return $return;
358 "GET /api/patient/:pid/dental_issue" => function ($pid) {
359 RestConfig::authorization_check("patients", "med");
360 $return = (new ListRestController())->getAll($pid, "dental");
361 RestConfig::apiLog($return);
362 return $return;
364 "GET /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
365 RestConfig::authorization_check("patients", "med");
366 $return = (new ListRestController())->getOne($pid, "dental", $did);
367 RestConfig::apiLog($return);
368 return $return;
370 "DELETE /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
371 RestConfig::authorization_check("patients", "med");
372 $return = (new ListRestController())->delete($pid, $did, "dental");
373 RestConfig::apiLog($return);
374 return $return;
376 "POST /api/patient/:pid/dental_issue" => function ($pid) {
377 RestConfig::authorization_check("patients", "med");
378 $data = (array) (json_decode(file_get_contents("php://input")));
379 $return = (new ListRestController())->post($pid, "dental", $data);
380 RestConfig::apiLog($return, $data);
381 return $return;
383 "PUT /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
384 RestConfig::authorization_check("patients", "med");
385 $data = (array) (json_decode(file_get_contents("php://input")));
386 $return = (new ListRestController())->put($pid, $did, "dental", $data);
387 RestConfig::apiLog($return, $data);
388 return $return;
390 "GET /api/patient/:pid/appointment" => function ($pid) {
391 RestConfig::authorization_check("patients", "appt");
392 $return = (new AppointmentRestController())->getAllForPatient($pid);
393 RestConfig::apiLog($return);
394 return $return;
396 "POST /api/patient/:pid/appointment" => function ($pid) {
397 RestConfig::authorization_check("patients", "appt");
398 $data = (array) (json_decode(file_get_contents("php://input")));
399 $return = (new AppointmentRestController())->post($pid, $data);
400 RestConfig::apiLog($return, $data);
401 return $return;
403 "GET /api/appointment" => function () {
404 RestConfig::authorization_check("patients", "appt");
405 $return = (new AppointmentRestController())->getAll();
406 RestConfig::apiLog($return);
407 return $return;
409 "GET /api/appointment/:eid" => function ($eid) {
410 RestConfig::authorization_check("patients", "appt");
411 $return = (new AppointmentRestController())->getOne($eid);
412 RestConfig::apiLog($return);
413 return $return;
415 "DELETE /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
416 RestConfig::authorization_check("patients", "appt");
417 $return = (new AppointmentRestController())->delete($eid);
418 RestConfig::apiLog($return);
419 return $return;
421 "GET /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
422 RestConfig::authorization_check("patients", "appt");
423 $return = (new AppointmentRestController())->getOne($eid);
424 RestConfig::apiLog($return);
425 return $return;
427 "GET /api/list/:list_name" => function ($list_name) {
428 RestConfig::authorization_check("lists", "default");
429 $return = (new ListRestController())->getOptions($list_name);
430 RestConfig::apiLog($return);
431 return $return;
433 "GET /api/version" => function () {
434 $return = (new VersionRestController())->getOne();
435 RestConfig::apiLog($return);
436 return $return;
438 "GET /api/product" => function () {
439 $return = (new ProductRegistrationRestController())->getOne();
440 RestConfig::apiLog($return);
441 return $return;
443 "GET /api/insurance_company" => function () {
444 $return = (new InsuranceCompanyRestController())->getAll();
445 RestConfig::apiLog($return);
446 return $return;
448 "GET /api/insurance_company/:iid" => function ($iid) {
449 $return = (new InsuranceCompanyRestController())->getOne($iid);
450 RestConfig::apiLog($return);
451 return $return;
453 "GET /api/insurance_type" => function () {
454 $return = (new InsuranceCompanyRestController())->getInsuranceTypes();
455 RestConfig::apiLog($return);
456 return $return;
458 "POST /api/insurance_company" => function () {
459 $data = (array) (json_decode(file_get_contents("php://input")));
460 $return = (new InsuranceCompanyRestController())->post($data);
461 RestConfig::apiLog($return, $data);
462 return $return;
464 "PUT /api/insurance_company/:iid" => function ($iid) {
465 $data = (array) (json_decode(file_get_contents("php://input")));
466 $return = (new InsuranceCompanyRestController())->put($iid, $data);
467 RestConfig::apiLog($return, $data);
468 return $return;
470 "POST /api/patient/:pid/document" => function ($pid) {
471 $return = (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
472 RestConfig::apiLog($return);
473 return $return;
475 "GET /api/patient/:pid/document" => function ($pid) {
476 $return = (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
477 RestConfig::apiLog($return);
478 return $return;
480 "GET /api/patient/:pid/document/:did" => function ($pid, $did) {
481 $return = (new DocumentRestController())->downloadFile($pid, $did);
482 RestConfig::apiLog($return);
483 return $return;
485 "GET /api/patient/:pid/insurance" => function ($pid) {
486 $return = (new InsuranceRestController())->getAll($pid);
487 RestConfig::apiLog($return);
488 return $return;
490 "GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
491 $return = (new InsuranceRestController())->getOne($pid, $type);
492 RestConfig::apiLog($return);
493 return $return;
495 "POST /api/patient/:pid/insurance/:type" => function ($pid, $type) {
496 $data = (array) (json_decode(file_get_contents("php://input")));
497 $return = (new InsuranceRestController())->post($pid, $type, $data);
498 RestConfig::apiLog($return, $data);
499 return $return;
501 "PUT /api/patient/:pid/insurance/:type" => function ($pid, $type) {
502 $data = (array) (json_decode(file_get_contents("php://input")));
503 $return = (new InsuranceRestController())->put($pid, $type, $data);
504 RestConfig::apiLog($return, $data);
505 return $return;
507 "POST /api/patient/:pid/message" => function ($pid) {
508 RestConfig::authorization_check("patients", "notes");
509 $data = (array) (json_decode(file_get_contents("php://input")));
510 $return = (new MessageRestController())->post($pid, $data);
511 RestConfig::apiLog($return, $data);
512 return $return;
514 "PUT /api/patient/:pid/message/:mid" => function ($pid, $mid) {
515 RestConfig::authorization_check("patients", "notes");
516 $data = (array) (json_decode(file_get_contents("php://input")));
517 $return = (new MessageRestController())->put($pid, $mid, $data);
518 RestConfig::apiLog($return, $data);
519 return $return;
521 "DELETE /api/patient/:pid/message/:mid" => function ($pid, $mid) {
522 RestConfig::authorization_check("patients", "notes");
523 $return = (new MessageRestController())->delete($pid, $mid);
524 RestConfig::apiLog($return);
525 return $return;
527 "GET /api/immunization" => function () {
528 RestConfig::authorization_check("patients", "med");
529 $return = (new ImmunizationRestController())->getAll($_GET);
530 RestConfig::apiLog($return);
531 return $return;
533 "GET /api/immunization/:uuid" => function ($uuid) {
534 RestConfig::authorization_check("patients", "med");
535 $return = (new ImmunizationRestController())->getOne($uuid);
536 RestConfig::apiLog($return);
537 return $return;
539 "GET /api/procedure" => function () {
540 RestConfig::authorization_check("patients", "med");
541 $return = (new ProcedureRestController())->getAll();
542 RestConfig::apiLog($return);
543 return $return;
545 "GET /api/procedure/:uuid" => function ($uuid) {
546 RestConfig::authorization_check("patients", "med");
547 $return = (new ProcedureRestController())->getOne($uuid);
548 RestConfig::apiLog($return);
549 return $return;
551 "GET /api/drug" => function () {
552 RestConfig::authorization_check("patients", "med");
553 $return = (new DrugRestController())->getAll();
554 RestConfig::apiLog($return);
555 return $return;
557 "GET /api/drug/:uuid" => function ($uuid) {
558 RestConfig::authorization_check("patients", "med");
559 $return = (new DrugRestController())->getOne($uuid);
560 RestConfig::apiLog($return);
561 return $return;
563 "GET /api/prescription" => function () {
564 RestConfig::authorization_check("patients", "med");
565 $return = (new PrescriptionRestController())->getAll();
566 RestConfig::apiLog($return);
567 return $return;
569 "GET /api/prescription/:uuid" => function ($uuid) {
570 RestConfig::authorization_check("patients", "med");
571 $return = (new PrescriptionRestController())->getOne($uuid);
572 RestConfig::apiLog($return);
573 return $return;
577 use OpenEMR\Common\Http\StatusCode;
578 use OpenEMR\Common\Http\Psr17Factory;
579 use OpenEMR\RestControllers\FHIR\FhirAllergyIntoleranceRestController;
580 use OpenEMR\RestControllers\FHIR\FhirCarePlanRestController;
581 use OpenEMR\RestControllers\FHIR\FhirCareTeamRestController;
582 use OpenEMR\RestControllers\FHIR\FhirConditionRestController;
583 use OpenEMR\RestControllers\FHIR\FhirCoverageRestController;
584 use OpenEMR\RestControllers\FHIR\FhirDeviceRestController;
585 use OpenEMR\RestControllers\FHIR\FhirDiagnosticReportRestController;
586 use OpenEMR\RestControllers\FHIR\FhirDocumentReferenceRestController;
587 use OpenEMR\RestControllers\FHIR\FhirEncounterRestController;
588 use OpenEMR\RestControllers\FHIR\FhirExportRestController;
589 use OpenEMR\RestControllers\FHIR\FhirObservationRestController;
590 use OpenEMR\RestControllers\FHIR\FhirImmunizationRestController;
591 use OpenEMR\RestControllers\FHIR\FhirGoalRestController;
592 use OpenEMR\RestControllers\FHIR\FhirLocationRestController;
593 use OpenEMR\RestControllers\FHIR\FhirMedicationRestController;
594 use OpenEMR\RestControllers\FHIR\FhirMedicationRequestRestController;
595 use OpenEMR\RestControllers\FHIR\FhirOrganizationRestController;
596 use OpenEMR\RestControllers\FHIR\FhirPatientRestController;
597 use OpenEMR\RestControllers\FHIR\FhirPersonRestController;
598 use OpenEMR\RestControllers\FHIR\FhirPractitionerRoleRestController;
599 use OpenEMR\RestControllers\FHIR\FhirPractitionerRestController;
600 use OpenEMR\RestControllers\FHIR\FhirProcedureRestController;
601 use OpenEMR\RestControllers\FHIR\FhirProvenanceRestController;
602 use OpenEMR\RestControllers\FHIR\FhirMetaDataRestController;
604 // Note that the fhir route includes both user role and patient role
605 // (there is a mechanism in place to ensure patient role is binded
606 // to only see the data of the one patient)
607 RestConfig::$FHIR_ROUTE_MAP = array(
608 "GET /fhir/AllergyIntolerance" => function (HttpRestRequest $request) {
609 $getParams = $request->getQueryParams();
610 if ($request->isPatientRequest()) {
611 // only allow access to data of binded patient
612 $return = (new FhirAllergyIntoleranceRestController($request))->getAll($getParams, $request->getPatientUUIDString());
613 } else {
614 RestConfig::authorization_check("patients", "med");
615 $return = (new FhirAllergyIntoleranceRestController($request))->getAll($getParams);
617 RestConfig::apiLog($return);
618 return $return;
620 "GET /fhir/AllergyIntolerance/:id" => function ($id, HttpRestRequest $request) {
621 if ($request->isPatientRequest()) {
622 // only allow access to data of binded patient
623 $return = (new FhirAllergyIntoleranceRestController($request))->getOne($id, $request->getPatientUUIDString());
624 } else {
625 RestConfig::authorization_check("patients", "med");
626 $return = (new FhirAllergyIntoleranceRestController($request))->getOne($id);
628 RestConfig::apiLog($return);
629 return $return;
630 },"GET /fhir/CarePlan" => function (HttpRestRequest $request) {
631 $getParams = $request->getQueryParams();
632 if ($request->isPatientRequest()) {
633 // only allow access to data of binded patient
634 $return = (new FhirCarePlanRestController())->getAll($getParams, $request->getPatientUUIDString());
635 } else {
636 RestConfig::authorization_check("patients", "med");
637 $return = (new FhirCareTeamRestController())->getAll($getParams);
639 RestConfig::apiLog($return);
640 return $return;
642 "GET /fhir/CarePlan/:uuid" => function ($uuid, HttpRestRequest $request) {
643 if ($request->isPatientRequest()) {
644 // only allow access to data of binded patient
645 $return = (new FhirCarePlanRestController())->getOne($uuid, $request->getPatientUUIDString());
646 } else {
647 RestConfig::authorization_check("patients", "med");
648 $return = (new FhirCarePlanRestController())->getOne($uuid);
650 RestConfig::apiLog($return);
651 return $return;
653 "GET /fhir/CareTeam" => function (HttpRestRequest $request) {
654 $getParams = $request->getQueryParams();
655 if ($request->isPatientRequest()) {
656 // only allow access to data of binded patient
657 $return = (new FhirCareTeamRestController())->getAll($getParams, $request->getPatientUUIDString());
658 } else {
659 RestConfig::authorization_check("patients", "med");
660 $return = (new FhirCareTeamRestController())->getAll($getParams);
662 RestConfig::apiLog($return);
663 return $return;
665 "GET /fhir/CareTeam/:uuid" => function ($uuid, HttpRestRequest $request) {
666 if ($request->isPatientRequest()) {
667 // only allow access to data of binded patient
668 $return = (new FhirCareTeamRestController())->getOne($uuid, $request->getPatientUUIDString());
669 } else {
670 RestConfig::authorization_check("patients", "med");
671 $return = (new FhirCareTeamRestController())->getOne($uuid);
673 RestConfig::apiLog($return);
674 return $return;
676 "GET /fhir/Condition" => function (HttpRestRequest $request) {
677 $getParams = $request->getQueryParams();
678 if ($request->isPatientRequest()) {
679 // only allow access to data of binded patient
680 $return = (new FhirConditionRestController())->getAll($getParams, $request->getPatientUUIDString());
681 } else {
682 RestConfig::authorization_check("patients", "med");
683 $return = (new FhirConditionRestController())->getAll($getParams);
685 RestConfig::apiLog($return);
686 return $return;
688 "GET /fhir/Condition/:id" => function ($uuid, HttpRestRequest $request) {
689 if ($request->isPatientRequest()) {
690 // only allow access to data of binded patient
691 $return = (new FhirConditionRestController())->getOne($uuid, $request->getPatientUUIDString());
692 } else {
693 RestConfig::authorization_check("patients", "med");
694 $return = (new FhirConditionRestController())->getOne($uuid);
696 RestConfig::apiLog($return);
697 return $return;
699 "GET /fhir/Coverage" => function (HttpRestRequest $request) {
700 RestConfig::authorization_check("admin", "super");
701 $return = (new FhirCoverageRestController())->getAll($request->getQueryParams());
702 RestConfig::apiLog($return);
703 return $return;
705 "GET /fhir/Coverage/:uuid" => function ($uuid, HttpRestRequest $request) {
706 RestConfig::authorization_check("admin", "super");
707 $return = (new FhirCoverageRestController())->getOne($uuid);
708 RestConfig::apiLog($return);
709 return $return;
711 "GET /fhir/Device" => function (HttpRestRequest $request) {
712 if ($request->isPatientRequest()) {
713 // only allow access to data of binded patient
714 $return = (new FhirDeviceRestController())->getAll($request->getQueryParams(), $request->getPatientUUIDString());
715 } else {
716 RestConfig::authorization_check("admin", "super");
717 $return = (new FhirEncounterRestController())->getAll($request->getQueryParams());
719 RestConfig::apiLog($return);
720 return $return;
722 "GET /fhir/Device/:uuid" => function ($uuid, HttpRestRequest $request) {
723 if ($request->isPatientRequest()) {
724 // only allow access to data of binded patient
725 $return = (new FhirDeviceRestController())->getOne($uuid, $request->getPatientUUIDString());
726 } else {
727 RestConfig::authorization_check("admin", "super");
728 $return = (new FhirEncounterRestController())->getOne($request->getQueryParams());
730 RestConfig::apiLog($return);
731 return $return;
733 "GET /fhir/DiagnosticReport" => function (HttpRestRequest $request) {
734 RestConfig::authorization_check("admin", "super");
735 $return = (new FhirDiagnosticReportRestController())->getAll($request->getQueryParams());
736 RestConfig::apiLog($return);
737 return $return;
739 "GET /fhir/DiagnosticReport/:uuid" => function ($uuid, HttpRestRequest $request) {
740 RestConfig::authorization_check("admin", "super");
741 $return = (new FhirDiagnosticReportRestController())->getOne($uuid);
742 RestConfig::apiLog($return);
743 return $return;
745 'GET /fhir/DocumentReference' => function (HttpRestRequest $request) {
746 RestConfig::authorization_check("admin", "super");
747 $return = (new FhirDocumentReferenceRestController())->getAll($request->getQueryParams());
748 RestConfig::apiLog($return);
749 return $return;
751 "GET /fhir/DocumentReference/:uuid" => function ($uuid, HttpRestRequest $request) {
752 RestConfig::authorization_check("admin", "super");
753 $return = (new FhirDocumentReferenceRestController())->getOne($uuid);
754 RestConfig::apiLog($return);
755 return $return;
757 'GET /fhir/Document/:id/Binary' => function ($documentId, HttpRestRequest $request) {
758 // currently only allow users with the same permissions as export to take a file out
759 // this could be relaxed to allow other types of files ie such as patient access etc.
760 RestConfig::authorization_check("admin", "users");
762 // Grab the document id
763 $docController = new \OpenEMR\RestControllers\FHIR\FhirDocumentRestController($request);
764 $response = $docController->downloadDocument($documentId, $request->getRequestUserId());
765 return $response;
767 "GET /fhir/Encounter" => function (HttpRestRequest $request) {
768 $getParams = $request->getQueryParams();
769 if ($request->isPatientRequest()) {
770 // only allow access to data of binded patient
771 $return = (new FhirEncounterRestController())->getAll($getParams, $request->getPatientUUIDString());
772 } else {
773 RestConfig::authorization_check("encounters", "auth_a");
774 $return = (new FhirEncounterRestController())->getAll($getParams);
776 RestConfig::apiLog($return);
777 return $return;
779 "GET /fhir/Encounter/:id" => function ($id, HttpRestRequest $request) {
780 if ($request->isPatientRequest()) {
781 // only allow access to data of binded patient
782 $return = (new FhirEncounterRestController())->getOne($id, $request->getPatientUUIDString());
783 } else {
784 RestConfig::authorization_check("admin", "super");
785 $return = (new FhirEncounterRestController())->getOne($id);
787 RestConfig::apiLog($return);
788 return $return;
790 "GET /fhir/Goal" => function (HttpRestRequest $request) {
791 $getParams = $request->getQueryParams();
792 if ($request->isPatientRequest()) {
793 // only allow access to data of binded patient
794 $return = (new FhirGoalRestController())->getAll($getParams, $request->getPatientUUIDString());
795 } else {
796 RestConfig::authorization_check("admin", "super");
797 $return = (new FhirGoalRestController())->getAll($getParams);
799 RestConfig::apiLog($return);
800 return $return;
802 "GET /fhir/Goal/:id" => function ($id, HttpRestRequest $request) {
803 if ($request->isPatientRequest()) {
804 // only allow access to data of binded patient
805 $return = (new FhirGoalRestController())->getOne($id, $request->getPatientUUIDString());
806 } else {
807 RestConfig::authorization_check("admin", "super");
808 $return = (new FhirGoalRestController())->getOne($id);
810 RestConfig::apiLog($return);
811 return $return;
814 'GET /fhir/Group/:id/$export' => function ($groupId, HttpRestRequest $request) {
815 RestConfig::authorization_check("admin", "users");
816 $fhirExportService = new FhirExportRestController($request);
817 $exportParams = $request->getQueryParams();
818 $exportParams['groupId'] = $groupId;
819 $return = $fhirExportService->processExport(
820 $exportParams,
821 'Group',
822 $request->getHeader('Accept'),
823 $request->getHeader('Prefer')
825 RestConfig::apiLog($return);
826 return $return;
828 "GET /fhir/Immunization" => function (HttpRestRequest $request) {
829 $getParams = $request->getQueryParams();
830 if ($request->isPatientRequest()) {
831 // only allow access to data of binded patient
832 $return = (new FhirImmunizationRestController())->getAll($getParams, $request->getPatientUUIDString());
833 } else {
834 RestConfig::authorization_check("patients", "med");
835 $return = (new FhirImmunizationRestController())->getAll($getParams);
837 RestConfig::apiLog($return);
838 return $return;
840 "GET /fhir/Immunization/:id" => function ($id, HttpRestRequest $request) {
841 if ($request->isPatientRequest()) {
842 // only allow access to data of binded patient
843 $return = (new FhirImmunizationRestController())->getOne($id, $request->getPatientUUIDString());
844 } else {
845 RestConfig::authorization_check("patients", "med");
846 $return = (new FhirImmunizationRestController())->getOne($id);
848 RestConfig::apiLog($return);
849 return $return;
851 "GET /fhir/Location" => function (HttpRestRequest $request) {
852 RestConfig::authorization_check("patients", "med");
853 $return = (new FhirLocationRestController())->getAll($request->getQueryParams());
854 RestConfig::apiLog($return);
855 return $return;
857 "GET /fhir/Location/:uuid" => function ($uuid, HttpRestRequest $request) {
858 RestConfig::authorization_check("patients", "med");
859 $return = (new FhirLocationRestController())->getOne($uuid);
860 RestConfig::apiLog($return);
861 return $return;
863 "GET /fhir/Medication" => function (HttpRestRequest $request) {
864 RestConfig::authorization_check("patients", "med");
865 $return = (new FhirMedicationRestController())->getAll($request->getQueryParams());
866 RestConfig::apiLog($return);
867 return $return;
869 "GET /fhir/Medication/:uuid" => function ($uuid, HttpRestRequest $request) {
870 RestConfig::authorization_check("patients", "med");
871 $return = (new FhirMedicationRestController())->getOne($uuid);
872 RestConfig::apiLog($return);
873 return $return;
875 "GET /fhir/MedicationRequest" => function (HttpRestRequest $request) {
876 $getParams = $request->getQueryParams();
877 if ($request->isPatientRequest()) {
878 // only allow access to data of binded patient
879 $return = (new FhirMedicationRequestRestController())->getAll($getParams, $request->getPatientUUIDString());
880 } else {
881 RestConfig::authorization_check("patients", "med");
882 $return = (new FhirMedicationRequestRestController())->getAll($getParams);
884 RestConfig::apiLog($return);
885 return $return;
887 "GET /fhir/MedicationRequest/:uuid" => function ($uuid, HttpRestRequest $request) {
888 if ($request->isPatientRequest()) {
889 // only allow access to data of binded patient
890 $return = (new FhirMedicationRequestRestController())->getOne($uuid, $request->getPatientUUIDString());
891 } else {
892 RestConfig::authorization_check("patients", "med");
893 $return = (new FhirMedicationRequestRestController())->getOne($uuid);
895 RestConfig::apiLog($return);
896 return $return;
898 "GET /fhir/Organization" => function (HttpRestRequest $request) {
899 if (!$request->isPatientRequest()) {
900 RestConfig::authorization_check("admin", "users");
902 $return = (new FhirOrganizationRestController())->getAll($request->getQueryParams());
903 RestConfig::apiLog($return);
904 return $return;
906 "GET /fhir/Organization/:id" => function ($id, HttpRestRequest $request) {
907 $patientUUID = null;
908 if (!$request->isPatientRequest()) {
909 RestConfig::authorization_check("admin", "users");
910 } else {
911 $patientUUID = $request->getPatientUUIDString();
913 $return = (new FhirOrganizationRestController())->getOne($id, $patientUUID);
915 RestConfig::apiLog($return);
916 return $return;
918 "POST /fhir/Organization" => function (HttpRestRequest $request) {
919 RestConfig::authorization_check("admin", "super");
920 $data = (array) (json_decode(file_get_contents("php://input"), true));
921 $return = (new FhirOrganizationRestController())->post($data);
922 RestConfig::apiLog($return, $data);
923 return $return;
925 "PUT /fhir/Organization/:id" => function ($id, HttpRestRequest $request) {
926 RestConfig::authorization_check("admin", "super");
927 $data = (array) (json_decode(file_get_contents("php://input"), true));
928 $return = (new FhirOrganizationRestController())->patch($id, $data);
929 RestConfig::apiLog($return, $data);
930 return $return;
932 "GET /fhir/Observation" => function (HttpRestRequest $request) {
933 $getParams = $request->getQueryParams();
934 if ($request->isPatientRequest()) {
935 // only allow access to data of binded patient
936 $return = (new FhirObservationRestController())->getAll($getParams, $request->getPatientUUIDString());
937 } else {
938 RestConfig::authorization_check("patients", "med");
939 $return = (new FhirObservationRestController())->getAll($getParams);
941 RestConfig::apiLog($return);
942 return $return;
944 "GET /fhir/Observation/:uuid" => function ($uuid, HttpRestRequest $request) {
945 if ($request->isPatientRequest()) {
946 // only allow access to data of binded patient
947 $return = (new FhirObservationRestController())->getOne($uuid, $request->getPatientUUIDString());
948 } else {
949 RestConfig::authorization_check("patients", "med");
950 $return = (new FhirObservationRestController())->getOne($uuid);
952 RestConfig::apiLog($return);
953 return $return;
955 "POST /fhir/Patient" => function (HttpRestRequest $request) {
956 RestConfig::authorization_check("patients", "demo");
957 $data = (array) (json_decode(file_get_contents("php://input"), true));
958 $return = (new FhirPatientRestController())->post($data);
959 RestConfig::apiLog($return, $data);
960 return $return;
962 "PUT /fhir/Patient/:id" => function ($id, HttpRestRequest $request) {
963 RestConfig::authorization_check("patients", "demo");
964 $data = (array) (json_decode(file_get_contents("php://input"), true));
965 $return = (new FhirPatientRestController())->put($id, $data);
966 RestConfig::apiLog($return, $data);
967 return $return;
969 "GET /fhir/Patient" => function (HttpRestRequest $request) {
970 $params = $request->getQueryParams();
971 if ($request->isPatientRequest()) {
972 // only allow access to data of binded patient
973 // Note in Patient context still have to return a bundle even if it is just one resource. (ie.
974 // need to use getAll rather than getOne)
975 $params['_id'] = $request->getPatientUUIDString();
976 $return = (new FhirPatientRestController())->getAll($params, $request->getPatientUUIDString());
977 } else {
978 RestConfig::authorization_check("patients", "demo");
979 $return = (new FhirPatientRestController())->getAll($params);
981 RestConfig::apiLog($return);
982 return $return;
984 // we have to have the bulk fhir export operation here otherwise it will match $export to the patient $id
985 'GET /fhir/Patient/$export' => function (HttpRestRequest $request) {
986 RestConfig::authorization_check("admin", "users");
987 $fhirExportService = new FhirExportRestController($request);
988 $return = $fhirExportService->processExport(
989 $request->getQueryParams(),
990 'Patient',
991 $request->getHeader('Accept'),
992 $request->getHeader('Prefer')
994 RestConfig::apiLog($return);
995 return $return;
997 "GET /fhir/Patient/:id" => function ($id, HttpRestRequest $request) {
998 if ($request->isPatientRequest()) {
999 // only allow access to data of binded patient
1000 if (empty($id) || ($id != $request->getPatientUUIDString())) {
1001 throw new AccessDeniedException("patients", "demo", "patient id invalid");
1003 $id = $request->getPatientUUIDString();
1004 } else {
1005 RestConfig::authorization_check("patients", "demo");
1007 $return = (new FhirPatientRestController())->getOne($id);
1008 RestConfig::apiLog($return);
1009 return $return;
1011 "GET /fhir/Person" => function (HttpRestRequest $request) {
1012 RestConfig::authorization_check("admin", "users");
1013 $return = (new FhirPersonRestController())->getAll($request->getQueryParams());
1014 RestConfig::apiLog($return);
1015 return $return;
1017 "GET /fhir/Person/:uuid" => function ($uuid, HttpRestRequest $request) {
1018 RestConfig::authorization_check("admin", "users");
1019 $return = (new FhirPersonRestController())->getOne($uuid);
1020 RestConfig::apiLog($return);
1021 return $return;
1023 "GET /fhir/Practitioner" => function (HttpRestRequest $request) {
1025 // TODO: @adunsulag talk with brady.miller about patients needing access to any practitioner resource
1026 // that is referenced in connected patient resources -- such as AllergyIntollerance.
1027 // I don't believe patients are assigned to a particular practitioner
1028 // should we allow just open api access to admin information? Should we restrict particular pieces
1029 // of data in the practitioner side (phone number, address information) based on a permission set?
1030 if (!$request->isPatientRequest()) {
1031 RestConfig::authorization_check("admin", "users");
1033 $return = (new FhirPractitionerRestController())->getAll($request->getQueryParams());
1034 RestConfig::apiLog($return);
1035 return $return;
1037 "GET /fhir/Practitioner/:id" => function ($id, HttpRestRequest $request) {
1038 // TODO: @adunsulag talk with brady.miller about patients needing access to any practitioner resource
1039 // that is referenced in connected patient resources -- such as AllergyIntollerance.
1040 // I don't believe patients are assigned to a particular practitioner
1041 // should we allow just open api access to admin information? Should we restrict particular pieces
1042 // of data in the practitioner side (phone number, address information) based on a permission set?
1043 if (!$request->isPatientRequest()) {
1044 RestConfig::authorization_check("admin", "users");
1046 $return = (new FhirPractitionerRestController())->getOne($id);
1047 RestConfig::apiLog($return);
1048 return $return;
1050 "POST /fhir/Practitioner" => function (HttpRestRequest $request) {
1051 RestConfig::authorization_check("admin", "users");
1052 $data = (array) (json_decode(file_get_contents("php://input"), true));
1053 $return = (new FhirPractitionerRestController())->post($data);
1054 RestConfig::apiLog($return, $data);
1055 return $return;
1057 "PUT /fhir/Practitioner/:id" => function ($id, HttpRestRequest $request) {
1058 RestConfig::authorization_check("admin", "users");
1059 $data = (array) (json_decode(file_get_contents("php://input"), true));
1060 $return = (new FhirPractitionerRestController())->patch($id, $data);
1061 RestConfig::apiLog($return, $data);
1062 return $return;
1064 "GET /fhir/PractitionerRole" => function (HttpRestRequest $request) {
1065 RestConfig::authorization_check("admin", "users");
1066 $return = (new FhirPractitionerRoleRestController())->getAll($request->getQueryParams());
1067 RestConfig::apiLog($return);
1068 return $return;
1070 "GET /fhir/PractitionerRole/:id" => function ($id, HttpRestRequest $request) {
1071 RestConfig::authorization_check("admin", "users");
1072 $return = (new FhirPractitionerRoleRestController())->getOne($id);
1073 RestConfig::apiLog($return);
1074 return $return;
1076 "GET /fhir/Procedure" => function (HttpRestRequest $request) {
1077 if ($request->isPatientRequest()) {
1078 // only allow access to data of binded patient
1079 $return = (new FhirProcedureRestController())->getAll($request->getQueryParams(), $request->getPatientUUIDString());
1080 } else {
1081 RestConfig::authorization_check("patients", "med");
1082 $return = (new FhirProcedureRestController())->getAll($request->getQueryParams());
1084 RestConfig::apiLog($return);
1085 return $return;
1087 "GET /fhir/Procedure/:uuid" => function ($uuid, HttpRestRequest $request) {
1088 if ($request->isPatientRequest()) {
1089 // only allow access to data of binded patient
1090 $return = (new FhirProcedureRestController())->getOne($uuid, $request->getPatientUUIDString());
1091 } else {
1092 RestConfig::authorization_check("patients", "med");
1093 $return = (new FhirProcedureRestController())->getOne($uuid);
1095 RestConfig::apiLog($return);
1096 return $return;
1098 "GET /fhir/Provenance/:uuid" => function ($uuid, HttpRestRequest $request) {
1099 if ($request->isPatientRequest()) {
1100 // only allow access to data of binded patient
1101 $return = (new FhirProvenanceRestController())->getOne($uuid, $request->getPatientUUIDString());
1102 } else {
1103 RestConfig::authorization_check("admin", "super");
1104 $return = (new FhirProvenanceRestController())->getOne($uuid);
1106 RestConfig::apiLog($return);
1107 return $return;
1109 // other endpoints
1110 "GET /fhir/metadata" => function () {
1111 $return = (new FhirMetaDataRestController())->getMetaData();
1112 RestConfig::apiLog($return);
1113 return $return;
1115 "GET /fhir/.well-known/smart-configuration" => function () {
1116 $authController = new \OpenEMR\RestControllers\AuthorizationController();
1117 $return = (new \OpenEMR\RestControllers\SMART\SMARTConfigurationController($authController))->getConfig();
1118 RestConfig::apiLog($return);
1119 return $return;
1122 // FHIR root level operations
1123 'GET /fhir/$export' => function (HttpRestRequest $request) {
1124 RestConfig::authorization_check("admin", "users");
1125 $fhirExportService = new FhirExportRestController($request);
1126 $return = $fhirExportService->processExport(
1127 $request->getQueryParams(),
1128 'System',
1129 $request->getHeader('Accept'),
1130 $request->getHeader('Prefer')
1132 RestConfig::apiLog($return);
1133 return $return;
1135 // these two operations are adopted based on the documentation used in the IBM FHIR Server
1136 // we'd reference cerner or epic but we couldn't find any documentation about those (Jan 30th 2021)
1137 // @see https://ibm.github.io/FHIR/guides/FHIRBulkOperations/
1138 'GET /fhir/$bulkdata-status' => function (HttpRestRequest $request) {
1139 RestConfig::authorization_check("admin", "users");
1140 $jobUuidString = $request->getQueryParam('job');
1141 // if we were truly async we would return 202 here to say we are in progress with a JSON response
1142 // since OpenEMR data is so small we just return the JSON from the database
1143 $fhirExportService = new FhirExportRestController($request);
1144 $return = $fhirExportService->processExportStatusRequestForJob($jobUuidString);
1145 RestConfig::apiLog($return);
1146 return $return;
1148 'DELETE /fhir/$bulkdata-status' => function (HttpRestRequest $request) {
1149 RestConfig::authorization_check("admin", "users");
1150 $job = $request->getQueryParam('job');
1151 $fhirExportService = new FhirExportRestController($request);
1152 $return = $fhirExportService->processDeleteExportForJob($job);
1153 RestConfig::apiLog($return);
1154 return $return;
1158 // Note that the portal (api) route is only for patient role
1159 // (there is a mechanism in place to ensure only patient role can access the portal (api) route)
1160 RestConfig::$PORTAL_ROUTE_MAP = array(
1161 "GET /portal/patient" => function (HttpRestRequest $request) {
1162 $return = (new PatientRestController())->getOne($request->getPatientUUIDString());
1163 RestConfig::apiLog($return);
1164 return $return;
1166 "GET /portal/patient/encounter" => function (HttpRestRequest $request) {
1167 $return = (new EncounterRestController())->getAll($request->getPatientUUIDString());
1168 RestConfig::apiLog($return);
1169 return $return;
1171 "GET /portal/patient/encounter/:euuid" => function ($euuid, HttpRestRequest $request) {
1172 $return = (new EncounterRestController())->getOne($request->getPatientUUIDString(), $euuid);
1173 RestConfig::apiLog($return);
1174 return $return;