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 - [Standard API Endpoints](API_README.md#api-endpoints)
56 - [Facility API](API_README.md#post-apifacility)
57 - [Provider API](API_README.md#get-apiprovider)
58 - [Patient API](API_README.md#post-apipatient)
59 - [Insurance API](API_README.md#get-apipatientpidinsurance)
60 - [Appointment API](API_README.md#get-apiappointment)
61 - [Document API](API_README.md#get-apipatientpiddocument)
62 - [Message API](API_README.md#post-apipatientpidmessage)
63 - [Portal API Endpoints](API_README.md#portal-Endpoints)
64 - [Patient API](API_README.md#get-portalpatient)
65 - [FHIR API Endpoints](FHIR_README.md#fhir-endpoints)
66 - [FHIR Patient API](FHIR_README.md#get-fhirpatient)
67 - [FHIR Encounter API](FHIR_README.md#get-fhirencounter)
68 - [FHIR Organization API](FHIR_README.md#get-fhirorganization)
69 - [FHIR AllergyIntolerance API](FHIR_README.md#get-fhirallergyintolerance)
70 - [FHIR Observation API](FHIR_README.md#get-fhirobservation)
71 - [FHIR QuestionnaireResponse API](FHIR_README.md#get-fhirquestionnaireresponse)
72 - [FHIR Immunization API](FHIR_README.md#get-fhirimmunization)
73 - [FHIR Condition API](FHIR_README.md#get-fhircondition)
74 - [FHIR Procedure API](FHIR_README.md#get-fhirprocedure)
75 - [FHIR MedicationStatement API](FHIR_README.md#get-fhirmedicationstatement)
76 - [FHIR Medication API](FHIR_README.md#get-fhirmedication)
77 - [Portal FHIR API Endpoints](FHIR_README.md#portalfhir-endpoints)
78 - [Patient API](FHIR_README.md#get-portalfhirpatient)
79 - [Dev notes](API_README.md#dev-notes)
80 - [Todos](API_README.md#project-management)
84 Enable the Standard API service (/api/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Standard REST API"
85 Enable the Patient Portal API service (/portal/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Patient Portal REST API"
87 ### Using API Internally
89 There are several ways to make API calls from an authorized session and maintain security:
91 - See the script at tests/api/InternalApiTest.php for examples of internal API use cases.
95 OpenEMR standard endpoints Use `http://localhost:8300/apis/api as base URI.`
97 _Example:_ `http://localhost:8300/apis/api/patient` returns a resource of all Patients.
101 The OpenEMR API utilizes the OAuth2 password credential flow for authentication. To obtain an API token, submit your login credentials and requested scope. The scope must match a site that has been setup in OpenEMR, in the /sites/ directory. If additional sites have not been created, set the scope
107 curl -X POST -H 'Content-Type: application/json' 'http://localhost:8300/apis/api/auth' \
109 "grant_type":"password",
110 "username": "ServiceUser",
111 "password": "password",
120 "token_type": "Bearer",
121 "access_token": "eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ==",
122 "expires_in": "3600",
129 The Bearer token is required for each OpenEMR API request, and is conveyed using an Authorization header.
134 curl -X GET 'http://localhost:8300/apis/api/patient/1/medical_problem' \
135 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
138 #### POST /api/facility
143 curl -X POST 'http://localhost:8300/apis/api/facility' -d \
146 "phone": "808-606-3030",
147 "fax": "808-606-3031",
148 "street": "1337 Bit Shifter Ln",
149 "city": "San Lorenzo",
151 "postal_code": "54321",
152 "email": "foo@bar.com",
153 "service_location": "1",
154 "billing_location": "1",
159 #### PUT /api/facility/:fid
164 curl -X PUT 'http://localhost:8300/apis/api/facility/1' -d \
167 "phone": "808-606-3030",
168 "fax": "808-606-3031",
169 "street": "1337 Bit Shifter Ln",
170 "city": "San Lorenzo",
172 "postal_code": "54321",
173 "email": "foo@bar.com",
174 "service_location": "1",
175 "billing_location": "1",
180 #### GET /api/facility
185 curl -X GET 'http://localhost:8300/apis/api/facility'
188 #### GET /api/facility/:fid
193 curl -X GET 'http://localhost:8300/apis/api/facility/1'
196 #### GET /api/provider
201 curl -X GET 'http://localhost:8300/apis/api/provider'
204 #### GET /api/provider/:prid
209 curl -X GET 'http://localhost:8300/apis/api/provider/1'
212 #### POST /api/patient
217 curl -X POST 'http://localhost:8300/apis/api/patient' -d \
223 "street": "456 Tree Lane",
224 "postal_code": "08642",
227 "country_code": "US",
228 "phone_contact": "123-456-7890",
240 "validationErrors": [],
241 "internalErrors": [],
248 #### PUT /api/patient/:puuid
253 curl -X PUT 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
259 "street": "456 Tree Lane",
260 "postal_code": "08642",
263 "country_code": "US",
264 "phone_contact": "123-456-7890",
276 "validationErrors": [],
277 "internalErrors": [],
287 "street": "456 Tree Lane",
288 "postal_code": "08642",
292 "country_code": "US",
293 "drivers_license": "",
294 "contact_relationship": "",
295 "phone_contact": "123-456-7890",
309 #### GET /api/patient
314 curl -X GET 'http://localhost:8300/apis/api/patient'
321 "validationErrors": [],
322 "internalErrors": [],
323 "data": [{ patientRecord }, { patientRecord }, etc]
330 curl -X GET 'http://localhost:8300/apis/api/patient&fname=...&lname=...&dob=...'
337 "validationErrors": [],
338 "internalErrors": [],
339 "data": [{ patientRecord }, { patientRecord }, etc]
343 #### GET /api/patient/:puuid
348 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
355 "validationErrors": [],
356 "internalErrors": [],
366 "street": "456 Tree Lane",
367 "postal_code": "08642",
371 "country_code": "US",
372 "drivers_license": "",
373 "contact_relationship": "",
374 "phone_contact": "123-456-7890",
388 #### POST /api/patient/:pid/encounter
393 curl -X POST 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
397 "reason": "Pregnancy Test",
398 "facility": "Owerri General Hospital",
401 "billing_facility": "3",
402 "sensitivity": "normal",
403 "referral_source": "",
415 "validationErrors": [],
416 "internalErrors": [],
419 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
424 #### PUT /api/patient/:pid/encounter/:eid
429 curl -X POST 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
432 "onset_date": "2019-04-20 00:00:00",
433 "reason": "Pregnancy Test",
436 "billing_facility": "3",
437 "sensitivity": "normal",
438 "referral_source": "",
447 "validationErrors": [],
448 "internalErrors": [],
451 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
452 "date": "2019-09-14 00:00:00",
453 "reason": "Pregnancy Test",
454 "facility": "Owerri General Hospital",
457 "onset_date": "2019-04-20 00:00:00",
458 "sensitivity": "normal",
459 "billing_note": null,
461 "last_level_billed": "0",
462 "last_level_closed": "0",
463 "last_stmt_date": null,
466 "supervisor_id": "0",
468 "referral_source": "",
469 "billing_facility": "3",
473 "class_title": "ambulatory",
474 "pc_catname": "Office Visit",
475 "billing_facility_name": "Owerri General Hospital"
480 #### GET /api/patient/:pid/encounter
485 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
492 "validationErrors": [],
493 "internalErrors": [],
494 "data": [{ encounterRecord }, { encounterRecord }, etc]
498 #### GET /api/patient/:pid/encounter/:eid
503 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
510 "validationErrors": [],
511 "internalErrors": [],
514 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
515 "date": "2019-09-14 00:00:00",
516 "reason": "Pregnancy Test",
517 "facility": "Owerri General Hospital",
520 "onset_date": "2019-04-20 00:00:00",
521 "sensitivity": "normal",
522 "billing_note": null,
524 "last_level_billed": "0",
525 "last_level_closed": "0",
526 "last_stmt_date": null,
529 "supervisor_id": "0",
531 "referral_source": "",
532 "billing_facility": "3",
536 "class_title": "ambulatory",
537 "pc_catname": "Office Visit",
538 "billing_facility_name": "Owerri General Hospital"
543 #### POST /api/patient/:pid/encounter/:eid/vital
548 curl -X POST 'http://localhost:8300/apis/api/patient/1/encounter/1/vital' -d \
555 "temp_method": "Oral",
561 "oxygen_saturation": "80"
565 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
570 curl -X PUT 'http://localhost:8300/apis/api/patient/1/encounter/1/vital/1' -d \
577 "temp_method": "Oral",
583 "oxygen_saturation": "80"
587 #### GET /api/patient/:pid/encounter/:eid/vital
592 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/vital'
595 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
600 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/vital/1'
603 #### POST /api/patient/:pid/encounter/:eid/soap_note
608 curl -X POST 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note' -d \
617 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
622 curl -X PUT 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note/1' -d \
631 #### GET /api/patient/:pid/encounter/:eid/soap_note
636 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note'
639 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
644 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note/1'
647 #### POST /api/patient/:pid/medical_problem
652 curl -X POST 'http://localhost:8300/apis/api/patient/1/medical_problem' -d \
654 "title": "Dermatochalasis",
655 "begdate": "2010-04-13",
657 "diagnosis": "ICD10:H02.839"
661 #### PUT /api/patient/:pid/medical_problem/:mid
666 curl -X PUT 'http://localhost:8300/apis/api/patient/1/medical_problem/1' -d \
668 "title": "Dermatochalasis",
669 "begdate": "2010-04-13",
670 "enddate": "2018-03-12",
671 "diagnosis": "ICD10:H02.839"
675 #### GET /api/patient/:pid/medical_problem
680 curl -X GET 'http://localhost:8300/apis/api/patient/1/medical_problem'
683 #### GET /api/patient/:pid/medical_problem/:mid
688 curl -X GET 'http://localhost:8300/apis/api/patient/1/medical_problem/1'
691 #### DELETE /api/patient/:pid/medical_problem/:mid
696 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/medical_problem/1'
699 #### POST /api/patient/:pid/allergy
704 curl -X POST 'http://localhost:8300/apis/api/patient/1/allergy' -d \
707 "begdate": "2010-10-13",
712 #### PUT /api/patient/:pid/allergy/:aid
717 curl -X PUT 'http://localhost:8300/apis/api/patient/1/allergy/1' -d \
720 "begdate": "2012-10-13",
725 #### GET /api/patient/:pid/allergy
730 curl -X GET 'http://localhost:8300/apis/api/patient/1/allergy'
733 #### GET /api/patient/:pid/allergy/:aid
738 curl -X GET 'http://localhost:8300/apis/api/patient/1/allergy/1'
741 #### DELETE /api/patient/:pid/allergy/:aid
746 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/allergy/1'
749 #### POST /api/patient/:pid/medication
754 curl -X POST 'http://localhost:8300/apis/api/patient/1/medication' -d \
757 "begdate": "2013-10-13",
762 #### PUT /api/patient/:pid/medication/:mid
767 curl -X PUT 'http://localhost:8300/apis/api/patient/1/medication/1' -d \
770 "begdate": "2013-04-13",
775 #### GET /api/patient/:pid/medication
780 curl -X GET 'http://localhost:8300/apis/api/patient/1/medication'
783 #### GET /api/patient/:pid/medication/:mid
788 curl -X GET 'http://localhost:8300/apis/api/patient/1/medication/1'
791 #### DELETE /api/patient/:pid/medication/:mid
796 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/medication/1'
799 #### POST /api/patient/:pid/surgery
804 curl -X POST 'http://localhost:8300/apis/api/patient/1/surgery' -d \
806 "title": "Blepharoplasty",
807 "begdate": "2013-10-13",
809 "diagnosis": "CPT4:15823-50"
813 #### PUT /api/patient/:pid/surgery/:sid
818 curl -X PUT 'http://localhost:8300/apis/api/patient/1/surgery/1' -d \
820 "title": "Blepharoplasty",
821 "begdate": "2013-10-14",
823 "diagnosis": "CPT4:15823-50"
827 #### GET /api/patient/:pid/surgery
832 curl -X GET 'http://localhost:8300/apis/api/patient/1/surgery'
835 #### GET /api/patient/:pid/surgery/:sid
840 curl -X GET 'http://localhost:8300/apis/api/patient/1/surgery/1'
843 #### DELETE /api/patient/:pid/surgery/:sid
848 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/surgery/1'
851 #### POST /api/patient/:pid/dental_issue
856 curl -X POST 'http://localhost:8300/apis/api/patient/1/dental_issue' -d \
858 "title": "Halitosis",
859 "begdate": "2015-03-17",
864 #### PUT /api/patient/:pid/dental_issue/:did
869 curl -X PUT 'http://localhost:8300/apis/api/patient/1/dental_issue/1' -d \
871 "title": "Halitosis",
872 "begdate": "2015-03-17",
873 "enddate": "2018-03-20"
877 #### GET /api/patient/:pid/dental_issue
882 curl -X GET 'http://localhost:8300/apis/api/patient/1/dental_issue'
885 #### GET /api/patient/:pid/dental_issue/:did
890 curl -X GET 'http://localhost:8300/apis/api/patient/1/dental_issue/1'
893 #### DELETE /api/patient/:pid/dental_issue/:did
898 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/dental_issue/1'
901 #### GET /api/patient/:pid/insurance
906 curl -X GET 'http://localhost:8300/apis/api/patient/1/insurance'
909 #### GET /api/patient/:pid/insurance/:type
914 curl -X GET 'http://localhost:8300/apis/api/patient/1/insurance/secondary'
917 #### POST /api/patient/:pid/insurance/:type
922 curl -X POST 'http://localhost:8300/apis/api/patient/10/insurance/primary' -d \
926 "plan_name": "Some Plan",
927 "policy_number": "12345",
928 "group_number": "252412",
929 "subscriber_lname": "Tester",
930 "subscriber_mname": "Xi",
931 "subscriber_fname": "Foo",
932 "subscriber_relationship": "other",
933 "subscriber_ss": "234231234",
934 "subscriber_DOB": "2018-10-03",
935 "subscriber_street": "183 Cool St",
936 "subscriber_postal_code": "23418",
937 "subscriber_city": "Cooltown",
938 "subscriber_state": "AZ",
939 "subscriber_country": "USA",
940 "subscriber_phone": "234-598-2123",
941 "subscriber_employer": "Some Employer",
942 "subscriber_employer_street": "123 Heather Lane",
943 "subscriber_employer_postal_code": "23415",
944 "subscriber_employer_state": "AZ",
945 "subscriber_employer_country": "USA",
946 "subscriber_employer_city": "Cooltown",
948 "date": "2018-10-15",
949 "subscriber_sex": "Female",
950 "accept_assignment": "TRUE",
957 - `provider` is the insurance company id
958 - `state` can be found by querying `resource=/api/list/state`
959 - `country` can be found by querying `resource=/api/list/country`
961 #### PUT /api/patient/:pid/insurance/:type
966 curl -X PUT 'http://localhost:8300/apis/api/patient/10/insurance/primary' -d \
970 "plan_name": "Some Plan",
971 "policy_number": "12345",
972 "group_number": "252412",
973 "subscriber_lname": "Tester",
974 "subscriber_mname": "Xi",
975 "subscriber_fname": "Foo",
976 "subscriber_relationship": "other",
977 "subscriber_ss": "234231234",
978 "subscriber_DOB": "2018-10-03",
979 "subscriber_street": "183 Cool St",
980 "subscriber_postal_code": "23418",
981 "subscriber_city": "Cooltown",
982 "subscriber_state": "AZ",
983 "subscriber_country": "USA",
984 "subscriber_phone": "234-598-2123",
985 "subscriber_employer": "Some Employer",
986 "subscriber_employer_street": "123 Heather Lane",
987 "subscriber_employer_postal_code": "23415",
988 "subscriber_employer_state": "AZ",
989 "subscriber_employer_country": "USA",
990 "subscriber_employer_city": "Cooltown",
992 "date": "2018-10-15",
993 "subscriber_sex": "Female",
994 "accept_assignment": "TRUE",
1001 - `provider` is the insurance company id
1002 - `state` can be found by querying `resource=/api/list/state`
1003 - `country` can be found by querying `resource=/api/list/country`
1005 #### GET /api/list/:list_name
1010 curl -X GET 'http://localhost:8300/apis/api/list/medical_problem_issue_list'
1013 #### GET /api/version
1018 curl -X GET 'http://localhost:8300/apis/api/version'
1021 #### GET /api/product
1026 curl -X GET 'http://localhost:8300/apis/api/product'
1029 #### GET /api/insurance_company
1034 curl -X GET 'http://localhost:8300/apis/api/insurance_company'
1037 #### GET /api/insurance_type
1042 curl -X GET 'http://localhost:8300/apis/api/insurance_type'
1045 #### POST /api/insurance_company
1050 curl -X POST 'http://localhost:8300/apis/api/insurance_company' -d \
1052 "name": "Cool Insurance Company",
1055 "ins_type_code": "2",
1056 "x12_receiver_id": null,
1057 "x12_default_partner_id": null,
1059 "line1": "123 Cool Lane",
1060 "line2": "Suite 123",
1068 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1070 #### PUT /api/insurance_company/:iid
1075 curl -X PUT 'http://localhost:8300/apis/api/insurance_company/1' -d \
1077 "name": "Super Insurance Company",
1080 "ins_type_code": "2",
1081 "x12_receiver_id": null,
1082 "x12_default_partner_id": null,
1084 "line1": "123 Cool Lane",
1085 "line2": "Suite 123",
1093 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1095 #### GET /api/appointment
1100 curl -X GET 'http://localhost:8300/apis/api/appointment'
1103 #### GET /api/appointment/:eid
1108 curl -X GET 'http://localhost:8300/apis/api/appointment/1'
1111 #### GET /api/patient/:pid/appointment
1116 curl -X GET 'http://localhost:8300/apis/api/patient/1/appointment'
1119 #### GET /api/patient/:pid/appointment/:eid
1124 curl -X GET 'http://localhost:8300/apis/api/patient/1/appointment/1'
1127 #### POST /api/patient/:pid/appointment
1132 curl -X POST 'http://localhost:8300/apis/api/patient/1/appointment' -d \
1136 "pc_title": "Office Visit",
1137 "pc_duration": "900",
1138 "pc_hometext": "Test",
1139 "pc_apptstatus": "-",
1140 "pc_eventDate": "2018-10-19",
1141 "pc_startTime": "09:00",
1143 "pc_billing_location": "10"
1147 #### DELETE /api/patient/:pid/appointment/:eid
1152 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/appointment/1' -d \
1155 #### GET /api/patient/:pid/document
1160 curl -X GET 'http://localhost:8300/apis/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1163 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1165 - Spaces are represented with `_`
1166 - All characters are lowercase
1168 #### POST /api/patient/:pid/document
1173 curl -X POST 'http://localhost:8300/apis/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1174 -F document=@/home/someone/Desktop/drawing.jpg
1177 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1179 - Spaces are represented with `_`
1180 - All characters are lowercase
1182 #### GET /api/patient/:pid/document/:did
1187 curl -X GET 'http://localhost:8300/apis/api/patient/1/document/1'
1190 #### POST /api/patient/:pid/message
1195 curl -X POST 'http://localhost:8300/apis/api/patient/1/message' -d \
1198 "groupname": "Default",
1202 "message_status": "New"
1208 - For `title`, use `resource=/api/list/note_type`
1209 - For `message_type`, use `resource=/api/list/message_status`
1211 #### PUT /api/patient/:pid/message/:mid
1216 curl -X PUT 'http://localhost:8300/apis/api/patient/1/message/1' -d \
1219 "groupname": "Default",
1223 "message_status": "New"
1229 - For `title`, use `resource=/api/list/note_type`
1230 - For `message_type`, use `resource=/api/list/message_status`
1232 #### DELETE /api/patient/:pid/message/:mid
1237 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/message/1'
1240 ### /portal/ Endpoints
1242 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/portal as base URI.`
1244 _Example:_ `http://localhost:8300/apis/portal/patient` returns a resource of the patient.
1246 #### POST /portal/auth
1248 The OpenEMR Patient Portal API utilizes the OAuth2 password credential flow for authentication. To obtain an API token, submit your login credentials and requested scope. The scope must match a site that has been setup in OpenEMR, in the /sites/ directory. If additional sites have not been created, set the scope
1249 to 'default'. If the patient portal is set to require email address on authenticate, then need to also include an `email` field in the request.
1254 curl -X POST -H 'Content-Type: application/json' 'http://localhost:8300/apis/portal/auth' \
1256 "grant_type":"password",
1257 "username": "ServiceUser",
1258 "password": "password",
1267 "token_type": "Bearer",
1268 "access_token": "eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ==",
1269 "expires_in": "3600",
1276 The Bearer token is required for each OpenEMR Patient Portal API request, and is conveyed using an Authorization header.
1281 curl -X GET 'http://localhost:8300/apis/portal/patient' \
1282 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1285 #### GET /portal/patient
1290 curl -X GET 'http://localhost:8300/apis/portal/patient'
1297 "validationErrors": [],
1298 "internalErrors": [],
1308 "street": "456 Tree Lane",
1309 "postal_code": "08642",
1313 "country_code": "US",
1314 "drivers_license": "",
1315 "contact_relationship": "",
1316 "phone_contact": "123-456-7890",
1321 "DOB": "1992-02-03",
1332 - For business logic, make or use the services [here](src/Services)
1333 - For controller logic, make or use the classes [here](src/RestControllers)
1334 - For routing declarations, use the class [here](_rest_routes.inc.php).
1336 ### Project Management
1340 - TODO(?): Prevent `ListService` from using `enddate` of `0000-00-00` by default
1341 - TODO(?): API for fee sheets
1342 - TODO(?): API for pharmacies
1343 - TODO(?): API for immunizations
1344 - TODO(?): API for prescriptions
1345 - TODO(?): Drug search API
1346 - TODO(?): API for onotes