Layout editor fixes to preserve sensitive column names. (#4408)
[openemr.git] / API_README.md
blob69af73358da75938025ec69388d81989279a9fbd
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::authorization_check("patients", "demo");
15     $data = (array) (json_decode(file_get_contents("php://input")));
16     $return = (new PatientRestController())->post($data);
17     RestConfig::apiLog($return, $data);
18     return $return;
20 ```
22 At a high level, the request processing flow consists of the following steps:
24 ```
25 JSON Request -> Controller Component -> Validation -> Service Component -> Database
26 ```
28 The logical response flow begins with the database result:
30 ```
31 Database Result -> Service Component -> Controller Component -> RequestControllerHelper -> JSON Response
32 ```
34 The [RequestControllerHelper class](./src/RestControllers/RestControllerHelper.php) evaluates the Service Component's
35 result and maps it to a http response code and response payload. Existing APIs should be updated to utilize the
36 `handleProcessingResult` method as it supports the [Validator](./src/Validators/BaseValidator.php) components.
38 The [PatientRestController](./src/RestControllers/PatientRestController.php) may be used as a reference to see how APIs are
39 integrated with `RequestControllerHelper::handleProcessingResult` and the `Validator` components.
41 Finally, APIs which are integrated with the new `handleProcessingResult` method utilize a common response format.
43 ```json
45     "validationErrors": [],
46     "internalErrors": [],
47     "data": < data payload >
49 ```
51 -   `validationErrors` contain "client based" data validation errors
52 -   `internalErrors` contain server related errors
53 -   `data` is the response payload, represented as an object/`{}` for single results or an array/`[]` for multiple results
55 ### Sections
57 -   [Authorization](API_README.md#authorization)
58     -   [Scopes](API_README.md#scopes)
59     -   [Registration](API_README.md#registration)
60         -   [SMART on FHIR Registration](API_README.md#smart-on-fhir-registration)
61     -   [Authorization Code Grant](API_README.md#authorization-code-grant)
62     -   [Refresh Token Grant](API_README.md#refresh-token-grant)
63     -   [Password Grant](API_README.md#password-grant)
64     -   [Client Credentials Grant](API_README#client-credentials-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 -   [Dev notes](API_README.md#dev-notes)
102 ### Prerequisite
104 Enable the Standard API service (/api/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Standard REST API"
106 ### Using API Internally
108 There are several ways to make API calls from an authorized session and maintain security:
110 -   See the script at tests/api/InternalApiTest.php for examples of internal API use cases.
112 ### Multisite Support
114 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`.
116 ### Authorization
118 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.
120 #### Scopes
122 This is a listing of scopes:
123 - `api:oemr` (user api which are the /api/ endpoints)
124   - `user/allergy.read`
125   - `user/allergy.write`
126   - `user/appointment.read`
127   - `user/appointment.write`
128   - `user/dental_issue.read`
129   - `user/dental_issue.write`
130   - `user/document.read`
131   - `user/document.write`
132   - `user/drug.read`
133   - `user/encounter.read`
134   - `user/encounter.write`
135   - `user/facility.read`
136   - `user/facility.write`
137   - `user/immunization.read`
138   - `user/insurance.read`
139   - `user/insurance.write`
140   - `user/insurance_company.read`
141   - `user/insurance_company.write`
142   - `user/insurance_type.read`
143   - `user/list.read`
144   - `user/medical_problem.read`
145   - `user/medical_problem.write`
146   - `user/medication.read`
147   - `user/medication.write`
148   - `user/message.write`
149   - `user/patient.read`
150   - `user/patient.write`
151   - `user/practitioner.read`
152   - `user/practitioner.write`
153   - `user/prescription.read`
154   - `user/procedure.read`
155   - `user/soap_note.read`
156   - `user/soap_note.write`
157   - `user/surgery.read`
158   - `user/surgery.write`
159   - `user/vital.read`
160   - `user/vital.write`
161 - `api:fhir` (fhir which are the /fhir/ endpoints)
162   - `patient/AllergyIntolerance.read`
163   - `patient/CareTeam.read`
164   - `patient/Condition.read`
165   - `patient/Encounter.read`
166   - `patient/Immunization.read`
167   - `patient/MedicationRequest.read`
168   - `patient/Observation.read`
169   - `patient/Patient.read`
170   - `patient/Procedure.read`
171   - `user/AllergyIntolerance.read`
172   - `user/CareTeam.read`
173   - `user/Condition.read`
174   - `user/Coverage.read`
175   - `user/Encounter.read`
176   - `user/Immunization.read`
177   - `user/Location.read`
178   - `user/Medication.read`
179   - `user/MedicationRequest.read`
180   - `user/Observation.read`
181   - `user/Organization.read`
182   - `user/Organization.write`
183   - `user/Patient.read`
184   - `user/Patient.write`
185   - `user/Practitioner.read`
186   - `user/Practitioner.write`
187   - `user/PractitionerRole.read`
188   - `user/Procedure.read`
189 - `api:port` (patient api which are the /portal/ endpoints) (EXPERIMENTAL)
190   - `patient/encounter.read`
191   - `patient/patient.read`
193 #### Registration
195 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.
197 Note that all scopes are included in this example for demonstration purposes. For production purposes, should only include the necessary scopes.
199 ```sh
200 curl -X POST -k -H 'Content-Type: application/json' -i https://localhost:9300/oauth2/default/registration --data '{
201    "application_type": "private",
202    "redirect_uris":
203      ["https://client.example.org/callback"],
204    "post_logout_redirect_uris":
205      ["https://client.example.org/logout/callback"],
206    "client_name": "A Private App",
207    "token_endpoint_auth_method": "client_secret_post",
208    "contacts": ["me@example.org", "them@example.org"],
209    "scope": "openid offline_access api:oemr api:fhir api:port 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/AllergyIntolerance.read patient/CareTeam.read patient/Condition.read patient/Encounter.read patient/Immunization.read patient/MedicationRequest.read patient/Observation.read patient/Patient.read patient/Procedure.read"
210   }'
213 Response:
214 ```sh
216     "client_id": "LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA",
217     "client_secret": "j21ecvLmFi9HPc_Hv0t7Ptmf1pVcZQLtHjIdU7U9tkS9WAjFJwVMav0G8ogTJ62q4BATovC7BQ19Qagc4x9BBg",
218     "registration_access_token": "uiDSXx2GNSvYy5n8eW50aGrJz0HjaGpUdrGf07Agv_Q",
219     "registration_client_uri": "https:\/\/localhost:9300\/oauth2\/default\/client\/6eUVG0-qK2dYiwfYdECKIw",
220     "client_id_issued_at": 1604767861,
221     "client_secret_expires_at": 0,
222     "contacts": ["me@example.org", "them@example.org"],
223     "application_type": "private",
224     "client_name": "A Private App",
225     "redirect_uris": ["https:\/\/client.example.org\/callback"],
226     "token_endpoint_auth_method": "client_secret_post",
227     "scope": "openid offline_access api:oemr api:fhir api:port 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/AllergyIntolerance.read patient/CareTeam.read patient/Condition.read patient/Encounter.read patient/Immunization.read patient/MedicationRequest.read patient/Observation.read patient/Patient.read patient/Procedure.read"
231 ##### SMART on FHIR Registration
233 SMART Enabled Apps are supported.
235 SMART client can be registered at <website>/interface/smart/register-app.php. For example https://localhost:9300/interface/smart/register-app.php
237 After registering the SMART client, can then Enable it in OpenEMR at Administration->System->API Clients
239 After it is enabled, the SMART App will then be available to use in the Patient Summary screen (SMART Enabled Apps widget).
241 See this github issue for an example of a Smart App installation: https://github.com/openemr/openemr/issues/4148
243 #### Authorization Code Grant
245 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`.
247 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting authorization grant.
249 #### Refresh Token Grant
251 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting authorization or password grant.
253 Example:
255 ```sh
256 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
257 -i 'https://localhost:9300/oauth2/default/token'
258 --data 'grant_type=refresh_token
259 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
260 &refresh_token=def5020089a766d16...'
263 Response:
265 ```json
267   "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
268   "token_type": "Bearer",
269   "expires_in": 3599,
270   "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
271   "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
275 #### Password Grant
277 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)'.
279 Note that all scopes are included in these examples for demonstration purposes. For production purposes, should only include the necessary scopes.
281 Note that a refresh token is only supplied if the `offline_access` scope is provided when requesting password grant.
283 Example for `users` role:
284 ```sh
285 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
286 -i 'https://localhost:9300/oauth2/default/token'
287 --data 'grant_type=password
288 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
289 &scope=openid%20offline_access%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
290 &user_role=users
291 &username=admin
292 &password=pass'
295 Example for `patient` role:
296 ```sh
297 curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded'
298 -i 'https://localhost:9300/oauth2/default/token'
299 --data 'grant_type=password
300 &client_id=LnjqojEEjFYe5j2Jp9m9UnmuxOnMg4VodEJj3yE8_OA
301 &scope=openid%20offline_access%20api%3Aport%20api%3Afhir%20patient%2Fencounter.read%20patient%2Fpatient.read%20patient%2FAllergyIntolerance.read%20patient%2FCareTeam.read%20patient%2FCondition.read%20patient%2FEncounter.read%20patient%2FImmunization.read%20patient%2FMedicationRequest.read%20patient%2FObservation.read%20patient%2FPatient.read%20patient%2FProcedure.read
302 &user_role=patient
303 &username=Phil1
304 &password=phil
305 &email=heya@invalid.email.com'
308 Response:
310 ```json
312   "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYn...",
313   "token_type": "Bearer",
314   "expires_in": 3599,
315   "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJrYnl1RkRp...",
316   "refresh_token": "def5020017b484b0add020bf3491a8a537fa04eda12..."
320 ### Client Credentials Grant
322 This is an advanced grant that uses JSON Web Key Sets(JWKS) to authenticate and identify the client.  This credential grant is
323 required to be used for access to any **system/\*.$export** scopes.  API clients must register either web accessible JWKS URI that hosts
324 a RSA384 compatible key, or provide their JWKS as part of the registration. Client Credentials Grant access tokens are short
325 lived and valid for only 1 minute and no refresh token is issued.  Tokens are requested at `/oauth2/default/token`
326 To walk you through how to do this process you can follow [this guide created by HL7](https://hl7.org/fhir/uv/bulkdata/authorization/index.html).
328 #### Logout
330 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.
332 #### More Details
334 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
336 More specific development api topics are discussed and described on the above forum thread (such as introspection).
338 ### /api/ Endpoints
340 OpenEMR standard endpoints Use `http://localhost:8300/apis/default/api as base URI.`
342 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
344 _Example:_ `http://localhost:8300/apis/default/api/patient` returns a resource of all Patients.
346 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.
348 Request:
350 ```sh
351 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medical_problem' \
352   -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
355 #### POST /api/facility
357 Request:
359 ```sh
360 curl -X POST 'http://localhost:8300/apis/default/api/facility' -d \
362     "name": "Aquaria",
363     "phone": "808-606-3030",
364     "fax": "808-606-3031",
365     "street": "1337 Bit Shifter Ln",
366     "city": "San Lorenzo",
367     "state": "ZZ",
368     "postal_code": "54321",
369     "email": "foo@bar.com",
370     "service_location": "1",
371     "billing_location": "1",
372     "color": "#FF69B4"
376 #### PUT /api/facility/:fid
378 Request:
380 ```sh
381 curl -X PUT 'http://localhost:8300/apis/default/api/facility/1' -d \
383     "name": "Aquaria",
384     "phone": "808-606-3030",
385     "fax": "808-606-3031",
386     "street": "1337 Bit Shifter Ln",
387     "city": "San Lorenzo",
388     "state": "AZ",
389     "postal_code": "54321",
390     "email": "foo@bar.com",
391     "service_location": "1",
392     "billing_location": "1",
393     "color": "#FF69B4"
397 #### GET /api/facility
399 Request:
401 ```sh
402 curl -X GET 'http://localhost:8300/apis/default/api/facility'
405 #### GET /api/facility/:fid
407 Request:
409 ```sh
410 curl -X GET 'http://localhost:8300/apis/default/api/facility/1'
413 #### GET /api/practitioner
415 Request:
417 ```sh
418 curl -X GET 'http://localhost:8300/apis/default/api/practitioner'
421 #### GET /api/practitioner/:uuid
423 Request:
425 ```sh
426 curl -X GET 'http://localhost:8300/apis/default/api/practitioner/90cde167-7b9b-4ed1-bd55-533925cb2605'
429 #### POST /api/practitioner
431 Request:
433 ```sh
434 curl -X POST 'http://localhost:8300/apis/default/api/practitioner' -d \
436     "title": "Mrs.",
437     "fname": "Eduardo",
438     "mname": "Kathy",
439     "lname": "Perez",
440     "federaltaxid": "",
441     "federaldrugid": "",
442     "upin": "",
443     "facility_id": "3",
444     "facility": "Your Clinic Name Here",
445     "npi": "0123456789",
446     "email": "info@pennfirm.com",
447     "specialty": "",
448     "billname": null,
449     "url": null,
450     "assistant": null,
451     "organization": null,
452     "valedictory": null,
453     "street": "789 Third Avenue",
454     "streetb": "123 Cannaut Street",
455     "city": "San Diego",
456     "state": "CA",
457     "zip": "90210",
458     "phone": "(619) 555-9827",
459     "fax": null,
460     "phonew1": "(619) 555-7822",
461     "phonecell": "(619) 555-7821",
462     "notes": null,
463     "state_license_number": "123456"
467 Response:
469 ```json
471     "validationErrors": [],
472     "internalErrors": [],
473     "data": {
474         "id": 7,
475         "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5"
476     }
480 #### PUT /api/practitioner/:uuid
482 Request:
484 ```sh
485 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
487     "title": "Mr",
488     "fname": "Baz",
489     "mname": "",
490     "lname": "Bop",
491     "street": "456 Tree Lane",
492     "zip": "08642",
493     "city": "FooTown",
494     "state": "FL",
495     "phone": "123-456-7890"
499 Response:
501 ```json
503     "validationErrors": [],
504     "internalErrors": [],
505     "data": {
506         "id": "7",
507         "uuid": "90d453fb-0248-4c0d-9575-d99d02b169f5",
508         "title": "Mr",
509         "fname": "Baz",
510         "lname": "Bop",
511         "mname": "",
512         "federaltaxid": "",
513         "federaldrugid": "",
514         "upin": "",
515         "facility_id": "3",
516         "facility": "Your Clinic Name Here",
517         "npi": "0123456789",
518         "email": "info@pennfirm.com",
519         "active": "1",
520         "specialty": "",
521         "billname": "",
522         "url": "",
523         "assistant": "",
524         "organization": "",
525         "valedictory": "",
526         "street": "456 Tree Lane",
527         "streetb": "123 Cannaut Street",
528         "city": "FooTown",
529         "state": "FL",
530         "zip": "08642",
531         "phone": "123-456-7890",
532         "fax": "",
533         "phonew1": "(619) 555-7822",
534         "phonecell": "(619) 555-7821",
535         "notes": "",
536         "state_license_number": "123456",
537         "abook_title": null,
538         "physician_title": null,
539         "physician_code": null
540     }
544 #### POST /api/patient
546 Request:
548 ```sh
549 curl -X POST 'http://localhost:8300/apis/default/api/patient' -d \
551     "title": "Mr",
552     "fname": "Foo",
553     "mname": "",
554     "lname": "Bar",
555     "street": "456 Tree Lane",
556     "postal_code": "08642",
557     "city": "FooTown",
558     "state": "FL",
559     "country_code": "US",
560     "phone_contact": "123-456-7890",
561     "DOB": "1992-02-02",
562     "sex": "Male",
563     "race": "",
564     "ethnicity": ""
568 Response:
570 ```json
572     "validationErrors": [],
573     "internalErrors": [],
574     "data": {
575         "pid": 1
576     }
580 #### PUT /api/patient/:puuid
582 Request:
584 ```sh
585 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7' -d \
587     "title": "Mr",
588     "fname": "Baz",
589     "mname": "",
590     "lname": "Bop",
591     "street": "456 Tree Lane",
592     "postal_code": "08642",
593     "city": "FooTown",
594     "state": "FL",
595     "country_code": "US",
596     "phone_contact": "123-456-7890",
597     "DOB": "1992-02-03",
598     "sex": "Male",
599     "race": "",
600     "ethnicity": ""
604 Response:
606 ```json
608     "validationErrors": [],
609     "internalErrors": [],
610     "data": {
611         "id": "193",
612         "pid": "1",
613         "pubpid": "",
614         "title": "Mr",
615         "fname": "Baz",
616         "mname": "",
617         "lname": "Bop",
618         "ss": "",
619         "street": "456 Tree Lane",
620         "postal_code": "08642",
621         "city": "FooTown",
622         "state": "FL",
623         "county": "",
624         "country_code": "US",
625         "drivers_license": "",
626         "contact_relationship": "",
627         "phone_contact": "123-456-7890",
628         "phone_home": "",
629         "phone_biz": "",
630         "phone_cell": "",
631         "email": "",
632         "DOB": "1992-02-03",
633         "sex": "Male",
634         "race": "",
635         "ethnicity": "",
636         "status": ""
637     }
641 #### GET /api/patient
643 Request:
645 ```sh
646 curl -X GET 'http://localhost:8300/apis/default/api/patient'
649 Response:
651 ```json
653     "validationErrors": [],
654     "internalErrors": [],
655     "data": [{ patientRecord }, { patientRecord }, etc]
659 Request:
661 ```sh
662 curl -X GET 'http://localhost:8300/apis/default/api/patient&fname=...&lname=...&dob=...'
665 Response:
667 ```json
669     "validationErrors": [],
670     "internalErrors": [],
671     "data": [{ patientRecord }, { patientRecord }, etc]
675 #### GET /api/patient/:puuid
677 Request:
679 ```sh
680 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7'
683 Response:
685 ```json
687     "validationErrors": [],
688     "internalErrors": [],
689     "data": {
690         "id": "193",
691         "pid": "1",
692         "pubpid": "",
693         "title": "Mr",
694         "fname": "Baz",
695         "mname": "",
696         "lname": "Bop",
697         "ss": "",
698         "street": "456 Tree Lane",
699         "postal_code": "08642",
700         "city": "FooTown",
701         "state": "FL",
702         "county": "",
703         "country_code": "US",
704         "drivers_license": "",
705         "contact_relationship": "",
706         "phone_contact": "123-456-7890",
707         "phone_home": "",
708         "phone_biz": "",
709         "phone_cell": "",
710         "email": "",
711         "DOB": "1992-02-03",
712         "sex": "Male",
713         "race": "",
714         "ethnicity": "",
715         "status": ""
716     }
720 #### GET /api/immunization
722 Request:
724 ```sh
725 curl -X GET 'http://localhost:8300/apis/default/api/immunization'
728 #### GET /api/immunization/:uuid
730 Request:
732 ```sh
733 curl -X GET 'http://localhost:8300/apis/default/api/immunization/90cde167-7b9b-4ed1-bd55-533925cb2605'
736 #### POST /api/patient/:pid/encounter
738 Request:
740 ```sh
741 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter' -d \
743     "date":"2020-11-10",
744     "onset_date": "",
745     "reason": "Pregnancy Test",
746     "facility": "Owerri General Hospital",
747     "pc_catid": "5",
748     "facility_id": "3",
749     "billing_facility": "3",
750     "sensitivity": "normal",
751     "referral_source": "",
752     "pos_code": "0",
753     "external_id": "",
754     "provider_id": "1",
755     "class_code" : "AMB"
759 Response:
761 ```json
763     "validationErrors": [],
764     "internalErrors": [],
765     "data": {
766         "encounter": 1,
767         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef"
768     }
772 #### PUT /api/patient/:pid/encounter/:eid
774 Request:
776 ```sh
777 curl -X POST 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
779     "date":"2019-09-14",
780     "onset_date": "2019-04-20 00:00:00",
781     "reason": "Pregnancy Test",
782     "pc_catid": "5",
783     "facility_id": "3",
784     "billing_facility": "3",
785     "sensitivity": "normal",
786     "referral_source": "",
787     "pos_code": "0"
791 Response:
793 ```json
795     "validationErrors": [],
796     "internalErrors": [],
797     "data": {
798         "id": "1",
799         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
800         "date": "2019-09-14 00:00:00",
801         "reason": "Pregnancy Test",
802         "facility": "Owerri General Hospital",
803         "facility_id": "3",
804         "pid": "1",
805         "onset_date": "2019-04-20 00:00:00",
806         "sensitivity": "normal",
807         "billing_note": null,
808         "pc_catid": "5",
809         "last_level_billed": "0",
810         "last_level_closed": "0",
811         "last_stmt_date": null,
812         "stmt_count": "0",
813         "provider_id": "1",
814         "supervisor_id": "0",
815         "invoice_refno": "",
816         "referral_source": "",
817         "billing_facility": "3",
818         "external_id": "",
819         "pos_code": "0",
820         "class_code": "AMB",
821         "class_title": "ambulatory",
822         "pc_catname": "Office Visit",
823         "billing_facility_name": "Owerri General Hospital"
824     }
828 #### GET /api/patient/:pid/encounter
830 Request:
832 ```sh
833 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter'
836 Response:
838 ```json
840     "validationErrors": [],
841     "internalErrors": [],
842     "data": [{ encounterRecord }, { encounterRecord }, etc]
846 #### GET /api/patient/:pid/encounter/:eid
848 Request:
850 ```sh
851 curl -X GET 'http://localhost:8300/apis/default/api/patient/90a8923c-0b1c-4d0a-9981-994b143381a7/encounter/90c196f2-51cc-4655-8858-3a80aebff3ef'
854 Response:
856 ```json
858     "validationErrors": [],
859     "internalErrors": [],
860     "data": {
861         "id": "1",
862         "uuid": "90c196f2-51cc-4655-8858-3a80aebff3ef",
863         "date": "2019-09-14 00:00:00",
864         "reason": "Pregnancy Test",
865         "facility": "Owerri General Hospital",
866         "facility_id": "3",
867         "pid": "1",
868         "onset_date": "2019-04-20 00:00:00",
869         "sensitivity": "normal",
870         "billing_note": null,
871         "pc_catid": "5",
872         "last_level_billed": "0",
873         "last_level_closed": "0",
874         "last_stmt_date": null,
875         "stmt_count": "0",
876         "provider_id": "1",
877         "supervisor_id": "0",
878         "invoice_refno": "",
879         "referral_source": "",
880         "billing_facility": "3",
881         "external_id": "",
882         "pos_code": "0",
883         "class_code": "AMB",
884         "class_title": "ambulatory",
885         "pc_catname": "Office Visit",
886         "billing_facility_name": "Owerri General Hospital"
887     }
891 #### POST /api/patient/:pid/encounter/:eid/vital
893 Request:
895 ```sh
896 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital' -d \
898     "bps": "130",
899     "bpd": "80",
900     "weight": "220",
901     "height": "70",
902     "temperature": "98",
903     "temp_method": "Oral",
904     "pulse": "60",
905     "respiration": "20",
906     "note": "...",
907     "waist_circ": "37",
908     "head_circ": "22.2",
909     "oxygen_saturation": "80"
913 #### PUT /api/patient/:pid/encounter/:eid/vital/:vid
915 Request:
917 ```sh
918 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1' -d \
920     "bps": "140",
921     "bpd": "80",
922     "weight": "220",
923     "height": "70",
924     "temperature": "98",
925     "temp_method": "Oral",
926     "pulse": "60",
927     "respiration": "20",
928     "note": "...",
929     "waist_circ": "37",
930     "head_circ": "22.2",
931     "oxygen_saturation": "80"
935 #### GET /api/patient/:pid/encounter/:eid/vital
937 Request:
939 ```sh
940 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital'
943 #### GET /api/patient/:pid/encounter/:eid/vital/:vid
945 Request:
947 ```sh
948 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/vital/1'
951 #### POST /api/patient/:pid/encounter/:eid/soap_note
953 Request:
955 ```sh
956 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note' -d \
958     "subjective": "...",
959     "objective": "...",
960     "assessment": "...",
961     "plan": "..."
965 #### PUT /api/patient/:pid/encounter/:eid/soap_note/:sid
967 Request:
969 ```sh
970 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1' -d \
972     "subjective": "...",
973     "objective": "...",
974     "assessment": "...",
975     "plan": "..."
979 #### GET /api/patient/:pid/encounter/:eid/soap_note
981 Request:
983 ```sh
984 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note'
987 #### GET /api/patient/:pid/encounter/:eid/soap_note/:sid
989 Request:
991 ```sh
992 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/encounter/1/soap_note/1'
995 #### GET /api/medical_problem
997 Request:
999 ```sh
1000 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem'
1003 #### GET /api/medical_problem/:muuid
1005 Request:
1007 ```sh
1008 curl -X GET 'http://localhost:8300/apis/default/api/medical_problem/9109890a-6756-44c1-a82d-bdfac91c7424'
1011 #### GET /api/patient/:puuid/medical_problem
1013 Request:
1015 ```sh
1016 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem'
1019 #### GET /api/patient/:puuid/medical_problem/:muuid
1021 Request:
1023 ```sh
1024 curl -X GET 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1027 #### POST /api/patient/:puuid/medical_problem
1029 Request:
1031 ```sh
1032 curl -X POST 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem' -d \
1034     "title": "Dermatochalasis",
1035     "begdate": "2010-04-13",
1036     "enddate": null,
1037     "diagnosis": "ICD10:H02.839"
1041 #### PUT /api/patient/:puuid/medical_problem/:muuid
1043 Request:
1045 ```sh
1046 curl -X PUT 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e' -d \
1048     "title": "Dermatochalasis",
1049     "begdate": "2010-04-13",
1050     "enddate": "2018-03-12",
1051     "diagnosis": "ICD10:H02.839"
1055 #### DELETE /api/patient/:puuid/medical_problem/:muuid
1057 Request:
1059 ```sh
1060 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/9101a093-da04-457f-a6a1-46ce93f0d629/medical_problem/91208832-47ab-4f65-ba44-08f57d4c028e'
1063 #### GET /api/allergy
1065 Request:
1067 ```sh
1068 curl -X GET 'http://localhost:8300/apis/default/api/allergy'
1071 #### GET /api/allergy/:auuid
1073 Request:
1075 ```sh
1076 curl -X GET 'http://localhost:8300/apis/default/api/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1079 #### GET /api/patient/:puuid/allergy
1081 Request:
1083 ```sh
1084 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy'
1087 #### GET /api/patient/:puuid/allergy/:auuid
1089 Request:
1091 ```sh
1092 curl -X GET 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1095 #### POST /api/patient/:puuid/allergy
1097 Request:
1099 ```sh
1100 curl -X POST 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy' -d \
1102     "title": "Iodine",
1103     "begdate": "2010-10-13",
1104     "enddate": null
1108 #### PUT /api/patient/:puuid/allergy/:auuid
1110 Request:
1112 ```sh
1113 curl -X PUT 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef' -d \
1115     "title": "Iodine",
1116     "begdate": "2012-10-13",
1117     "enddate": null
1121 #### DELETE /api/patient/:puuid/allergy/:auuid
1123 Request:
1125 ```sh
1126 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/90c196f2-51cc-4655-8858-3a80aebff3ef/allergy/90c196f2-51cc-4655-8858-3a80aebff3ef'
1129 #### GET /api/procedure
1131 Request:
1133 ```sh
1134 curl -X GET 'http://localhost:8300/apis/default/api/procedure'
1137 #### GET /api/procedure/:uuid
1139 Request:
1141 ```sh
1142 curl -X GET 'http://localhost:8300/apis/default/api/procedure/90c196f2-51cc-4655-8858-3a80aebff3ef'
1145 #### GET /api/drug
1147 Request:
1149 ```sh
1150 curl -X GET 'http://localhost:8300/apis/default/api/drug'
1153 #### GET /api/drug/:uuid
1155 Request:
1157 ```sh
1158 curl -X GET 'http://localhost:8300/apis/default/api/drug/90c196f2-51cc-4655-8858-3a80aebff3ef'
1161 #### GET /api/prescription
1163 Request:
1165 ```sh
1166 curl -X GET 'http://localhost:8300/apis/default/api/prescription'
1169 #### GET /api/prescription/:uuid
1171 Request:
1173 ```sh
1174 curl -X GET 'http://localhost:8300/apis/default/api/prescription/9128a1ec-95be-4649-8a66-d3686b7ab0ca'
1177 #### POST /api/patient/:pid/medication
1179 Request:
1181 ```sh
1182 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/medication' -d \
1184     "title": "Norvasc",
1185     "begdate": "2013-10-13",
1186     "enddate": null
1190 #### PUT /api/patient/:pid/medication/:mid
1192 Request:
1194 ```sh
1195 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/medication/1' -d \
1197     "title": "Norvasc",
1198     "begdate": "2013-04-13",
1199     "enddate": null
1203 #### GET /api/patient/:pid/medication
1205 Request:
1207 ```sh
1208 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication'
1211 #### GET /api/patient/:pid/medication/:mid
1213 Request:
1215 ```sh
1216 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1219 #### DELETE /api/patient/:pid/medication/:mid
1221 Request:
1223 ```sh
1224 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/medication/1'
1227 #### POST /api/patient/:pid/surgery
1229 Request:
1231 ```sh
1232 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/surgery' -d \
1234     "title": "Blepharoplasty",
1235     "begdate": "2013-10-13",
1236     "enddate": null,
1237     "diagnosis": "CPT4:15823-50"
1241 #### PUT /api/patient/:pid/surgery/:sid
1243 Request:
1245 ```sh
1246 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/surgery/1' -d \
1248     "title": "Blepharoplasty",
1249     "begdate": "2013-10-14",
1250     "enddate": null,
1251     "diagnosis": "CPT4:15823-50"
1255 #### GET /api/patient/:pid/surgery
1257 Request:
1259 ```sh
1260 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery'
1263 #### GET /api/patient/:pid/surgery/:sid
1265 Request:
1267 ```sh
1268 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1271 #### DELETE /api/patient/:pid/surgery/:sid
1273 Request:
1275 ```sh
1276 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/surgery/1'
1279 #### POST /api/patient/:pid/dental_issue
1281 Request:
1283 ```sh
1284 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/dental_issue' -d \
1286     "title": "Halitosis",
1287     "begdate": "2015-03-17",
1288     "enddate": null
1292 #### PUT /api/patient/:pid/dental_issue/:did
1294 Request:
1296 ```sh
1297 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1' -d \
1299     "title": "Halitosis",
1300     "begdate": "2015-03-17",
1301     "enddate": "2018-03-20"
1305 #### GET /api/patient/:pid/dental_issue
1307 Request:
1309 ```sh
1310 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue'
1313 #### GET /api/patient/:pid/dental_issue/:did
1315 Request:
1317 ```sh
1318 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1321 #### DELETE /api/patient/:pid/dental_issue/:did
1323 Request:
1325 ```sh
1326 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/dental_issue/1'
1329 #### GET /api/patient/:pid/insurance
1331 Request:
1333 ```sh
1334 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance'
1337 #### GET /api/patient/:pid/insurance/:type
1339 Request:
1341 ```sh
1342 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/insurance/secondary'
1345 #### POST /api/patient/:pid/insurance/:type
1347 Request:
1349 ```sh
1350 curl -X POST 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1352     "type": "primary",
1353     "provider": "33",
1354     "plan_name": "Some Plan",
1355     "policy_number": "12345",
1356     "group_number": "252412",
1357     "subscriber_lname": "Tester",
1358     "subscriber_mname": "Xi",
1359     "subscriber_fname": "Foo",
1360     "subscriber_relationship": "other",
1361     "subscriber_ss": "234231234",
1362     "subscriber_DOB": "2018-10-03",
1363     "subscriber_street": "183 Cool St",
1364     "subscriber_postal_code": "23418",
1365     "subscriber_city": "Cooltown",
1366     "subscriber_state": "AZ",
1367     "subscriber_country": "USA",
1368     "subscriber_phone": "234-598-2123",
1369     "subscriber_employer": "Some Employer",
1370     "subscriber_employer_street": "123 Heather Lane",
1371     "subscriber_employer_postal_code": "23415",
1372     "subscriber_employer_state": "AZ",
1373     "subscriber_employer_country": "USA",
1374     "subscriber_employer_city": "Cooltown",
1375     "copay": "35",
1376     "date": "2018-10-15",
1377     "subscriber_sex": "Female",
1378     "accept_assignment": "TRUE",
1379     "policy_type": "a"
1383 Notes:
1385 -   `provider` is the insurance company id
1386 -   `state` can be found by querying `resource=/api/list/state`
1387 -   `country` can be found by querying `resource=/api/list/country`
1389 #### PUT /api/patient/:pid/insurance/:type
1391 Request:
1393 ```sh
1394 curl -X PUT 'http://localhost:8300/apis/default/api/patient/10/insurance/primary' -d \
1396     "type": "primary",
1397     "provider": "33",
1398     "plan_name": "Some Plan",
1399     "policy_number": "12345",
1400     "group_number": "252412",
1401     "subscriber_lname": "Tester",
1402     "subscriber_mname": "Xi",
1403     "subscriber_fname": "Foo",
1404     "subscriber_relationship": "other",
1405     "subscriber_ss": "234231234",
1406     "subscriber_DOB": "2018-10-03",
1407     "subscriber_street": "183 Cool St",
1408     "subscriber_postal_code": "23418",
1409     "subscriber_city": "Cooltown",
1410     "subscriber_state": "AZ",
1411     "subscriber_country": "USA",
1412     "subscriber_phone": "234-598-2123",
1413     "subscriber_employer": "Some Employer",
1414     "subscriber_employer_street": "123 Heather Lane",
1415     "subscriber_employer_postal_code": "23415",
1416     "subscriber_employer_state": "AZ",
1417     "subscriber_employer_country": "USA",
1418     "subscriber_employer_city": "Cooltown",
1419     "copay": "35",
1420     "date": "2018-10-15",
1421     "subscriber_sex": "Female",
1422     "accept_assignment": "TRUE",
1423     "policy_type": "a"
1427 Notes:
1429 -   `provider` is the insurance company id
1430 -   `state` can be found by querying `resource=/api/list/state`
1431 -   `country` can be found by querying `resource=/api/list/country`
1433 #### GET /api/list/:list_name
1435 Request:
1437 ```sh
1438 curl -X GET 'http://localhost:8300/apis/default/api/list/medical_problem_issue_list'
1441 #### GET /api/version
1443 Request:
1445 ```sh
1446 curl -X GET 'http://localhost:8300/apis/default/api/version'
1449 #### GET /api/product
1451 Request:
1453 ```sh
1454 curl -X GET 'http://localhost:8300/apis/default/api/product'
1457 #### GET /api/insurance_company
1459 Request:
1461 ```sh
1462 curl -X GET 'http://localhost:8300/apis/default/api/insurance_company'
1465 #### GET /api/insurance_type
1467 Request:
1469 ```sh
1470 curl -X GET 'http://localhost:8300/apis/default/api/insurance_type'
1473 #### POST /api/insurance_company
1475 Request:
1477 ```sh
1478 curl -X POST 'http://localhost:8300/apis/default/api/insurance_company' -d \
1480     "name": "Cool Insurance Company",
1481     "attn": null,
1482     "cms_id": null,
1483     "ins_type_code": "2",
1484     "x12_receiver_id": null,
1485     "x12_default_partner_id": null,
1486     "alt_cms_id": "",
1487     "line1": "123 Cool Lane",
1488     "line2": "Suite 123",
1489     "city": "Cooltown",
1490     "state": "CA",
1491     "zip": "12245",
1492     "country": "USA"
1496 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1498 #### PUT /api/insurance_company/:iid
1500 Request:
1502 ```sh
1503 curl -X PUT 'http://localhost:8300/apis/default/api/insurance_company/1' -d \
1505     "name": "Super Insurance Company",
1506     "attn": null,
1507     "cms_id": null,
1508     "ins_type_code": "2",
1509     "x12_receiver_id": null,
1510     "x12_default_partner_id": null,
1511     "alt_cms_id": "",
1512     "line1": "123 Cool Lane",
1513     "line2": "Suite 123",
1514     "city": "Cooltown",
1515     "state": "CA",
1516     "zip": "12245",
1517     "country": "USA"
1521 Notes: `ins_type_code` can be found by inspecting the above route (/api/insurance_type).
1523 #### GET /api/appointment
1525 Request:
1527 ```sh
1528 curl -X GET 'http://localhost:8300/apis/default/api/appointment'
1531 #### GET /api/appointment/:eid
1533 Request:
1535 ```sh
1536 curl -X GET 'http://localhost:8300/apis/default/api/appointment/1'
1539 #### GET /api/patient/:pid/appointment
1541 Request:
1543 ```sh
1544 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment'
1547 #### GET /api/patient/:pid/appointment/:eid
1549 Request:
1551 ```sh
1552 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/appointment/1'
1555 #### POST /api/patient/:pid/appointment
1557 Request:
1559 ```sh
1560 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/appointment' -d \
1562     "pc_eid":"1",
1563     "pc_catid": "5",
1564     "pc_title": "Office Visit",
1565     "pc_duration": "900",
1566     "pc_hometext": "Test",
1567     "pc_apptstatus": "-",
1568     "pc_eventDate": "2018-10-19",
1569     "pc_startTime": "09:00",
1570     "pc_facility": "9",
1571     "pc_billing_location": "10"
1575 #### DELETE /api/patient/:pid/appointment/:eid
1577 Request:
1579 ```sh
1580 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/appointment/1' -d \
1583 #### GET /api/patient/:pid/document
1585 Request:
1587 ```sh
1588 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye'
1591 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1593 -   Spaces are represented with `_`
1594 -   All characters are lowercase
1596 #### POST /api/patient/:pid/document
1598 Request:
1600 ```sh
1601 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/document&path=/eye_module/imaging-eye/drawings-eye' \
1602  -F document=@/home/someone/Desktop/drawing.jpg
1605 Note: The `path` query string represents the OpenEMR documents paths with two exceptions:
1607 -   Spaces are represented with `_`
1608 -   All characters are lowercase
1610 #### GET /api/patient/:pid/document/:did
1612 Request:
1614 ```sh
1615 curl -X GET 'http://localhost:8300/apis/default/api/patient/1/document/1'
1618 #### POST /api/patient/:pid/message
1620 Request:
1622 ```sh
1623 curl -X POST 'http://localhost:8300/apis/default/api/patient/1/message' -d \
1625     "body": "Test 123",
1626     "groupname": "Default",
1627     "from": "admin",
1628     "to": "Matthew",
1629     "title": "Other",
1630     "message_status": "New"
1634 Notes:
1636 -   For `title`, use `resource=/api/list/note_type`
1637 -   For `message_type`, use `resource=/api/list/message_status`
1639 #### PUT /api/patient/:pid/message/:mid
1641 Request:
1643 ```sh
1644 curl -X PUT 'http://localhost:8300/apis/default/api/patient/1/message/1' -d \
1646     "body": "Test 456",
1647     "groupname": "Default",
1648     "from": "Matthew",
1649     "to": "admin",
1650     "title": "Other",
1651     "message_status": "New"
1655 Notes:
1657 -   For `title`, use `resource=/api/list/note_type`
1658 -   For `message_type`, use `resource=/api/list/message_status`
1660 #### DELETE /api/patient/:pid/message/:mid
1662 Request:
1664 ```sh
1665 curl -X DELETE 'http://localhost:8300/apis/default/api/patient/1/message/1'
1668 ### /portal/ Endpoints
1670 This is under development and is considered EXPERIMENTAL.
1672 Enable the Patient Portal API service (/portal/ endpoints) in OpenEMR menu: Administration->Globals->Connectors->"Enable OpenEMR Patient Portal REST API (EXPERIMENTAL)"
1674 OpenEMR patient portal endpoints Use `http://localhost:8300/apis/default/portal as base URI.`
1676 Note that the `default` component can be changed to the name of the site when using OpenEMR's multisite feature.
1678 _Example:_ `http://localhost:8300/apis/default/portal/patient` returns a resource of the patient.
1680 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.
1682 Request:
1684 ```sh
1685 curl -X GET 'http://localhost:8300/apis/default/portal/patient' \
1686   -H 'Authorization: Bearer eyJ0b2tlbiI6IjAwNmZ4TWpsNWhsZmNPelZicXBEdEZVUlNPQUY5KzdzR1Jjejc4WGZyeGFjUjY2QlhaaEs4eThkU3cxbTd5VXFBeTVyeEZpck9mVzBQNWc5dUlidERLZ0trUElCME5wRDVtTVk5bE9WaE5DTHF5RnRnT0Q0OHVuaHRvbXZ6OTEyNmZGUmVPUllSYVJORGoyZTkzTDA5OWZSb0ZRVGViTUtWUFd4ZW5cL1piSzhIWFpJZUxsV3VNcUdjQXR5dmlLQXRXNDAiLCJzaXRlX2lkIjoiZGVmYXVsdCIsImFwaSI6Im9lbXIifQ=='
1689 #### GET /portal/patient
1691 Request:
1693 ```sh
1694 curl -X GET 'http://localhost:8300/apis/default/portal/patient'
1697 Response:
1699 ```json
1701     "validationErrors": [],
1702     "internalErrors": [],
1703     "data": {
1704         "id": "193",
1705         "pid": "1",
1706         "pubpid": "",
1707         "title": "Mr",
1708         "fname": "Baz",
1709         "mname": "",
1710         "lname": "Bop",
1711         "ss": "",
1712         "street": "456 Tree Lane",
1713         "postal_code": "08642",
1714         "city": "FooTown",
1715         "state": "FL",
1716         "county": "",
1717         "country_code": "US",
1718         "drivers_license": "",
1719         "contact_relationship": "",
1720         "phone_contact": "123-456-7890",
1721         "phone_home": "",
1722         "phone_biz": "",
1723         "phone_cell": "",
1724         "email": "",
1725         "DOB": "1992-02-03",
1726         "sex": "Male",
1727         "race": "",
1728         "ethnicity": "",
1729         "status": ""
1730     }
1734 ### Dev Notes
1736 -   For business logic, make or use the services [here](src/Services)
1737 -   For controller logic, make or use the classes [here](src/RestControllers)
1738 -   For routing declarations, use the class [here](_rest_routes.inc.php).