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 - [Practitioner API](API_README.md#get-apipractitioner)
58 - [Patient API](API_README.md#post-apipatient)
59 - [Immunization API](API_README.md#get-apiimmunization)
60 - [Allergy API](API_README.md#get-apiallergy)
61 - [Procedure API](API_README.md#get-apiprocedure)
62 - [Drug API](API_README.md#get-apidrug)
63 - [Prescription API](API_README.md#get-apiprescription)
64 - [Insurance API](API_README.md#get-apipatientpidinsurance)
65 - [Appointment API](API_README.md#get-apiappointment)
66 - [Document API](API_README.md#get-apipatientpiddocument)
67 - [Message API](API_README.md#post-apipatientpidmessage)
68 - [Portal API Endpoints](API_README.md#portal-Endpoints)
69 - [Patient API](API_README.md#get-portalpatient)
70 - [FHIR API Endpoints](FHIR_README.md#fhir-endpoints)
71 - [FHIR Capability Statement](FHIR_README.md#capability-statement)
72 - [FHIR Authorization](FHIR_README.md#authorization)
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 Authorization](FHIR_README.md#patient-portal-authorization)
91 - [Patient Portal FHIR Patient](FHIR_README.md#patient-portal-patient-resource)
92 - [Dev notes](API_README.md#dev-notes)
93 - [Todos](API_README.md#project-management)
97 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.
108 OpenEMR standard endpoints Use `http://localhost:8300/apis/api as base URI.`
110 _Example:_ `http://localhost:8300/apis/api/patient` returns a resource of all Patients.
114 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
120 curl -X POST -H 'Content-Type: application/json' 'http://localhost:8300/apis/api/auth' \
122 "grant_type":"password",
123 "username": "ServiceUser",
124 "password": "password",
133 "token_type": "Bearer",
134 "access_token": "eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ==",
135 "expires_in": "3600",
142 The Bearer token is required for each OpenEMR API request, and is conveyed using an Authorization header.
147 curl -X GET 'http://localhost:8300/apis/api/patient/1/medical_problem' \
148 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
151 #### POST /api/facility
156 curl -X POST 'http://localhost:8300/apis/api/facility' -d \
159 "phone": "808-606-3030",
160 "fax": "808-606-3031",
161 "street": "1337 Bit Shifter Ln",
162 "city": "San Lorenzo",
164 "postal_code": "54321",
165 "email": "foo@bar.com",
166 "service_location": "1",
167 "billing_location": "1",
172 #### PUT /api/facility/:fid
177 curl -X PUT 'http://localhost:8300/apis/api/facility/1' -d \
180 "phone": "808-606-3030",
181 "fax": "808-606-3031",
182 "street": "1337 Bit Shifter Ln",
183 "city": "San Lorenzo",
185 "postal_code": "54321",
186 "email": "foo@bar.com",
187 "service_location": "1",
188 "billing_location": "1",
193 #### GET /api/facility
198 curl -X GET 'http://localhost:8300/apis/api/facility'
201 #### GET /api/facility/:fid
206 curl -X GET 'http://localhost:8300/apis/api/facility/1'
209 #### GET /api/practitioner
214 curl -X GET 'http://localhost:8300/apis/api/practitioner'
217 #### GET /api/practitioner/:uuid
222 curl -X GET 'http://localhost:8300/apis/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
225 #### POST /api/practitioner
230 curl -X POST 'http://localhost:8300/apis/api/practitioner' -d \
240 "facility": "Your Clinic Name Here",
242 "email": "info@pennfirm.com",
247 "organization": null,
249 "street": "789 Third Avenue",
250 "streetb": "123 Cannaut Street",
254 "phone": "(619) 555-9827",
256 "phonew1": "(619) 555-7822",
257 "phonecell": "(619) 555-7821",
259 "state_license_number": "123456"
267 "validationErrors": [],
268 "internalErrors": [],
271 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
276 #### PATCH /api/practitioner/:uuid
281 curl -X PATCH 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
287 "street": "456 Tree Lane",
291 "phone": "123-456-7890"
299 "validationErrors": [],
300 "internalErrors": [],
303 "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
312 "facility": "Your Clinic Name Here",
314 "email": "info@pennfirm.com",
322 "street": "456 Tree Lane",
323 "streetb": "123 Cannaut Street",
327 "phone": "123-456-7890",
329 "phonew1": "(619) 555-7822",
330 "phonecell": "(619) 555-7821",
332 "state_license_number": "123456",
334 "physician_title": null,
335 "physician_code": null
340 #### POST /api/patient
345 curl -X POST 'http://localhost:8300/apis/api/patient' -d \
351 "street": "456 Tree Lane",
352 "postal_code": "08642",
355 "country_code": "US",
356 "phone_contact": "123-456-7890",
368 "validationErrors": [],
369 "internalErrors": [],
376 #### PUT /api/patient/:puuid
381 curl -X PUT 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
387 "street": "456 Tree Lane",
388 "postal_code": "08642",
391 "country_code": "US",
392 "phone_contact": "123-456-7890",
404 "validationErrors": [],
405 "internalErrors": [],
415 "street": "456 Tree Lane",
416 "postal_code": "08642",
420 "country_code": "US",
421 "drivers_license": "",
422 "contact_relationship": "",
423 "phone_contact": "123-456-7890",
437 #### GET /api/patient
442 curl -X GET 'http://localhost:8300/apis/api/patient'
449 "validationErrors": [],
450 "internalErrors": [],
451 "data": [{ patientRecord }, { patientRecord }, etc]
458 curl -X GET 'http://localhost:8300/apis/api/patient&fname=...&lname=...&dob=...'
465 "validationErrors": [],
466 "internalErrors": [],
467 "data": [{ patientRecord }, { patientRecord }, etc]
471 #### GET /api/patient/:puuid
476 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
483 "validationErrors": [],
484 "internalErrors": [],
494 "street": "456 Tree Lane",
495 "postal_code": "08642",
499 "country_code": "US",
500 "drivers_license": "",
501 "contact_relationship": "",
502 "phone_contact": "123-456-7890",
516 #### GET /api/immunization
521 curl -X GET 'http://localhost:8300/apis/api/immunization'
524 #### GET /api/immunization/:uuid
529 curl -X GET 'http://localhost:8300/apis/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
532 #### POST /api/patient/:pid/encounter
537 curl -X POST 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
541 "reason": "Pregnancy Test",
542 "facility": "Owerri General Hospital",
545 "billing_facility": "3",
546 "sensitivity": "normal",
547 "referral_source": "",
559 "validationErrors": [],
560 "internalErrors": [],
563 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
568 #### PUT /api/patient/:pid/encounter/:eid
573 curl -X POST 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
576 "onset_date": "2019-04-20 00:00:00",
577 "reason": "Pregnancy Test",
580 "billing_facility": "3",
581 "sensitivity": "normal",
582 "referral_source": "",
591 "validationErrors": [],
592 "internalErrors": [],
595 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
596 "date": "2019-09-14 00:00:00",
597 "reason": "Pregnancy Test",
598 "facility": "Owerri General Hospital",
601 "onset_date": "2019-04-20 00:00:00",
602 "sensitivity": "normal",
603 "billing_note": null,
605 "last_level_billed": "0",
606 "last_level_closed": "0",
607 "last_stmt_date": null,
610 "supervisor_id": "0",
612 "referral_source": "",
613 "billing_facility": "3",
617 "class_title": "ambulatory",
618 "pc_catname": "Office Visit",
619 "billing_facility_name": "Owerri General Hospital"
624 #### GET /api/patient/:pid/encounter
629 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
636 "validationErrors": [],
637 "internalErrors": [],
638 "data": [{ encounterRecord }, { encounterRecord }, etc]
642 #### GET /api/patient/:pid/encounter/:eid
647 curl -X GET 'http://localhost:8300/apis/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
654 "validationErrors": [],
655 "internalErrors": [],
658 "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
659 "date": "2019-09-14 00:00:00",
660 "reason": "Pregnancy Test",
661 "facility": "Owerri General Hospital",
664 "onset_date": "2019-04-20 00:00:00",
665 "sensitivity": "normal",
666 "billing_note": null,
668 "last_level_billed": "0",
669 "last_level_closed": "0",
670 "last_stmt_date": null,
673 "supervisor_id": "0",
675 "referral_source": "",
676 "billing_facility": "3",
680 "class_title": "ambulatory",
681 "pc_catname": "Office Visit",
682 "billing_facility_name": "Owerri General Hospital"
687 #### POST /api/patient/:pid/encounter/:eid/vital
692 curl -X POST 'http://localhost:8300/apis/api/patient/1/encounter/1/vital' -d \
699 "temp_method": "Oral",
705 "oxygen_saturation": "80"
709 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
714 curl -X PUT 'http://localhost:8300/apis/api/patient/1/encounter/1/vital/1' -d \
721 "temp_method": "Oral",
727 "oxygen_saturation": "80"
731 #### GET /api/patient/:pid/encounter/:eid/vital
736 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/vital'
739 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
744 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/vital/1'
747 #### POST /api/patient/:pid/encounter/:eid/soap_note
752 curl -X POST 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note' -d \
761 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
766 curl -X PUT 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note/1' -d \
775 #### GET /api/patient/:pid/encounter/:eid/soap_note
780 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note'
783 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
788 curl -X GET 'http://localhost:8300/apis/api/patient/1/encounter/1/soap_note/1'
791 #### GET /api/medical_problem
796 curl -X GET 'http://localhost:8300/apis/api/medical_problem'
799 #### GET /api/medical_problem/:muuid
804 curl -X GET 'http://localhost:8300/apis/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
807 #### GET /api/patient/:puuid/medical_problem
812 curl -X GET 'http://localhost:8300/apis/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
815 #### GET /api/patient/:puuid/medical_problem/:muuid
820 curl -X GET 'http://localhost:8300/apis/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
823 #### POST /api/patient/:puuid/medical_problem
828 curl -X POST 'http://localhost:8300/apis/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
830 "title": "Dermatochalasis",
831 "begdate": "2010-04-13",
833 "diagnosis": "ICD10:H02.839"
837 #### PUT /api/patient/:puuid/medical_problem/:muuid
842 curl -X PUT 'http://localhost:8300/apis/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
844 "title": "Dermatochalasis",
845 "begdate": "2010-04-13",
846 "enddate": "2018-03-12",
847 "diagnosis": "ICD10:H02.839"
851 #### DELETE /api/patient/:puuid/medical_problem/:muuid
856 curl -X DELETE 'http://localhost:8300/apis/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
859 #### GET /api/allergy
864 curl -X GET 'http://localhost:8300/apis/api/allergy'
867 #### GET /api/allergy/:auuid
872 curl -X GET 'http://localhost:8300/apis/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
875 #### GET /api/patient/:puuid/allergy
880 curl -X GET 'http://localhost:8300/apis/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
883 #### GET /api/patient/:puuid/allergy/:auuid
888 curl -X GET 'http://localhost:8300/apis/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
891 #### POST /api/patient/:puuid/allergy
896 curl -X POST 'http://localhost:8300/apis/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
899 "begdate": "2010-10-13",
904 #### PUT /api/patient/:puuid/allergy/:auuid
909 curl -X PUT 'http://localhost:8300/apis/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
912 "begdate": "2012-10-13",
917 #### DELETE /api/patient/:puuid/allergy/:auuid
922 curl -X DELETE 'http://localhost:8300/apis/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
925 #### GET /api/procedure
930 curl -X GET 'http://localhost:8300/apis/api/procedure'
933 #### GET /api/procedure/:uuid
938 curl -X GET 'http://localhost:8300/apis/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
946 curl -X GET 'http://localhost:8300/apis/api/drug'
949 #### GET /api/drug/:uuid
954 curl -X GET 'http://localhost:8300/apis/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
957 #### GET /api/prescription
962 curl -X GET 'http://localhost:8300/apis/api/prescription'
965 #### GET /api/prescription/:uuid
970 curl -X GET 'http://localhost:8300/apis/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
973 #### POST /api/patient/:pid/medication
978 curl -X POST 'http://localhost:8300/apis/api/patient/1/medication' -d \
981 "begdate": "2013-10-13",
986 #### PUT /api/patient/:pid/medication/:mid
991 curl -X PUT 'http://localhost:8300/apis/api/patient/1/medication/1' -d \
994 "begdate": "2013-04-13",
999 #### GET /api/patient/:pid/medication
1004 curl -X GET 'http://localhost:8300/apis/api/patient/1/medication'
1007 #### GET /api/patient/:pid/medication/:mid
1012 curl -X GET 'http://localhost:8300/apis/api/patient/1/medication/1'
1015 #### DELETE /api/patient/:pid/medication/:mid
1020 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/medication/1'
1023 #### POST /api/patient/:pid/surgery
1028 curl -X POST 'http://localhost:8300/apis/api/patient/1/surgery' -d \
1030 "title": "Blepharoplasty",
1031 "begdate": "2013-10-13",
1033 "diagnosis": "CPT4:15823-50"
1037 #### PUT /api/patient/:pid/surgery/:sid
1042 curl -X PUT 'http://localhost:8300/apis/api/patient/1/surgery/1' -d \
1044 "title": "Blepharoplasty",
1045 "begdate": "2013-10-14",
1047 "diagnosis": "CPT4:15823-50"
1051 #### GET /api/patient/:pid/surgery
1056 curl -X GET 'http://localhost:8300/apis/api/patient/1/surgery'
1059 #### GET /api/patient/:pid/surgery/:sid
1064 curl -X GET 'http://localhost:8300/apis/api/patient/1/surgery/1'
1067 #### DELETE /api/patient/:pid/surgery/:sid
1072 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/surgery/1'
1075 #### POST /api/patient/:pid/dental_issue
1080 curl -X POST 'http://localhost:8300/apis/api/patient/1/dental_issue' -d \
1082 "title": "Halitosis",
1083 "begdate": "2015-03-17",
1088 #### PUT /api/patient/:pid/dental_issue/:did
1093 curl -X PUT 'http://localhost:8300/apis/api/patient/1/dental_issue/1' -d \
1095 "title": "Halitosis",
1096 "begdate": "2015-03-17",
1097 "enddate": "2018-03-20"
1101 #### GET /api/patient/:pid/dental_issue
1106 curl -X GET 'http://localhost:8300/apis/api/patient/1/dental_issue'
1109 #### GET /api/patient/:pid/dental_issue/:did
1114 curl -X GET 'http://localhost:8300/apis/api/patient/1/dental_issue/1'
1117 #### DELETE /api/patient/:pid/dental_issue/:did
1122 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/dental_issue/1'
1125 #### GET /api/patient/:pid/insurance
1130 curl -X GET 'http://localhost:8300/apis/api/patient/1/insurance'
1133 #### GET /api/patient/:pid/insurance/:type
1138 curl -X GET 'http://localhost:8300/apis/api/patient/1/insurance/secondary'
1141 #### POST /api/patient/:pid/insurance/:type
1146 curl -X POST 'http://localhost:8300/apis/api/patient/10/insurance/primary' -d \
1150 "plan_name": "Some Plan",
1151 "policy_number": "12345",
1152 "group_number": "252412",
1153 "subscriber_lname": "Tester",
1154 "subscriber_mname": "Xi",
1155 "subscriber_fname": "Foo",
1156 "subscriber_relationship": "other",
1157 "subscriber_ss": "234231234",
1158 "subscriber_DOB": "2018-10-03",
1159 "subscriber_street": "183 Cool St",
1160 "subscriber_postal_code": "23418",
1161 "subscriber_city": "Cooltown",
1162 "subscriber_state": "AZ",
1163 "subscriber_country": "USA",
1164 "subscriber_phone": "234-598-2123",
1165 "subscriber_employer": "Some Employer",
1166 "subscriber_employer_street": "123 Heather Lane",
1167 "subscriber_employer_postal_code": "23415",
1168 "subscriber_employer_state": "AZ",
1169 "subscriber_employer_country": "USA",
1170 "subscriber_employer_city": "Cooltown",
1172 "date": "2018-10-15",
1173 "subscriber_sex": "Female",
1174 "accept_assignment": "TRUE",
1181 - `provider` is the insurance company id
1182 - `state` can be found by querying `resource=/api/list/state`
1183 - `country` can be found by querying `resource=/api/list/country`
1185 #### PUT /api/patient/:pid/insurance/:type
1190 curl -X PUT 'http://localhost:8300/apis/api/patient/10/insurance/primary' -d \
1194 "plan_name": "Some Plan",
1195 "policy_number": "12345",
1196 "group_number": "252412",
1197 "subscriber_lname": "Tester",
1198 "subscriber_mname": "Xi",
1199 "subscriber_fname": "Foo",
1200 "subscriber_relationship": "other",
1201 "subscriber_ss": "234231234",
1202 "subscriber_DOB": "2018-10-03",
1203 "subscriber_street": "183 Cool St",
1204 "subscriber_postal_code": "23418",
1205 "subscriber_city": "Cooltown",
1206 "subscriber_state": "AZ",
1207 "subscriber_country": "USA",
1208 "subscriber_phone": "234-598-2123",
1209 "subscriber_employer": "Some Employer",
1210 "subscriber_employer_street": "123 Heather Lane",
1211 "subscriber_employer_postal_code": "23415",
1212 "subscriber_employer_state": "AZ",
1213 "subscriber_employer_country": "USA",
1214 "subscriber_employer_city": "Cooltown",
1216 "date": "2018-10-15",
1217 "subscriber_sex": "Female",
1218 "accept_assignment": "TRUE",
1225 - `provider` is the insurance company id
1226 - `state` can be found by querying `resource=/api/list/state`
1227 - `country` can be found by querying `resource=/api/list/country`
1229 #### GET /api/list/:list_name
1234 curl -X GET 'http://localhost:8300/apis/api/list/medical_problem_issue_list'
1237 #### GET /api/version
1242 curl -X GET 'http://localhost:8300/apis/api/version'
1245 #### GET /api/product
1250 curl -X GET 'http://localhost:8300/apis/api/product'
1253 #### GET /api/insurance_company
1258 curl -X GET 'http://localhost:8300/apis/api/insurance_company'
1261 #### GET /api/insurance_type
1266 curl -X GET 'http://localhost:8300/apis/api/insurance_type'
1269 #### POST /api/insurance_company
1274 curl -X POST 'http://localhost:8300/apis/api/insurance_company' -d \
1276 "name": "Cool Insurance Company",
1279 "ins_type_code": "2",
1280 "x12_receiver_id": null,
1281 "x12_default_partner_id": null,
1283 "line1": "123 Cool Lane",
1284 "line2": "Suite 123",
1292 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1294 #### PUT /api/insurance_company/:iid
1299 curl -X PUT 'http://localhost:8300/apis/api/insurance_company/1' -d \
1301 "name": "Super Insurance Company",
1304 "ins_type_code": "2",
1305 "x12_receiver_id": null,
1306 "x12_default_partner_id": null,
1308 "line1": "123 Cool Lane",
1309 "line2": "Suite 123",
1317 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1319 #### GET /api/appointment
1324 curl -X GET 'http://localhost:8300/apis/api/appointment'
1327 #### GET /api/appointment/:eid
1332 curl -X GET 'http://localhost:8300/apis/api/appointment/1'
1335 #### GET /api/patient/:pid/appointment
1340 curl -X GET 'http://localhost:8300/apis/api/patient/1/appointment'
1343 #### GET /api/patient/:pid/appointment/:eid
1348 curl -X GET 'http://localhost:8300/apis/api/patient/1/appointment/1'
1351 #### POST /api/patient/:pid/appointment
1356 curl -X POST 'http://localhost:8300/apis/api/patient/1/appointment' -d \
1360 "pc_title": "Office Visit",
1361 "pc_duration": "900",
1362 "pc_hometext": "Test",
1363 "pc_apptstatus": "-",
1364 "pc_eventDate": "2018-10-19",
1365 "pc_startTime": "09:00",
1367 "pc_billing_location": "10"
1371 #### DELETE /api/patient/:pid/appointment/:eid
1376 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/appointment/1' -d \
1379 #### GET /api/patient/:pid/document
1384 curl -X GET 'http://localhost:8300/apis/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1387 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1389 - Spaces are represented with `_`
1390 - All characters are lowercase
1392 #### POST /api/patient/:pid/document
1397 curl -X POST 'http://localhost:8300/apis/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1398 -F document=@/home/someone/Desktop/drawing.jpg
1401 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1403 - Spaces are represented with `_`
1404 - All characters are lowercase
1406 #### GET /api/patient/:pid/document/:did
1411 curl -X GET 'http://localhost:8300/apis/api/patient/1/document/1'
1414 #### POST /api/patient/:pid/message
1419 curl -X POST 'http://localhost:8300/apis/api/patient/1/message' -d \
1422 "groupname": "Default",
1426 "message_status": "New"
1432 - For `title`, use `resource=/api/list/note_type`
1433 - For `message_type`, use `resource=/api/list/message_status`
1435 #### PUT /api/patient/:pid/message/:mid
1440 curl -X PUT 'http://localhost:8300/apis/api/patient/1/message/1' -d \
1443 "groupname": "Default",
1447 "message_status": "New"
1453 - For `title`, use `resource=/api/list/note_type`
1454 - For `message_type`, use `resource=/api/list/message_status`
1456 #### DELETE /api/patient/:pid/message/:mid
1461 curl -X DELETE 'http://localhost:8300/apis/api/patient/1/message/1'
1464 ### /portal/ Endpoints
1466 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/portal as base URI.`
1468 _Example:_ `http://localhost:8300/apis/portal/patient` returns a resource of the patient.
1470 #### POST /portal/auth
1472 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
1473 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.
1478 curl -X POST -H 'Content-Type: application/json' 'http://localhost:8300/apis/portal/auth' \
1480 "grant_type":"password",
1481 "username": "ServiceUser",
1482 "password": "password",
1491 "token_type": "Bearer",
1492 "access_token": "eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ==",
1493 "expires_in": "3600",
1500 The Bearer token is required for each OpenEMR Patient Portal API request, and is conveyed using an Authorization header.
1505 curl -X GET 'http://localhost:8300/apis/portal/patient' \
1506 -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1509 #### GET /portal/patient
1514 curl -X GET 'http://localhost:8300/apis/portal/patient'
1521 "validationErrors": [],
1522 "internalErrors": [],
1532 "street": "456 Tree Lane",
1533 "postal_code": "08642",
1537 "country_code": "US",
1538 "drivers_license": "",
1539 "contact_relationship": "",
1540 "phone_contact": "123-456-7890",
1545 "DOB": "1992-02-03",
1556 - For business logic, make or use the services [here](src/Services)
1557 - For controller logic, make or use the classes [here](src/RestControllers)
1558 - For routing declarations, use the class [here](_rest_routes.inc.php).
1560 ### Project Management
1564 - TODO(?): Prevent `ListService` from using `enddate` of `0000-00-00` by default
1565 - TODO(?): API for fee sheets
1566 - TODO(?): API for pharmacies
1567 - TODO(?): API for immunizations
1568 - TODO(?): API for prescriptions
1569 - TODO(?): Drug search API
1570 - TODO(?): API for onotes