E2E test case adding a new system user (#4026)
[openemr.git] / _rest_routes.inc.php
blob58b058c7afc77449f189f3e72792118ac9a9f928
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\Uuid\UuidRegistry;
23 use OpenEMR\RestControllers\AllergyIntoleranceRestController;
24 use OpenEMR\RestControllers\FacilityRestController;
25 use OpenEMR\RestControllers\VersionRestController;
26 use OpenEMR\RestControllers\ProductRegistrationRestController;
27 use OpenEMR\RestControllers\PatientRestController;
28 use OpenEMR\RestControllers\EncounterRestController;
29 use OpenEMR\RestControllers\PractitionerRestController;
30 use OpenEMR\RestControllers\ListRestController;
31 use OpenEMR\RestControllers\InsuranceCompanyRestController;
32 use OpenEMR\RestControllers\AppointmentRestController;
33 use OpenEMR\RestControllers\ConditionRestController;
34 use OpenEMR\RestControllers\ONoteRestController;
35 use OpenEMR\RestControllers\DocumentRestController;
36 use OpenEMR\RestControllers\DrugRestController;
37 use OpenEMR\RestControllers\ImmunizationRestController;
38 use OpenEMR\RestControllers\InsuranceRestController;
39 use OpenEMR\RestControllers\MessageRestController;
40 use OpenEMR\RestControllers\PrescriptionRestController;
41 use OpenEMR\RestControllers\ProcedureRestController;
43 // Note some Http clients may not send auth as json so a function
44 // is implemented to determine and parse encoding on auth route's.
46 RestConfig::$ROUTE_MAP = array(
47 "GET /api/facility" => function () {
48 RestConfig::authorization_check("admin", "users");
49 $return = (new FacilityRestController())->getAll($_GET);
50 RestConfig::apiLog($return);
51 return $return;
53 "GET /api/facility/:fuuid" => function ($fuuid) {
54 RestConfig::authorization_check("admin", "users");
55 $return = (new FacilityRestController())->getOne($fuuid);
56 RestConfig::apiLog($return);
57 return $return;
59 "POST /api/facility" => function () {
60 RestConfig::authorization_check("admin", "super");
61 $data = (array) (json_decode(file_get_contents("php://input")));
62 $return = (new FacilityRestController())->post($data);
63 RestConfig::apiLog($return, $data);
64 return $return;
66 "PATCH /api/facility/:fuuid" => function ($fuuid) {
67 RestConfig::authorization_check("admin", "super");
68 $data = (array) (json_decode(file_get_contents("php://input")));
69 $return = (new FacilityRestController())->patch($fuuid, $data);
70 RestConfig::apiLog($return, $data);
71 return $return;
73 "GET /api/patient" => function () {
74 RestConfig::authorization_check("patients", "demo");
75 $return = (new PatientRestController())->getAll($_GET);
76 RestConfig::apiLog($return);
77 return $return;
79 "POST /api/patient" => function () {
80 RestConfig::authorization_check("patients", "demo");
81 $data = (array) (json_decode(file_get_contents("php://input")));
82 $return = (new PatientRestController())->post($data);
83 RestConfig::apiLog($return, $data);
84 return $return;
86 "PUT /api/patient/:puuid" => function ($puuid) {
87 RestConfig::authorization_check("patients", "demo");
88 $data = (array) (json_decode(file_get_contents("php://input")));
89 $return = (new PatientRestController())->put($puuid, $data);
90 RestConfig::apiLog($return, $data);
91 return $return;
93 "GET /api/patient/:puuid" => function ($puuid) {
94 RestConfig::authorization_check("patients", "demo");
95 $return = (new PatientRestController())->getOne($puuid);
96 RestConfig::apiLog($return);
97 return $return;
99 "GET /api/patient/:puuid/encounter" => function ($puuid) {
100 RestConfig::authorization_check("encounters", "auth_a");
101 $return = (new EncounterRestController())->getAll($puuid);
102 RestConfig::apiLog($return);
103 return $return;
105 "POST /api/patient/:puuid/encounter" => function ($puuid) {
106 RestConfig::authorization_check("encounters", "auth_a");
107 $data = (array) (json_decode(file_get_contents("php://input")));
108 $return = (new EncounterRestController())->post($puuid, $data);
109 RestConfig::apiLog($return, $data);
110 return $return;
112 "PUT /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
113 RestConfig::authorization_check("encounters", "auth_a");
114 $data = (array) (json_decode(file_get_contents("php://input")));
115 $return = (new EncounterRestController())->put($puuid, $euuid, $data);
116 RestConfig::apiLog($return, $data);
117 return $return;
119 "GET /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
120 RestConfig::authorization_check("encounters", "auth_a");
121 $return = (new EncounterRestController())->getOne($puuid, $euuid);
122 RestConfig::apiLog($return);
123 return $return;
125 "GET /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
126 RestConfig::authorization_check("encounters", "notes");
127 $return = (new EncounterRestController())->getSoapNotes($pid, $eid);
128 RestConfig::apiLog($return);
129 return $return;
131 "POST /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
132 RestConfig::authorization_check("encounters", "notes");
133 $data = (array) (json_decode(file_get_contents("php://input")));
134 $return = (new EncounterRestController())->postVital($pid, $eid, $data);
135 RestConfig::apiLog($return, $data);
136 return $return;
138 "PUT /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
139 RestConfig::authorization_check("encounters", "notes");
140 $data = (array) (json_decode(file_get_contents("php://input")));
141 $return = (new EncounterRestController())->putVital($pid, $eid, $vid, $data);
142 RestConfig::apiLog($return, $data);
143 return $return;
145 "GET /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
146 RestConfig::authorization_check("encounters", "notes");
147 $return = (new EncounterRestController())->getVitals($pid, $eid);
148 RestConfig::apiLog($return);
149 return $return;
151 "GET /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
152 RestConfig::authorization_check("encounters", "notes");
153 $return = (new EncounterRestController())->getVital($pid, $eid, $vid);
154 RestConfig::apiLog($return);
155 return $return;
157 "GET /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
158 RestConfig::authorization_check("encounters", "notes");
159 $return = (new EncounterRestController())->getSoapNote($pid, $eid, $sid);
160 RestConfig::apiLog($return);
161 return $return;
163 "POST /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
164 RestConfig::authorization_check("encounters", "notes");
165 $data = (array) (json_decode(file_get_contents("php://input")));
166 $return = (new EncounterRestController())->postSoapNote($pid, $eid, $data);
167 RestConfig::apiLog($return, $data);
168 return $return;
170 "PUT /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
171 RestConfig::authorization_check("encounters", "notes");
172 $data = (array) (json_decode(file_get_contents("php://input")));
173 $return = (new EncounterRestController())->putSoapNote($pid, $eid, $sid, $data);
174 RestConfig::apiLog($return, $data);
175 return $return;
177 "GET /api/practitioner" => function () {
178 RestConfig::authorization_check("admin", "users");
179 $return = (new PractitionerRestController())->getAll($_GET);
180 RestConfig::apiLog($return);
181 return $return;
183 "GET /api/practitioner/:prid" => function ($prid) {
184 RestConfig::authorization_check("admin", "users");
185 $return = (new PractitionerRestController())->getOne($prid);
186 RestConfig::apiLog($return);
187 return $return;
189 "POST /api/practitioner" => function () {
190 RestConfig::authorization_check("admin", "users");
191 $data = (array) (json_decode(file_get_contents("php://input")));
192 $return = (new PractitionerRestController())->post($data);
193 RestConfig::apiLog($return, $data);
194 return $return;
196 "PATCH /api/practitioner/:prid" => function ($prid) {
197 RestConfig::authorization_check("admin", "users");
198 $data = (array) (json_decode(file_get_contents("php://input")));
199 $return = (new PractitionerRestController())->patch($prid, $data);
200 RestConfig::apiLog($return, $data);
201 return $return;
203 "GET /api/medical_problem" => function () {
204 RestConfig::authorization_check("encounters", "notes");
205 $return = (new ConditionRestController())->getAll();
206 RestConfig::apiLog($return);
207 return $return;
209 "GET /api/medical_problem/:muuid" => function ($muuid) {
210 RestConfig::authorization_check("encounters", "notes");
211 $return = (new ConditionRestController())->getOne($muuid);
212 RestConfig::apiLog($return);
213 return $return;
215 "GET /api/patient/:puuid/medical_problem" => function ($puuid) {
216 RestConfig::authorization_check("encounters", "notes");
217 $return = (new ConditionRestController())->getAll($puuid, "medical_problem");
218 RestConfig::apiLog($return);
219 return $return;
221 "GET /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
222 RestConfig::authorization_check("patients", "med");
223 $return = (new ConditionRestController())->getAll(['lists.pid' => $puuid, 'lists.id' => $muuid]);
224 RestConfig::apiLog($return);
225 return $return;
227 "POST /api/patient/:puuid/medical_problem" => function ($puuid) {
228 RestConfig::authorization_check("patients", "med");
229 $data = (array) (json_decode(file_get_contents("php://input")));
230 $return = (new ConditionRestController())->post($puuid, $data);
231 RestConfig::apiLog($return, $data);
232 return $return;
234 "PUT /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
235 RestConfig::authorization_check("patients", "med");
236 $data = (array) (json_decode(file_get_contents("php://input")));
237 $return = (new ConditionRestController())->put($puuid, $muuid, $data);
238 RestConfig::apiLog($return, $data);
239 return $return;
241 "DELETE /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
242 RestConfig::authorization_check("patients", "med");
243 $return = (new ConditionRestController())->delete($puuid, $muuid);
244 RestConfig::apiLog($return);
245 return $return;
247 "GET /api/allergy" => function () {
248 RestConfig::authorization_check("patients", "med");
249 $return = (new AllergyIntoleranceRestController())->getAll();
250 RestConfig::apiLog($return);
251 return $return;
253 "GET /api/allergy/:auuid" => function ($auuid) {
254 RestConfig::authorization_check("patients", "med");
255 $return = (new AllergyIntoleranceRestController())->getOne($auuid);
256 RestConfig::apiLog($return);
257 return $return;
259 "GET /api/patient/:puuid/allergy" => function ($puuid) {
260 RestConfig::authorization_check("patients", "med");
261 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid]);
262 RestConfig::apiLog($return);
263 return $return;
265 "GET /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
266 RestConfig::authorization_check("patients", "med");
267 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid, 'lists.id' => $auuid]);
268 RestConfig::apiLog($return);
269 return $return;
271 "POST /api/patient/:puuid/allergy" => function ($puuid) {
272 RestConfig::authorization_check("patients", "med");
273 $data = (array) (json_decode(file_get_contents("php://input")));
274 $return = (new AllergyIntoleranceRestController())->post($puuid, $data);
275 RestConfig::apiLog($return, $data);
276 return $return;
278 "PUT /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
279 RestConfig::authorization_check("patients", "med");
280 $data = (array) (json_decode(file_get_contents("php://input")));
281 $return = (new AllergyIntoleranceRestController())->put($puuid, $auuid, $data);
282 RestConfig::apiLog($return, $data);
283 return $return;
285 "DELETE /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
286 RestConfig::authorization_check("patients", "med");
287 $return = (new AllergyIntoleranceRestController())->delete($puuid, $auuid);
288 RestConfig::apiLog($return);
289 return $return;
291 "GET /api/patient/:pid/medication" => function ($pid) {
292 RestConfig::authorization_check("patients", "med");
293 $return = (new ListRestController())->getAll($pid, "medication");
294 RestConfig::apiLog($return);
295 return $return;
297 "POST /api/patient/:pid/medication" => function ($pid) {
298 RestConfig::authorization_check("patients", "med");
299 $data = (array) (json_decode(file_get_contents("php://input")));
300 $return = (new ListRestController())->post($pid, "medication", $data);
301 RestConfig::apiLog($return, $data);
302 return $return;
304 "PUT /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
305 RestConfig::authorization_check("patients", "med");
306 $data = (array) (json_decode(file_get_contents("php://input")));
307 $return = (new ListRestController())->put($pid, $mid, "medication", $data);
308 RestConfig::apiLog($return, $data);
309 return $return;
311 "GET /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
312 RestConfig::authorization_check("patients", "med");
313 $return = (new ListRestController())->getOne($pid, "medication", $mid);
314 RestConfig::apiLog($return);
315 return $return;
317 "DELETE /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
318 RestConfig::authorization_check("patients", "med");
319 $return = (new ListRestController())->delete($pid, $mid, "medication");
320 RestConfig::apiLog($return);
321 return $return;
323 "GET /api/patient/:pid/surgery" => function ($pid) {
324 RestConfig::authorization_check("patients", "med");
325 $return = (new ListRestController())->getAll($pid, "surgery");
326 RestConfig::apiLog($return);
327 return $return;
329 "GET /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
330 RestConfig::authorization_check("patients", "med");
331 $return = (new ListRestController())->getOne($pid, "surgery", $sid);
332 RestConfig::apiLog($return);
333 return $return;
335 "DELETE /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
336 RestConfig::authorization_check("patients", "med");
337 $return = (new ListRestController())->delete($pid, $sid, "surgery");
338 RestConfig::apiLog($return);
339 return $return;
341 "POST /api/patient/:pid/surgery" => function ($pid) {
342 RestConfig::authorization_check("patients", "med");
343 $data = (array) (json_decode(file_get_contents("php://input")));
344 $return = (new ListRestController())->post($pid, "surgery", $data);
345 RestConfig::apiLog($return, $data);
346 return $return;
348 "PUT /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
349 RestConfig::authorization_check("patients", "med");
350 $data = (array) (json_decode(file_get_contents("php://input")));
351 $return = (new ListRestController())->put($pid, $sid, "surgery", $data);
352 RestConfig::apiLog($return, $data);
353 return $return;
355 "GET /api/patient/:pid/dental_issue" => function ($pid) {
356 RestConfig::authorization_check("patients", "med");
357 $return = (new ListRestController())->getAll($pid, "dental");
358 RestConfig::apiLog($return);
359 return $return;
361 "GET /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
362 RestConfig::authorization_check("patients", "med");
363 $return = (new ListRestController())->getOne($pid, "dental", $did);
364 RestConfig::apiLog($return);
365 return $return;
367 "DELETE /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
368 RestConfig::authorization_check("patients", "med");
369 $return = (new ListRestController())->delete($pid, $did, "dental");
370 RestConfig::apiLog($return);
371 return $return;
373 "POST /api/patient/:pid/dental_issue" => function ($pid) {
374 RestConfig::authorization_check("patients", "med");
375 $data = (array) (json_decode(file_get_contents("php://input")));
376 $return = (new ListRestController())->post($pid, "dental", $data);
377 RestConfig::apiLog($return, $data);
378 return $return;
380 "PUT /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
381 RestConfig::authorization_check("patients", "med");
382 $data = (array) (json_decode(file_get_contents("php://input")));
383 $return = (new ListRestController())->put($pid, $did, "dental", $data);
384 RestConfig::apiLog($return, $data);
385 return $return;
387 "GET /api/patient/:pid/appointment" => function ($pid) {
388 RestConfig::authorization_check("patients", "appt");
389 $return = (new AppointmentRestController())->getAllForPatient($pid);
390 RestConfig::apiLog($return);
391 return $return;
393 "POST /api/patient/:pid/appointment" => function ($pid) {
394 RestConfig::authorization_check("patients", "appt");
395 $data = (array) (json_decode(file_get_contents("php://input")));
396 $return = (new AppointmentRestController())->post($pid, $data);
397 RestConfig::apiLog($return, $data);
398 return $return;
400 "GET /api/appointment" => function () {
401 RestConfig::authorization_check("patients", "appt");
402 $return = (new AppointmentRestController())->getAll();
403 RestConfig::apiLog($return);
404 return $return;
406 "GET /api/appointment/:eid" => function ($eid) {
407 RestConfig::authorization_check("patients", "appt");
408 $return = (new AppointmentRestController())->getOne($eid);
409 RestConfig::apiLog($return);
410 return $return;
412 "DELETE /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
413 RestConfig::authorization_check("patients", "appt");
414 $return = (new AppointmentRestController())->delete($eid);
415 RestConfig::apiLog($return);
416 return $return;
418 "GET /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
419 RestConfig::authorization_check("patients", "appt");
420 $return = (new AppointmentRestController())->getOne($eid);
421 RestConfig::apiLog($return);
422 return $return;
424 "GET /api/list/:list_name" => function ($list_name) {
425 RestConfig::authorization_check("lists", "default");
426 $return = (new ListRestController())->getOptions($list_name);
427 RestConfig::apiLog($return);
428 return $return;
430 "GET /api/version" => function () {
431 $return = (new VersionRestController())->getOne();
432 RestConfig::apiLog($return);
433 return $return;
435 "GET /api/product" => function () {
436 $return = (new ProductRegistrationRestController())->getOne();
437 RestConfig::apiLog($return);
438 return $return;
440 "GET /api/insurance_company" => function () {
441 $return = (new InsuranceCompanyRestController())->getAll();
442 RestConfig::apiLog($return);
443 return $return;
445 "GET /api/insurance_company/:iid" => function ($iid) {
446 $return = (new InsuranceCompanyRestController())->getOne($iid);
447 RestConfig::apiLog($return);
448 return $return;
450 "GET /api/insurance_type" => function () {
451 $return = (new InsuranceCompanyRestController())->getInsuranceTypes();
452 RestConfig::apiLog($return);
453 return $return;
455 "POST /api/insurance_company" => function () {
456 $data = (array) (json_decode(file_get_contents("php://input")));
457 $return = (new InsuranceCompanyRestController())->post($data);
458 RestConfig::apiLog($return, $data);
459 return $return;
461 "PUT /api/insurance_company/:iid" => function ($iid) {
462 $data = (array) (json_decode(file_get_contents("php://input")));
463 $return = (new InsuranceCompanyRestController())->put($iid, $data);
464 RestConfig::apiLog($return, $data);
465 return $return;
467 "POST /api/patient/:pid/document" => function ($pid) {
468 $return = (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
469 RestConfig::apiLog($return);
470 return $return;
472 "GET /api/patient/:pid/document" => function ($pid) {
473 $return = (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
474 RestConfig::apiLog($return);
475 return $return;
477 "GET /api/patient/:pid/document/:did" => function ($pid, $did) {
478 $return = (new DocumentRestController())->downloadFile($pid, $did);
479 RestConfig::apiLog($return);
480 return $return;
482 "GET /api/patient/:pid/insurance" => function ($pid) {
483 $return = (new InsuranceRestController())->getAll($pid);
484 RestConfig::apiLog($return);
485 return $return;
487 "GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
488 $return = (new InsuranceRestController())->getOne($pid, $type);
489 RestConfig::apiLog($return);
490 return $return;
492 "POST /api/patient/:pid/insurance/:type" => function ($pid, $type) {
493 $data = (array) (json_decode(file_get_contents("php://input")));
494 $return = (new InsuranceRestController())->post($pid, $type, $data);
495 RestConfig::apiLog($return, $data);
496 return $return;
498 "PUT /api/patient/:pid/insurance/:type" => function ($pid, $type) {
499 $data = (array) (json_decode(file_get_contents("php://input")));
500 $return = (new InsuranceRestController())->put($pid, $type, $data);
501 RestConfig::apiLog($return, $data);
502 return $return;
504 "POST /api/patient/:pid/message" => function ($pid) {
505 RestConfig::authorization_check("patients", "notes");
506 $data = (array) (json_decode(file_get_contents("php://input")));
507 $return = (new MessageRestController())->post($pid, $data);
508 RestConfig::apiLog($return, $data);
509 return $return;
511 "PUT /api/patient/:pid/message/:mid" => function ($pid, $mid) {
512 RestConfig::authorization_check("patients", "notes");
513 $data = (array) (json_decode(file_get_contents("php://input")));
514 $return = (new MessageRestController())->put($pid, $mid, $data);
515 RestConfig::apiLog($return, $data);
516 return $return;
518 "DELETE /api/patient/:pid/message/:mid" => function ($pid, $mid) {
519 RestConfig::authorization_check("patients", "notes");
520 $return = (new MessageRestController())->delete($pid, $mid);
521 RestConfig::apiLog($return);
522 return $return;
524 "GET /api/immunization" => function () {
525 RestConfig::authorization_check("patients", "med");
526 $return = (new ImmunizationRestController())->getAll($_GET);
527 RestConfig::apiLog($return);
528 return $return;
530 "GET /api/immunization/:uuid" => function ($uuid) {
531 RestConfig::authorization_check("patients", "med");
532 $return = (new ImmunizationRestController())->getOne($uuid);
533 RestConfig::apiLog($return);
534 return $return;
536 "GET /api/procedure" => function () {
537 RestConfig::authorization_check("patients", "med");
538 $return = (new ProcedureRestController())->getAll();
539 RestConfig::apiLog($return);
540 return $return;
542 "GET /api/procedure/:uuid" => function ($uuid) {
543 RestConfig::authorization_check("patients", "med");
544 $return = (new ProcedureRestController())->getOne($uuid);
545 RestConfig::apiLog($return);
546 return $return;
548 "GET /api/drug" => function () {
549 RestConfig::authorization_check("patients", "med");
550 $return = (new DrugRestController())->getAll();
551 RestConfig::apiLog($return);
552 return $return;
554 "GET /api/drug/:uuid" => function ($uuid) {
555 RestConfig::authorization_check("patients", "med");
556 $return = (new DrugRestController())->getOne($uuid);
557 RestConfig::apiLog($return);
558 return $return;
560 "GET /api/prescription" => function () {
561 RestConfig::authorization_check("patients", "med");
562 $return = (new PrescriptionRestController())->getAll();
563 RestConfig::apiLog($return);
564 return $return;
566 "GET /api/prescription/:uuid" => function ($uuid) {
567 RestConfig::authorization_check("patients", "med");
568 $return = (new PrescriptionRestController())->getOne($uuid);
569 RestConfig::apiLog($return);
570 return $return;
575 use OpenEMR\RestControllers\FHIR\FhirAllergyIntoleranceRestController;
576 use OpenEMR\RestControllers\FHIR\FhirCareTeamRestController;
577 use OpenEMR\RestControllers\FHIR\FhirConditionRestController;
578 use OpenEMR\RestControllers\FHIR\FhirEncounterRestController;
579 use OpenEMR\RestControllers\FHIR\FhirObservationRestController;
580 use OpenEMR\RestControllers\FHIR\FhirImmunizationRestController;
581 use OpenEMR\RestControllers\FHIR\FhirLocationRestController;
582 use OpenEMR\RestControllers\FHIR\FhirMedicationRestController;
583 use OpenEMR\RestControllers\FHIR\FhirMedicationRequestRestController;
584 use OpenEMR\RestControllers\FHIR\FhirOrganizationRestController;
585 use OpenEMR\RestControllers\FHIR\FhirPatientRestController;
586 use OpenEMR\RestControllers\FHIR\FhirPractitionerRoleRestController;
587 use OpenEMR\RestControllers\FHIR\FhirPractitionerRestController;
588 use OpenEMR\RestControllers\FHIR\FhirProcedureRestController;
589 use OpenEMR\RestControllers\FHIR\FhirQuestionnaireResponseController;
590 use OpenEMR\RestControllers\FHIR\FhirMetaDataRestController;
592 RestConfig::$FHIR_ROUTE_MAP = array(
593 "GET /fhir/metadata" => function () {
594 $return = (new FhirMetaDataRestController())->getMetaData();
595 RestConfig::apiLog($return);
596 return $return;
598 "POST /fhir/Patient" => function () {
599 RestConfig::authorization_check("patients", "demo");
600 $data = (array) (json_decode(file_get_contents("php://input"), true));
601 $return = (new FhirPatientRestController())->post($data);
602 RestConfig::apiLog($return, $data);
603 return $return;
605 "PUT /fhir/Patient/:id" => function ($id) {
606 RestConfig::authorization_check("patients", "demo");
607 $data = (array) (json_decode(file_get_contents("php://input"), true));
608 $return = (new FhirPatientRestController())->put($id, $data);
609 RestConfig::apiLog($return, $data);
610 return $return;
612 "PATCH /fhir/Patient/:id" => function ($id) {
613 RestConfig::authorization_check("patients", "demo");
614 $data = (array) (json_decode(file_get_contents("php://input"), true));
615 $return = (new FhirPatientRestController())->put($id, $data);
616 RestConfig::apiLog($return, $data);
617 return $return;
619 "GET /fhir/Patient" => function () {
620 RestConfig::authorization_check("patients", "demo");
621 $return = (new FhirPatientRestController())->getAll($_GET);
622 RestConfig::apiLog($return);
623 return $return;
625 "GET /fhir/Patient/:id" => function ($id) {
626 RestConfig::authorization_check("patients", "demo");
627 $return = (new FhirPatientRestController())->getOne($id);
628 RestConfig::apiLog($return);
629 return $return;
631 "GET /fhir/Encounter" => function () {
632 RestConfig::authorization_check("encounters", "auth_a");
633 $return = (new FhirEncounterRestController(null))->getAll($_GET);
634 RestConfig::apiLog($return);
635 return $return;
637 "GET /fhir/Encounter/:id" => function ($id) {
638 RestConfig::authorization_check("encounters", "auth_a");
639 $return = (new FhirEncounterRestController())->getOne($id);
640 RestConfig::apiLog($return);
641 return $return;
643 "GET /fhir/Practitioner" => function () {
644 RestConfig::authorization_check("admin", "users");
645 $return = (new FhirPractitionerRestController())->getAll($_GET);
646 RestConfig::apiLog($return);
647 return $return;
649 "GET /fhir/Practitioner/:id" => function ($id) {
650 RestConfig::authorization_check("admin", "users");
651 $return = (new FhirPractitionerRestController())->getOne($id);
652 RestConfig::apiLog($return);
653 return $return;
655 "POST /fhir/Practitioner" => function () {
656 RestConfig::authorization_check("admin", "users");
657 $data = (array) (json_decode(file_get_contents("php://input"), true));
658 $return = (new FhirPractitionerRestController())->post($data);
659 RestConfig::apiLog($return, $data);
660 return $return;
662 "PATCH /fhir/Practitioner/:id" => function ($id) {
663 RestConfig::authorization_check("admin", "users");
664 $data = (array) (json_decode(file_get_contents("php://input"), true));
665 $return = (new FhirPractitionerRestController())->patch($id, $data);
666 RestConfig::apiLog($return, $data);
667 return $return;
669 "GET /fhir/Organization" => function () {
670 RestConfig::authorization_check("admin", "users");
671 $return = (new FhirOrganizationRestController())->getAll($_GET);
672 RestConfig::apiLog($return);
673 return $return;
675 "GET /fhir/Organization/:id" => function ($id) {
676 RestConfig::authorization_check("admin", "users");
677 $return = (new FhirOrganizationRestController())->getOne($id);
678 RestConfig::apiLog($return);
679 return $return;
681 "POST /fhir/Organization" => function () {
682 RestConfig::authorization_check("admin", "super");
683 $data = (array) (json_decode(file_get_contents("php://input"), true));
684 $return = (new FhirOrganizationRestController())->post($data);
685 RestConfig::apiLog($return, $data);
686 return $return;
688 "PATCH /fhir/Organization/:id" => function ($id) {
689 RestConfig::authorization_check("admin", "super");
690 $data = (array) (json_decode(file_get_contents("php://input"), true));
691 $return = (new FhirOrganizationRestController())->patch($id, $data);
692 RestConfig::apiLog($return, $data);
693 return $return;
695 "GET /fhir/PractitionerRole" => function () {
696 RestConfig::authorization_check("admin", "users");
697 $return = (new FhirPractitionerRoleRestController())->getAll($_GET);
698 RestConfig::apiLog($return);
699 return $return;
701 "GET /fhir/PractitionerRole/:id" => function ($id) {
702 RestConfig::authorization_check("admin", "users");
703 $return = (new FhirPractitionerRoleRestController())->getOne($id);
704 RestConfig::apiLog($return);
705 return $return;
707 "GET /fhir/AllergyIntolerance" => function () {
708 RestConfig::authorization_check("patients", "med");
709 $return = (new FhirAllergyIntoleranceRestController(null))->getAll($_GET);
710 RestConfig::apiLog($return);
711 return $return;
713 "GET /fhir/AllergyIntolerance/:id" => function ($id) {
714 RestConfig::authorization_check("patients", "med");
715 $return = (new FhirAllergyIntoleranceRestController(null))->getOne($id);
716 RestConfig::apiLog($return);
717 return $return;
719 "GET /fhir/Observation" => function () {
720 RestConfig::authorization_check("patients", "med");
721 $return = (new FhirObservationRestController())->getAll($_GET);
722 RestConfig::apiLog($return);
723 return $return;
725 "GET /fhir/Observation/:uuid" => function ($uuid) {
726 RestConfig::authorization_check("patients", "med");
727 $return = (new FhirObservationRestController())->getOne($uuid);
728 RestConfig::apiLog($return);
729 return $return;
731 "POST /fhir/QuestionnaireResponse" => function () {
732 RestConfig::authorization_check("patients", "demo");
733 $data = (array) (json_decode(file_get_contents("php://input"), true));
734 $return = (new FhirQuestionnaireResponseController(null))->post($data);
735 RestConfig::apiLog($return, $data);
736 return $return;
738 "GET /fhir/Immunization" => function () {
739 RestConfig::authorization_check("patients", "med");
740 $return = (new FhirImmunizationRestController())->getAll($_GET);
741 RestConfig::apiLog($return);
742 return $return;
744 "GET /fhir/Immunization/:id" => function ($id) {
745 RestConfig::authorization_check("patients", "med");
746 $return = (new FhirImmunizationRestController())->getOne($id);
747 RestConfig::apiLog($return);
748 return $return;
750 "GET /fhir/Condition" => function () {
751 RestConfig::authorization_check("patients", "med");
752 $return = (new FhirConditionRestController())->getAll($_GET);
753 RestConfig::apiLog($return);
754 return $return;
756 "GET /fhir/Condition/:id" => function ($uuid) {
757 RestConfig::authorization_check("patients", "med");
758 $return = (new FhirConditionRestController())->getOne($uuid);
759 RestConfig::apiLog($return);
760 return $return;
762 "GET /fhir/Procedure" => function () {
763 RestConfig::authorization_check("patients", "med");
764 $return = (new FhirProcedureRestController())->getAll($_GET);
765 RestConfig::apiLog($return);
766 return $return;
768 "GET /fhir/Procedure/:uuid" => function ($uuid) {
769 RestConfig::authorization_check("patients", "med");
770 $return = (new FhirProcedureRestController())->getOne($uuid);
771 RestConfig::apiLog($return);
772 return $return;
774 "GET /fhir/MedicationRequest" => function () {
775 RestConfig::authorization_check("patients", "med");
776 $return = (new FhirMedicationRequestRestController())->getAll($_GET);
777 RestConfig::apiLog($return);
778 return $return;
780 "GET /fhir/MedicationRequest/:uuid" => function ($uuid) {
781 RestConfig::authorization_check("patients", "med");
782 $return = (new FhirMedicationRequestRestController())->getOne($uuid);
783 RestConfig::apiLog($return);
784 return $return;
786 "GET /fhir/Medication" => function () {
787 RestConfig::authorization_check("patients", "med");
788 $return = (new FhirMedicationRestController())->getAll($_GET);
789 RestConfig::apiLog($return);
790 return $return;
792 "GET /fhir/Medication/:uuid" => function ($uuid) {
793 RestConfig::authorization_check("patients", "med");
794 $return = (new FhirMedicationRestController())->getOne($uuid);
795 RestConfig::apiLog($return);
796 return $return;
798 "GET /fhir/Location" => function () {
799 RestConfig::authorization_check("patients", "med");
800 $return = (new FhirLocationRestController())->getAll($_GET);
801 RestConfig::apiLog($return);
802 return $return;
804 "GET /fhir/Location/:uuid" => function ($uuid) {
805 RestConfig::authorization_check("patients", "med");
806 $return = (new FhirLocationRestController())->getOne($uuid);
807 RestConfig::apiLog($return);
808 return $return;
810 "GET /fhir/CareTeam" => function () {
811 RestConfig::authorization_check("patients", "med");
812 $return = (new FhirCareTeamRestController())->getAll($_GET);
813 RestConfig::apiLog($return);
814 return $return;
816 "GET /fhir/CareTeam/:uuid" => function ($uuid) {
817 RestConfig::authorization_check("patients", "med");
818 $return = (new FhirCareTeamRestController())->getOne($uuid);
819 RestConfig::apiLog($return);
820 return $return;
824 // Patient portal api routes
825 RestConfig::$PORTAL_ROUTE_MAP = array(
826 "GET /portal/patient" => function () {
827 $return = (new PatientRestController())->getOne(UuidRegistry::uuidToString($_SESSION['puuid']));
828 RestConfig::apiLog($return);
829 return $return;
831 "GET /portal/patient/encounter" => function () {
832 $return = (new EncounterRestController())->getAll(UuidRegistry::uuidToString($_SESSION['puuid']));
833 RestConfig::apiLog($return);
834 return $return;
836 "GET /portal/patient/encounter/:euuid" => function ($euuid) {
837 $return = (new EncounterRestController())->getOne(UuidRegistry::uuidToString($_SESSION['puuid']), $euuid);
838 RestConfig::apiLog($return);
839 return $return;
843 // Patient portal fhir api routes
844 RestConfig::$PORTAL_FHIR_ROUTE_MAP = array(
845 "GET /portalfhir/Patient" => function () {
846 $return = (new FhirPatientRestController())->getOne(UuidRegistry::uuidToString($_SESSION['puuid']));
847 RestConfig::apiLog($return);
848 return $return;
850 "GET /portalfhir/Encounter" => function () {
851 $return = (new FhirEncounterRestController(null))->getAll(['patient' => UuidRegistry::uuidToString($_SESSION['puuid'])]);
852 RestConfig::apiLog($return);
853 return $return;
855 "GET /portalfhir/Encounter/:id" => function ($id) {
856 $return = (new FhirEncounterRestController(null))->getAll(['_id' => $id, 'patient' => UuidRegistry::uuidToString($_SESSION['puuid'])]);
857 RestConfig::apiLog($return);
858 return $return;