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);
53 "GET /api/facility/:fuuid" => function ($fuuid) {
54 RestConfig
::authorization_check("admin", "users");
55 $return = (new FacilityRestController())->getOne($fuuid);
56 RestConfig
::apiLog($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);
66 "PUT /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);
73 "GET /api/patient" => function () {
74 RestConfig
::authorization_check("patients", "demo");
75 $return = (new PatientRestController())->getAll($_GET);
76 RestConfig
::apiLog($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);
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);
93 "GET /api/patient/:puuid" => function ($puuid) {
94 RestConfig
::authorization_check("patients", "demo");
95 $return = (new PatientRestController())->getOne($puuid);
96 RestConfig
::apiLog($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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
177 "GET /api/practitioner" => function () {
178 RestConfig
::authorization_check("admin", "users");
179 $return = (new PractitionerRestController())->getAll($_GET);
180 RestConfig
::apiLog($return);
183 "GET /api/practitioner/:prid" => function ($prid) {
184 RestConfig
::authorization_check("admin", "users");
185 $return = (new PractitionerRestController())->getOne($prid);
186 RestConfig
::apiLog($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);
196 "PUT /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);
203 "GET /api/medical_problem" => function () {
204 RestConfig
::authorization_check("encounters", "notes");
205 $return = (new ConditionRestController())->getAll();
206 RestConfig
::apiLog($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);
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);
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);
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);
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);
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);
247 "GET /api/allergy" => function () {
248 RestConfig
::authorization_check("patients", "med");
249 $return = (new AllergyIntoleranceRestController())->getAll();
250 RestConfig
::apiLog($return);
253 "GET /api/allergy/:auuid" => function ($auuid) {
254 RestConfig
::authorization_check("patients", "med");
255 $return = (new AllergyIntoleranceRestController())->getOne($auuid);
256 RestConfig
::apiLog($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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
387 "GET /api/patient/:pid/appointment" => function ($pid) {
388 RestConfig
::authorization_check("patients", "appt");
389 $return = (new AppointmentRestController())->getAllForPatient($pid);
390 RestConfig
::apiLog($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);
400 "GET /api/appointment" => function () {
401 RestConfig
::authorization_check("patients", "appt");
402 $return = (new AppointmentRestController())->getAll();
403 RestConfig
::apiLog($return);
406 "GET /api/appointment/:eid" => function ($eid) {
407 RestConfig
::authorization_check("patients", "appt");
408 $return = (new AppointmentRestController())->getOne($eid);
409 RestConfig
::apiLog($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);
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);
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);
430 "GET /api/version" => function () {
431 $return = (new VersionRestController())->getOne();
432 RestConfig
::apiLog($return);
435 "GET /api/product" => function () {
436 $return = (new ProductRegistrationRestController())->getOne();
437 RestConfig
::apiLog($return);
440 "GET /api/insurance_company" => function () {
441 $return = (new InsuranceCompanyRestController())->getAll();
442 RestConfig
::apiLog($return);
445 "GET /api/insurance_company/:iid" => function ($iid) {
446 $return = (new InsuranceCompanyRestController())->getOne($iid);
447 RestConfig
::apiLog($return);
450 "GET /api/insurance_type" => function () {
451 $return = (new InsuranceCompanyRestController())->getInsuranceTypes();
452 RestConfig
::apiLog($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);
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);
467 "POST /api/patient/:pid/document" => function ($pid) {
468 $return = (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
469 RestConfig
::apiLog($return);
472 "GET /api/patient/:pid/document" => function ($pid) {
473 $return = (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
474 RestConfig
::apiLog($return);
477 "GET /api/patient/:pid/document/:did" => function ($pid, $did) {
478 $return = (new DocumentRestController())->downloadFile($pid, $did);
479 RestConfig
::apiLog($return);
482 "GET /api/patient/:pid/insurance" => function ($pid) {
483 $return = (new InsuranceRestController())->getAll($pid);
484 RestConfig
::apiLog($return);
487 "GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
488 $return = (new InsuranceRestController())->getOne($pid, $type);
489 RestConfig
::apiLog($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);
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);
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);
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);
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);
524 "GET /api/immunization" => function () {
525 RestConfig
::authorization_check("patients", "med");
526 $return = (new ImmunizationRestController())->getAll($_GET);
527 RestConfig
::apiLog($return);
530 "GET /api/immunization/:uuid" => function ($uuid) {
531 RestConfig
::authorization_check("patients", "med");
532 $return = (new ImmunizationRestController())->getOne($uuid);
533 RestConfig
::apiLog($return);
536 "GET /api/procedure" => function () {
537 RestConfig
::authorization_check("patients", "med");
538 $return = (new ProcedureRestController())->getAll();
539 RestConfig
::apiLog($return);
542 "GET /api/procedure/:uuid" => function ($uuid) {
543 RestConfig
::authorization_check("patients", "med");
544 $return = (new ProcedureRestController())->getOne($uuid);
545 RestConfig
::apiLog($return);
548 "GET /api/drug" => function () {
549 RestConfig
::authorization_check("patients", "med");
550 $return = (new DrugRestController())->getAll();
551 RestConfig
::apiLog($return);
554 "GET /api/drug/:uuid" => function ($uuid) {
555 RestConfig
::authorization_check("patients", "med");
556 $return = (new DrugRestController())->getOne($uuid);
557 RestConfig
::apiLog($return);
560 "GET /api/prescription" => function () {
561 RestConfig
::authorization_check("patients", "med");
562 $return = (new PrescriptionRestController())->getAll();
563 RestConfig
::apiLog($return);
566 "GET /api/prescription/:uuid" => function ($uuid) {
567 RestConfig
::authorization_check("patients", "med");
568 $return = (new PrescriptionRestController())->getOne($uuid);
569 RestConfig
::apiLog($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);
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);
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);
612 "GET /fhir/Patient" => function () {
613 RestConfig
::authorization_check("patients", "demo");
614 $return = (new FhirPatientRestController())->getAll($_GET);
615 RestConfig
::apiLog($return);
618 "GET /fhir/Patient/:id" => function ($id) {
619 RestConfig
::authorization_check("patients", "demo");
620 $return = (new FhirPatientRestController())->getOne($id);
621 RestConfig
::apiLog($return);
624 "GET /fhir/Encounter" => function () {
625 RestConfig
::authorization_check("encounters", "auth_a");
626 $return = (new FhirEncounterRestController(null))->getAll($_GET);
627 RestConfig
::apiLog($return);
630 "GET /fhir/Encounter/:id" => function ($id) {
631 RestConfig
::authorization_check("encounters", "auth_a");
632 $return = (new FhirEncounterRestController())->getOne($id);
633 RestConfig
::apiLog($return);
636 "GET /fhir/Practitioner" => function () {
637 RestConfig
::authorization_check("admin", "users");
638 $return = (new FhirPractitionerRestController())->getAll($_GET);
639 RestConfig
::apiLog($return);
642 "GET /fhir/Practitioner/:id" => function ($id) {
643 RestConfig
::authorization_check("admin", "users");
644 $return = (new FhirPractitionerRestController())->getOne($id);
645 RestConfig
::apiLog($return);
648 "POST /fhir/Practitioner" => function () {
649 RestConfig
::authorization_check("admin", "users");
650 $data = (array) (json_decode(file_get_contents("php://input"), true));
651 $return = (new FhirPractitionerRestController())->post($data);
652 RestConfig
::apiLog($return, $data);
655 "PUT /fhir/Practitioner/:id" => function ($id) {
656 RestConfig
::authorization_check("admin", "users");
657 $data = (array) (json_decode(file_get_contents("php://input"), true));
658 $return = (new FhirPractitionerRestController())->patch($id, $data);
659 RestConfig
::apiLog($return, $data);
662 "GET /fhir/Organization" => function () {
663 RestConfig
::authorization_check("admin", "users");
664 $return = (new FhirOrganizationRestController())->getAll($_GET);
665 RestConfig
::apiLog($return);
668 "GET /fhir/Organization/:id" => function ($id) {
669 RestConfig
::authorization_check("admin", "users");
670 $return = (new FhirOrganizationRestController())->getOne($id);
671 RestConfig
::apiLog($return);
674 "POST /fhir/Organization" => function () {
675 RestConfig
::authorization_check("admin", "super");
676 $data = (array) (json_decode(file_get_contents("php://input"), true));
677 $return = (new FhirOrganizationRestController())->post($data);
678 RestConfig
::apiLog($return, $data);
681 "PUT /fhir/Organization/:id" => function ($id) {
682 RestConfig
::authorization_check("admin", "super");
683 $data = (array) (json_decode(file_get_contents("php://input"), true));
684 $return = (new FhirOrganizationRestController())->patch($id, $data);
685 RestConfig
::apiLog($return, $data);
688 "GET /fhir/PractitionerRole" => function () {
689 RestConfig
::authorization_check("admin", "users");
690 $return = (new FhirPractitionerRoleRestController())->getAll($_GET);
691 RestConfig
::apiLog($return);
694 "GET /fhir/PractitionerRole/:id" => function ($id) {
695 RestConfig
::authorization_check("admin", "users");
696 $return = (new FhirPractitionerRoleRestController())->getOne($id);
697 RestConfig
::apiLog($return);
700 "GET /fhir/AllergyIntolerance" => function () {
701 RestConfig
::authorization_check("patients", "med");
702 $return = (new FhirAllergyIntoleranceRestController(null))->getAll($_GET);
703 RestConfig
::apiLog($return);
706 "GET /fhir/AllergyIntolerance/:id" => function ($id) {
707 RestConfig
::authorization_check("patients", "med");
708 $return = (new FhirAllergyIntoleranceRestController(null))->getOne($id);
709 RestConfig
::apiLog($return);
712 "GET /fhir/Observation" => function () {
713 RestConfig
::authorization_check("patients", "med");
714 $return = (new FhirObservationRestController())->getAll($_GET);
715 RestConfig
::apiLog($return);
718 "GET /fhir/Observation/:uuid" => function ($uuid) {
719 RestConfig
::authorization_check("patients", "med");
720 $return = (new FhirObservationRestController())->getOne($uuid);
721 RestConfig
::apiLog($return);
724 "POST /fhir/QuestionnaireResponse" => function () {
725 RestConfig
::authorization_check("patients", "demo");
726 $data = (array) (json_decode(file_get_contents("php://input"), true));
727 $return = (new FhirQuestionnaireResponseController(null))->post($data);
728 RestConfig
::apiLog($return, $data);
731 "GET /fhir/Immunization" => function () {
732 RestConfig
::authorization_check("patients", "med");
733 $return = (new FhirImmunizationRestController())->getAll($_GET);
734 RestConfig
::apiLog($return);
737 "GET /fhir/Immunization/:id" => function ($id) {
738 RestConfig
::authorization_check("patients", "med");
739 $return = (new FhirImmunizationRestController())->getOne($id);
740 RestConfig
::apiLog($return);
743 "GET /fhir/Condition" => function () {
744 RestConfig
::authorization_check("patients", "med");
745 $return = (new FhirConditionRestController())->getAll($_GET);
746 RestConfig
::apiLog($return);
749 "GET /fhir/Condition/:id" => function ($uuid) {
750 RestConfig
::authorization_check("patients", "med");
751 $return = (new FhirConditionRestController())->getOne($uuid);
752 RestConfig
::apiLog($return);
755 "GET /fhir/Procedure" => function () {
756 RestConfig
::authorization_check("patients", "med");
757 $return = (new FhirProcedureRestController())->getAll($_GET);
758 RestConfig
::apiLog($return);
761 "GET /fhir/Procedure/:uuid" => function ($uuid) {
762 RestConfig
::authorization_check("patients", "med");
763 $return = (new FhirProcedureRestController())->getOne($uuid);
764 RestConfig
::apiLog($return);
767 "GET /fhir/MedicationRequest" => function () {
768 RestConfig
::authorization_check("patients", "med");
769 $return = (new FhirMedicationRequestRestController())->getAll($_GET);
770 RestConfig
::apiLog($return);
773 "GET /fhir/MedicationRequest/:uuid" => function ($uuid) {
774 RestConfig
::authorization_check("patients", "med");
775 $return = (new FhirMedicationRequestRestController())->getOne($uuid);
776 RestConfig
::apiLog($return);
779 "GET /fhir/Medication" => function () {
780 RestConfig
::authorization_check("patients", "med");
781 $return = (new FhirMedicationRestController())->getAll($_GET);
782 RestConfig
::apiLog($return);
785 "GET /fhir/Medication/:uuid" => function ($uuid) {
786 RestConfig
::authorization_check("patients", "med");
787 $return = (new FhirMedicationRestController())->getOne($uuid);
788 RestConfig
::apiLog($return);
791 "GET /fhir/Location" => function () {
792 RestConfig
::authorization_check("patients", "med");
793 $return = (new FhirLocationRestController())->getAll($_GET);
794 RestConfig
::apiLog($return);
797 "GET /fhir/Location/:uuid" => function ($uuid) {
798 RestConfig
::authorization_check("patients", "med");
799 $return = (new FhirLocationRestController())->getOne($uuid);
800 RestConfig
::apiLog($return);
803 "GET /fhir/CareTeam" => function () {
804 RestConfig
::authorization_check("patients", "med");
805 $return = (new FhirCareTeamRestController())->getAll($_GET);
806 RestConfig
::apiLog($return);
809 "GET /fhir/CareTeam/:uuid" => function ($uuid) {
810 RestConfig
::authorization_check("patients", "med");
811 $return = (new FhirCareTeamRestController())->getOne($uuid);
812 RestConfig
::apiLog($return);
817 // Patient portal api routes
818 RestConfig
::$PORTAL_ROUTE_MAP = array(
819 "GET /portal/patient" => function () {
820 $return = (new PatientRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']));
821 RestConfig
::apiLog($return);
824 "GET /portal/patient/encounter" => function () {
825 $return = (new EncounterRestController())->getAll(UuidRegistry
::uuidToString($_SESSION['puuid']));
826 RestConfig
::apiLog($return);
829 "GET /portal/patient/encounter/:euuid" => function ($euuid) {
830 $return = (new EncounterRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']), $euuid);
831 RestConfig
::apiLog($return);
836 // Patient portal fhir api routes
837 RestConfig
::$PORTAL_FHIR_ROUTE_MAP = array(
838 "GET /portalfhir/Patient" => function () {
839 $return = (new FhirPatientRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']));
840 RestConfig
::apiLog($return);
843 "GET /portalfhir/Encounter" => function () {
844 $return = (new FhirEncounterRestController(null))->getAll(['patient' => UuidRegistry
::uuidToString($_SESSION['puuid'])]);
845 RestConfig
::apiLog($return);
848 "GET /portalfhir/Encounter/:id" => function ($id) {
849 $return = (new FhirEncounterRestController(null))->getAll(['_id' => $id, 'patient' => UuidRegistry
::uuidToString($_SESSION['puuid'])]);
850 RestConfig
::apiLog($return);