jquery updates
[openemr.git] / _rest_routes.inc.php
blobcf3d12c086f1860beb5f177d0b6af5943127f126
1 <?php
2 /**
3 * Routes
4 * (All REST routes)
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Matthew Vita <matthewvita48@gmail.com>
9 * @author Jerry Padgett <sjpadgett@gmail.com>
10 * @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
11 * @copyright Copyright (c) 2018 Jerry Padgett <sjpadgett@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 // Lets keep our controller classes with the routes.
17 use OpenEMR\RestControllers\FacilityRestController;
18 use OpenEMR\RestControllers\VersionRestController;
19 use OpenEMR\RestControllers\ProductRegistrationRestController;
20 use OpenEMR\RestControllers\PatientRestController;
21 use OpenEMR\RestControllers\EncounterRestController;
22 use OpenEMR\RestControllers\ProviderRestController;
23 use OpenEMR\RestControllers\ListRestController;
24 use OpenEMR\RestControllers\InsuranceCompanyRestController;
25 use OpenEMR\RestControllers\AppointmentRestController;
26 use OpenEMR\RestControllers\AuthRestController;
27 use OpenEMR\RestControllers\ONoteRestController;
28 use OpenEMR\RestControllers\DocumentRestController;
29 use OpenEMR\RestControllers\InsuranceRestController;
30 use OpenEMR\RestControllers\MessageRestController;
32 RestConfig::$ROUTE_MAP = array(
33 "POST /api/auth" => function () {
34 $data = (array)(json_decode(file_get_contents("php://input")));
35 return (new AuthRestController())->authenticate($data);
37 "GET /api/facility" => function () {
38 authorization_check("admin", "users");
39 return (new FacilityRestController())->getAll();
41 "GET /api/facility/:fid" => function ($fid) {
42 authorization_check("admin", "users");
43 return (new FacilityRestController())->getOne($fid);
45 "POST /api/facility" => function () {
46 authorization_check("admin", "super");
47 $data = (array)(json_decode(file_get_contents("php://input")));
48 return (new FacilityRestController())->post($data);
50 "PUT /api/facility/:fid" => function ($fid) {
51 authorization_check("admin", "super");
52 $data = (array)(json_decode(file_get_contents("php://input")));
53 $data["fid"] = $fid;
54 return (new FacilityRestController())->put($data);
56 "GET /api/provider" => function () {
57 authorization_check("admin", "users");
58 return (new ProviderRestController())->getAll();
60 "GET /api/provider/:prid" => function ($prid) {
61 authorization_check("admin", "users");
62 return (new ProviderRestController())->getOne($prid);
64 "GET /api/patient" => function () {
65 authorization_check("patients", "demo");
66 return (new PatientRestController(null))->getAll($_GET);
68 "POST /api/patient" => function () {
69 authorization_check("patients", "demo");
70 $data = (array)(json_decode(file_get_contents("php://input")));
71 return (new PatientRestController(null))->post($data);
73 "PUT /api/patient/:pid" => function ($pid) {
74 authorization_check("patients", "demo");
75 $data = (array)(json_decode(file_get_contents("php://input")));
76 return (new PatientRestController(null))->put($pid, $data);
78 "GET /api/patient/:pid" => function ($pid) {
79 authorization_check("patients", "demo");
80 return (new PatientRestController($pid))->getOne();
82 "GET /api/patient/:pid/encounter" => function ($pid) {
83 authorization_check("encounters", "auth_a");
84 return (new EncounterRestController())->getAll($pid);
86 "GET /api/patient/:pid/encounter/:eid" => function ($pid, $eid) {
87 authorization_check("encounters", "auth_a");
88 return (new EncounterRestController())->getOne($pid, $eid);
90 "GET /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
91 authorization_check("encounters", "notes");
92 return (new EncounterRestController())->getSoapNotes($pid, $eid);
94 "POST /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
95 authorization_check("encounters", "notes");
96 $data = (array)(json_decode(file_get_contents("php://input")));
97 return (new EncounterRestController())->postVital($pid, $eid, $data);
99 "PUT /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
100 authorization_check("encounters", "notes");
101 $data = (array)(json_decode(file_get_contents("php://input")));
102 return (new EncounterRestController())->putVital($pid, $eid, $vid, $data);
104 "GET /api/patient/:pid/encounter/:eid/vital" => function ($pid, $eid) {
105 authorization_check("encounters", "notes");
106 return (new EncounterRestController())->getVitals($pid, $eid);
108 "GET /api/patient/:pid/encounter/:eid/vital/:vid" => function ($pid, $eid, $vid) {
109 authorization_check("encounters", "notes");
110 return (new EncounterRestController())->getVital($pid, $eid, $vid);
112 "GET /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
113 authorization_check("encounters", "notes");
114 return (new EncounterRestController())->getSoapNote($pid, $eid, $sid);
116 "POST /api/patient/:pid/encounter/:eid/soap_note" => function ($pid, $eid) {
117 authorization_check("encounters", "notes");
118 $data = (array)(json_decode(file_get_contents("php://input")));
119 return (new EncounterRestController())->postSoapNote($pid, $eid, $data);
121 "PUT /api/patient/:pid/encounter/:eid/soap_note/:sid" => function ($pid, $eid, $sid) {
122 authorization_check("encounters", "notes");
123 $data = (array)(json_decode(file_get_contents("php://input")));
124 return (new EncounterRestController())->putSoapNote($pid, $eid, $sid, $data);
126 "GET /api/patient/:pid/medical_problem" => function ($pid) {
127 authorization_check("encounters", "notes");
128 return (new ListRestController())->getAll($pid, "medical_problem");
130 "GET /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
131 authorization_check("patients", "med");
132 return (new ListRestController())->getOne($pid, "medical_problem", $mid);
134 "POST /api/patient/:pid/medical_problem" => function ($pid) {
135 authorization_check("patients", "med");
136 $data = (array)(json_decode(file_get_contents("php://input")));
137 return (new ListRestController())->post($pid, "medical_problem", $data);
139 "PUT /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
140 authorization_check("patients", "med");
141 $data = (array)(json_decode(file_get_contents("php://input")));
142 return (new ListRestController())->put($pid, $mid, "medical_problem", $data);
144 "DELETE /api/patient/:pid/medical_problem/:mid" => function ($pid, $mid) {
145 authorization_check("patients", "med");
146 return (new ListRestController())->delete($pid, $mid, "medical_problem");
148 "GET /api/patient/:pid/allergy" => function ($pid) {
149 authorization_check("patients", "med");
150 return (new ListRestController())->getAll($pid, "allergy");
152 "GET /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
153 authorization_check("patients", "med");
154 return (new ListRestController())->getOne($pid, "allergy", $aid);
156 "DELETE /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
157 authorization_check("patients", "med");
158 return (new ListRestController())->delete($pid, $aid, "allergy");
160 "POST /api/patient/:pid/allergy" => function ($pid) {
161 authorization_check("patients", "med");
162 $data = (array)(json_decode(file_get_contents("php://input")));
163 return (new ListRestController())->post($pid, "allergy", $data);
165 "PUT /api/patient/:pid/allergy/:aid" => function ($pid, $aid) {
166 authorization_check("patients", "med");
167 $data = (array)(json_decode(file_get_contents("php://input")));
168 return (new ListRestController())->put($pid, $aid, "allergy", $data);
170 "GET /api/patient/:pid/medication" => function ($pid) {
171 authorization_check("patients", "med");
172 return (new ListRestController())->getAll($pid, "medication");
174 "POST /api/patient/:pid/medication" => function ($pid) {
175 authorization_check("patients", "med");
176 $data = (array)(json_decode(file_get_contents("php://input")));
177 return (new ListRestController())->post($pid, "medication", $data);
179 "PUT /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
180 authorization_check("patients", "med");
181 $data = (array)(json_decode(file_get_contents("php://input")));
182 return (new ListRestController())->put($pid, $mid, "medication", $data);
184 "GET /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
185 authorization_check("patients", "med");
186 return (new ListRestController())->getOne($pid, "medication", $mid);
188 "DELETE /api/patient/:pid/medication/:mid" => function ($pid, $mid) {
189 authorization_check("patients", "med");
190 return (new ListRestController())->delete($pid, $mid, "medication");
192 "GET /api/patient/:pid/surgery" => function ($pid) {
193 authorization_check("patients", "med");
194 return (new ListRestController())->getAll($pid, "surgery");
196 "GET /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
197 authorization_check("patients", "med");
198 return (new ListRestController())->getOne($pid, "surgery", $sid);
200 "DELETE /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
201 authorization_check("patients", "med");
202 return (new ListRestController())->delete($pid, $sid, "surgery");
204 "POST /api/patient/:pid/surgery" => function ($pid) {
205 authorization_check("patients", "med");
206 $data = (array)(json_decode(file_get_contents("php://input")));
207 return (new ListRestController())->post($pid, "surgery", $data);
209 "PUT /api/patient/:pid/surgery/:sid" => function ($pid, $sid) {
210 authorization_check("patients", "med");
211 $data = (array)(json_decode(file_get_contents("php://input")));
212 return (new ListRestController())->put($pid, $sid, "surgery", $data);
214 "GET /api/patient/:pid/dental_issue" => function ($pid) {
215 authorization_check("patients", "med");
216 return (new ListRestController())->getAll($pid, "dental");
218 "GET /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
219 authorization_check("patients", "med");
220 return (new ListRestController())->getOne($pid, "dental", $did);
222 "DELETE /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
223 authorization_check("patients", "med");
224 return (new ListRestController())->delete($pid, $did, "dental");
226 "POST /api/patient/:pid/dental_issue" => function ($pid) {
227 authorization_check("patients", "med");
228 $data = (array)(json_decode(file_get_contents("php://input")));
229 return (new ListRestController())->post($pid, "dental", $data);
231 "PUT /api/patient/:pid/dental_issue/:did" => function ($pid, $did) {
232 authorization_check("patients", "med");
233 $data = (array)(json_decode(file_get_contents("php://input")));
234 return (new ListRestController())->put($pid, $did, "dental", $data);
236 "GET /api/patient/:pid/appointment" => function ($pid) {
237 authorization_check("patients", "appt");
238 return (new AppointmentRestController())->getAllForPatient($pid);
240 "POST /api/patient/:pid/appointment" => function ($pid) {
241 authorization_check("patients", "appt");
242 $data = (array)(json_decode(file_get_contents("php://input")));
243 return (new AppointmentRestController())->post($pid, $data);
245 "GET /api/appointment" => function () {
246 authorization_check("patients", "appt");
247 return (new AppointmentRestController())->getAll();
249 "GET /api/appointment/:eid" => function ($eid) {
250 authorization_check("patients", "appt");
251 return (new AppointmentRestController())->getOne($eid);
253 "DELETE /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
254 authorization_check("patients", "appt");
255 return (new AppointmentRestController())->delete($eid);
257 "GET /api/patient/:pid/appointment/:eid" => function ($pid, $eid) {
258 authorization_check("patients", "appt");
259 return (new AppointmentRestController())->getOne($eid);
261 "GET /api/list/:list_name" => function ($list_name) {
262 authorization_check("lists", "default");
263 return (new ListRestController())->getOptions($list_name);
265 "GET /api/version" => function () {
266 return (new VersionRestController())->getOne();
268 "GET /api/product" => function () {
269 return (new ProductRegistrationRestController())->getOne();
271 "GET /api/insurance_company" => function () {
272 return (new InsuranceCompanyRestController())->getAll();
274 "GET /api/insurance_type" => function () {
275 return (new InsuranceCompanyRestController())->getInsuranceTypes();
277 "POST /api/insurance_company" => function () {
278 $data = (array)(json_decode(file_get_contents("php://input")));
279 return (new InsuranceCompanyRestController())->post($data);
281 "PUT /api/insurance_company/:iid" => function ($iid) {
282 $data = (array)(json_decode(file_get_contents("php://input")));
283 return (new InsuranceCompanyRestController())->put($iid, $data);
285 "POST /api/patient/:pid/document" => function ($pid) {
286 return (new DocumentRestController())->postWithPath($pid, $_GET['path'], $_FILES['document']);
288 "GET /api/patient/:pid/document" => function ($pid) {
289 return (new DocumentRestController())->getAllAtPath($pid, $_GET['path']);
291 "GET /api/patient/:pid/document/:did" => function ($pid, $did) {
292 return (new DocumentRestController())->downloadFile($pid, $did);
294 "GET /api/patient/:pid/insurance" => function ($pid) {
295 return (new InsuranceRestController())->getAll($pid);
297 "GET /api/patient/:pid/insurance/:type" => function ($pid, $type) {
298 return (new InsuranceRestController())->getOne($pid, $type);
300 "POST /api/patient/:pid/insurance/:type" => function ($pid, $type) {
301 $data = (array)(json_decode(file_get_contents("php://input")));
302 return (new InsuranceRestController())->post($pid, $type, $data);
304 "PUT /api/patient/:pid/insurance/:type" => function ($pid, $type) {
305 $data = (array)(json_decode(file_get_contents("php://input")));
306 return (new InsuranceRestController())->put($pid, $type, $data);
308 "POST /api/patient/:pid/message" => function ($pid) {
309 authorization_check("patients", "notes");
310 $data = (array)(json_decode(file_get_contents("php://input")));
311 return (new MessageRestController())->post($pid, $data);
313 "PUT /api/patient/:pid/message/:mid" => function ($pid, $mid) {
314 authorization_check("patients", "notes");
315 $data = (array)(json_decode(file_get_contents("php://input")));
316 return (new MessageRestController())->put($pid, $mid, $data);
318 "DELETE /api/patient/:pid/message/:mid" => function ($pid, $mid) {
319 authorization_check("patients", "notes");
320 return (new MessageRestController())->delete($pid, $mid);
325 use OpenEMR\RestControllers\FhirPatientRestController;
326 use OpenEMR\RestControllers\FhirEncounterRestController;
328 RestConfig::$FHIR_ROUTE_MAP = array(
329 "POST /fhir/auth" => function () {
330 $data = (array)(json_decode(file_get_contents("php://input")));
331 return (new AuthRestController())->authenticate($data);
333 "GET /fhir/Patient" => function () {
334 authorization_check("patients", "demo");
335 return (new FhirPatientRestController(null))->getAll($_GET);
337 "GET /fhir/Patient/:pid" => function ($pid) {
338 authorization_check("patients", "demo");
339 return (new FhirPatientRestController($pid))->getOne();
341 "GET /fhir/Encounter" => function () {
342 authorization_check("encounters", "auth_a");
343 return (new FhirEncounterRestController(null))->getAll($_GET);
345 "GET /fhir/Encounter/:eid" => function ($eid) {
346 authorization_check("encounters", "auth_a");
347 return (new FhirEncounterRestController())->getOne($eid);