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.
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 "client_name": "A Private App",
124 "token_endpoint_auth_method": "client_secret_post",
125 "contacts": ["me@example.org", "them@example.org"]
133 "client_id": "LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA",
134 "client_secret": "j21ecvLmFi9HPc_Hv0t7Ptmf1pVcZQLtHjIdU7U9tkS9WAjFJwVMav0G8ogTJ62q4BATovC7BQ19Qagc4x9BBg",
135 "registration_access_token": "uiDSXx2GNSvYy5n8eW50aGrJz0HjaGpUdrGf07Agv_Q",
136 "registration_client_uri": "https:\/\/localhost:9300\/oauth2\/default\/client\/6eUVG0-qK2dYiwfYdECKIw",
137 "client_id_issued_at": 1604767861,
138 "client_secret_expires_at": 0,
139 "contacts": ["me@example.org", "them@example.org"],
140 "application_type": "private",
141 "client_name": "A Private App",
142 "redirect_uris": ["https:\/\/client.example.org\/callback"],
143 "token_endpoint_auth_method": "client_secret_post"
147 #### Authorization Code Grant
149 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`.
151 #### Refresh Token Grant
156 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
157 -i 'https://localhost:9300/oauth2/default/token'
158 --data 'grant_type=refresh_token
159 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
160 &refresh_token=def5020089a766d16...'
167 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
168 "token_type": "Bearer",
170 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
171 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
177 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)'.
179 Example for `users` role:
181 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
182 -i 'https://localhost:9300/oauth2/default/token'
183 --data 'grant_type=password
184 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
190 Example for `patient` role:
192 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
193 -i 'https://localhost:9300/oauth2/default/token'
194 --data 'grant_type=password
195 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
199 &email=heya@invalid.email.com'
206 "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
207 "token_type": "Bearer",
209 "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
210 "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
216 OpenEMR standard endpoints Use `http://localhost:8300/apis/default/api as base URI.`
218 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
220 _Example:_ `http://localhost:8300/apis/default/api/patient` returns a resource of all Patients.
222 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.
227 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medical_problem' \
228 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
231 #### POST /api/facility
236 curl -X POST 'http://localhost:8300/apis/default/api/facility' -d \
239 "phone": "808-606-3030",
240 "fax": "808-606-3031",
241 "street": "1337 Bit Shifter Ln",
242 "city": "San Lorenzo",
244 "postal_code": "54321",
245 "email": "foo@bar.com",
246 "service_location": "1",
247 "billing_location": "1",
252 #### PUT /api/facility/:fid
257 curl -X PUT 'http://localhost:8300/apis/default/api/facility/1' -d \
260 "phone": "808-606-3030",
261 "fax": "808-606-3031",
262 "street": "1337 Bit Shifter Ln",
263 "city": "San Lorenzo",
265 "postal_code": "54321",
266 "email": "foo@bar.com",
267 "service_location": "1",
268 "billing_location": "1",
273 #### GET /api/facility
278 curl -X GET 'http://localhost:8300/apis/default/api/facility'
281 #### GET /api/facility/:fid
286 curl -X GET 'http://localhost:8300/apis/default/api/facility/1'
289 #### GET /api/practitioner
294 curl -X GET 'http://localhost:8300/apis/default/api/practitioner'
297 #### GET /api/practitioner/:uuid
302 curl -X GET 'http://localhost:8300/apis/default/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
305 #### POST /api/practitioner
310 curl -X POST 'http://localhost:8300/apis/default/api/practitioner' -d \
320 "facility": "Your Clinic Name Here",
322 "email": "info@pennfirm.com",
327 "organization": null,
329 "street": "789 Third Avenue",
330 "streetb": "123 Cannaut Street",
334 "phone": "(619) 555-9827",
336 "phonew1": "(619) 555-7822",
337 "phonecell": "(619) 555-7821",
339 "state_license_number": "123456"
347 "validationErrors": [],
348 "internalErrors": [],
351 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
356 #### PATCH /api/practitioner/:uuid
361 curl -X PATCH 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
367 "street": "456 Tree Lane",
371 "phone": "123-456-7890"
379 "validationErrors": [],
380 "internalErrors": [],
383 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
392 "facility": "Your Clinic Name Here",
394 "email": "info@pennfirm.com",
402 "street": "456 Tree Lane",
403 "streetb": "123 Cannaut Street",
407 "phone": "123-456-7890",
409 "phonew1": "(619) 555-7822",
410 "phonecell": "(619) 555-7821",
412 "state_license_number": "123456",
414 "physician_title": null,
415 "physician_code": null
420 #### POST /api/patient
425 curl -X POST 'http://localhost:8300/apis/default/api/patient' -d \
431 "street": "456 Tree Lane",
432 "postal_code": "08642",
435 "country_code": "US",
436 "phone_contact": "123-456-7890",
448 "validationErrors": [],
449 "internalErrors": [],
456 #### PUT /api/patient/:puuid
461 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
467 "street": "456 Tree Lane",
468 "postal_code": "08642",
471 "country_code": "US",
472 "phone_contact": "123-456-7890",
484 "validationErrors": [],
485 "internalErrors": [],
495 "street": "456 Tree Lane",
496 "postal_code": "08642",
500 "country_code": "US",
501 "drivers_license": "",
502 "contact_relationship": "",
503 "phone_contact": "123-456-7890",
517 #### GET /api/patient
522 curl -X GET 'http://localhost:8300/apis/default/api/patient'
529 "validationErrors": [],
530 "internalErrors": [],
531 "data": [{ patientRecord }, { patientRecord }, etc]
538 curl -X GET 'http://localhost:8300/apis/default/api/patient&fname=...&lname=...&dob=...'
545 "validationErrors": [],
546 "internalErrors": [],
547 "data": [{ patientRecord }, { patientRecord }, etc]
551 #### GET /api/patient/:puuid
556 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
563 "validationErrors": [],
564 "internalErrors": [],
574 "street": "456 Tree Lane",
575 "postal_code": "08642",
579 "country_code": "US",
580 "drivers_license": "",
581 "contact_relationship": "",
582 "phone_contact": "123-456-7890",
596 #### GET /api/immunization
601 curl -X GET 'http://localhost:8300/apis/default/api/immunization'
604 #### GET /api/immunization/:uuid
609 curl -X GET 'http://localhost:8300/apis/default/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
612 #### POST /api/patient/:pid/encounter
617 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
621 "reason": "Pregnancy Test",
622 "facility": "Owerri General Hospital",
625 "billing_facility": "3",
626 "sensitivity": "normal",
627 "referral_source": "",
639 "validationErrors": [],
640 "internalErrors": [],
643 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
648 #### PUT /api/patient/:pid/encounter/:eid
653 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
656 "onset_date": "2019-04-20 00:00:00",
657 "reason": "Pregnancy Test",
660 "billing_facility": "3",
661 "sensitivity": "normal",
662 "referral_source": "",
671 "validationErrors": [],
672 "internalErrors": [],
675 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
676 "date": "2019-09-14 00:00:00",
677 "reason": "Pregnancy Test",
678 "facility": "Owerri General Hospital",
681 "onset_date": "2019-04-20 00:00:00",
682 "sensitivity": "normal",
683 "billing_note": null,
685 "last_level_billed": "0",
686 "last_level_closed": "0",
687 "last_stmt_date": null,
690 "supervisor_id": "0",
692 "referral_source": "",
693 "billing_facility": "3",
697 "class_title": "ambulatory",
698 "pc_catname": "Office Visit",
699 "billing_facility_name": "Owerri General Hospital"
704 #### GET /api/patient/:pid/encounter
709 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
716 "validationErrors": [],
717 "internalErrors": [],
718 "data": [{ encounterRecord }, { encounterRecord }, etc]
722 #### GET /api/patient/:pid/encounter/:eid
727 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
734 "validationErrors": [],
735 "internalErrors": [],
738 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
739 "date": "2019-09-14 00:00:00",
740 "reason": "Pregnancy Test",
741 "facility": "Owerri General Hospital",
744 "onset_date": "2019-04-20 00:00:00",
745 "sensitivity": "normal",
746 "billing_note": null,
748 "last_level_billed": "0",
749 "last_level_closed": "0",
750 "last_stmt_date": null,
753 "supervisor_id": "0",
755 "referral_source": "",
756 "billing_facility": "3",
760 "class_title": "ambulatory",
761 "pc_catname": "Office Visit",
762 "billing_facility_name": "Owerri General Hospital"
767 #### POST /api/patient/:pid/encounter/:eid/vital
772 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital' -d \
779 "temp_method": "Oral",
785 "oxygen_saturation": "80"
789 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
794 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1' -d \
801 "temp_method": "Oral",
807 "oxygen_saturation": "80"
811 #### GET /api/patient/:pid/encounter/:eid/vital
816 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital'
819 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
824 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1'
827 #### POST /api/patient/:pid/encounter/:eid/soap_note
832 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note' -d \
841 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
846 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1' -d \
855 #### GET /api/patient/:pid/encounter/:eid/soap_note
860 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note'
863 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
868 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1'
871 #### GET /api/medical_problem
876 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem'
879 #### GET /api/medical_problem/:muuid
884 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
887 #### GET /api/patient/:puuid/medical_problem
892 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
895 #### GET /api/patient/:puuid/medical_problem/:muuid
900 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
903 #### POST /api/patient/:puuid/medical_problem
908 curl -X POST 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
910 "title": "Dermatochalasis",
911 "begdate": "2010-04-13",
913 "diagnosis": "ICD10:H02.839"
917 #### PUT /api/patient/:puuid/medical_problem/:muuid
922 curl -X PUT 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
924 "title": "Dermatochalasis",
925 "begdate": "2010-04-13",
926 "enddate": "2018-03-12",
927 "diagnosis": "ICD10:H02.839"
931 #### DELETE /api/patient/:puuid/medical_problem/:muuid
936 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
939 #### GET /api/allergy
944 curl -X GET 'http://localhost:8300/apis/default/api/allergy'
947 #### GET /api/allergy/:auuid
952 curl -X GET 'http://localhost:8300/apis/default/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
955 #### GET /api/patient/:puuid/allergy
960 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
963 #### GET /api/patient/:puuid/allergy/:auuid
968 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
971 #### POST /api/patient/:puuid/allergy
976 curl -X POST 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
979 "begdate": "2010-10-13",
984 #### PUT /api/patient/:puuid/allergy/:auuid
989 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
992 "begdate": "2012-10-13",
997 #### DELETE /api/patient/:puuid/allergy/:auuid
1002 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1005 #### GET /api/procedure
1010 curl -X GET 'http://localhost:8300/apis/default/api/procedure'
1013 #### GET /api/procedure/:uuid
1018 curl -X GET 'http://localhost:8300/apis/default/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
1026 curl -X GET 'http://localhost:8300/apis/default/api/drug'
1029 #### GET /api/drug/:uuid
1034 curl -X GET 'http://localhost:8300/apis/default/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
1037 #### GET /api/prescription
1042 curl -X GET 'http://localhost:8300/apis/default/api/prescription'
1045 #### GET /api/prescription/:uuid
1050 curl -X GET 'http://localhost:8300/apis/default/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
1053 #### POST /api/patient/:pid/medication
1058 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/medication' -d \
1061 "begdate": "2013-10-13",
1066 #### PUT /api/patient/:pid/medication/:mid
1071 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/medication/1' -d \
1074 "begdate": "2013-04-13",
1079 #### GET /api/patient/:pid/medication
1084 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication'
1087 #### GET /api/patient/:pid/medication/:mid
1092 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1095 #### DELETE /api/patient/:pid/medication/:mid
1100 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1103 #### POST /api/patient/:pid/surgery
1108 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/surgery' -d \
1110 "title": "Blepharoplasty",
1111 "begdate": "2013-10-13",
1113 "diagnosis": "CPT4:15823-50"
1117 #### PUT /api/patient/:pid/surgery/:sid
1122 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/surgery/1' -d \
1124 "title": "Blepharoplasty",
1125 "begdate": "2013-10-14",
1127 "diagnosis": "CPT4:15823-50"
1131 #### GET /api/patient/:pid/surgery
1136 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery'
1139 #### GET /api/patient/:pid/surgery/:sid
1144 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1147 #### DELETE /api/patient/:pid/surgery/:sid
1152 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1155 #### POST /api/patient/:pid/dental_issue
1160 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/dental_issue' -d \
1162 "title": "Halitosis",
1163 "begdate": "2015-03-17",
1168 #### PUT /api/patient/:pid/dental_issue/:did
1173 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1' -d \
1175 "title": "Halitosis",
1176 "begdate": "2015-03-17",
1177 "enddate": "2018-03-20"
1181 #### GET /api/patient/:pid/dental_issue
1186 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue'
1189 #### GET /api/patient/:pid/dental_issue/:did
1194 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1197 #### DELETE /api/patient/:pid/dental_issue/:did
1202 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1205 #### GET /api/patient/:pid/insurance
1210 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance'
1213 #### GET /api/patient/:pid/insurance/:type
1218 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance/secondary'
1221 #### POST /api/patient/:pid/insurance/:type
1226 curl -X POST 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1230 "plan_name": "Some Plan",
1231 "policy_number": "12345",
1232 "group_number": "252412",
1233 "subscriber_lname": "Tester",
1234 "subscriber_mname": "Xi",
1235 "subscriber_fname": "Foo",
1236 "subscriber_relationship": "other",
1237 "subscriber_ss": "234231234",
1238 "subscriber_DOB": "2018-10-03",
1239 "subscriber_street": "183 Cool St",
1240 "subscriber_postal_code": "23418",
1241 "subscriber_city": "Cooltown",
1242 "subscriber_state": "AZ",
1243 "subscriber_country": "USA",
1244 "subscriber_phone": "234-598-2123",
1245 "subscriber_employer": "Some Employer",
1246 "subscriber_employer_street": "123 Heather Lane",
1247 "subscriber_employer_postal_code": "23415",
1248 "subscriber_employer_state": "AZ",
1249 "subscriber_employer_country": "USA",
1250 "subscriber_employer_city": "Cooltown",
1252 "date": "2018-10-15",
1253 "subscriber_sex": "Female",
1254 "accept_assignment": "TRUE",
1261 - `provider` is the insurance company id
1262 - `state` can be found by querying `resource=/api/list/state`
1263 - `country` can be found by querying `resource=/api/list/country`
1265 #### PUT /api/patient/:pid/insurance/:type
1270 curl -X PUT 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1274 "plan_name": "Some Plan",
1275 "policy_number": "12345",
1276 "group_number": "252412",
1277 "subscriber_lname": "Tester",
1278 "subscriber_mname": "Xi",
1279 "subscriber_fname": "Foo",
1280 "subscriber_relationship": "other",
1281 "subscriber_ss": "234231234",
1282 "subscriber_DOB": "2018-10-03",
1283 "subscriber_street": "183 Cool St",
1284 "subscriber_postal_code": "23418",
1285 "subscriber_city": "Cooltown",
1286 "subscriber_state": "AZ",
1287 "subscriber_country": "USA",
1288 "subscriber_phone": "234-598-2123",
1289 "subscriber_employer": "Some Employer",
1290 "subscriber_employer_street": "123 Heather Lane",
1291 "subscriber_employer_postal_code": "23415",
1292 "subscriber_employer_state": "AZ",
1293 "subscriber_employer_country": "USA",
1294 "subscriber_employer_city": "Cooltown",
1296 "date": "2018-10-15",
1297 "subscriber_sex": "Female",
1298 "accept_assignment": "TRUE",
1305 - `provider` is the insurance company id
1306 - `state` can be found by querying `resource=/api/list/state`
1307 - `country` can be found by querying `resource=/api/list/country`
1309 #### GET /api/list/:list_name
1314 curl -X GET 'http://localhost:8300/apis/default/api/list/medical_problem_issue_list'
1317 #### GET /api/version
1322 curl -X GET 'http://localhost:8300/apis/default/api/version'
1325 #### GET /api/product
1330 curl -X GET 'http://localhost:8300/apis/default/api/product'
1333 #### GET /api/insurance_company
1338 curl -X GET 'http://localhost:8300/apis/default/api/insurance_company'
1341 #### GET /api/insurance_type
1346 curl -X GET 'http://localhost:8300/apis/default/api/insurance_type'
1349 #### POST /api/insurance_company
1354 curl -X POST 'http://localhost:8300/apis/default/api/insurance_company' -d \
1356 "name": "Cool Insurance Company",
1359 "ins_type_code": "2",
1360 "x12_receiver_id": null,
1361 "x12_default_partner_id": null,
1363 "line1": "123 Cool Lane",
1364 "line2": "Suite 123",
1372 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1374 #### PUT /api/insurance_company/:iid
1379 curl -X PUT 'http://localhost:8300/apis/default/api/insurance_company/1' -d \
1381 "name": "Super Insurance Company",
1384 "ins_type_code": "2",
1385 "x12_receiver_id": null,
1386 "x12_default_partner_id": null,
1388 "line1": "123 Cool Lane",
1389 "line2": "Suite 123",
1397 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1399 #### GET /api/appointment
1404 curl -X GET 'http://localhost:8300/apis/default/api/appointment'
1407 #### GET /api/appointment/:eid
1412 curl -X GET 'http://localhost:8300/apis/default/api/appointment/1'
1415 #### GET /api/patient/:pid/appointment
1420 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment'
1423 #### GET /api/patient/:pid/appointment/:eid
1428 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment/1'
1431 #### POST /api/patient/:pid/appointment
1436 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/appointment' -d \
1440 "pc_title": "Office Visit",
1441 "pc_duration": "900",
1442 "pc_hometext": "Test",
1443 "pc_apptstatus": "-",
1444 "pc_eventDate": "2018-10-19",
1445 "pc_startTime": "09:00",
1447 "pc_billing_location": "10"
1451 #### DELETE /api/patient/:pid/appointment/:eid
1456 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/appointment/1' -d \
1459 #### GET /api/patient/:pid/document
1464 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1467 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1469 - Spaces are represented with `_`
1470 - All characters are lowercase
1472 #### POST /api/patient/:pid/document
1477 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1478 -F document=@/home/someone/Desktop/drawing.jpg
1481 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1483 - Spaces are represented with `_`
1484 - All characters are lowercase
1486 #### GET /api/patient/:pid/document/:did
1491 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document/1'
1494 #### POST /api/patient/:pid/message
1499 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/message' -d \
1502 "groupname": "Default",
1506 "message_status": "New"
1512 - For `title`, use `resource=/api/list/note_type`
1513 - For `message_type`, use `resource=/api/list/message_status`
1515 #### PUT /api/patient/:pid/message/:mid
1520 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/message/1' -d \
1523 "groupname": "Default",
1527 "message_status": "New"
1533 - For `title`, use `resource=/api/list/note_type`
1534 - For `message_type`, use `resource=/api/list/message_status`
1536 #### DELETE /api/patient/:pid/message/:mid
1541 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/message/1'
1544 ### /portal/ Endpoints
1546 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/default/portal as base URI.`
1548 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
1550 _Example:_ `http://localhost:8300/apis/default/portal/patient` returns a resource of the patient.
1552 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.
1557 curl -X GET 'http://localhost:8300/apis/default/portal/patient' \
1558 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1561 #### GET /portal/patient
1566 curl -X GET 'http://localhost:8300/apis/default/portal/patient'
1573 "validationErrors": [],
1574 "internalErrors": [],
1584 "street": "456 Tree Lane",
1585 "postal_code": "08642",
1589 "country_code": "US",
1590 "drivers_license": "",
1591 "contact_relationship": "",
1592 "phone_contact": "123-456-7890",
1597 "DOB": "1992-02-03",
1608 - For business logic, make or use the services [here](src/Services)
1609 - For controller logic, make or use the classes [here](src/RestControllers)
1610 - For routing declarations, use the class [here](_rest_routes.inc.php).
1612 ### Project Management
1616 - TODO(?): Prevent `ListService` from using `enddate` of `0000-00-00` by default
1617 - TODO(?): API for fee sheets
1618 - TODO(?): API for pharmacies
1619 - TODO(?): API for immunizations
1620 - TODO(?): API for prescriptions
1621 - TODO(?): Drug search API
1622 - TODO(?): API for onotes