1 # OpenEMR REST API Documentation
5 Easy-to-use JSON-based REST API for OpenEMR. All code is done in classes and separate from the view to help with codebase modernization efforts. FHIR is also supported, see FHIR API documentation [here](FHIR_README.md)
9 REST API endpoints are defined in the [primary routes file](_rest_routes.inc.php). The routes file maps an external, addressable
10 endpoint to the OpenEMR controller which handles the request, and also handles the JSON data conversions.
13 "POST /api/patient" => function () {
14 RestConfig::authorization_check("patients", "demo");
15 $data = (array) (json_decode(file_get_contents("php://input")));
16 $return = (new PatientRestController())->post($data);
17 RestConfig::apiLog($return, $data);
22 At a high level, the request processing flow consists of the following steps:
25 JSON Request -> Controller Component -> Validation -> Service Component -> Database
28 The logical response flow begins with the database result:
31 Database Result -> Service Component -> Controller Component -> RequestControllerHelper -> JSON Response
34 The [RequestControllerHelper class](./src/RestControllers/RestControllerHelper.php) evaluates the Service Component's
35 result and maps it to a http response code and response payload. Existing APIs should be updated to utilize the
36 `handleProcessingResult` method as it supports the [Validator](./src/Validators/BaseValidator.php) components.
38 The [PatientRestController](./src/RestControllers/PatientRestController.php) may be used as a reference to see how APIs are
39 integrated with `RequestControllerHelper::handleProcessingResult` and the `Validator` components.
41 Finally, APIs which are integrated with the new `handleProcessingResult` method utilize a common response format.
45 "validationErrors": [],
47 "data": < data payload >
51 - `validationErrors` contain "client based" data validation errors
52 - `internalErrors` contain server related errors
53 - `data` is the response payload, represented as an object/`{}` for single results or an array/`[]` for multiple results
57 - [Authorization](API_README.md#authorization)
58 - [Scopes](API_README.md#scopes)
59 - [Registration](API_README.md#registration)
60 - [SMART on FHIR Registration](API_README.md#smart-on-fhir-registration)
61 - [Authorization Code Grant](API_README.md#authorization-code-grant)
62 - [Refresh Token Grant](API_README.md#refresh-token-grant)
63 - [Password Grant](API_README.md#password-grant)
64 - [Client Credentials Grant](API_README#client-credentials-grant)
65 - [Logout](API_README.md#logout)
66 - [More Details](API_README.md#more-details)
67 - [Standard API Endpoints](API_README.md#api-endpoints)
68 - [Facility API](API_README.md#post-apifacility)
69 - [Practitioner API](API_README.md#get-apipractitioner)
70 - [Patient API](API_README.md#post-apipatient)
71 - [Immunization API](API_README.md#get-apiimmunization)
72 - [Allergy API](API_README.md#get-apiallergy)
73 - [Procedure API](API_README.md#get-apiprocedure)
74 - [Drug API](API_README.md#get-apidrug)
75 - [Prescription API](API_README.md#get-apiprescription)
76 - [Insurance API](API_README.md#get-apipatientpidinsurance)
77 - [Appointment API](API_README.md#get-apiappointment)
78 - [Document API](API_README.md#get-apipatientpiddocument)
79 - [Message API](API_README.md#post-apipatientpidmessage)
80 - [Portal API Endpoints](API_README.md#portal-Endpoints)
81 - [Patient API](API_README.md#get-portalpatient)
82 - [FHIR API Endpoints](FHIR_README.md#fhir-endpoints)
83 - [FHIR Capability Statement](FHIR_README.md#capability-statement)
84 - [FHIR Patient](FHIR_README.md#patient-resource)
85 - [FHIR Coverage](FHIR_README.md#coverage-resource)
86 - [FHIR Encounter](FHIR_README.md#encounter-resource)
87 - [FHIR Practitioner](FHIR_README.md#practitioner-resource)
88 - [FHIR PractitionerRole](FHIR_README.md#practitionerrole-resource)
89 - [FHIR Immunization](FHIR_README.md#immunization-resource)
90 - [FHIR AllergyIntolerance](FHIR_README.md#allergyintolerance-resource)
91 - [FHIR Organization](FHIR_README.md#organization-resource)
92 - [FHIR Observation](FHIR_README.md#observation-resource)
93 - [FHIR Condition](FHIR_README.md#condition-resource)
94 - [FHIR Procedure](FHIR_README.md#procedure-resource)
95 - [FHIR MedicationRequest](FHIR_README.md#medicationrequest-resource)
96 - [FHIR Medication](FHIR_README.md#medication-resource)
97 - [FHIR Location](FHIR_README.md#location-resource)
98 - [FHIR CareTeam](FHIR_README.md#careTeam-resource)
99 - [FHIR Provenance](FHIR_README.md#Provenance-resources)
100 - [Dev notes](API_README.md#dev-notes)
104 Enable the Standard API service (/api/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Standard REST API"
106 ### Using API Internally
108 There are several ways to make API calls from an authorized session and maintain security:
110 - See the script at tests/api/InternalApiTest.php for examples of internal API use cases.
112 ### Multisite Support
114 Multisite is supported by including the site in the endpoint. When not using multisite or using the `default` multisite site, then a typical path would look like `apis/default/api/patient`. If you are using multisite and using a site called `alternate`, then the path would look like `apis/alternate/api/patient`.
118 OpenEMR uses OIDC compliant authorization for API. SSL is required and setting baseurl at Administration->Globals->Connectors->'Site Address (required for OAuth2 and FHIR)' is required. The listing of scopes can be found in below Scopes section.
122 This is a listing of scopes:
123 - `api:oemr` (user api which are the /api/ endpoints)
124 - `user/allergy.read`
125 - `user/allergy.write`
126 - `user/appointment.read`
127 - `user/appointment.write`
128 - `user/dental_issue.read`
129 - `user/dental_issue.write`
130 - `user/document.read`
131 - `user/document.write`
133 - `user/encounter.read`
134 - `user/encounter.write`
135 - `user/facility.read`
136 - `user/facility.write`
137 - `user/immunization.read`
138 - `user/insurance.read`
139 - `user/insurance.write`
140 - `user/insurance_company.read`
141 - `user/insurance_company.write`
142 - `user/insurance_type.read`
144 - `user/medical_problem.read`
145 - `user/medical_problem.write`
146 - `user/medication.read`
147 - `user/medication.write`
148 - `user/message.write`
149 - `user/patient.read`
150 - `user/patient.write`
151 - `user/practitioner.read`
152 - `user/practitioner.write`
153 - `user/prescription.read`
154 - `user/procedure.read`
155 - `user/soap_note.read`
156 - `user/soap_note.write`
157 - `user/surgery.read`
158 - `user/surgery.write`
161 - `api:fhir` (fhir which are the /fhir/ endpoints)
162 - `patient/AllergyIntolerance.read`
163 - `patient/CareTeam.read`
164 - `patient/Condition.read`
165 - `patient/Encounter.read`
166 - `patient/Immunization.read`
167 - `patient/MedicationRequest.read`
168 - `patient/Observation.read`
169 - `patient/Patient.read`
170 - `patient/Procedure.read`
171 - `user/AllergyIntolerance.read`
172 - `user/CareTeam.read`
173 - `user/Condition.read`
174 - `user/Coverage.read`
175 - `user/Encounter.read`
176 - `user/Immunization.read`
177 - `user/Location.read`
178 - `user/Medication.read`
179 - `user/MedicationRequest.read`
180 - `user/Observation.read`
181 - `user/Organization.read`
182 - `user/Organization.write`
183 - `user/Patient.read`
184 - `user/Patient.write`
185 - `user/Practitioner.read`
186 - `user/Practitioner.write`
187 - `user/PractitionerRole.read`
188 - `user/Procedure.read`
189 - `api:port` (patient api which are the /portal/ endpoints) (EXPERIMENTAL)
190 - `patient/encounter.read`
191 - `patient/patient.read`
195 Here is an example for registering a client. A client needs to be registered before applying for grant to obtain access/refresh tokens. Note: "post_logout_redirect_uris" is optional and only used if client wants a redirect to its own confirmation workflow.
197 Note that all scopes are included in this example for demonstration purposes. For production purposes, should only include the necessary scopes.
200 curl -X POST -k -H 'Content-Type: application/json' -i https://localhost:9300/oauth2/default/registration --data '{
201 "application_type": "private",
203 ["https://client.example.org/callback"],
204 "post_logout_redirect_uris":
205 ["https://client.example.org/logout/callback"],
206 "client_name": "A Private App",
207 "token_endpoint_auth_method": "client_secret_post",
208 "contacts": ["me@example.org", "them@example.org"],
209 "scope": "openid offline_access api:oemr api:fhir api:port user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Coverage.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read patient/encounter.read patient/patient.read patient/AllergyIntolerance.read patient/CareTeam.read patient/Condition.read patient/Encounter.read patient/Immunization.read patient/MedicationRequest.read patient/Observation.read patient/Patient.read patient/Procedure.read"
216 "client_id": "LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA",
217 "client_secret": "j21ecvLmFi9HPc_Hv0t7Ptmf1pVcZQLtHjIdU7U9tkS9WAjFJwVMav0G8ogTJ62q4BATovC7BQ19Qagc4x9BBg",
218 "registration_access_token": "uiDSXx2GNSvYy5n8eW50aGrJz0HjaGpUdrGf07Agv_Q",
219 "registration_client_uri": "https:\/\/localhost:9300\/oauth2\/default\/client\/6eUVG0-qK2dYiwfYdECKIw",
220 "client_id_issued_at": 1604767861,
221 "client_secret_expires_at": 0,
222 "contacts": ["me@example.org", "them@example.org"],
223 "application_type": "private",
224 "client_name": "A Private App",
225 "redirect_uris": ["https:\/\/client.example.org\/callback"],
226 "token_endpoint_auth_method": "client_secret_post",
227 "scope": "openid offline_access api:oemr api:fhir api:port user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Coverage.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read patient/encounter.read patient/patient.read patient/AllergyIntolerance.read patient/CareTeam.read patient/Condition.read patient/Encounter.read patient/Immunization.read patient/MedicationRequest.read patient/Observation.read patient/Patient.read patient/Procedure.read"
231 ##### SMART on FHIR Registration
233 SMART Enabled Apps are supported.
235 SMART client can be registered at <website>/interface/smart/register-app.php. For example https://localhost:9300/interface/smart/register-app.php
237 After registering the SMART client, can then Enable it in OpenEMR at Administration->System->API Clients
239 After it is enabled, the SMART App will then be available to use in the Patient Summary screen (SMART Enabled Apps widget).
241 See this github issue for an example of a Smart App installation: https://github.com/openemr/openemr/issues/4148
243 #### Authorization Code Grant
245 This is the recommended standard mechanism to obtain access/refresh tokens. This is done by using an OAuth2 client with provider url of `oauth2/<site>`; an example full path would be `https://localhost:9300/oauth2/default`.
247 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting authorization grant.
249 #### Refresh Token Grant
251 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting authorization or password grant.
256 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
257 -i 'https://localhost:9300/oauth2/default/token'
258 --data 'grant_type=refresh_token
259 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
260 &refresh_token=def5020089a766d16...'
267 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
268 "token_type": "Bearer",
270 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
271 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
277 Recommend not using this mechanism unless you know what you are doing. It is considered far less secure than the standard authorization code method. Because of security implications, it is not turned on by default. It can be turned on at Administration->Globals->Connectors->'Enable OAuth2 Password Grant (Not considered secure)'.
279 Note that all scopes are included in these examples for demonstration purposes. For production purposes, should only include the necessary scopes.
281 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting password grant.
283 Example for `users` role:
285 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
286 -i 'https://localhost:9300/oauth2/default/token'
287 --data 'grant_type=password
288 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
289 &scope=openid%20offline_access%20api%3Aoemr%20api%3Afhir%20user%2Fallergy.read%20user%2Fallergy.write%20user%2Fappointment.read%20user%2Fappointment.write%20user%2Fdental_issue.read%20user%2Fdental_issue.write%20user%2Fdocument.read%20user%2Fdocument.write%20user%2Fdrug.read%20user%2Fencounter.read%20user%2Fencounter.write%20user%2Ffacility.read%20user%2Ffacility.write%20user%2Fimmunization.read%20user%2Finsurance.read%20user%2Finsurance.write%20user%2Finsurance_company.read%20user%2Finsurance_company.write%20user%2Finsurance_type.read%20user%2Flist.read%20user%2Fmedical_problem.read%20user%2Fmedical_problem.write%20user%2Fmedication.read%20user%2Fmedication.write%20user%2Fmessage.write%20user%2Fpatient.read%20user%2Fpatient.write%20user%2Fpractitioner.read%20user%2Fpractitioner.write%20user%2Fprescription.read%20user%2Fprocedure.read%20user%2Fsoap_note.read%20user%2Fsoap_note.write%20user%2Fsurgery.read%20user%2Fsurgery.write%20user%2Fvital.read%20user%2Fvital.write%20user%2FAllergyIntolerance.read%20user%2FCareTeam.read%20user%2FCondition.read%20user%2FCoverage.read%20user%2FEncounter.read%20user%2FImmunization.read%20user%2FLocation.read%20user%2FMedication.read%20user%2FMedicationRequest.read%20user%2FObservation.read%20user%2FOrganization.read%20user%2FOrganization.write%20user%2FPatient.read%20user%2FPatient.write%20user%2FPractitioner.read%20user%2FPractitioner.write%20user%2FPractitionerRole.read%20user%2FProcedure.read
295 Example for `patient` role:
297 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
298 -i 'https://localhost:9300/oauth2/default/token'
299 --data 'grant_type=password
300 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
301 &scope=openid%20offline_access%20api%3Aport%20api%3Afhir%20patient%2Fencounter.read%20patient%2Fpatient.read%20patient%2FAllergyIntolerance.read%20patient%2FCareTeam.read%20patient%2FCondition.read%20patient%2FEncounter.read%20patient%2FImmunization.read%20patient%2FMedicationRequest.read%20patient%2FObservation.read%20patient%2FPatient.read%20patient%2FProcedure.read
305 &email=heya@invalid.email.com'
312 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
313 "token_type": "Bearer",
315 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
316 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
320 ### Client Credentials Grant
322 This is an advanced grant that uses JSON Web Key Sets(JWKS) to authenticate and identify the client. This credential grant is
323 required to be used for access to any **system/\*.$export** scopes. API clients must register either web accessible JWKS URI that hosts
324 a RSA384 compatible key, or provide their JWKS as part of the registration. Client Credentials Grant access tokens are short
325 lived and valid for only 1 minute and no refresh token is issued. Tokens are requested at `/oauth2/default/token`
326 To walk you through how to do this process you can follow [this guide created by HL7](https://hl7.org/fhir/uv/bulkdata/authorization/index.html).
330 A grant (both Authorization Code and Password grants) can be logged out (ie. removed) by url of `oauth2/<site>/logout?id_token_hint=<id_token>`; an example full path would be `https://localhost:9300/oauth2/default/logout?id_token_hint=<id_token>`. Optional: `post_logout_redirect_uri` and `state` parameters can also be sent; note that `post_logout_redirect_uris` also needs to be set during registration for it to work.
334 The forum thread that detailed development of Authorization and where questions and issues are addressed is here: https://community.open-emr.org/t/v6-authorization-and-api-changes-afoot/15450
336 More specific development api topics are discussed and described on the above forum thread (such as introspection).
340 OpenEMR standard endpoints Use `http://localhost:8300/apis/default/api as base URI.`
342 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
344 _Example:_ `http://localhost:8300/apis/default/api/patient` returns a resource of all Patients.
346 The Bearer token is required for each OpenEMR API request, and is conveyed using an Authorization header. Note that the Bearer token is the access_token that is obtained in the above [Authorization](API_README.md#authorization) section.
351 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medical_problem' \
352 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
355 #### POST /api/facility
360 curl -X POST 'http://localhost:8300/apis/default/api/facility' -d \
363 "phone": "808-606-3030",
364 "fax": "808-606-3031",
365 "street": "1337 Bit Shifter Ln",
366 "city": "San Lorenzo",
368 "postal_code": "54321",
369 "email": "foo@bar.com",
370 "service_location": "1",
371 "billing_location": "1",
376 #### PUT /api/facility/:fid
381 curl -X PUT 'http://localhost:8300/apis/default/api/facility/1' -d \
384 "phone": "808-606-3030",
385 "fax": "808-606-3031",
386 "street": "1337 Bit Shifter Ln",
387 "city": "San Lorenzo",
389 "postal_code": "54321",
390 "email": "foo@bar.com",
391 "service_location": "1",
392 "billing_location": "1",
397 #### GET /api/facility
402 curl -X GET 'http://localhost:8300/apis/default/api/facility'
405 #### GET /api/facility/:fid
410 curl -X GET 'http://localhost:8300/apis/default/api/facility/1'
413 #### GET /api/practitioner
418 curl -X GET 'http://localhost:8300/apis/default/api/practitioner'
421 #### GET /api/practitioner/:uuid
426 curl -X GET 'http://localhost:8300/apis/default/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
429 #### POST /api/practitioner
434 curl -X POST 'http://localhost:8300/apis/default/api/practitioner' -d \
444 "facility": "Your Clinic Name Here",
446 "email": "info@pennfirm.com",
451 "organization": null,
453 "street": "789 Third Avenue",
454 "streetb": "123 Cannaut Street",
458 "phone": "(619) 555-9827",
460 "phonew1": "(619) 555-7822",
461 "phonecell": "(619) 555-7821",
463 "state_license_number": "123456"
471 "validationErrors": [],
472 "internalErrors": [],
475 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
480 #### PUT /api/practitioner/:uuid
485 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
491 "street": "456 Tree Lane",
495 "phone": "123-456-7890"
503 "validationErrors": [],
504 "internalErrors": [],
507 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
516 "facility": "Your Clinic Name Here",
518 "email": "info@pennfirm.com",
526 "street": "456 Tree Lane",
527 "streetb": "123 Cannaut Street",
531 "phone": "123-456-7890",
533 "phonew1": "(619) 555-7822",
534 "phonecell": "(619) 555-7821",
536 "state_license_number": "123456",
538 "physician_title": null,
539 "physician_code": null
544 #### POST /api/patient
549 curl -X POST 'http://localhost:8300/apis/default/api/patient' -d \
555 "street": "456 Tree Lane",
556 "postal_code": "08642",
559 "country_code": "US",
560 "phone_contact": "123-456-7890",
572 "validationErrors": [],
573 "internalErrors": [],
580 #### PUT /api/patient/:puuid
585 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
591 "street": "456 Tree Lane",
592 "postal_code": "08642",
595 "country_code": "US",
596 "phone_contact": "123-456-7890",
608 "validationErrors": [],
609 "internalErrors": [],
619 "street": "456 Tree Lane",
620 "postal_code": "08642",
624 "country_code": "US",
625 "drivers_license": "",
626 "contact_relationship": "",
627 "phone_contact": "123-456-7890",
641 #### GET /api/patient
646 curl -X GET 'http://localhost:8300/apis/default/api/patient'
653 "validationErrors": [],
654 "internalErrors": [],
655 "data": [{ patientRecord }, { patientRecord }, etc]
662 curl -X GET 'http://localhost:8300/apis/default/api/patient&fname=...&lname=...&dob=...'
669 "validationErrors": [],
670 "internalErrors": [],
671 "data": [{ patientRecord }, { patientRecord }, etc]
675 #### GET /api/patient/:puuid
680 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
687 "validationErrors": [],
688 "internalErrors": [],
698 "street": "456 Tree Lane",
699 "postal_code": "08642",
703 "country_code": "US",
704 "drivers_license": "",
705 "contact_relationship": "",
706 "phone_contact": "123-456-7890",
720 #### GET /api/immunization
725 curl -X GET 'http://localhost:8300/apis/default/api/immunization'
728 #### GET /api/immunization/:uuid
733 curl -X GET 'http://localhost:8300/apis/default/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
736 #### POST /api/patient/:pid/encounter
741 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
745 "reason": "Pregnancy Test",
746 "facility": "Owerri General Hospital",
749 "billing_facility": "3",
750 "sensitivity": "normal",
751 "referral_source": "",
763 "validationErrors": [],
764 "internalErrors": [],
767 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
772 #### PUT /api/patient/:pid/encounter/:eid
777 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
780 "onset_date": "2019-04-20 00:00:00",
781 "reason": "Pregnancy Test",
784 "billing_facility": "3",
785 "sensitivity": "normal",
786 "referral_source": "",
795 "validationErrors": [],
796 "internalErrors": [],
799 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
800 "date": "2019-09-14 00:00:00",
801 "reason": "Pregnancy Test",
802 "facility": "Owerri General Hospital",
805 "onset_date": "2019-04-20 00:00:00",
806 "sensitivity": "normal",
807 "billing_note": null,
809 "last_level_billed": "0",
810 "last_level_closed": "0",
811 "last_stmt_date": null,
814 "supervisor_id": "0",
816 "referral_source": "",
817 "billing_facility": "3",
821 "class_title": "ambulatory",
822 "pc_catname": "Office Visit",
823 "billing_facility_name": "Owerri General Hospital"
828 #### GET /api/patient/:pid/encounter
833 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
840 "validationErrors": [],
841 "internalErrors": [],
842 "data": [{ encounterRecord }, { encounterRecord }, etc]
846 #### GET /api/patient/:pid/encounter/:eid
851 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
858 "validationErrors": [],
859 "internalErrors": [],
862 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
863 "date": "2019-09-14 00:00:00",
864 "reason": "Pregnancy Test",
865 "facility": "Owerri General Hospital",
868 "onset_date": "2019-04-20 00:00:00",
869 "sensitivity": "normal",
870 "billing_note": null,
872 "last_level_billed": "0",
873 "last_level_closed": "0",
874 "last_stmt_date": null,
877 "supervisor_id": "0",
879 "referral_source": "",
880 "billing_facility": "3",
884 "class_title": "ambulatory",
885 "pc_catname": "Office Visit",
886 "billing_facility_name": "Owerri General Hospital"
891 #### POST /api/patient/:pid/encounter/:eid/vital
896 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital' -d \
903 "temp_method": "Oral",
909 "oxygen_saturation": "80"
913 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
918 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1' -d \
925 "temp_method": "Oral",
931 "oxygen_saturation": "80"
935 #### GET /api/patient/:pid/encounter/:eid/vital
940 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital'
943 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
948 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1'
951 #### POST /api/patient/:pid/encounter/:eid/soap_note
956 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note' -d \
965 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
970 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1' -d \
979 #### GET /api/patient/:pid/encounter/:eid/soap_note
984 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note'
987 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
992 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1'
995 #### GET /api/medical_problem
1000 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem'
1003 #### GET /api/medical_problem/:muuid
1008 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
1011 #### GET /api/patient/:puuid/medical_problem
1016 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
1019 #### GET /api/patient/:puuid/medical_problem/:muuid
1024 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1027 #### POST /api/patient/:puuid/medical_problem
1032 curl -X POST 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
1034 "title": "Dermatochalasis",
1035 "begdate": "2010-04-13",
1037 "diagnosis": "ICD10:H02.839"
1041 #### PUT /api/patient/:puuid/medical_problem/:muuid
1046 curl -X PUT 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
1048 "title": "Dermatochalasis",
1049 "begdate": "2010-04-13",
1050 "enddate": "2018-03-12",
1051 "diagnosis": "ICD10:H02.839"
1055 #### DELETE /api/patient/:puuid/medical_problem/:muuid
1060 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1063 #### GET /api/allergy
1068 curl -X GET 'http://localhost:8300/apis/default/api/allergy'
1071 #### GET /api/allergy/:auuid
1076 curl -X GET 'http://localhost:8300/apis/default/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1079 #### GET /api/patient/:puuid/allergy
1084 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
1087 #### GET /api/patient/:puuid/allergy/:auuid
1092 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1095 #### POST /api/patient/:puuid/allergy
1100 curl -X POST 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
1103 "begdate": "2010-10-13",
1108 #### PUT /api/patient/:puuid/allergy/:auuid
1113 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
1116 "begdate": "2012-10-13",
1121 #### DELETE /api/patient/:puuid/allergy/:auuid
1126 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1129 #### GET /api/procedure
1134 curl -X GET 'http://localhost:8300/apis/default/api/procedure'
1137 #### GET /api/procedure/:uuid
1142 curl -X GET 'http://localhost:8300/apis/default/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
1150 curl -X GET 'http://localhost:8300/apis/default/api/drug'
1153 #### GET /api/drug/:uuid
1158 curl -X GET 'http://localhost:8300/apis/default/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
1161 #### GET /api/prescription
1166 curl -X GET 'http://localhost:8300/apis/default/api/prescription'
1169 #### GET /api/prescription/:uuid
1174 curl -X GET 'http://localhost:8300/apis/default/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
1177 #### POST /api/patient/:pid/medication
1182 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/medication' -d \
1185 "begdate": "2013-10-13",
1190 #### PUT /api/patient/:pid/medication/:mid
1195 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/medication/1' -d \
1198 "begdate": "2013-04-13",
1203 #### GET /api/patient/:pid/medication
1208 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication'
1211 #### GET /api/patient/:pid/medication/:mid
1216 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1219 #### DELETE /api/patient/:pid/medication/:mid
1224 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1227 #### POST /api/patient/:pid/surgery
1232 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/surgery' -d \
1234 "title": "Blepharoplasty",
1235 "begdate": "2013-10-13",
1237 "diagnosis": "CPT4:15823-50"
1241 #### PUT /api/patient/:pid/surgery/:sid
1246 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/surgery/1' -d \
1248 "title": "Blepharoplasty",
1249 "begdate": "2013-10-14",
1251 "diagnosis": "CPT4:15823-50"
1255 #### GET /api/patient/:pid/surgery
1260 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery'
1263 #### GET /api/patient/:pid/surgery/:sid
1268 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1271 #### DELETE /api/patient/:pid/surgery/:sid
1276 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1279 #### POST /api/patient/:pid/dental_issue
1284 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/dental_issue' -d \
1286 "title": "Halitosis",
1287 "begdate": "2015-03-17",
1292 #### PUT /api/patient/:pid/dental_issue/:did
1297 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1' -d \
1299 "title": "Halitosis",
1300 "begdate": "2015-03-17",
1301 "enddate": "2018-03-20"
1305 #### GET /api/patient/:pid/dental_issue
1310 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue'
1313 #### GET /api/patient/:pid/dental_issue/:did
1318 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1321 #### DELETE /api/patient/:pid/dental_issue/:did
1326 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1329 #### GET /api/patient/:pid/insurance
1334 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance'
1337 #### GET /api/patient/:pid/insurance/:type
1342 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance/secondary'
1345 #### POST /api/patient/:pid/insurance/:type
1350 curl -X POST 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1354 "plan_name": "Some Plan",
1355 "policy_number": "12345",
1356 "group_number": "252412",
1357 "subscriber_lname": "Tester",
1358 "subscriber_mname": "Xi",
1359 "subscriber_fname": "Foo",
1360 "subscriber_relationship": "other",
1361 "subscriber_ss": "234231234",
1362 "subscriber_DOB": "2018-10-03",
1363 "subscriber_street": "183 Cool St",
1364 "subscriber_postal_code": "23418",
1365 "subscriber_city": "Cooltown",
1366 "subscriber_state": "AZ",
1367 "subscriber_country": "USA",
1368 "subscriber_phone": "234-598-2123",
1369 "subscriber_employer": "Some Employer",
1370 "subscriber_employer_street": "123 Heather Lane",
1371 "subscriber_employer_postal_code": "23415",
1372 "subscriber_employer_state": "AZ",
1373 "subscriber_employer_country": "USA",
1374 "subscriber_employer_city": "Cooltown",
1376 "date": "2018-10-15",
1377 "subscriber_sex": "Female",
1378 "accept_assignment": "TRUE",
1385 - `provider` is the insurance company id
1386 - `state` can be found by querying `resource=/api/list/state`
1387 - `country` can be found by querying `resource=/api/list/country`
1389 #### PUT /api/patient/:pid/insurance/:type
1394 curl -X PUT 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1398 "plan_name": "Some Plan",
1399 "policy_number": "12345",
1400 "group_number": "252412",
1401 "subscriber_lname": "Tester",
1402 "subscriber_mname": "Xi",
1403 "subscriber_fname": "Foo",
1404 "subscriber_relationship": "other",
1405 "subscriber_ss": "234231234",
1406 "subscriber_DOB": "2018-10-03",
1407 "subscriber_street": "183 Cool St",
1408 "subscriber_postal_code": "23418",
1409 "subscriber_city": "Cooltown",
1410 "subscriber_state": "AZ",
1411 "subscriber_country": "USA",
1412 "subscriber_phone": "234-598-2123",
1413 "subscriber_employer": "Some Employer",
1414 "subscriber_employer_street": "123 Heather Lane",
1415 "subscriber_employer_postal_code": "23415",
1416 "subscriber_employer_state": "AZ",
1417 "subscriber_employer_country": "USA",
1418 "subscriber_employer_city": "Cooltown",
1420 "date": "2018-10-15",
1421 "subscriber_sex": "Female",
1422 "accept_assignment": "TRUE",
1429 - `provider` is the insurance company id
1430 - `state` can be found by querying `resource=/api/list/state`
1431 - `country` can be found by querying `resource=/api/list/country`
1433 #### GET /api/list/:list_name
1438 curl -X GET 'http://localhost:8300/apis/default/api/list/medical_problem_issue_list'
1441 #### GET /api/version
1446 curl -X GET 'http://localhost:8300/apis/default/api/version'
1449 #### GET /api/product
1454 curl -X GET 'http://localhost:8300/apis/default/api/product'
1457 #### GET /api/insurance_company
1462 curl -X GET 'http://localhost:8300/apis/default/api/insurance_company'
1465 #### GET /api/insurance_type
1470 curl -X GET 'http://localhost:8300/apis/default/api/insurance_type'
1473 #### POST /api/insurance_company
1478 curl -X POST 'http://localhost:8300/apis/default/api/insurance_company' -d \
1480 "name": "Cool Insurance Company",
1483 "ins_type_code": "2",
1484 "x12_receiver_id": null,
1485 "x12_default_partner_id": null,
1487 "line1": "123 Cool Lane",
1488 "line2": "Suite 123",
1496 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1498 #### PUT /api/insurance_company/:iid
1503 curl -X PUT 'http://localhost:8300/apis/default/api/insurance_company/1' -d \
1505 "name": "Super Insurance Company",
1508 "ins_type_code": "2",
1509 "x12_receiver_id": null,
1510 "x12_default_partner_id": null,
1512 "line1": "123 Cool Lane",
1513 "line2": "Suite 123",
1521 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1523 #### GET /api/appointment
1528 curl -X GET 'http://localhost:8300/apis/default/api/appointment'
1531 #### GET /api/appointment/:eid
1536 curl -X GET 'http://localhost:8300/apis/default/api/appointment/1'
1539 #### GET /api/patient/:pid/appointment
1544 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment'
1547 #### GET /api/patient/:pid/appointment/:eid
1552 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment/1'
1555 #### POST /api/patient/:pid/appointment
1560 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/appointment' -d \
1564 "pc_title": "Office Visit",
1565 "pc_duration": "900",
1566 "pc_hometext": "Test",
1567 "pc_apptstatus": "-",
1568 "pc_eventDate": "2018-10-19",
1569 "pc_startTime": "09:00",
1571 "pc_billing_location": "10"
1575 #### DELETE /api/patient/:pid/appointment/:eid
1580 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/appointment/1' -d \
1583 #### GET /api/patient/:pid/document
1588 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1591 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1593 - Spaces are represented with `_`
1594 - All characters are lowercase
1596 #### POST /api/patient/:pid/document
1601 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1602 -F document=@/home/someone/Desktop/drawing.jpg
1605 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1607 - Spaces are represented with `_`
1608 - All characters are lowercase
1610 #### GET /api/patient/:pid/document/:did
1615 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document/1'
1618 #### POST /api/patient/:pid/message
1623 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/message' -d \
1626 "groupname": "Default",
1630 "message_status": "New"
1636 - For `title`, use `resource=/api/list/note_type`
1637 - For `message_type`, use `resource=/api/list/message_status`
1639 #### PUT /api/patient/:pid/message/:mid
1644 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/message/1' -d \
1647 "groupname": "Default",
1651 "message_status": "New"
1657 - For `title`, use `resource=/api/list/note_type`
1658 - For `message_type`, use `resource=/api/list/message_status`
1660 #### DELETE /api/patient/:pid/message/:mid
1665 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/message/1'
1668 ### /portal/ Endpoints
1670 This is under development and is considered EXPERIMENTAL.
1672 Enable the Patient Portal API service (/portal/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Patient Portal REST API (EXPERIMENTAL)"
1674 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/default/portal as base URI.`
1676 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
1678 _Example:_ `http://localhost:8300/apis/default/portal/patient` returns a resource of the patient.
1680 The Bearer token is required for each OpenEMR API request, and is conveyed using an Authorization header. Note that the Bearer token is the access_token that is obtained in the above [Authorization](API_README.md#authorization) section.
1685 curl -X GET 'http://localhost:8300/apis/default/portal/patient' \
1686 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1689 #### GET /portal/patient
1694 curl -X GET 'http://localhost:8300/apis/default/portal/patient'
1701 "validationErrors": [],
1702 "internalErrors": [],
1712 "street": "456 Tree Lane",
1713 "postal_code": "08642",
1717 "country_code": "US",
1718 "drivers_license": "",
1719 "contact_relationship": "",
1720 "phone_contact": "123-456-7890",
1725 "DOB": "1992-02-03",
1736 - For business logic, make or use the services [here](src/Services)
1737 - For controller logic, make or use the classes [here](src/RestControllers)
1738 - For routing declarations, use the class [here](_rest_routes.inc.php).