forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_rest_routes.inc.php
352 lines (347 loc) · 16.4 KB
/
_rest_routes.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?php
/**
* Routes
* (All REST routes)
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Matthew Vita <[email protected]>
* @author Jerry Padgett <[email protected]>
* @copyright Copyright (c) 2018 Matthew Vita <[email protected]>
* @copyright Copyright (c) 2018 Jerry Padgett <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
// Lets keep our controller classes with the routes.
//
use OpenEMR\RestControllers\FacilityRestController;
use OpenEMR\RestControllers\VersionRestController;
use OpenEMR\RestControllers\ProductRegistrationRestController;
use OpenEMR\RestControllers\PatientRestController;
use OpenEMR\RestControllers\EncounterRestController;
use OpenEMR\RestControllers\ProviderRestController;
use OpenEMR\RestControllers\ListRestController;
use OpenEMR\RestControllers\InsuranceCompanyRestController;
use OpenEMR\RestControllers\AppointmentRestController;
use OpenEMR\RestControllers\AuthRestController;
use OpenEMR\RestControllers\ONoteRestController;
use OpenEMR\RestControllers\DocumentRestController;
use OpenEMR\RestControllers\InsuranceRestController;
use OpenEMR\RestControllers\MessageRestController;
// Note some Http clients may not send auth as json so a function
// is implemented to determine and parse encoding on auth route's.
//
RestConfig::$ROUTE_MAP = array(
"POST /api/auth" => function () {
$data = (array) RestConfig::getPostData((file_get_contents("php://input")));
return (new AuthRestController())->authenticate($data);
},
"GET /api/facility" => function () {
authorization_check("admin", "users");
return (new FacilityRestController())->getAll();
},
"GET /api/facility/:fid" => function ($fid) {
authorization_check("admin", "users");
return (new FacilityRestController())->getOne($fid);
},
"POST /api/facility" => function () {
authorization_check("admin", "super");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new FacilityRestController())->post($data);
},
"PUT /api/facility/:fid" => function ($fid) {
authorization_check("admin", "super");
$data = (array)(json_decode(file_get_contents("php://input")));
$data["fid"] = $fid;
return (new FacilityRestController())->put($data);
},
"GET /api/provider" => function () {
authorization_check("admin", "users");
return (new ProviderRestController())->getAll();
},
"GET /api/provider/:prid" => function ($prid) {
authorization_check("admin", "users");
return (new ProviderRestController())->getOne($prid);
},
"GET /api/patient" => function () {
authorization_check("patients", "demo");
return (new PatientRestController(null))->getAll($_GET);
},
"POST /api/patient" => function () {
authorization_check("patients", "demo");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new PatientRestController(null))->post($data);
},
"PUT /api/patient/:pid" => function ($pid) {
authorization_check("patients", "demo");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new PatientRestController(null))->put($pid, $data);
},
"GET /api/patient/:pid" => function ($pid) {
authorization_check("patients", "demo");
return (new PatientRestController($pid))->getOne();
},
"GET /api/patient/:pid/encounter" => function ($pid) {
authorization_check("encounters", "auth_a");
return (new EncounterRestController())->getAll($pid);
},
"GET /api/patient/:pid/encounter/:eid" => function ($pid, $eid) {
authorization_check("encounters", "auth_a");
return (new EncounterRestController())->getOne($pid, $eid);
},
"GET /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
authorization_check("encounters", "notes");
return (new EncounterRestController())->getSoapNotes($pid, $eid);
},
"POST /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
authorization_check("encounters", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new EncounterRestController())->postVital($pid, $eid, $data);
},
"PUT /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
authorization_check("encounters", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new EncounterRestController())->putVital($pid, $eid, $vid, $data);
},
"GET /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
authorization_check("encounters", "notes");
return (new EncounterRestController())->getVitals($pid, $eid);
},
"GET /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
authorization_check("encounters", "notes");
return (new EncounterRestController())->getVital($pid, $eid, $vid);
},
"GET /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
authorization_check("encounters", "notes");
return (new EncounterRestController())->getSoapNote($pid, $eid, $sid);
},
"POST /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
authorization_check("encounters", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new EncounterRestController())->postSoapNote($pid, $eid, $data);
},
"PUT /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
authorization_check("encounters", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new EncounterRestController())->putSoapNote($pid, $eid, $sid, $data);
},
"GET /api/patient/:pid/medical_problem" => function ($pid) {
authorization_check("encounters", "notes");
return (new ListRestController())->getAll($pid, "medical_problem");
},
"GET /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
return (new ListRestController())->getOne($pid, "medical_problem", $mid);
},
"POST /api/patient/:pid/medical_problem" => function ($pid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->post($pid, "medical_problem", $data);
},
"PUT /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->put($pid, $mid, "medical_problem", $data);
},
"DELETE /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
return (new ListRestController())->delete($pid, $mid, "medical_problem");
},
"GET /api/patient/:pid/allergy" => function ($pid) {
authorization_check("patients", "med");
return (new ListRestController())->getAll($pid, "allergy");
},
"GET /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
authorization_check("patients", "med");
return (new ListRestController())->getOne($pid, "allergy", $aid);
},
"DELETE /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
authorization_check("patients", "med");
return (new ListRestController())->delete($pid, $aid, "allergy");
},
"POST /api/patient/:pid/allergy" => function ($pid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->post($pid, "allergy", $data);
},
"PUT /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->put($pid, $aid, "allergy", $data);
},
"GET /api/patient/:pid/medication" => function ($pid) {
authorization_check("patients", "med");
return (new ListRestController())->getAll($pid, "medication");
},
"POST /api/patient/:pid/medication" => function ($pid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->post($pid, "medication", $data);
},
"PUT /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->put($pid, $mid, "medication", $data);
},
"GET /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
return (new ListRestController())->getOne($pid, "medication", $mid);
},
"DELETE /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
authorization_check("patients", "med");
return (new ListRestController())->delete($pid, $mid, "medication");
},
"GET /api/patient/:pid/surgery" => function ($pid) {
authorization_check("patients", "med");
return (new ListRestController())->getAll($pid, "surgery");
},
"GET /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
authorization_check("patients", "med");
return (new ListRestController())->getOne($pid, "surgery", $sid);
},
"DELETE /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
authorization_check("patients", "med");
return (new ListRestController())->delete($pid, $sid, "surgery");
},
"POST /api/patient/:pid/surgery" => function ($pid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->post($pid, "surgery", $data);
},
"PUT /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->put($pid, $sid, "surgery", $data);
},
"GET /api/patient/:pid/dental_issue" => function ($pid) {
authorization_check("patients", "med");
return (new ListRestController())->getAll($pid, "dental");
},
"GET /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
authorization_check("patients", "med");
return (new ListRestController())->getOne($pid, "dental", $did);
},
"DELETE /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
authorization_check("patients", "med");
return (new ListRestController())->delete($pid, $did, "dental");
},
"POST /api/patient/:pid/dental_issue" => function ($pid) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->post($pid, "dental", $data);
},
"PUT /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
authorization_check("patients", "med");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new ListRestController())->put($pid, $did, "dental", $data);
},
"GET /api/patient/:pid/appointment" => function ($pid) {
authorization_check("patients", "appt");
return (new AppointmentRestController())->getAllForPatient($pid);
},
"POST /api/patient/:pid/appointment" => function ($pid) {
authorization_check("patients", "appt");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new AppointmentRestController())->post($pid, $data);
},
"GET /api/appointment" => function () {
authorization_check("patients", "appt");
return (new AppointmentRestController())->getAll();
},
"GET /api/appointment/:eid" => function ($eid) {
authorization_check("patients", "appt");
return (new AppointmentRestController())->getOne($eid);
},
"DELETE /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
authorization_check("patients", "appt");
return (new AppointmentRestController())->delete($eid);
},
"GET /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
authorization_check("patients", "appt");
return (new AppointmentRestController())->getOne($eid);
},
"GET /api/list/:list_name" => function ($list_name) {
authorization_check("lists", "default");
return (new ListRestController())->getOptions($list_name);
},
"GET /api/version" => function () {
return (new VersionRestController())->getOne();
},
"GET /api/product" => function () {
return (new ProductRegistrationRestController())->getOne();
},
"GET /api/insurance_company" => function () {
return (new InsuranceCompanyRestController())->getAll();
},
"GET /api/insurance_type" => function () {
return (new InsuranceCompanyRestController())->getInsuranceTypes();
},
"POST /api/insurance_company" => function () {
$data = (array)(json_decode(file_get_contents("php://input")));
return (new InsuranceCompanyRestController())->post($data);
},
"PUT /api/insurance_company/:iid" => function ($iid) {
$data = (array)(json_decode(file_get_contents("php://input")));
return (new InsuranceCompanyRestController())->put($iid, $data);
},
"POST /api/patient/:pid/document" => function ($pid) {
return (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
},
"GET /api/patient/:pid/document" => function ($pid) {
return (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
},
"GET /api/patient/:pid/document/:did" => function ($pid, $did) {
return (new DocumentRestController())->downloadFile($pid, $did);
},
"GET /api/patient/:pid/insurance" => function ($pid) {
return (new InsuranceRestController())->getAll($pid);
},
"GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
return (new InsuranceRestController())->getOne($pid, $type);
},
"POST /api/patient/:pid/insurance/:type" => function ($pid, $type) {
$data = (array)(json_decode(file_get_contents("php://input")));
return (new InsuranceRestController())->post($pid, $type, $data);
},
"PUT /api/patient/:pid/insurance/:type" => function ($pid, $type) {
$data = (array)(json_decode(file_get_contents("php://input")));
return (new InsuranceRestController())->put($pid, $type, $data);
},
"POST /api/patient/:pid/message" => function ($pid) {
authorization_check("patients", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new MessageRestController())->post($pid, $data);
},
"PUT /api/patient/:pid/message/:mid" => function ($pid, $mid) {
authorization_check("patients", "notes");
$data = (array)(json_decode(file_get_contents("php://input")));
return (new MessageRestController())->put($pid, $mid, $data);
},
"DELETE /api/patient/:pid/message/:mid" => function ($pid, $mid) {
authorization_check("patients", "notes");
return (new MessageRestController())->delete($pid, $mid);
},
);
use OpenEMR\RestControllers\FhirPatientRestController;
use OpenEMR\RestControllers\FhirEncounterRestController;
RestConfig::$FHIR_ROUTE_MAP = array(
"POST /fhir/auth" => function () {
$data = (array) RestConfig::getPostData((file_get_contents("php://input")));
return (new AuthRestController())->authenticate($data);
},
"GET /fhir/Patient" => function () {
authorization_check("patients", "demo");
return (new FhirPatientRestController(null))->getAll($_GET);
},
"GET /fhir/Patient/:pid" => function ($pid) {
authorization_check("patients", "demo");
return (new FhirPatientRestController($pid))->getOne();
},
"GET /fhir/Encounter" => function () {
authorization_check("encounters", "auth_a");
return (new FhirEncounterRestController(null))->getAll($_GET);
},
"GET /fhir/Encounter/:eid" => function ($eid) {
authorization_check("encounters", "auth_a");
return (new FhirEncounterRestController())->getOne($eid);
},
);