demographics style change (#4195)
[openemr.git] / API_README.md
bloba7e19c1ac6e991ca21f3ecccc1e31c9c1530f95d
1 # OpenEMR REST API Documentation
3 ## Overview
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)
7 ## Implementation
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.
12 ```php
13 "POST /api/patient" => function () {
14     RestConfig::scope_check("user", "patient", "write");
15     RestConfig::authorization_check("patients", "demo");
16     $data = (array) (json_decode(file_get_contents("php://input")));
17     $return = (new PatientRestController())->post($data);
18     RestConfig::apiLog($return, $data);
19     return $return;
21 ```
23 At a high level, the request processing flow consists of the following steps:
25 ```
26 JSON Request -> Controller Component -> Validation -> Service Component -> Database
27 ```
29 The logical response flow begins with the database result:
31 ```
32 Database Result -> Service Component -> Controller Component -> RequestControllerHelper -> JSON Response
33 ```
35 The [RequestControllerHelper class](./src/RestControllers/RestControllerHelper.php) evaluates the Service Component's
36 result and maps it to a http response code and response payload. Existing APIs should be updated to utilize the
37 `handleProcessingResult` method as it supports the [Validator](./src/Validators/BaseValidator.php) components.
39 The [PatientRestController](./src/RestControllers/PatientRestController.php) may be used as a reference to see how APIs are
40 integrated with `RequestControllerHelper::handleProcessingResult` and the `Validator` components.
42 Finally, APIs which are integrated with the new `handleProcessingResult` method utilize a common response format.
44 ```json
46     "validationErrors": [],
47     "internalErrors": [],
48     "data": < data payload >
50 ```
52 -   `validationErrors` contain "client based" data validation errors
53 -   `internalErrors` contain server related errors
54 -   `data` is the response payload, represented as an object/`{}` for single results or an array/`[]` for multiple results
56 ### Sections
58 -   [Authorization](API_README.md#authorization)
59     -   [Scopes](API_README.md#scopes)
60     -   [Registration](API_README.md#registration)
61         -   [SMART on FHIR Registration](API_README.md#smart-on-fhir-registration)
62     -   [Authorization Code Grant](API_README.md#authorization-code-grant)
63     -   [Refresh Token Grant](API_README.md#refresh-token-grant)
64     -   [Password Grant](API_README.md#password-grant)
65     -   [Logout](API_README.md#logout)
66     -   [More Details](API_README.md#more-details)
67 -   [Standard API Endpoints](API_README.md#api-endpoints)
68     -   [Facility API](API_README.md#post-apifacility)
69     -   [Practitioner API](API_README.md#get-apipractitioner)
70     -   [Patient API](API_README.md#post-apipatient)
71     -   [Immunization API](API_README.md#get-apiimmunization)
72     -   [Allergy API](API_README.md#get-apiallergy)
73     -   [Procedure API](API_README.md#get-apiprocedure)
74     -   [Drug API](API_README.md#get-apidrug)
75     -   [Prescription API](API_README.md#get-apiprescription)
76     -   [Insurance API](API_README.md#get-apipatientpidinsurance)
77     -   [Appointment API](API_README.md#get-apiappointment)
78     -   [Document API](API_README.md#get-apipatientpiddocument)
79     -   [Message API](API_README.md#post-apipatientpidmessage)
80 -   [Portal API Endpoints](API_README.md#portal-Endpoints)
81     -   [Patient API](API_README.md#get-portalpatient)
82 -   [FHIR API Endpoints](FHIR_README.md#fhir-endpoints)
83     -   [FHIR Capability Statement](FHIR_README.md#capability-statement)
84     -   [FHIR Patient](FHIR_README.md#patient-resource)
85     -   [FHIR Coverage](FHIR_README.md#coverage-resource)
86     -   [FHIR Encounter](FHIR_README.md#encounter-resource)
87     -   [FHIR Practitioner](FHIR_README.md#practitioner-resource)
88     -   [FHIR PractitionerRole](FHIR_README.md#practitionerrole-resource)
89     -   [FHIR Immunization](FHIR_README.md#immunization-resource)
90     -   [FHIR AllergyIntolerance](FHIR_README.md#allergyintolerance-resource)
91     -   [FHIR Organization](FHIR_README.md#organization-resource)
92     -   [FHIR Observation](FHIR_README.md#observation-resource)
93     -   [FHIR Condition](FHIR_README.md#condition-resource)
94     -   [FHIR Procedure](FHIR_README.md#procedure-resource)
95     -   [FHIR MedicationRequest](FHIR_README.md#medicationrequest-resource)
96     -   [FHIR Medication](FHIR_README.md#medication-resource)
97     -   [FHIR Location](FHIR_README.md#location-resource)
98     -   [FHIR CareTeam](FHIR_README.md#careTeam-resource)
99     -   [FHIR Provenance](FHIR_README.md#Provenance-resources)
100 -   [Patient Portal FHIR API Endpoints](FHIR_README.md#patient-portal-fhir-endpoints)
101     -   [Patient Portal FHIR Patient](FHIR_README.md#patient-portal-patient-resource)
102 -   [Dev notes](API_README.md#dev-notes)
104 ### Prerequisite
106 Enable the Standard API service (/api/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Standard REST API"
108 ### Using API Internally
110 There are several ways to make API calls from an authorized session and maintain security:
112 -   See the script at tests/api/InternalApiTest.php for examples of internal API use cases.
114 ### Multisite Support
116 Multisite is supported by including the site in the endpoint. When not using multisite or using the `default` multisite site, then a typical path would look like `apis/default/api/patient`. If you are using multisite and using a site called `alternate`, then the path would look like `apis/alternate/api/patient`.
118 ### Authorization
120 OpenEMR uses OIDC compliant authorization for API. SSL is required and setting baseurl at Administration->Globals->Connectors->'Site Address (required for OAuth2 and FHIR)' is required. The listing of scopes can be found in below Scopes section.
122 #### Scopes
124 This is a listing of scopes:
125 - `api:oemr` (user api which are the /api/ endpoints)
126   - `user/allergy.read`
127   - `user/allergy.write`
128   - `user/appointment.read`
129   - `user/appointment.write`
130   - `user/dental_issue.read`
131   - `user/dental_issue.write`
132   - `user/document.read`
133   - `user/document.write`
134   - `user/drug.read`
135   - `user/encounter.read`
136   - `user/encounter.write`
137   - `user/facility.read`
138   - `user/facility.write`
139   - `user/immunization.read`
140   - `user/insurance.read`
141   - `user/insurance.write`
142   - `user/insurance_company.read`
143   - `user/insurance_company.write`
144   - `user/insurance_type.read`
145   - `user/list.read`
146   - `user/medical_problem.read`
147   - `user/medical_problem.write`
148   - `user/medication.read`
149   - `user/medication.write`
150   - `user/message.write`
151   - `user/patient.read`
152   - `user/patient.write`
153   - `user/practitioner.read`
154   - `user/practitioner.write`
155   - `user/prescription.read`
156   - `user/procedure.read`
157   - `user/soap_note.read`
158   - `user/soap_note.write`
159   - `user/surgery.read`
160   - `user/surgery.write`
161   - `user/vital.read`
162   - `user/vital.write`
163 - `api:fhir` (user fhir which are the /fhir/ endpoints)
164   - `user/AllergyIntolerance.read`
165   - `user/CareTeam.read`
166   - `user/Condition.read`
167   - `user/Coverage.read`
168   - `user/Encounter.read`
169   - `user/Immunization.read`
170   - `user/Location.read`
171   - `user/Medication.read`
172   - `user/MedicationRequest.read`
173   - `user/Observation.read`
174   - `user/Organization.read`
175   - `user/Organization.write`
176   - `user/Patient.read`
177   - `user/Patient.write`
178   - `user/Practitioner.read`
179   - `user/Practitioner.write`
180   - `user/PractitionerRole.read`
181   - `user/Procedure.read`
182 - `api:port` (patient api which are the /portal/ endpoints) (EXPERIMENTAL)
183   - `patient/encounter.read`
184   - `patient/patient.read`
185 - `api:pofh` (patient fhir which are the /portalfhir/ endpoints) (EXPERIMENTAL)
186   - `patient/Encounter.read`
187   - `patient/Patient.read`
189 #### Registration
191 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.
193 Note that all scopes are included in this example for demonstration purposes. For production purposes, should only include the necessary scopes.
195 ```sh
196 curl -X POST -k -H 'Content-Type: application/json' -i https://localhost:9300/oauth2/default/registration --data '{
197    "application_type": "private",
198    "redirect_uris":
199      ["https://client.example.org/callback"],
200    "post_logout_redirect_uris":
201      ["https://client.example.org/logout/callback"],
202    "client_name": "A Private App",
203    "token_endpoint_auth_method": "client_secret_post",
204    "contacts": ["me@example.org", "them@example.org"],
205    "scope": "openid api:oemr api:fhir api:port api:pofh user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Coverage.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read patient/encounter.read patient/patient.read patient/Encounter.read patient/Patient.read"
206   }'
209 Response:
210 ```sh
212     "client_id": "LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA",
213     "client_secret": "j21ecvLmFi9HPc_Hv0t7Ptmf1pVcZQLtHjIdU7U9tkS9WAjFJwVMav0G8ogTJ62q4BATovC7BQ19Qagc4x9BBg",
214     "registration_access_token": "uiDSXx2GNSvYy5n8eW50aGrJz0HjaGpUdrGf07Agv_Q",
215     "registration_client_uri": "https:\/\/localhost:9300\/oauth2\/default\/client\/6eUVG0-qK2dYiwfYdECKIw",
216     "client_id_issued_at": 1604767861,
217     "client_secret_expires_at": 0,
218     "contacts": ["me@example.org", "them@example.org"],
219     "application_type": "private",
220     "client_name": "A Private App",
221     "redirect_uris": ["https:\/\/client.example.org\/callback"],
222     "token_endpoint_auth_method": "client_secret_post",
223     "scope": "openid api:oemr api:fhir api:port api:pofh user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Coverage.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read patient/encounter.read patient/patient.read patient/Encounter.read patient/Patient.read"
227 ##### SMART on FHIR Registration
229 SMART Enabled Apps are supported.
231 SMART client can be registered at <website>/interface/smart/register-app.php. For example https://localhost:9300/interface/smart/register-app.php
233 After registering the SMART client, can then Enable it in OpenEMR at Administration->System->API Clients
235 After it is enabled, the SMART App will then be available to use in the Patient Summary screen (SMART Enabled Apps widget).
237 See this github issue for an example of a Smart App installation: https://github.com/openemr/openemr/issues/4148
239 #### Authorization Code Grant
241 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`.
243 #### Refresh Token Grant
245 Example:
247 ```sh
248 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
249 -i 'https://localhost:9300/oauth2/default/token'
250 --data 'grant_type=refresh_token
251 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
252 &refresh_token=def5020089a766d16...'
255 Response:
257 ```json
259   "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
260   "token_type": "Bearer",
261   "expires_in": 3599,
262   "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
263   "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
267 #### Password Grant
269 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)'.
271 Note that all scopes are included in these examples for demonstration purposes. For production purposes, should only include the necessary scopes.
273 Example for `users` role:
274 ```sh
275 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
276 -i 'https://localhost:9300/oauth2/default/token'
277 --data 'grant_type=password
278 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
279 &scope=openid%20api%3Aoemr%20api%3Afhir%20user%2Fallergy.read%20user%2Fallergy.write%20user%2Fappointment.read%20user%2Fappointment.write%20user%2Fdental_issue.read%20user%2Fdental_issue.write%20user%2Fdocument.read%20user%2Fdocument.write%20user%2Fdrug.read%20user%2Fencounter.read%20user%2Fencounter.write%20user%2Ffacility.read%20user%2Ffacility.write%20user%2Fimmunization.read%20user%2Finsurance.read%20user%2Finsurance.write%20user%2Finsurance_company.read%20user%2Finsurance_company.write%20user%2Finsurance_type.read%20user%2Flist.read%20user%2Fmedical_problem.read%20user%2Fmedical_problem.write%20user%2Fmedication.read%20user%2Fmedication.write%20user%2Fmessage.write%20user%2Fpatient.read%20user%2Fpatient.write%20user%2Fpractitioner.read%20user%2Fpractitioner.write%20user%2Fprescription.read%20user%2Fprocedure.read%20user%2Fsoap_note.read%20user%2Fsoap_note.write%20user%2Fsurgery.read%20user%2Fsurgery.write%20user%2Fvital.read%20user%2Fvital.write%20user%2FAllergyIntolerance.read%20user%2FCareTeam.read%20user%2FCondition.read%20user%2FCoverage.read%20user%2FEncounter.read%20user%2FImmunization.read%20user%2FLocation.read%20user%2FMedication.read%20user%2FMedicationRequest.read%20user%2FObservation.read%20user%2FOrganization.read%20user%2FOrganization.write%20user%2FPatient.read%20user%2FPatient.write%20user%2FPractitioner.read%20user%2FPractitioner.write%20user%2FPractitionerRole.read%20user%2FProcedure.read
280 &user_role=users
281 &username=admin
282 &password=pass'
285 Example for `patient` role:
286 ```sh
287 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
288 -i 'https://localhost:9300/oauth2/default/token'
289 --data 'grant_type=password
290 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
291 &scope=openid%20api%3Aport%20api%3Apofh%20patient%2Fencounter.read%20patient%2Fpatient.read%20patient%2FEncounter.read%20patient%2FPatient.read
292 &user_role=patient
293 &username=Phil1
294 &password=phil
295 &email=heya@invalid.email.com'
298 Response:
300 ```json
302   "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
303   "token_type": "Bearer",
304   "expires_in": 3599,
305   "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
306   "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
310 #### Logout
312 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.
314 #### More Details
316 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
318 More specific development api topics are discussed and described on the above forum thread (such as introspection).
320 ### /api/ Endpoints
322 OpenEMR standard endpoints Use `http://localhost:8300/apis/default/api as base URI.`
324 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
326 _Example:_ `http://localhost:8300/apis/default/api/patient` returns a resource of all Patients.
328 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.
330 Request:
332 ```sh
333 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medical_problem' \
334   -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
337 #### POST /api/facility
339 Request:
341 ```sh
342 curl -X POST 'http://localhost:8300/apis/default/api/facility' -d \
344     "name": "Aquaria",
345     "phone": "808-606-3030",
346     "fax": "808-606-3031",
347     "street": "1337 Bit Shifter Ln",
348     "city": "San Lorenzo",
349     "state": "ZZ",
350     "postal_code": "54321",
351     "email": "foo@bar.com",
352     "service_location": "1",
353     "billing_location": "1",
354     "color": "#FF69B4"
358 #### PUT /api/facility/:fid
360 Request:
362 ```sh
363 curl -X PUT 'http://localhost:8300/apis/default/api/facility/1' -d \
365     "name": "Aquaria",
366     "phone": "808-606-3030",
367     "fax": "808-606-3031",
368     "street": "1337 Bit Shifter Ln",
369     "city": "San Lorenzo",
370     "state": "AZ",
371     "postal_code": "54321",
372     "email": "foo@bar.com",
373     "service_location": "1",
374     "billing_location": "1",
375     "color": "#FF69B4"
379 #### GET /api/facility
381 Request:
383 ```sh
384 curl -X GET 'http://localhost:8300/apis/default/api/facility'
387 #### GET /api/facility/:fid
389 Request:
391 ```sh
392 curl -X GET 'http://localhost:8300/apis/default/api/facility/1'
395 #### GET /api/practitioner
397 Request:
399 ```sh
400 curl -X GET 'http://localhost:8300/apis/default/api/practitioner'
403 #### GET /api/practitioner/:uuid
405 Request:
407 ```sh
408 curl -X GET 'http://localhost:8300/apis/default/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
411 #### POST /api/practitioner
413 Request:
415 ```sh
416 curl -X POST 'http://localhost:8300/apis/default/api/practitioner' -d \
418     "title": "Mrs.",
419     "fname": "Eduardo",
420     "mname": "Kathy",
421     "lname": "Perez",
422     "federaltaxid": "",
423     "federaldrugid": "",
424     "upin": "",
425     "facility_id": "3",
426     "facility": "Your Clinic Name Here",
427     "npi": "0123456789",
428     "email": "info@pennfirm.com",
429     "specialty": "",
430     "billname": null,
431     "url": null,
432     "assistant": null,
433     "organization": null,
434     "valedictory": null,
435     "street": "789 Third Avenue",
436     "streetb": "123 Cannaut Street",
437     "city": "San Diego",
438     "state": "CA",
439     "zip": "90210",
440     "phone": "(619) 555-9827",
441     "fax": null,
442     "phonew1": "(619) 555-7822",
443     "phonecell": "(619) 555-7821",
444     "notes": null,
445     "state_license_number": "123456"
449 Response:
451 ```json
453     "validationErrors": [],
454     "internalErrors": [],
455     "data": {
456         "id": 7,
457         "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
458     }
462 #### PUT /api/practitioner/:uuid
464 Request:
466 ```sh
467 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
469     "title": "Mr",
470     "fname": "Baz",
471     "mname": "",
472     "lname": "Bop",
473     "street": "456 Tree Lane",
474     "zip": "08642",
475     "city": "FooTown",
476     "state": "FL",
477     "phone": "123-456-7890"
481 Response:
483 ```json
485     "validationErrors": [],
486     "internalErrors": [],
487     "data": {
488         "id": "7",
489         "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
490         "title": "Mr",
491         "fname": "Baz",
492         "lname": "Bop",
493         "mname": "",
494         "federaltaxid": "",
495         "federaldrugid": "",
496         "upin": "",
497         "facility_id": "3",
498         "facility": "Your Clinic Name Here",
499         "npi": "0123456789",
500         "email": "info@pennfirm.com",
501         "active": "1",
502         "specialty": "",
503         "billname": "",
504         "url": "",
505         "assistant": "",
506         "organization": "",
507         "valedictory": "",
508         "street": "456 Tree Lane",
509         "streetb": "123 Cannaut Street",
510         "city": "FooTown",
511         "state": "FL",
512         "zip": "08642",
513         "phone": "123-456-7890",
514         "fax": "",
515         "phonew1": "(619) 555-7822",
516         "phonecell": "(619) 555-7821",
517         "notes": "",
518         "state_license_number": "123456",
519         "abook_title": null,
520         "physician_title": null,
521         "physician_code": null
522     }
526 #### POST /api/patient
528 Request:
530 ```sh
531 curl -X POST 'http://localhost:8300/apis/default/api/patient' -d \
533     "title": "Mr",
534     "fname": "Foo",
535     "mname": "",
536     "lname": "Bar",
537     "street": "456 Tree Lane",
538     "postal_code": "08642",
539     "city": "FooTown",
540     "state": "FL",
541     "country_code": "US",
542     "phone_contact": "123-456-7890",
543     "DOB": "1992-02-02",
544     "sex": "Male",
545     "race": "",
546     "ethnicity": ""
550 Response:
552 ```json
554     "validationErrors": [],
555     "internalErrors": [],
556     "data": {
557         "pid": 1
558     }
562 #### PUT /api/patient/:puuid
564 Request:
566 ```sh
567 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
569     "title": "Mr",
570     "fname": "Baz",
571     "mname": "",
572     "lname": "Bop",
573     "street": "456 Tree Lane",
574     "postal_code": "08642",
575     "city": "FooTown",
576     "state": "FL",
577     "country_code": "US",
578     "phone_contact": "123-456-7890",
579     "DOB": "1992-02-03",
580     "sex": "Male",
581     "race": "",
582     "ethnicity": ""
586 Response:
588 ```json
590     "validationErrors": [],
591     "internalErrors": [],
592     "data": {
593         "id": "193",
594         "pid": "1",
595         "pubpid": "",
596         "title": "Mr",
597         "fname": "Baz",
598         "mname": "",
599         "lname": "Bop",
600         "ss": "",
601         "street": "456 Tree Lane",
602         "postal_code": "08642",
603         "city": "FooTown",
604         "state": "FL",
605         "county": "",
606         "country_code": "US",
607         "drivers_license": "",
608         "contact_relationship": "",
609         "phone_contact": "123-456-7890",
610         "phone_home": "",
611         "phone_biz": "",
612         "phone_cell": "",
613         "email": "",
614         "DOB": "1992-02-03",
615         "sex": "Male",
616         "race": "",
617         "ethnicity": "",
618         "status": ""
619     }
623 #### GET /api/patient
625 Request:
627 ```sh
628 curl -X GET 'http://localhost:8300/apis/default/api/patient'
631 Response:
633 ```json
635     "validationErrors": [],
636     "internalErrors": [],
637     "data": [{ patientRecord }, { patientRecord }, etc]
641 Request:
643 ```sh
644 curl -X GET 'http://localhost:8300/apis/default/api/patient&fname=...&lname=...&dob=...'
647 Response:
649 ```json
651     "validationErrors": [],
652     "internalErrors": [],
653     "data": [{ patientRecord }, { patientRecord }, etc]
657 #### GET /api/patient/:puuid
659 Request:
661 ```sh
662 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
665 Response:
667 ```json
669     "validationErrors": [],
670     "internalErrors": [],
671     "data": {
672         "id": "193",
673         "pid": "1",
674         "pubpid": "",
675         "title": "Mr",
676         "fname": "Baz",
677         "mname": "",
678         "lname": "Bop",
679         "ss": "",
680         "street": "456 Tree Lane",
681         "postal_code": "08642",
682         "city": "FooTown",
683         "state": "FL",
684         "county": "",
685         "country_code": "US",
686         "drivers_license": "",
687         "contact_relationship": "",
688         "phone_contact": "123-456-7890",
689         "phone_home": "",
690         "phone_biz": "",
691         "phone_cell": "",
692         "email": "",
693         "DOB": "1992-02-03",
694         "sex": "Male",
695         "race": "",
696         "ethnicity": "",
697         "status": ""
698     }
702 #### GET /api/immunization
704 Request:
706 ```sh
707 curl -X GET 'http://localhost:8300/apis/default/api/immunization'
710 #### GET /api/immunization/:uuid
712 Request:
714 ```sh
715 curl -X GET 'http://localhost:8300/apis/default/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
718 #### POST /api/patient/:pid/encounter
720 Request:
722 ```sh
723 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
725     "date":"2020-11-10",
726     "onset_date": "",
727     "reason": "Pregnancy Test",
728     "facility": "Owerri General Hospital",
729     "pc_catid": "5",
730     "facility_id": "3",
731     "billing_facility": "3",
732     "sensitivity": "normal",
733     "referral_source": "",
734     "pos_code": "0",
735     "external_id": "",
736     "provider_id": "1",
737     "class_code" : "AMB"
741 Response:
743 ```json
745     "validationErrors": [],
746     "internalErrors": [],
747     "data": {
748         "encounter": 1,
749         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
750     }
754 #### PUT /api/patient/:pid/encounter/:eid
756 Request:
758 ```sh
759 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
761     "date":"2019-09-14",
762     "onset_date": "2019-04-20 00:00:00",
763     "reason": "Pregnancy Test",
764     "pc_catid": "5",
765     "facility_id": "3",
766     "billing_facility": "3",
767     "sensitivity": "normal",
768     "referral_source": "",
769     "pos_code": "0"
773 Response:
775 ```json
777     "validationErrors": [],
778     "internalErrors": [],
779     "data": {
780         "id": "1",
781         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
782         "date": "2019-09-14 00:00:00",
783         "reason": "Pregnancy Test",
784         "facility": "Owerri General Hospital",
785         "facility_id": "3",
786         "pid": "1",
787         "onset_date": "2019-04-20 00:00:00",
788         "sensitivity": "normal",
789         "billing_note": null,
790         "pc_catid": "5",
791         "last_level_billed": "0",
792         "last_level_closed": "0",
793         "last_stmt_date": null,
794         "stmt_count": "0",
795         "provider_id": "1",
796         "supervisor_id": "0",
797         "invoice_refno": "",
798         "referral_source": "",
799         "billing_facility": "3",
800         "external_id": "",
801         "pos_code": "0",
802         "class_code": "AMB",
803         "class_title": "ambulatory",
804         "pc_catname": "Office Visit",
805         "billing_facility_name": "Owerri General Hospital"
806     }
810 #### GET /api/patient/:pid/encounter
812 Request:
814 ```sh
815 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
818 Response:
820 ```json
822     "validationErrors": [],
823     "internalErrors": [],
824     "data": [{ encounterRecord }, { encounterRecord }, etc]
828 #### GET /api/patient/:pid/encounter/:eid
830 Request:
832 ```sh
833 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
836 Response:
838 ```json
840     "validationErrors": [],
841     "internalErrors": [],
842     "data": {
843         "id": "1",
844         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
845         "date": "2019-09-14 00:00:00",
846         "reason": "Pregnancy Test",
847         "facility": "Owerri General Hospital",
848         "facility_id": "3",
849         "pid": "1",
850         "onset_date": "2019-04-20 00:00:00",
851         "sensitivity": "normal",
852         "billing_note": null,
853         "pc_catid": "5",
854         "last_level_billed": "0",
855         "last_level_closed": "0",
856         "last_stmt_date": null,
857         "stmt_count": "0",
858         "provider_id": "1",
859         "supervisor_id": "0",
860         "invoice_refno": "",
861         "referral_source": "",
862         "billing_facility": "3",
863         "external_id": "",
864         "pos_code": "0",
865         "class_code": "AMB",
866         "class_title": "ambulatory",
867         "pc_catname": "Office Visit",
868         "billing_facility_name": "Owerri General Hospital"
869     }
873 #### POST /api/patient/:pid/encounter/:eid/vital
875 Request:
877 ```sh
878 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital' -d \
880     "bps": "130",
881     "bpd": "80",
882     "weight": "220",
883     "height": "70",
884     "temperature": "98",
885     "temp_method": "Oral",
886     "pulse": "60",
887     "respiration": "20",
888     "note": "...",
889     "waist_circ": "37",
890     "head_circ": "22.2",
891     "oxygen_saturation": "80"
895 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
897 Request:
899 ```sh
900 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1' -d \
902     "bps": "140",
903     "bpd": "80",
904     "weight": "220",
905     "height": "70",
906     "temperature": "98",
907     "temp_method": "Oral",
908     "pulse": "60",
909     "respiration": "20",
910     "note": "...",
911     "waist_circ": "37",
912     "head_circ": "22.2",
913     "oxygen_saturation": "80"
917 #### GET /api/patient/:pid/encounter/:eid/vital
919 Request:
921 ```sh
922 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital'
925 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
927 Request:
929 ```sh
930 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1'
933 #### POST /api/patient/:pid/encounter/:eid/soap_note
935 Request:
937 ```sh
938 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note' -d \
940     "subjective": "...",
941     "objective": "...",
942     "assessment": "...",
943     "plan": "..."
947 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
949 Request:
951 ```sh
952 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1' -d \
954     "subjective": "...",
955     "objective": "...",
956     "assessment": "...",
957     "plan": "..."
961 #### GET /api/patient/:pid/encounter/:eid/soap_note
963 Request:
965 ```sh
966 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note'
969 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
971 Request:
973 ```sh
974 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1'
977 #### GET /api/medical_problem
979 Request:
981 ```sh
982 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem'
985 #### GET /api/medical_problem/:muuid
987 Request:
989 ```sh
990 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
993 #### GET /api/patient/:puuid/medical_problem
995 Request:
997 ```sh
998 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
1001 #### GET /api/patient/:puuid/medical_problem/:muuid
1003 Request:
1005 ```sh
1006 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1009 #### POST /api/patient/:puuid/medical_problem
1011 Request:
1013 ```sh
1014 curl -X POST 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
1016     "title": "Dermatochalasis",
1017     "begdate": "2010-04-13",
1018     "enddate": null,
1019     "diagnosis": "ICD10:H02.839"
1023 #### PUT /api/patient/:puuid/medical_problem/:muuid
1025 Request:
1027 ```sh
1028 curl -X PUT 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
1030     "title": "Dermatochalasis",
1031     "begdate": "2010-04-13",
1032     "enddate": "2018-03-12",
1033     "diagnosis": "ICD10:H02.839"
1037 #### DELETE /api/patient/:puuid/medical_problem/:muuid
1039 Request:
1041 ```sh
1042 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1045 #### GET /api/allergy
1047 Request:
1049 ```sh
1050 curl -X GET 'http://localhost:8300/apis/default/api/allergy'
1053 #### GET /api/allergy/:auuid
1055 Request:
1057 ```sh
1058 curl -X GET 'http://localhost:8300/apis/default/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1061 #### GET /api/patient/:puuid/allergy
1063 Request:
1065 ```sh
1066 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
1069 #### GET /api/patient/:puuid/allergy/:auuid
1071 Request:
1073 ```sh
1074 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1077 #### POST /api/patient/:puuid/allergy
1079 Request:
1081 ```sh
1082 curl -X POST 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
1084     "title": "Iodine",
1085     "begdate": "2010-10-13",
1086     "enddate": null
1090 #### PUT /api/patient/:puuid/allergy/:auuid
1092 Request:
1094 ```sh
1095 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
1097     "title": "Iodine",
1098     "begdate": "2012-10-13",
1099     "enddate": null
1103 #### DELETE /api/patient/:puuid/allergy/:auuid
1105 Request:
1107 ```sh
1108 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1111 #### GET /api/procedure
1113 Request:
1115 ```sh
1116 curl -X GET 'http://localhost:8300/apis/default/api/procedure'
1119 #### GET /api/procedure/:uuid
1121 Request:
1123 ```sh
1124 curl -X GET 'http://localhost:8300/apis/default/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
1127 #### GET /api/drug
1129 Request:
1131 ```sh
1132 curl -X GET 'http://localhost:8300/apis/default/api/drug'
1135 #### GET /api/drug/:uuid
1137 Request:
1139 ```sh
1140 curl -X GET 'http://localhost:8300/apis/default/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
1143 #### GET /api/prescription
1145 Request:
1147 ```sh
1148 curl -X GET 'http://localhost:8300/apis/default/api/prescription'
1151 #### GET /api/prescription/:uuid
1153 Request:
1155 ```sh
1156 curl -X GET 'http://localhost:8300/apis/default/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
1159 #### POST /api/patient/:pid/medication
1161 Request:
1163 ```sh
1164 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/medication' -d \
1166     "title": "Norvasc",
1167     "begdate": "2013-10-13",
1168     "enddate": null
1172 #### PUT /api/patient/:pid/medication/:mid
1174 Request:
1176 ```sh
1177 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/medication/1' -d \
1179     "title": "Norvasc",
1180     "begdate": "2013-04-13",
1181     "enddate": null
1185 #### GET /api/patient/:pid/medication
1187 Request:
1189 ```sh
1190 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication'
1193 #### GET /api/patient/:pid/medication/:mid
1195 Request:
1197 ```sh
1198 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1201 #### DELETE /api/patient/:pid/medication/:mid
1203 Request:
1205 ```sh
1206 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1209 #### POST /api/patient/:pid/surgery
1211 Request:
1213 ```sh
1214 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/surgery' -d \
1216     "title": "Blepharoplasty",
1217     "begdate": "2013-10-13",
1218     "enddate": null,
1219     "diagnosis": "CPT4:15823-50"
1223 #### PUT /api/patient/:pid/surgery/:sid
1225 Request:
1227 ```sh
1228 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/surgery/1' -d \
1230     "title": "Blepharoplasty",
1231     "begdate": "2013-10-14",
1232     "enddate": null,
1233     "diagnosis": "CPT4:15823-50"
1237 #### GET /api/patient/:pid/surgery
1239 Request:
1241 ```sh
1242 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery'
1245 #### GET /api/patient/:pid/surgery/:sid
1247 Request:
1249 ```sh
1250 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1253 #### DELETE /api/patient/:pid/surgery/:sid
1255 Request:
1257 ```sh
1258 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1261 #### POST /api/patient/:pid/dental_issue
1263 Request:
1265 ```sh
1266 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/dental_issue' -d \
1268     "title": "Halitosis",
1269     "begdate": "2015-03-17",
1270     "enddate": null
1274 #### PUT /api/patient/:pid/dental_issue/:did
1276 Request:
1278 ```sh
1279 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1' -d \
1281     "title": "Halitosis",
1282     "begdate": "2015-03-17",
1283     "enddate": "2018-03-20"
1287 #### GET /api/patient/:pid/dental_issue
1289 Request:
1291 ```sh
1292 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue'
1295 #### GET /api/patient/:pid/dental_issue/:did
1297 Request:
1299 ```sh
1300 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1303 #### DELETE /api/patient/:pid/dental_issue/:did
1305 Request:
1307 ```sh
1308 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1311 #### GET /api/patient/:pid/insurance
1313 Request:
1315 ```sh
1316 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance'
1319 #### GET /api/patient/:pid/insurance/:type
1321 Request:
1323 ```sh
1324 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance/secondary'
1327 #### POST /api/patient/:pid/insurance/:type
1329 Request:
1331 ```sh
1332 curl -X POST 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1334     "type": "primary",
1335     "provider": "33",
1336     "plan_name": "Some Plan",
1337     "policy_number": "12345",
1338     "group_number": "252412",
1339     "subscriber_lname": "Tester",
1340     "subscriber_mname": "Xi",
1341     "subscriber_fname": "Foo",
1342     "subscriber_relationship": "other",
1343     "subscriber_ss": "234231234",
1344     "subscriber_DOB": "2018-10-03",
1345     "subscriber_street": "183 Cool St",
1346     "subscriber_postal_code": "23418",
1347     "subscriber_city": "Cooltown",
1348     "subscriber_state": "AZ",
1349     "subscriber_country": "USA",
1350     "subscriber_phone": "234-598-2123",
1351     "subscriber_employer": "Some Employer",
1352     "subscriber_employer_street": "123 Heather Lane",
1353     "subscriber_employer_postal_code": "23415",
1354     "subscriber_employer_state": "AZ",
1355     "subscriber_employer_country": "USA",
1356     "subscriber_employer_city": "Cooltown",
1357     "copay": "35",
1358     "date": "2018-10-15",
1359     "subscriber_sex": "Female",
1360     "accept_assignment": "TRUE",
1361     "policy_type": "a"
1365 Notes:
1367 -   `provider` is the insurance company id
1368 -   `state` can be found by querying `resource=/api/list/state`
1369 -   `country` can be found by querying `resource=/api/list/country`
1371 #### PUT /api/patient/:pid/insurance/:type
1373 Request:
1375 ```sh
1376 curl -X PUT 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1378     "type": "primary",
1379     "provider": "33",
1380     "plan_name": "Some Plan",
1381     "policy_number": "12345",
1382     "group_number": "252412",
1383     "subscriber_lname": "Tester",
1384     "subscriber_mname": "Xi",
1385     "subscriber_fname": "Foo",
1386     "subscriber_relationship": "other",
1387     "subscriber_ss": "234231234",
1388     "subscriber_DOB": "2018-10-03",
1389     "subscriber_street": "183 Cool St",
1390     "subscriber_postal_code": "23418",
1391     "subscriber_city": "Cooltown",
1392     "subscriber_state": "AZ",
1393     "subscriber_country": "USA",
1394     "subscriber_phone": "234-598-2123",
1395     "subscriber_employer": "Some Employer",
1396     "subscriber_employer_street": "123 Heather Lane",
1397     "subscriber_employer_postal_code": "23415",
1398     "subscriber_employer_state": "AZ",
1399     "subscriber_employer_country": "USA",
1400     "subscriber_employer_city": "Cooltown",
1401     "copay": "35",
1402     "date": "2018-10-15",
1403     "subscriber_sex": "Female",
1404     "accept_assignment": "TRUE",
1405     "policy_type": "a"
1409 Notes:
1411 -   `provider` is the insurance company id
1412 -   `state` can be found by querying `resource=/api/list/state`
1413 -   `country` can be found by querying `resource=/api/list/country`
1415 #### GET /api/list/:list_name
1417 Request:
1419 ```sh
1420 curl -X GET 'http://localhost:8300/apis/default/api/list/medical_problem_issue_list'
1423 #### GET /api/version
1425 Request:
1427 ```sh
1428 curl -X GET 'http://localhost:8300/apis/default/api/version'
1431 #### GET /api/product
1433 Request:
1435 ```sh
1436 curl -X GET 'http://localhost:8300/apis/default/api/product'
1439 #### GET /api/insurance_company
1441 Request:
1443 ```sh
1444 curl -X GET 'http://localhost:8300/apis/default/api/insurance_company'
1447 #### GET /api/insurance_type
1449 Request:
1451 ```sh
1452 curl -X GET 'http://localhost:8300/apis/default/api/insurance_type'
1455 #### POST /api/insurance_company
1457 Request:
1459 ```sh
1460 curl -X POST 'http://localhost:8300/apis/default/api/insurance_company' -d \
1462     "name": "Cool Insurance Company",
1463     "attn": null,
1464     "cms_id": null,
1465     "ins_type_code": "2",
1466     "x12_receiver_id": null,
1467     "x12_default_partner_id": null,
1468     "alt_cms_id": "",
1469     "line1": "123 Cool Lane",
1470     "line2": "Suite 123",
1471     "city": "Cooltown",
1472     "state": "CA",
1473     "zip": "12245",
1474     "country": "USA"
1478 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1480 #### PUT /api/insurance_company/:iid
1482 Request:
1484 ```sh
1485 curl -X PUT 'http://localhost:8300/apis/default/api/insurance_company/1' -d \
1487     "name": "Super Insurance Company",
1488     "attn": null,
1489     "cms_id": null,
1490     "ins_type_code": "2",
1491     "x12_receiver_id": null,
1492     "x12_default_partner_id": null,
1493     "alt_cms_id": "",
1494     "line1": "123 Cool Lane",
1495     "line2": "Suite 123",
1496     "city": "Cooltown",
1497     "state": "CA",
1498     "zip": "12245",
1499     "country": "USA"
1503 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1505 #### GET /api/appointment
1507 Request:
1509 ```sh
1510 curl -X GET 'http://localhost:8300/apis/default/api/appointment'
1513 #### GET /api/appointment/:eid
1515 Request:
1517 ```sh
1518 curl -X GET 'http://localhost:8300/apis/default/api/appointment/1'
1521 #### GET /api/patient/:pid/appointment
1523 Request:
1525 ```sh
1526 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment'
1529 #### GET /api/patient/:pid/appointment/:eid
1531 Request:
1533 ```sh
1534 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment/1'
1537 #### POST /api/patient/:pid/appointment
1539 Request:
1541 ```sh
1542 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/appointment' -d \
1544     "pc_eid":"1",
1545     "pc_catid": "5",
1546     "pc_title": "Office Visit",
1547     "pc_duration": "900",
1548     "pc_hometext": "Test",
1549     "pc_apptstatus": "-",
1550     "pc_eventDate": "2018-10-19",
1551     "pc_startTime": "09:00",
1552     "pc_facility": "9",
1553     "pc_billing_location": "10"
1557 #### DELETE /api/patient/:pid/appointment/:eid
1559 Request:
1561 ```sh
1562 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/appointment/1' -d \
1565 #### GET /api/patient/:pid/document
1567 Request:
1569 ```sh
1570 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1573 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1575 -   Spaces are represented with `_`
1576 -   All characters are lowercase
1578 #### POST /api/patient/:pid/document
1580 Request:
1582 ```sh
1583 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1584  -F document=@/home/someone/Desktop/drawing.jpg
1587 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1589 -   Spaces are represented with `_`
1590 -   All characters are lowercase
1592 #### GET /api/patient/:pid/document/:did
1594 Request:
1596 ```sh
1597 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document/1'
1600 #### POST /api/patient/:pid/message
1602 Request:
1604 ```sh
1605 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/message' -d \
1607     "body": "Test 123",
1608     "groupname": "Default",
1609     "from": "admin",
1610     "to": "Matthew",
1611     "title": "Other",
1612     "message_status": "New"
1616 Notes:
1618 -   For `title`, use `resource=/api/list/note_type`
1619 -   For `message_type`, use `resource=/api/list/message_status`
1621 #### PUT /api/patient/:pid/message/:mid
1623 Request:
1625 ```sh
1626 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/message/1' -d \
1628     "body": "Test 456",
1629     "groupname": "Default",
1630     "from": "Matthew",
1631     "to": "admin",
1632     "title": "Other",
1633     "message_status": "New"
1637 Notes:
1639 -   For `title`, use `resource=/api/list/note_type`
1640 -   For `message_type`, use `resource=/api/list/message_status`
1642 #### DELETE /api/patient/:pid/message/:mid
1644 Request:
1646 ```sh
1647 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/message/1'
1650 ### /portal/ Endpoints
1652 This is under development and is considered EXPERIMENTAL.
1654 Enable the Patient Portal API service (/portal/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Patient Portal REST API (EXPERIMENTAL)"
1656 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/default/portal as base URI.`
1658 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
1660 _Example:_ `http://localhost:8300/apis/default/portal/patient` returns a resource of the patient.
1662 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.
1664 Request:
1666 ```sh
1667 curl -X GET 'http://localhost:8300/apis/default/portal/patient' \
1668   -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1671 #### GET /portal/patient
1673 Request:
1675 ```sh
1676 curl -X GET 'http://localhost:8300/apis/default/portal/patient'
1679 Response:
1681 ```json
1683     "validationErrors": [],
1684     "internalErrors": [],
1685     "data": {
1686         "id": "193",
1687         "pid": "1",
1688         "pubpid": "",
1689         "title": "Mr",
1690         "fname": "Baz",
1691         "mname": "",
1692         "lname": "Bop",
1693         "ss": "",
1694         "street": "456 Tree Lane",
1695         "postal_code": "08642",
1696         "city": "FooTown",
1697         "state": "FL",
1698         "county": "",
1699         "country_code": "US",
1700         "drivers_license": "",
1701         "contact_relationship": "",
1702         "phone_contact": "123-456-7890",
1703         "phone_home": "",
1704         "phone_biz": "",
1705         "phone_cell": "",
1706         "email": "",
1707         "DOB": "1992-02-03",
1708         "sex": "Male",
1709         "race": "",
1710         "ethnicity": "",
1711         "status": ""
1712     }
1716 ### Dev Notes
1718 -   For business logic, make or use the services [here](src/Services)
1719 -   For controller logic, make or use the classes [here](src/RestControllers)
1720 -   For routing declarations, use the class [here](_rest_routes.inc.php).