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);
20 At a high level, the request processing flow consists of the following steps:
23 JSON Request -> Controller Component -> Validation -> Service Component -> Database
26 The logical response flow begins with the database result:
29 Database Result -> Service Component -> Controller Component -> RequestControllerHelper -> JSON Response
32 The [RequestControllerHelper class](./src/RestControllers/RestControllerHelper.php) evaluates the Service Component's
33 result and maps it to a http response code and response payload. Existing APIs should be updated to utilize the
34 `handleProcessingResult` method as it supports the [Validator](./src/Validators/BaseValidator.php) components.
36 The [PatientRestController](./src/RestControllers/PatientRestController.php) may be used as a reference to see how APIs are
37 integrated with `RequestControllerHelper::handleProcessingResult` and the `Validator` components.
39 Finally, APIs which are integrated with the new `handleProcessingResult` method utilize a common response format.
43 "validationErrors": [],
45 "data": < data payload >
49 - `validationErrors` contain "client based" data validation errors
50 - `internalErrors` contain server related errors
51 - `data` is the response payload, represented as an object/`{}` for single results or an array/`[]` for multiple results
55 - [Authorization](API_README.md#authorization)
56 - [Standard API Endpoints](API_README.md#api-endpoints)
57 - [Facility API](API_README.md#post-apifacility)
58 - [Practitioner API](API_README.md#get-apipractitioner)
59 - [Patient API](API_README.md#post-apipatient)
60 - [Immunization API](API_README.md#get-apiimmunization)
61 - [Allergy API](API_README.md#get-apiallergy)
62 - [Procedure API](API_README.md#get-apiprocedure)
63 - [Drug API](API_README.md#get-apidrug)
64 - [Prescription API](API_README.md#get-apiprescription)
65 - [Insurance API](API_README.md#get-apipatientpidinsurance)
66 - [Appointment API](API_README.md#get-apiappointment)
67 - [Document API](API_README.md#get-apipatientpiddocument)
68 - [Message API](API_README.md#post-apipatientpidmessage)
69 - [Portal API Endpoints](API_README.md#portal-Endpoints)
70 - [Patient API](API_README.md#get-portalpatient)
71 - [FHIR API Endpoints](FHIR_README.md#fhir-endpoints)
72 - [FHIR Capability Statement](FHIR_README.md#capability-statement)
73 - [FHIR Patient](FHIR_README.md#patient-resource)
74 - [FHIR Encounter](FHIR_README.md#encounter-resource)
75 - [FHIR Practitioner](FHIR_README.md#practitioner-resource)
76 - [FHIR PractitionerRole](FHIR_README.md#practitionerrole-resource)
77 - [FHIR Immunization](FHIR_README.md#immunization-resource)
78 - [FHIR AllergyIntolerance](FHIR_README.md#allergyintolerance-resource)
79 - [FHIR Organization](FHIR_README.md#organization-resource)
80 - [FHIR Observation](FHIR_README.md#observation-resource)
81 - [FHIR QuestionnaireResponse](FHIR_README.md#questionnaireresponse-resource)
82 - [FHIR Condition](FHIR_README.md#condition-resource)
83 - [FHIR Procedure](FHIR_README.md#procedure-resource)
84 - [FHIR MedicationRequest](FHIR_README.md#medicationrequest-resource)
85 - [FHIR Medication](FHIR_README.md#medication-resource)
86 - [FHIR Location](FHIR_README.md#location-resource)
87 - [FHIR CareTeam](FHIR_README.md#careTeam-resource)
88 - [FHIR Provenance](FHIR_README.md#Provenance-resources)
89 - [Patient Portal FHIR API Endpoints](FHIR_README.md#patient-portal-fhir-endpoints)
90 - [Patient Portal FHIR Patient](FHIR_README.md#patient-portal-patient-resource)
91 - [Dev notes](API_README.md#dev-notes)
92 - [Todos](API_README.md#project-management)
96 Enable the Standard API service (/api/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Standard REST API"
98 Enable the Patient Portal API service (/portal/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Patient Portal REST API"
100 ### Using API Internally
102 There are several ways to make API calls from an authorized session and maintain security:
104 - See the script at tests/api/InternalApiTest.php for examples of internal API use cases.
106 ### Multisite Support
108 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`.
112 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.
116 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.
119 curl -X POST -k -H 'Content-Type: application/json' -i https://localhost:9300/oauth2/default/registration --data '{
120 "application_type": "private",
122 ["https://client.example.org/callback"],
123 "post_logout_redirect_uris":
124 ["https://client.example.org/logout/callback"],
125 "client_name": "A Private App",
126 "token_endpoint_auth_method": "client_secret_post",
127 "contacts": ["me@example.org", "them@example.org"]
135 "client_id": "LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA",
136 "client_secret": "j21ecvLmFi9HPc_Hv0t7Ptmf1pVcZQLtHjIdU7U9tkS9WAjFJwVMav0G8ogTJ62q4BATovC7BQ19Qagc4x9BBg",
137 "registration_access_token": "uiDSXx2GNSvYy5n8eW50aGrJz0HjaGpUdrGf07Agv_Q",
138 "registration_client_uri": "https:\/\/localhost:9300\/oauth2\/default\/client\/6eUVG0-qK2dYiwfYdECKIw",
139 "client_id_issued_at": 1604767861,
140 "client_secret_expires_at": 0,
141 "contacts": ["me@example.org", "them@example.org"],
142 "application_type": "private",
143 "client_name": "A Private App",
144 "redirect_uris": ["https:\/\/client.example.org\/callback"],
145 "token_endpoint_auth_method": "client_secret_post"
149 #### Authorization Code Grant
151 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`.
153 #### Refresh Token Grant
158 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
159 -i 'https://localhost:9300/oauth2/default/token'
160 --data 'grant_type=refresh_token
161 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
163 &refresh_token=def5020089a766d16...'
170 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
171 "token_type": "Bearer",
173 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
174 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
180 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)'.
182 Example for `users` role:
184 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
185 -i 'https://localhost:9300/oauth2/default/token'
186 --data 'grant_type=password
187 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
194 Example for `patient` role:
196 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
197 -i 'https://localhost:9300/oauth2/default/token'
198 --data 'grant_type=password
199 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
204 &email=heya@invalid.email.com'
211 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
212 "token_type": "Bearer",
214 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
215 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
221 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.
225 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
227 More specific development api topics are discussed and described on the above forum thread (such as introspection).
231 OpenEMR standard endpoints Use `http://localhost:8300/apis/default/api as base URI.`
233 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
235 _Example:_ `http://localhost:8300/apis/default/api/patient` returns a resource of all Patients.
237 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.
242 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medical_problem' \
243 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
246 #### POST /api/facility
251 curl -X POST 'http://localhost:8300/apis/default/api/facility' -d \
254 "phone": "808-606-3030",
255 "fax": "808-606-3031",
256 "street": "1337 Bit Shifter Ln",
257 "city": "San Lorenzo",
259 "postal_code": "54321",
260 "email": "foo@bar.com",
261 "service_location": "1",
262 "billing_location": "1",
267 #### PUT /api/facility/:fid
272 curl -X PUT 'http://localhost:8300/apis/default/api/facility/1' -d \
275 "phone": "808-606-3030",
276 "fax": "808-606-3031",
277 "street": "1337 Bit Shifter Ln",
278 "city": "San Lorenzo",
280 "postal_code": "54321",
281 "email": "foo@bar.com",
282 "service_location": "1",
283 "billing_location": "1",
288 #### GET /api/facility
293 curl -X GET 'http://localhost:8300/apis/default/api/facility'
296 #### GET /api/facility/:fid
301 curl -X GET 'http://localhost:8300/apis/default/api/facility/1'
304 #### GET /api/practitioner
309 curl -X GET 'http://localhost:8300/apis/default/api/practitioner'
312 #### GET /api/practitioner/:uuid
317 curl -X GET 'http://localhost:8300/apis/default/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
320 #### POST /api/practitioner
325 curl -X POST 'http://localhost:8300/apis/default/api/practitioner' -d \
335 "facility": "Your Clinic Name Here",
337 "email": "info@pennfirm.com",
342 "organization": null,
344 "street": "789 Third Avenue",
345 "streetb": "123 Cannaut Street",
349 "phone": "(619) 555-9827",
351 "phonew1": "(619) 555-7822",
352 "phonecell": "(619) 555-7821",
354 "state_license_number": "123456"
362 "validationErrors": [],
363 "internalErrors": [],
366 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
371 #### PUT /api/practitioner/:uuid
376 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
382 "street": "456 Tree Lane",
386 "phone": "123-456-7890"
394 "validationErrors": [],
395 "internalErrors": [],
398 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
407 "facility": "Your Clinic Name Here",
409 "email": "info@pennfirm.com",
417 "street": "456 Tree Lane",
418 "streetb": "123 Cannaut Street",
422 "phone": "123-456-7890",
424 "phonew1": "(619) 555-7822",
425 "phonecell": "(619) 555-7821",
427 "state_license_number": "123456",
429 "physician_title": null,
430 "physician_code": null
435 #### POST /api/patient
440 curl -X POST 'http://localhost:8300/apis/default/api/patient' -d \
446 "street": "456 Tree Lane",
447 "postal_code": "08642",
450 "country_code": "US",
451 "phone_contact": "123-456-7890",
463 "validationErrors": [],
464 "internalErrors": [],
471 #### PUT /api/patient/:puuid
476 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
482 "street": "456 Tree Lane",
483 "postal_code": "08642",
486 "country_code": "US",
487 "phone_contact": "123-456-7890",
499 "validationErrors": [],
500 "internalErrors": [],
510 "street": "456 Tree Lane",
511 "postal_code": "08642",
515 "country_code": "US",
516 "drivers_license": "",
517 "contact_relationship": "",
518 "phone_contact": "123-456-7890",
532 #### GET /api/patient
537 curl -X GET 'http://localhost:8300/apis/default/api/patient'
544 "validationErrors": [],
545 "internalErrors": [],
546 "data": [{ patientRecord }, { patientRecord }, etc]
553 curl -X GET 'http://localhost:8300/apis/default/api/patient&fname=...&lname=...&dob=...'
560 "validationErrors": [],
561 "internalErrors": [],
562 "data": [{ patientRecord }, { patientRecord }, etc]
566 #### GET /api/patient/:puuid
571 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
578 "validationErrors": [],
579 "internalErrors": [],
589 "street": "456 Tree Lane",
590 "postal_code": "08642",
594 "country_code": "US",
595 "drivers_license": "",
596 "contact_relationship": "",
597 "phone_contact": "123-456-7890",
611 #### GET /api/immunization
616 curl -X GET 'http://localhost:8300/apis/default/api/immunization'
619 #### GET /api/immunization/:uuid
624 curl -X GET 'http://localhost:8300/apis/default/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
627 #### POST /api/patient/:pid/encounter
632 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
636 "reason": "Pregnancy Test",
637 "facility": "Owerri General Hospital",
640 "billing_facility": "3",
641 "sensitivity": "normal",
642 "referral_source": "",
654 "validationErrors": [],
655 "internalErrors": [],
658 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
663 #### PUT /api/patient/:pid/encounter/:eid
668 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
671 "onset_date": "2019-04-20 00:00:00",
672 "reason": "Pregnancy Test",
675 "billing_facility": "3",
676 "sensitivity": "normal",
677 "referral_source": "",
686 "validationErrors": [],
687 "internalErrors": [],
690 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
691 "date": "2019-09-14 00:00:00",
692 "reason": "Pregnancy Test",
693 "facility": "Owerri General Hospital",
696 "onset_date": "2019-04-20 00:00:00",
697 "sensitivity": "normal",
698 "billing_note": null,
700 "last_level_billed": "0",
701 "last_level_closed": "0",
702 "last_stmt_date": null,
705 "supervisor_id": "0",
707 "referral_source": "",
708 "billing_facility": "3",
712 "class_title": "ambulatory",
713 "pc_catname": "Office Visit",
714 "billing_facility_name": "Owerri General Hospital"
719 #### GET /api/patient/:pid/encounter
724 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
731 "validationErrors": [],
732 "internalErrors": [],
733 "data": [{ encounterRecord }, { encounterRecord }, etc]
737 #### GET /api/patient/:pid/encounter/:eid
742 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
749 "validationErrors": [],
750 "internalErrors": [],
753 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
754 "date": "2019-09-14 00:00:00",
755 "reason": "Pregnancy Test",
756 "facility": "Owerri General Hospital",
759 "onset_date": "2019-04-20 00:00:00",
760 "sensitivity": "normal",
761 "billing_note": null,
763 "last_level_billed": "0",
764 "last_level_closed": "0",
765 "last_stmt_date": null,
768 "supervisor_id": "0",
770 "referral_source": "",
771 "billing_facility": "3",
775 "class_title": "ambulatory",
776 "pc_catname": "Office Visit",
777 "billing_facility_name": "Owerri General Hospital"
782 #### POST /api/patient/:pid/encounter/:eid/vital
787 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital' -d \
794 "temp_method": "Oral",
800 "oxygen_saturation": "80"
804 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
809 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1' -d \
816 "temp_method": "Oral",
822 "oxygen_saturation": "80"
826 #### GET /api/patient/:pid/encounter/:eid/vital
831 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital'
834 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
839 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1'
842 #### POST /api/patient/:pid/encounter/:eid/soap_note
847 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note' -d \
856 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
861 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1' -d \
870 #### GET /api/patient/:pid/encounter/:eid/soap_note
875 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note'
878 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
883 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1'
886 #### GET /api/medical_problem
891 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem'
894 #### GET /api/medical_problem/:muuid
899 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
902 #### GET /api/patient/:puuid/medical_problem
907 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
910 #### GET /api/patient/:puuid/medical_problem/:muuid
915 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
918 #### POST /api/patient/:puuid/medical_problem
923 curl -X POST 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
925 "title": "Dermatochalasis",
926 "begdate": "2010-04-13",
928 "diagnosis": "ICD10:H02.839"
932 #### PUT /api/patient/:puuid/medical_problem/:muuid
937 curl -X PUT 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
939 "title": "Dermatochalasis",
940 "begdate": "2010-04-13",
941 "enddate": "2018-03-12",
942 "diagnosis": "ICD10:H02.839"
946 #### DELETE /api/patient/:puuid/medical_problem/:muuid
951 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
954 #### GET /api/allergy
959 curl -X GET 'http://localhost:8300/apis/default/api/allergy'
962 #### GET /api/allergy/:auuid
967 curl -X GET 'http://localhost:8300/apis/default/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
970 #### GET /api/patient/:puuid/allergy
975 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
978 #### GET /api/patient/:puuid/allergy/:auuid
983 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
986 #### POST /api/patient/:puuid/allergy
991 curl -X POST 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
994 "begdate": "2010-10-13",
999 #### PUT /api/patient/:puuid/allergy/:auuid
1004 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
1007 "begdate": "2012-10-13",
1012 #### DELETE /api/patient/:puuid/allergy/:auuid
1017 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1020 #### GET /api/procedure
1025 curl -X GET 'http://localhost:8300/apis/default/api/procedure'
1028 #### GET /api/procedure/:uuid
1033 curl -X GET 'http://localhost:8300/apis/default/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
1041 curl -X GET 'http://localhost:8300/apis/default/api/drug'
1044 #### GET /api/drug/:uuid
1049 curl -X GET 'http://localhost:8300/apis/default/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
1052 #### GET /api/prescription
1057 curl -X GET 'http://localhost:8300/apis/default/api/prescription'
1060 #### GET /api/prescription/:uuid
1065 curl -X GET 'http://localhost:8300/apis/default/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
1068 #### POST /api/patient/:pid/medication
1073 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/medication' -d \
1076 "begdate": "2013-10-13",
1081 #### PUT /api/patient/:pid/medication/:mid
1086 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/medication/1' -d \
1089 "begdate": "2013-04-13",
1094 #### GET /api/patient/:pid/medication
1099 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication'
1102 #### GET /api/patient/:pid/medication/:mid
1107 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1110 #### DELETE /api/patient/:pid/medication/:mid
1115 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1118 #### POST /api/patient/:pid/surgery
1123 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/surgery' -d \
1125 "title": "Blepharoplasty",
1126 "begdate": "2013-10-13",
1128 "diagnosis": "CPT4:15823-50"
1132 #### PUT /api/patient/:pid/surgery/:sid
1137 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/surgery/1' -d \
1139 "title": "Blepharoplasty",
1140 "begdate": "2013-10-14",
1142 "diagnosis": "CPT4:15823-50"
1146 #### GET /api/patient/:pid/surgery
1151 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery'
1154 #### GET /api/patient/:pid/surgery/:sid
1159 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1162 #### DELETE /api/patient/:pid/surgery/:sid
1167 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1170 #### POST /api/patient/:pid/dental_issue
1175 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/dental_issue' -d \
1177 "title": "Halitosis",
1178 "begdate": "2015-03-17",
1183 #### PUT /api/patient/:pid/dental_issue/:did
1188 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1' -d \
1190 "title": "Halitosis",
1191 "begdate": "2015-03-17",
1192 "enddate": "2018-03-20"
1196 #### GET /api/patient/:pid/dental_issue
1201 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue'
1204 #### GET /api/patient/:pid/dental_issue/:did
1209 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1212 #### DELETE /api/patient/:pid/dental_issue/:did
1217 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1220 #### GET /api/patient/:pid/insurance
1225 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance'
1228 #### GET /api/patient/:pid/insurance/:type
1233 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance/secondary'
1236 #### POST /api/patient/:pid/insurance/:type
1241 curl -X POST 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1245 "plan_name": "Some Plan",
1246 "policy_number": "12345",
1247 "group_number": "252412",
1248 "subscriber_lname": "Tester",
1249 "subscriber_mname": "Xi",
1250 "subscriber_fname": "Foo",
1251 "subscriber_relationship": "other",
1252 "subscriber_ss": "234231234",
1253 "subscriber_DOB": "2018-10-03",
1254 "subscriber_street": "183 Cool St",
1255 "subscriber_postal_code": "23418",
1256 "subscriber_city": "Cooltown",
1257 "subscriber_state": "AZ",
1258 "subscriber_country": "USA",
1259 "subscriber_phone": "234-598-2123",
1260 "subscriber_employer": "Some Employer",
1261 "subscriber_employer_street": "123 Heather Lane",
1262 "subscriber_employer_postal_code": "23415",
1263 "subscriber_employer_state": "AZ",
1264 "subscriber_employer_country": "USA",
1265 "subscriber_employer_city": "Cooltown",
1267 "date": "2018-10-15",
1268 "subscriber_sex": "Female",
1269 "accept_assignment": "TRUE",
1276 - `provider` is the insurance company id
1277 - `state` can be found by querying `resource=/api/list/state`
1278 - `country` can be found by querying `resource=/api/list/country`
1280 #### PUT /api/patient/:pid/insurance/:type
1285 curl -X PUT 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1289 "plan_name": "Some Plan",
1290 "policy_number": "12345",
1291 "group_number": "252412",
1292 "subscriber_lname": "Tester",
1293 "subscriber_mname": "Xi",
1294 "subscriber_fname": "Foo",
1295 "subscriber_relationship": "other",
1296 "subscriber_ss": "234231234",
1297 "subscriber_DOB": "2018-10-03",
1298 "subscriber_street": "183 Cool St",
1299 "subscriber_postal_code": "23418",
1300 "subscriber_city": "Cooltown",
1301 "subscriber_state": "AZ",
1302 "subscriber_country": "USA",
1303 "subscriber_phone": "234-598-2123",
1304 "subscriber_employer": "Some Employer",
1305 "subscriber_employer_street": "123 Heather Lane",
1306 "subscriber_employer_postal_code": "23415",
1307 "subscriber_employer_state": "AZ",
1308 "subscriber_employer_country": "USA",
1309 "subscriber_employer_city": "Cooltown",
1311 "date": "2018-10-15",
1312 "subscriber_sex": "Female",
1313 "accept_assignment": "TRUE",
1320 - `provider` is the insurance company id
1321 - `state` can be found by querying `resource=/api/list/state`
1322 - `country` can be found by querying `resource=/api/list/country`
1324 #### GET /api/list/:list_name
1329 curl -X GET 'http://localhost:8300/apis/default/api/list/medical_problem_issue_list'
1332 #### GET /api/version
1337 curl -X GET 'http://localhost:8300/apis/default/api/version'
1340 #### GET /api/product
1345 curl -X GET 'http://localhost:8300/apis/default/api/product'
1348 #### GET /api/insurance_company
1353 curl -X GET 'http://localhost:8300/apis/default/api/insurance_company'
1356 #### GET /api/insurance_type
1361 curl -X GET 'http://localhost:8300/apis/default/api/insurance_type'
1364 #### POST /api/insurance_company
1369 curl -X POST 'http://localhost:8300/apis/default/api/insurance_company' -d \
1371 "name": "Cool Insurance Company",
1374 "ins_type_code": "2",
1375 "x12_receiver_id": null,
1376 "x12_default_partner_id": null,
1378 "line1": "123 Cool Lane",
1379 "line2": "Suite 123",
1387 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1389 #### PUT /api/insurance_company/:iid
1394 curl -X PUT 'http://localhost:8300/apis/default/api/insurance_company/1' -d \
1396 "name": "Super Insurance Company",
1399 "ins_type_code": "2",
1400 "x12_receiver_id": null,
1401 "x12_default_partner_id": null,
1403 "line1": "123 Cool Lane",
1404 "line2": "Suite 123",
1412 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1414 #### GET /api/appointment
1419 curl -X GET 'http://localhost:8300/apis/default/api/appointment'
1422 #### GET /api/appointment/:eid
1427 curl -X GET 'http://localhost:8300/apis/default/api/appointment/1'
1430 #### GET /api/patient/:pid/appointment
1435 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment'
1438 #### GET /api/patient/:pid/appointment/:eid
1443 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment/1'
1446 #### POST /api/patient/:pid/appointment
1451 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/appointment' -d \
1455 "pc_title": "Office Visit",
1456 "pc_duration": "900",
1457 "pc_hometext": "Test",
1458 "pc_apptstatus": "-",
1459 "pc_eventDate": "2018-10-19",
1460 "pc_startTime": "09:00",
1462 "pc_billing_location": "10"
1466 #### DELETE /api/patient/:pid/appointment/:eid
1471 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/appointment/1' -d \
1474 #### GET /api/patient/:pid/document
1479 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1482 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1484 - Spaces are represented with `_`
1485 - All characters are lowercase
1487 #### POST /api/patient/:pid/document
1492 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1493 -F document=@/home/someone/Desktop/drawing.jpg
1496 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1498 - Spaces are represented with `_`
1499 - All characters are lowercase
1501 #### GET /api/patient/:pid/document/:did
1506 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document/1'
1509 #### POST /api/patient/:pid/message
1514 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/message' -d \
1517 "groupname": "Default",
1521 "message_status": "New"
1527 - For `title`, use `resource=/api/list/note_type`
1528 - For `message_type`, use `resource=/api/list/message_status`
1530 #### PUT /api/patient/:pid/message/:mid
1535 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/message/1' -d \
1538 "groupname": "Default",
1542 "message_status": "New"
1548 - For `title`, use `resource=/api/list/note_type`
1549 - For `message_type`, use `resource=/api/list/message_status`
1551 #### DELETE /api/patient/:pid/message/:mid
1556 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/message/1'
1559 ### /portal/ Endpoints
1561 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/default/portal as base URI.`
1563 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
1565 _Example:_ `http://localhost:8300/apis/default/portal/patient` returns a resource of the patient.
1567 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.
1572 curl -X GET 'http://localhost:8300/apis/default/portal/patient' \
1573 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1576 #### GET /portal/patient
1581 curl -X GET 'http://localhost:8300/apis/default/portal/patient'
1588 "validationErrors": [],
1589 "internalErrors": [],
1599 "street": "456 Tree Lane",
1600 "postal_code": "08642",
1604 "country_code": "US",
1605 "drivers_license": "",
1606 "contact_relationship": "",
1607 "phone_contact": "123-456-7890",
1612 "DOB": "1992-02-03",
1623 - For business logic, make or use the services [here](src/Services)
1624 - For controller logic, make or use the classes [here](src/RestControllers)
1625 - For routing declarations, use the class [here](_rest_routes.inc.php).
1627 ### Project Management
1631 - TODO(?): Prevent `ListService` from using `enddate` of `0000-00-00` by default
1632 - TODO(?): API for fee sheets
1633 - TODO(?): API for pharmacies
1634 - TODO(?): API for immunizations
1635 - TODO(?): API for prescriptions
1636 - TODO(?): Drug search API
1637 - TODO(?): API for onotes