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\AuthRestController
;
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 RestConfig
::$ROUTE_MAP = array(
48 "POST /api/auth" => function () {
49 $data = (array) RestConfig
::getPostData((file_get_contents("php://input")));
50 $return = (new AuthRestController())->authenticate($data);
51 // sensitive data, so will not log the $data or $return for this endpoint
55 "GET /api/facility" => function () {
56 RestConfig
::authorization_check("admin", "users");
57 $return = (new FacilityRestController())->getAll($_GET);
58 RestConfig
::apiLog($return);
61 "GET /api/facility/:fuuid" => function ($fuuid) {
62 RestConfig
::authorization_check("admin", "users");
63 $return = (new FacilityRestController())->getOne($fuuid);
64 RestConfig
::apiLog($return);
67 "POST /api/facility" => function () {
68 RestConfig
::authorization_check("admin", "super");
69 $data = (array) (json_decode(file_get_contents("php://input")));
70 $return = (new FacilityRestController())->post($data);
71 RestConfig
::apiLog($return, $data);
74 "PATCH /api/facility/:fuuid" => function ($fuuid) {
75 RestConfig
::authorization_check("admin", "super");
76 $data = (array) (json_decode(file_get_contents("php://input")));
77 $return = (new FacilityRestController())->patch($fuuid, $data);
78 RestConfig
::apiLog($return, $data);
81 "GET /api/patient" => function () {
82 RestConfig
::authorization_check("patients", "demo");
83 $return = (new PatientRestController())->getAll($_GET);
84 RestConfig
::apiLog($return);
87 "POST /api/patient" => function () {
88 RestConfig
::authorization_check("patients", "demo");
89 $data = (array) (json_decode(file_get_contents("php://input")));
90 $return = (new PatientRestController())->post($data);
91 RestConfig
::apiLog($return, $data);
94 "PUT /api/patient/:puuid" => function ($puuid) {
95 RestConfig
::authorization_check("patients", "demo");
96 $data = (array) (json_decode(file_get_contents("php://input")));
97 $return = (new PatientRestController())->put($puuid, $data);
98 RestConfig
::apiLog($return, $data);
101 "GET /api/patient/:puuid" => function ($puuid) {
102 RestConfig
::authorization_check("patients", "demo");
103 $return = (new PatientRestController())->getOne($puuid);
104 RestConfig
::apiLog($return);
107 "GET /api/patient/:puuid/encounter" => function ($puuid) {
108 RestConfig
::authorization_check("encounters", "auth_a");
109 $return = (new EncounterRestController())->getAll($puuid);
110 RestConfig
::apiLog($return);
113 "POST /api/patient/:puuid/encounter" => function ($puuid) {
114 RestConfig
::authorization_check("encounters", "auth_a");
115 $data = (array) (json_decode(file_get_contents("php://input")));
116 $return = (new EncounterRestController())->post($puuid, $data);
117 RestConfig
::apiLog($return, $data);
120 "PUT /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
121 RestConfig
::authorization_check("encounters", "auth_a");
122 $data = (array) (json_decode(file_get_contents("php://input")));
123 $return = (new EncounterRestController())->put($puuid, $euuid, $data);
124 RestConfig
::apiLog($return, $data);
127 "GET /api/patient/:puuid/encounter/:euuid" => function ($puuid, $euuid) {
128 RestConfig
::authorization_check("encounters", "auth_a");
129 $return = (new EncounterRestController())->getOne($puuid, $euuid);
130 RestConfig
::apiLog($return);
133 "GET /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
134 RestConfig
::authorization_check("encounters", "notes");
135 $return = (new EncounterRestController())->getSoapNotes($pid, $eid);
136 RestConfig
::apiLog($return);
139 "POST /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
140 RestConfig
::authorization_check("encounters", "notes");
141 $data = (array) (json_decode(file_get_contents("php://input")));
142 $return = (new EncounterRestController())->postVital($pid, $eid, $data);
143 RestConfig
::apiLog($return, $data);
146 "PUT /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
147 RestConfig
::authorization_check("encounters", "notes");
148 $data = (array) (json_decode(file_get_contents("php://input")));
149 $return = (new EncounterRestController())->putVital($pid, $eid, $vid, $data);
150 RestConfig
::apiLog($return, $data);
153 "GET /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
154 RestConfig
::authorization_check("encounters", "notes");
155 $return = (new EncounterRestController())->getVitals($pid, $eid);
156 RestConfig
::apiLog($return);
159 "GET /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
160 RestConfig
::authorization_check("encounters", "notes");
161 $return = (new EncounterRestController())->getVital($pid, $eid, $vid);
162 RestConfig
::apiLog($return);
165 "GET /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
166 RestConfig
::authorization_check("encounters", "notes");
167 $return = (new EncounterRestController())->getSoapNote($pid, $eid, $sid);
168 RestConfig
::apiLog($return);
171 "POST /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
172 RestConfig
::authorization_check("encounters", "notes");
173 $data = (array) (json_decode(file_get_contents("php://input")));
174 $return = (new EncounterRestController())->postSoapNote($pid, $eid, $data);
175 RestConfig
::apiLog($return, $data);
178 "PUT /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
179 RestConfig
::authorization_check("encounters", "notes");
180 $data = (array) (json_decode(file_get_contents("php://input")));
181 $return = (new EncounterRestController())->putSoapNote($pid, $eid, $sid, $data);
182 RestConfig
::apiLog($return, $data);
185 "GET /api/practitioner" => function () {
186 RestConfig
::authorization_check("admin", "users");
187 $return = (new PractitionerRestController())->getAll($_GET);
188 RestConfig
::apiLog($return);
191 "GET /api/practitioner/:prid" => function ($prid) {
192 RestConfig
::authorization_check("admin", "users");
193 $return = (new PractitionerRestController())->getOne($prid);
194 RestConfig
::apiLog($return);
197 "POST /api/practitioner" => function () {
198 RestConfig
::authorization_check("admin", "users");
199 $data = (array) (json_decode(file_get_contents("php://input")));
200 $return = (new PractitionerRestController())->post($data);
201 RestConfig
::apiLog($return, $data);
204 "PATCH /api/practitioner/:prid" => function ($prid) {
205 RestConfig
::authorization_check("admin", "users");
206 $data = (array) (json_decode(file_get_contents("php://input")));
207 $return = (new PractitionerRestController())->patch($prid, $data);
208 RestConfig
::apiLog($return, $data);
211 "GET /api/medical_problem" => function () {
212 RestConfig
::authorization_check("encounters", "notes");
213 $return = (new ConditionRestController())->getAll();
214 RestConfig
::apiLog($return);
217 "GET /api/medical_problem/:muuid" => function ($muuid) {
218 RestConfig
::authorization_check("encounters", "notes");
219 $return = (new ConditionRestController())->getOne($muuid);
220 RestConfig
::apiLog($return);
223 "GET /api/patient/:puuid/medical_problem" => function ($puuid) {
224 RestConfig
::authorization_check("encounters", "notes");
225 $return = (new ConditionRestController())->getAll($puuid, "medical_problem");
226 RestConfig
::apiLog($return);
229 "GET /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
230 RestConfig
::authorization_check("patients", "med");
231 $return = (new ConditionRestController())->getAll(['lists.pid' => $puuid, 'lists.id' => $muuid]);
232 RestConfig
::apiLog($return);
235 "POST /api/patient/:puuid/medical_problem" => function ($puuid) {
236 RestConfig
::authorization_check("patients", "med");
237 $data = (array) (json_decode(file_get_contents("php://input")));
238 $return = (new ConditionRestController())->post($puuid, $data);
239 RestConfig
::apiLog($return, $data);
242 "PUT /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
243 RestConfig
::authorization_check("patients", "med");
244 $data = (array) (json_decode(file_get_contents("php://input")));
245 $return = (new ConditionRestController())->put($puuid, $muuid, $data);
246 RestConfig
::apiLog($return, $data);
249 "DELETE /api/patient/:puuid/medical_problem/:muuid" => function ($puuid, $muuid) {
250 RestConfig
::authorization_check("patients", "med");
251 $return = (new ConditionRestController())->delete($puuid, $muuid);
252 RestConfig
::apiLog($return);
255 "GET /api/allergy" => function () {
256 RestConfig
::authorization_check("patients", "med");
257 $return = (new AllergyIntoleranceRestController())->getAll();
258 RestConfig
::apiLog($return);
261 "GET /api/allergy/:auuid" => function ($auuid) {
262 RestConfig
::authorization_check("patients", "med");
263 $return = (new AllergyIntoleranceRestController())->getOne($auuid);
264 RestConfig
::apiLog($return);
267 "GET /api/patient/:puuid/allergy" => function ($puuid) {
268 RestConfig
::authorization_check("patients", "med");
269 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid]);
270 RestConfig
::apiLog($return);
273 "GET /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
274 RestConfig
::authorization_check("patients", "med");
275 $return = (new AllergyIntoleranceRestController())->getAll(['lists.pid' => $puuid, 'lists.id' => $auuid]);
276 RestConfig
::apiLog($return);
279 "POST /api/patient/:puuid/allergy" => function ($puuid) {
280 RestConfig
::authorization_check("patients", "med");
281 $data = (array) (json_decode(file_get_contents("php://input")));
282 $return = (new AllergyIntoleranceRestController())->post($puuid, $data);
283 RestConfig
::apiLog($return, $data);
286 "PUT /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
287 RestConfig
::authorization_check("patients", "med");
288 $data = (array) (json_decode(file_get_contents("php://input")));
289 $return = (new AllergyIntoleranceRestController())->put($puuid, $auuid, $data);
290 RestConfig
::apiLog($return, $data);
293 "DELETE /api/patient/:puuid/allergy/:auuid" => function ($puuid, $auuid) {
294 RestConfig
::authorization_check("patients", "med");
295 $return = (new AllergyIntoleranceRestController())->delete($puuid, $auuid);
296 RestConfig
::apiLog($return);
299 "GET /api/patient/:pid/medication" => function ($pid) {
300 RestConfig
::authorization_check("patients", "med");
301 $return = (new ListRestController())->getAll($pid, "medication");
302 RestConfig
::apiLog($return);
305 "POST /api/patient/:pid/medication" => function ($pid) {
306 RestConfig
::authorization_check("patients", "med");
307 $data = (array) (json_decode(file_get_contents("php://input")));
308 $return = (new ListRestController())->post($pid, "medication", $data);
309 RestConfig
::apiLog($return, $data);
312 "PUT /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
313 RestConfig
::authorization_check("patients", "med");
314 $data = (array) (json_decode(file_get_contents("php://input")));
315 $return = (new ListRestController())->put($pid, $mid, "medication", $data);
316 RestConfig
::apiLog($return, $data);
319 "GET /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
320 RestConfig
::authorization_check("patients", "med");
321 $return = (new ListRestController())->getOne($pid, "medication", $mid);
322 RestConfig
::apiLog($return);
325 "DELETE /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
326 RestConfig
::authorization_check("patients", "med");
327 $return = (new ListRestController())->delete($pid, $mid, "medication");
328 RestConfig
::apiLog($return);
331 "GET /api/patient/:pid/surgery" => function ($pid) {
332 RestConfig
::authorization_check("patients", "med");
333 $return = (new ListRestController())->getAll($pid, "surgery");
334 RestConfig
::apiLog($return);
337 "GET /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
338 RestConfig
::authorization_check("patients", "med");
339 $return = (new ListRestController())->getOne($pid, "surgery", $sid);
340 RestConfig
::apiLog($return);
343 "DELETE /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
344 RestConfig
::authorization_check("patients", "med");
345 $return = (new ListRestController())->delete($pid, $sid, "surgery");
346 RestConfig
::apiLog($return);
349 "POST /api/patient/:pid/surgery" => function ($pid) {
350 RestConfig
::authorization_check("patients", "med");
351 $data = (array) (json_decode(file_get_contents("php://input")));
352 $return = (new ListRestController())->post($pid, "surgery", $data);
353 RestConfig
::apiLog($return, $data);
356 "PUT /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
357 RestConfig
::authorization_check("patients", "med");
358 $data = (array) (json_decode(file_get_contents("php://input")));
359 $return = (new ListRestController())->put($pid, $sid, "surgery", $data);
360 RestConfig
::apiLog($return, $data);
363 "GET /api/patient/:pid/dental_issue" => function ($pid) {
364 RestConfig
::authorization_check("patients", "med");
365 $return = (new ListRestController())->getAll($pid, "dental");
366 RestConfig
::apiLog($return);
369 "GET /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
370 RestConfig
::authorization_check("patients", "med");
371 $return = (new ListRestController())->getOne($pid, "dental", $did);
372 RestConfig
::apiLog($return);
375 "DELETE /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
376 RestConfig
::authorization_check("patients", "med");
377 $return = (new ListRestController())->delete($pid, $did, "dental");
378 RestConfig
::apiLog($return);
381 "POST /api/patient/:pid/dental_issue" => function ($pid) {
382 RestConfig
::authorization_check("patients", "med");
383 $data = (array) (json_decode(file_get_contents("php://input")));
384 $return = (new ListRestController())->post($pid, "dental", $data);
385 RestConfig
::apiLog($return, $data);
388 "PUT /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
389 RestConfig
::authorization_check("patients", "med");
390 $data = (array) (json_decode(file_get_contents("php://input")));
391 $return = (new ListRestController())->put($pid, $did, "dental", $data);
392 RestConfig
::apiLog($return, $data);
395 "GET /api/patient/:pid/appointment" => function ($pid) {
396 RestConfig
::authorization_check("patients", "appt");
397 $return = (new AppointmentRestController())->getAllForPatient($pid);
398 RestConfig
::apiLog($return);
401 "POST /api/patient/:pid/appointment" => function ($pid) {
402 RestConfig
::authorization_check("patients", "appt");
403 $data = (array) (json_decode(file_get_contents("php://input")));
404 $return = (new AppointmentRestController())->post($pid, $data);
405 RestConfig
::apiLog($return, $data);
408 "GET /api/appointment" => function () {
409 RestConfig
::authorization_check("patients", "appt");
410 $return = (new AppointmentRestController())->getAll();
411 RestConfig
::apiLog($return);
414 "GET /api/appointment/:eid" => function ($eid) {
415 RestConfig
::authorization_check("patients", "appt");
416 $return = (new AppointmentRestController())->getOne($eid);
417 RestConfig
::apiLog($return);
420 "DELETE /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
421 RestConfig
::authorization_check("patients", "appt");
422 $return = (new AppointmentRestController())->delete($eid);
423 RestConfig
::apiLog($return);
426 "GET /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
427 RestConfig
::authorization_check("patients", "appt");
428 $return = (new AppointmentRestController())->getOne($eid);
429 RestConfig
::apiLog($return);
432 "GET /api/list/:list_name" => function ($list_name) {
433 RestConfig
::authorization_check("lists", "default");
434 $return = (new ListRestController())->getOptions($list_name);
435 RestConfig
::apiLog($return);
438 "GET /api/version" => function () {
439 $return = (new VersionRestController())->getOne();
440 RestConfig
::apiLog($return);
443 "GET /api/product" => function () {
444 $return = (new ProductRegistrationRestController())->getOne();
445 RestConfig
::apiLog($return);
448 "GET /api/insurance_company" => function () {
449 $return = (new InsuranceCompanyRestController())->getAll();
450 RestConfig
::apiLog($return);
453 "GET /api/insurance_company/:iid" => function ($iid) {
454 $return = (new InsuranceCompanyRestController())->getOne($iid);
455 RestConfig
::apiLog($return);
458 "GET /api/insurance_type" => function () {
459 $return = (new InsuranceCompanyRestController())->getInsuranceTypes();
460 RestConfig
::apiLog($return);
463 "POST /api/insurance_company" => function () {
464 $data = (array) (json_decode(file_get_contents("php://input")));
465 $return = (new InsuranceCompanyRestController())->post($data);
466 RestConfig
::apiLog($return, $data);
469 "PUT /api/insurance_company/:iid" => function ($iid) {
470 $data = (array) (json_decode(file_get_contents("php://input")));
471 $return = (new InsuranceCompanyRestController())->put($iid, $data);
472 RestConfig
::apiLog($return, $data);
475 "POST /api/patient/:pid/document" => function ($pid) {
476 $return = (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
477 RestConfig
::apiLog($return);
480 "GET /api/patient/:pid/document" => function ($pid) {
481 $return = (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
482 RestConfig
::apiLog($return);
485 "GET /api/patient/:pid/document/:did" => function ($pid, $did) {
486 $return = (new DocumentRestController())->downloadFile($pid, $did);
487 RestConfig
::apiLog($return);
490 "GET /api/patient/:pid/insurance" => function ($pid) {
491 $return = (new InsuranceRestController())->getAll($pid);
492 RestConfig
::apiLog($return);
495 "GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
496 $return = (new InsuranceRestController())->getOne($pid, $type);
497 RestConfig
::apiLog($return);
500 "POST /api/patient/:pid/insurance/:type" => function ($pid, $type) {
501 $data = (array) (json_decode(file_get_contents("php://input")));
502 $return = (new InsuranceRestController())->post($pid, $type, $data);
503 RestConfig
::apiLog($return, $data);
506 "PUT /api/patient/:pid/insurance/:type" => function ($pid, $type) {
507 $data = (array) (json_decode(file_get_contents("php://input")));
508 $return = (new InsuranceRestController())->put($pid, $type, $data);
509 RestConfig
::apiLog($return, $data);
512 "POST /api/patient/:pid/message" => function ($pid) {
513 RestConfig
::authorization_check("patients", "notes");
514 $data = (array) (json_decode(file_get_contents("php://input")));
515 $return = (new MessageRestController())->post($pid, $data);
516 RestConfig
::apiLog($return, $data);
519 "PUT /api/patient/:pid/message/:mid" => function ($pid, $mid) {
520 RestConfig
::authorization_check("patients", "notes");
521 $data = (array) (json_decode(file_get_contents("php://input")));
522 $return = (new MessageRestController())->put($pid, $mid, $data);
523 RestConfig
::apiLog($return, $data);
526 "DELETE /api/patient/:pid/message/:mid" => function ($pid, $mid) {
527 RestConfig
::authorization_check("patients", "notes");
528 $return = (new MessageRestController())->delete($pid, $mid);
529 RestConfig
::apiLog($return);
532 "GET /api/immunization" => function () {
533 RestConfig
::authorization_check("patients", "med");
534 $return = (new ImmunizationRestController())->getAll($_GET);
535 RestConfig
::apiLog($return);
538 "GET /api/immunization/:uuid" => function ($uuid) {
539 RestConfig
::authorization_check("patients", "med");
540 $return = (new ImmunizationRestController())->getOne($uuid);
541 RestConfig
::apiLog($return);
544 "GET /api/procedure" => function () {
545 RestConfig
::authorization_check("patients", "med");
546 $return = (new ProcedureRestController())->getAll();
547 RestConfig
::apiLog($return);
550 "GET /api/procedure/:uuid" => function ($uuid) {
551 RestConfig
::authorization_check("patients", "med");
552 $return = (new ProcedureRestController())->getOne($uuid);
553 RestConfig
::apiLog($return);
556 "GET /api/drug" => function () {
557 RestConfig
::authorization_check("patients", "med");
558 $return = (new DrugRestController())->getAll();
559 RestConfig
::apiLog($return);
562 "GET /api/drug/:uuid" => function ($uuid) {
563 RestConfig
::authorization_check("patients", "med");
564 $return = (new DrugRestController())->getOne($uuid);
565 RestConfig
::apiLog($return);
568 "GET /api/prescription" => function () {
569 RestConfig
::authorization_check("patients", "med");
570 $return = (new PrescriptionRestController())->getAll();
571 RestConfig
::apiLog($return);
574 "GET /api/prescription/:uuid" => function ($uuid) {
575 RestConfig
::authorization_check("patients", "med");
576 $return = (new PrescriptionRestController())->getOne($uuid);
577 RestConfig
::apiLog($return);
583 use OpenEMR\RestControllers\FHIR\FhirAllergyIntoleranceRestController
;
584 use OpenEMR\RestControllers\FHIR\FhirCareTeamRestController
;
585 use OpenEMR\RestControllers\FHIR\FhirConditionRestController
;
586 use OpenEMR\RestControllers\FHIR\FhirEncounterRestController
;
587 use OpenEMR\RestControllers\FHIR\FhirObservationRestController
;
588 use OpenEMR\RestControllers\FHIR\FhirImmunizationRestController
;
589 use OpenEMR\RestControllers\FHIR\FhirLocationRestController
;
590 use OpenEMR\RestControllers\FHIR\FhirMedicationRestController
;
591 use OpenEMR\RestControllers\FHIR\FhirMedicationRequestRestController
;
592 use OpenEMR\RestControllers\FHIR\FhirOrganizationRestController
;
593 use OpenEMR\RestControllers\FHIR\FhirPatientRestController
;
594 use OpenEMR\RestControllers\FHIR\FhirPractitionerRoleRestController
;
595 use OpenEMR\RestControllers\FHIR\FhirPractitionerRestController
;
596 use OpenEMR\RestControllers\FHIR\FhirProcedureRestController
;
597 use OpenEMR\RestControllers\FHIR\FhirQuestionnaireResponseController
;
598 use OpenEMR\RestControllers\FHIR\FhirMetaDataRestController
;
600 RestConfig
::$FHIR_ROUTE_MAP = array(
601 "POST /fhir/auth" => function () {
602 $data = (array) RestConfig
::getPostData((file_get_contents("php://input")));
603 $return = (new AuthRestController())->authenticate($data);
604 // sensitive data, so will not log the $data or $return for this endpoint
605 RestConfig
::apiLog();
608 "GET /fhir/metadata" => function () {
609 $return = (new FhirMetaDataRestController())->getMetaData();
610 RestConfig
::apiLog($return);
613 "POST /fhir/Patient" => function () {
614 RestConfig
::authorization_check("patients", "demo");
615 $data = (array) (json_decode(file_get_contents("php://input"), true));
616 $return = (new FhirPatientRestController())->post($data);
617 RestConfig
::apiLog($return, $data);
620 "PUT /fhir/Patient/:id" => function ($id) {
621 RestConfig
::authorization_check("patients", "demo");
622 $data = (array) (json_decode(file_get_contents("php://input"), true));
623 $return = (new FhirPatientRestController())->put($id, $data);
624 RestConfig
::apiLog($return, $data);
627 "PATCH /fhir/Patient/:id" => function ($id) {
628 RestConfig
::authorization_check("patients", "demo");
629 $data = (array) (json_decode(file_get_contents("php://input"), true));
630 $return = (new FhirPatientRestController())->put($id, $data);
631 RestConfig
::apiLog($return, $data);
634 "GET /fhir/Patient" => function () {
635 RestConfig
::authorization_check("patients", "demo");
636 $return = (new FhirPatientRestController())->getAll($_GET);
637 RestConfig
::apiLog($return);
640 "GET /fhir/Patient/:id" => function ($id) {
641 RestConfig
::authorization_check("patients", "demo");
642 $return = (new FhirPatientRestController())->getOne($id);
643 RestConfig
::apiLog($return);
646 "GET /fhir/Encounter" => function () {
647 RestConfig
::authorization_check("encounters", "auth_a");
648 $return = (new FhirEncounterRestController(null))->getAll($_GET);
649 RestConfig
::apiLog($return);
652 "GET /fhir/Encounter/:id" => function ($id) {
653 RestConfig
::authorization_check("encounters", "auth_a");
654 $return = (new FhirEncounterRestController())->getOne($id);
655 RestConfig
::apiLog($return);
658 "GET /fhir/Practitioner" => function () {
659 RestConfig
::authorization_check("admin", "users");
660 $return = (new FhirPractitionerRestController())->getAll($_GET);
661 RestConfig
::apiLog($return);
664 "GET /fhir/Practitioner/:id" => function ($id) {
665 RestConfig
::authorization_check("admin", "users");
666 $return = (new FhirPractitionerRestController())->getOne($id);
667 RestConfig
::apiLog($return);
670 "POST /fhir/Practitioner" => function () {
671 RestConfig
::authorization_check("admin", "users");
672 $data = (array) (json_decode(file_get_contents("php://input"), true));
673 $return = (new FhirPractitionerRestController())->post($data);
674 RestConfig
::apiLog($return, $data);
677 "PATCH /fhir/Practitioner/:id" => function ($id) {
678 RestConfig
::authorization_check("admin", "users");
679 $data = (array) (json_decode(file_get_contents("php://input"), true));
680 $return = (new FhirPractitionerRestController())->patch($id, $data);
681 RestConfig
::apiLog($return, $data);
684 "GET /fhir/Organization" => function () {
685 RestConfig
::authorization_check("admin", "users");
686 $return = (new FhirOrganizationRestController())->getAll($_GET);
687 RestConfig
::apiLog($return);
690 "GET /fhir/Organization/:id" => function ($id) {
691 RestConfig
::authorization_check("admin", "users");
692 $return = (new FhirOrganizationRestController())->getOne($id);
693 RestConfig
::apiLog($return);
696 "POST /fhir/Organization" => function () {
697 RestConfig
::authorization_check("admin", "super");
698 $data = (array) (json_decode(file_get_contents("php://input"), true));
699 $return = (new FhirOrganizationRestController())->post($data);
700 RestConfig
::apiLog($return, $data);
703 "PATCH /fhir/Organization/:id" => function ($id) {
704 RestConfig
::authorization_check("admin", "super");
705 $data = (array) (json_decode(file_get_contents("php://input"), true));
706 $return = (new FhirOrganizationRestController())->patch($id, $data);
707 RestConfig
::apiLog($return, $data);
710 "GET /fhir/PractitionerRole" => function () {
711 RestConfig
::authorization_check("admin", "users");
712 $return = (new FhirPractitionerRoleRestController())->getAll($_GET);
713 RestConfig
::apiLog($return);
716 "GET /fhir/PractitionerRole/:id" => function ($id) {
717 RestConfig
::authorization_check("admin", "users");
718 $return = (new FhirPractitionerRoleRestController())->getOne($id);
719 RestConfig
::apiLog($return);
722 "GET /fhir/AllergyIntolerance" => function () {
723 RestConfig
::authorization_check("patients", "med");
724 $return = (new FhirAllergyIntoleranceRestController(null))->getAll($_GET);
725 RestConfig
::apiLog($return);
728 "GET /fhir/AllergyIntolerance/:id" => function ($id) {
729 RestConfig
::authorization_check("patients", "med");
730 $return = (new FhirAllergyIntoleranceRestController(null))->getOne($id);
731 RestConfig
::apiLog($return);
734 "GET /fhir/Observation" => function () {
735 RestConfig
::authorization_check("patients", "med");
736 $return = (new FhirObservationRestController())->getAll($_GET);
737 RestConfig
::apiLog($return);
740 "GET /fhir/Observation/:uuid" => function ($uuid) {
741 RestConfig
::authorization_check("patients", "med");
742 $return = (new FhirObservationRestController())->getOne($uuid);
743 RestConfig
::apiLog($return);
746 "POST /fhir/QuestionnaireResponse" => function () {
747 RestConfig
::authorization_check("patients", "demo");
748 $data = (array) (json_decode(file_get_contents("php://input"), true));
749 $return = (new FhirQuestionnaireResponseController(null))->post($data);
750 RestConfig
::apiLog($return, $data);
753 "GET /fhir/Immunization" => function () {
754 RestConfig
::authorization_check("patients", "med");
755 $return = (new FhirImmunizationRestController())->getAll($_GET);
756 RestConfig
::apiLog($return);
759 "GET /fhir/Immunization/:id" => function ($id) {
760 RestConfig
::authorization_check("patients", "med");
761 $return = (new FhirImmunizationRestController())->getOne($id);
762 RestConfig
::apiLog($return);
765 "GET /fhir/Condition" => function () {
766 RestConfig
::authorization_check("patients", "med");
767 $return = (new FhirConditionRestController())->getAll($_GET);
768 RestConfig
::apiLog($return);
771 "GET /fhir/Condition/:id" => function ($uuid) {
772 RestConfig
::authorization_check("patients", "med");
773 $return = (new FhirConditionRestController())->getOne($uuid);
774 RestConfig
::apiLog($return);
777 "GET /fhir/Procedure" => function () {
778 RestConfig
::authorization_check("patients", "med");
779 $return = (new FhirProcedureRestController())->getAll($_GET);
780 RestConfig
::apiLog($return);
783 "GET /fhir/Procedure/:uuid" => function ($uuid) {
784 RestConfig
::authorization_check("patients", "med");
785 $return = (new FhirProcedureRestController())->getOne($uuid);
786 RestConfig
::apiLog($return);
789 "GET /fhir/MedicationRequest" => function () {
790 RestConfig
::authorization_check("patients", "med");
791 $return = (new FhirMedicationRequestRestController())->getAll($_GET);
792 RestConfig
::apiLog($return);
795 "GET /fhir/MedicationRequest/:uuid" => function ($uuid) {
796 RestConfig
::authorization_check("patients", "med");
797 $return = (new FhirMedicationRequestRestController())->getOne($uuid);
798 RestConfig
::apiLog($return);
801 "GET /fhir/Medication" => function () {
802 RestConfig
::authorization_check("patients", "med");
803 $return = (new FhirMedicationRestController())->getAll($_GET);
804 RestConfig
::apiLog($return);
807 "GET /fhir/Medication/:uuid" => function ($uuid) {
808 RestConfig
::authorization_check("patients", "med");
809 $return = (new FhirMedicationRestController())->getOne($uuid);
810 RestConfig
::apiLog($return);
813 "GET /fhir/Location" => function () {
814 RestConfig
::authorization_check("patients", "med");
815 $return = (new FhirLocationRestController())->getAll($_GET);
816 RestConfig
::apiLog($return);
819 "GET /fhir/Location/:uuid" => function ($uuid) {
820 RestConfig
::authorization_check("patients", "med");
821 $return = (new FhirLocationRestController())->getOne($uuid);
822 RestConfig
::apiLog($return);
825 "GET /fhir/CareTeam" => function () {
826 RestConfig
::authorization_check("patients", "med");
827 $return = (new FhirCareTeamRestController())->getAll($_GET);
828 RestConfig
::apiLog($return);
831 "GET /fhir/CareTeam/:uuid" => function ($uuid) {
832 RestConfig
::authorization_check("patients", "med");
833 $return = (new FhirCareTeamRestController())->getOne($uuid);
834 RestConfig
::apiLog($return);
839 // Patient portal api routes
840 RestConfig
::$PORTAL_ROUTE_MAP = array(
841 "POST /portal/auth" => function () {
842 $data = (array) RestConfig
::getPostData((file_get_contents("php://input")));
843 $return = (new AuthRestController())->authenticate($data);
844 // sensitive data, so will not log the $data or $return for this endpoint
845 RestConfig
::apiLog();
848 "GET /portal/patient" => function () {
849 $return = (new PatientRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']));
850 RestConfig
::apiLog($return);
853 "GET /portal/patient/encounter" => function () {
854 $return = (new EncounterRestController())->getAll(UuidRegistry
::uuidToString($_SESSION['puuid']));
855 RestConfig
::apiLog($return);
858 "GET /portal/patient/encounter/:euuid" => function ($euuid) {
859 $return = (new EncounterRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']), $euuid);
860 RestConfig
::apiLog($return);
865 // Patient portal fhir api routes
866 RestConfig
::$PORTAL_FHIR_ROUTE_MAP = array(
867 "POST /portalfhir/auth" => function () {
868 $data = (array) RestConfig
::getPostData((file_get_contents("php://input")));
869 $return = (new AuthRestController())->authenticate($data);
870 // sensitive data, so will not log the $data or $return for this endpoint
871 RestConfig
::apiLog();
874 "GET /portalfhir/Patient" => function () {
875 $return = (new FhirPatientRestController())->getOne(UuidRegistry
::uuidToString($_SESSION['puuid']));
876 RestConfig
::apiLog($return);
879 "GET /portalfhir/Encounter" => function () {
880 $return = (new FhirEncounterRestController(null))->getAll(['patient' => UuidRegistry
::uuidToString($_SESSION['puuid'])]);
881 RestConfig
::apiLog($return);
884 "GET /portalfhir/Encounter/:id" => function ($id) {
885 $return = (new FhirEncounterRestController(null))->getAll(['_id' => $id, 'patient' => UuidRegistry
::uuidToString($_SESSION['puuid'])]);
886 RestConfig
::apiLog($return);