Use the api_get_company_json function to get a list of healthcare organizations (HCOs) in JSON format. The list includes HCOs with at least one call, for any period.
Note: The API doesn't return the list right away. The first request only starts a job on the server and returns its number (job_id). To get the list, you send two more requests: one to check that the job is finished, and one to download the result. The HCO list is usually large, so the result comes in several parts (batches).
How it works
| Step | Request | What you get |
|---|---|---|
| 1 | POST /crm-api/db-function/run |
The job number: {"job_id": 115668}
|
| 2 | GET /crm-api/db-function/status/{job_id} |
The job status and the number of batches. Wait for "status": 3 (finished). |
| 3 | GET /crm-api/db-function/result/{job_id}?batch=1 |
Up to 500 HCOs as a JSON array. Repeat for each batch. |
Before you start
- Get a token. See Authentication (Login).
- Add the token to every request in this article:
Authorization: Bearer <token>. - Replace
yourdomainin the URLs with your company's Proxima Cloud CRM domain.
Step 1. Start the job
POST https://yourdomain.pharmahrm.com/crm-api/db-function/run
Headers
| Header | Value |
|---|---|
Authorization |
Bearer <token> |
Content-Type |
application/json |
Body: all HCOs
{
"function": "api_get_company_json",
"format": "json"
}Body: only some HCOs
To get only specific HCOs, add their IDs in arguments:
{
"function": "api_get_company_json",
"format": "json",
"arguments": {
"ids": "4298,12628,15275"
}
}Note: ids is a filter. If you copy an example with ids, you get only those HCOs. To get all HCOs, leave out arguments.
| Field | Type | Required | Description |
|---|---|---|---|
function |
string | Yes | Always api_get_company_json. |
format |
string | Yes | Always json. To get the list as a CSV table, see Get a list of HCOs (CSV). |
arguments |
object | No | Filters. Leave it out to get all HCOs. |
arguments.ids |
string | No | HCO IDs (company_id), separated by commas, for example "4298,12628". |
Response
{
"job_id": 115668
}Save the job_id. You need it in steps 2 and 3.
Step 2. Check the job status
GET https://yourdomain.pharmahrm.com/crm-api/db-function/status/115668
Replace 115668 with your job_id. The request has no body.
Response
{
"id": 115668,
"status": 3,
"batch_count": 21
}| Field | Description |
|---|---|
id |
The job number. |
status |
1: Pending. 2: Running. Wait a few seconds and check again.3: Finished. Go to step 3.4: Error. Start a new job. If it fails again, contact technical support. |
batch_count |
How many batches the result has. One batch holds up to 500 HCOs. In this example, there are 21 batches, so the list has up to 10,500 HCOs. |
For details, see Get Data Generation Job Status.
Step 3. Get the list of HCOs
GET https://yourdomain.pharmahrm.com/crm-api/db-function/result/115668?batch=1
Replace 115668 with your job_id. The request has no body.
| Parameter | Type | Required | Description |
|---|---|---|---|
batch |
integer | Yes | The batch number, from 1 to batch_count. |
Get all batches
Each request returns one batch. To get the whole list, send the request once for each batch number and join the arrays. For example, if batch_count is 21, send 21 requests: batch=1, batch=2, …, batch=21.
In Postman, change the batch number and click Send for each batch.
To get all batches automatically, you can use a script. For example, in a terminal (bash):
TOKEN="your_token"
JOB_ID=115668
BATCH_COUNT=21
for i in $(seq 1 $BATCH_COUNT); do
curl -s "https://yourdomain.pharmahrm.com/crm-api/db-function/result/$JOB_ID?batch=$i" \
-H "Authorization: Bearer $TOKEN" \
-o "hcos_batch_$i.json"
doneThe script saves each batch to a separate file: hcos_batch_1.json, hcos_batch_2.json and so on.
Response
Each batch is a JSON array. Each object is one HCO:
[
{
"isarchive": null,
"company_id": 4298,
"company_city": "Київ",
"company_code": "12345678",
"company_main": "HEALTH GROUP LLC",
"company_name": "Pharmacy No. 6 HEALTH GROUP LLC",
"company_type": "Аптека",
"company_categ": null,
"company_phone": "Стаціон. (робочий): 0441234567, 0447654321",
"company_center": null,
"company_isshop": 1,
"company_region": "Київ та район",
"company_address": "Лісовий 25",
"company_country": "Україна",
"company_gps_lat": "50.482610",
"company_gps_lng": "30.631834",
"company_morionid": 370932,
"company_categ_by_direction": ["OTC_UA -C", "RX_UA -B"]
},
{
"isarchive": "Does not work",
"company_id": 691054,
"company_city": "Cape Town",
"company_code": null,
"company_main": null,
"company_name": "City Clinic",
"company_type": "Hospital institutions",
"company_categ": null,
"company_phone": "",
"company_center": null,
"company_isshop": 0,
"company_region": "Western Cape",
"company_address": "29 Main Street",
"company_country": "South Africa",
"company_gps_lat": null,
"company_gps_lng": null,
"company_morionid": null,
"company_categ_by_direction": null
}
]Note: Postman may show the result as HTML on one long line. To make it readable, above the response, change HTML to JSON.
For details, see Get Data Generation Job Result.
Fields
| Field | Type | Description |
|---|---|---|
company_id |
integer | The HCO ID in Proxima Cloud CRM. Use it in the ids filter. |
company_name |
string | The HCO name. |
company_type |
string | The HCO type, for example a pharmacy or a hospital. Shown in the CRM language. |
company_main |
string or null | The name of the main (parent) HCO. |
company_center |
string or null | The name of the related center. Usually empty. |
company_code |
string or null | The tax ID of the legal entity. |
company_isshop |
integer |
1: a retail point (for example, a pharmacy). 0: not a retail point. |
company_categ |
string or null | The general category of the HCO. |
company_categ_by_direction |
array of strings or null | Categories by product direction. Each value is the direction and the category, for example "RX_UA -B": direction RX_UA, category B. |
company_country |
string or null | The country. |
company_region |
string | The region. |
company_city |
string | The city. |
company_address |
string or null | The street and building number. |
company_gps_lat |
string or null | The latitude, as text, for example "50.482610". |
company_gps_lng |
string or null | The longitude, as text, for example "30.631834". |
company_phone |
string | Phone numbers with their types, separated by commas. An empty string ("") means there are no phone numbers. Very long lists may be cut off. |
company_morionid |
integer or null | The HCO ID in the Axioma database. |
isarchive |
string or null |
null: the HCO is active. Text: the HCO is archived, and the text is the reason, for example "Does not work". Shown in the CRM language. |
null means the field has no value. Some values, such as type, region and archive reason, are in the CRM language.
Errors
If a request fails, the server returns a 4xx or 5xx status code with a message:
{
"message": "Error message"
}| Problem | What to do |
|---|---|
| 401 Unauthorized | The token is missing or expired. Get a new token. See Authentication (Login). |
| Fewer HCOs than expected | Check whether you got all batches, from 1 to batch_count. Also check whether the request body has an ids filter. |
| Step 3 returns an error | The job may not be finished yet, or the batch number is larger than batch_count. Check the status (step 2). |
| 5xx | A server error. Try again later. If it repeats, contact technical support. |