Use the api_get_company function to get a list of healthcare organizations (HCOs) as a CSV table. 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.
How it works
| Step | Request | What you get |
|---|---|---|
| 1 | POST /crm-api/db-function/run |
The job number: {"job_id": 115669}
|
| 2 | GET /crm-api/db-function/status/{job_id} |
The job status. Wait for "status": 3 (finished). |
| 3 | GET /crm-api/db-function/result/{job_id} |
The list of HCOs as CSV text, all in one response. |
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",
"format": "csv"
}Body: only some HCOs
To get only specific HCOs, add their IDs in arguments:
{
"function": "api_get_company",
"format": "csv",
"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. |
format |
string | Yes | Always csv. To get the list as JSON, see Get a list of HCOs (JSON). |
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": 115669
}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/115669
Replace 115669 with your job_id. The request has no body.
Response
{
"id": 115669,
"status": 3,
"batch_count": null
}| status | Meaning | What to do |
|---|---|---|
1 |
Pending | The job is in the queue. Wait a few seconds and check again. |
2 |
Running | The job is in progress. Wait a few seconds and check again. |
3 |
Finished | Go to step 3. |
4 |
Error | The job failed. Start a new job (step 1). If it fails again, contact technical support. |
For CSV jobs, batch_count is always null. The whole list comes in one response. 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/115669
Replace 115669 with your job_id. The request has no body.
Note: The HCO list can be large. For example, a list of about 10,000 HCOs is about 2.6 MB and can take several seconds to download.
Response
The list comes as plain CSV text. The first line has the column names. Each next line is one HCO.
company_name,company_type,company_address,company_categ,company_categ_by_direction,company_code,company_chain,company_main,isarchive,company_isshop,company_morionid,company_region,company_city,company_phone,company_gps_lat,company_gps_lng,company_country,company_id Pharmacy No. 6 HEALTH GROUP LLC,Аптека,Лісовий 25,,"OTC_UA -C,RX_UA -B",12345678,HEALTH GROUP LLC,HEALTH GROUP LLC,,1,370932,Київ та район,Київ,"Стаціон. (робочий): 0441234567, 0447654321",50.482610,30.631834,Україна,4298 City Clinic,Hospital institutions,29 Main Street,,,,,,Does not work,0,,Western Cape,Cape Town,"",,,South Africa,691054
How to read it:
- Values are separated by commas.
- Two commas in a row (
,,) mean an empty field. For example,City Clinichas no tax ID, chain or GPS coordinates. - Values in quotes can contain commas. For example,
"OTC_UA -C,RX_UA -B"is one field with two categories. - Some values, such as type, region and archive reason, are in the CRM language.
For details, see Get Data Generation Job Result.
Open the list as a table
CSV text is hard to read in Postman. To view it as a table:
- In Postman, above the response, click Save Response and then Save to a file.
- Save the file with the
.csvextension, for examplehcos.csv. - In Excel, go to Data > From Text/CSV, select the file, set File Origin to 65001: Unicode (UTF-8) and Delimiter to Comma, and then click Load.
Note: If you open the file with a double-click, Excel may show Cyrillic text as unreadable characters. Use From Text/CSV with UTF-8 instead.
Fields
The columns come in this order:
| Field | Description |
|---|---|
company_name |
The HCO name. |
company_type |
The HCO type, for example a pharmacy or a hospital. |
company_address |
The street and building number. |
company_categ |
The general category of the HCO. |
company_categ_by_direction |
Categories by product direction, in one quoted field. Each value is the direction and the category, for example RX_UA -B: direction RX_UA, category B. |
company_code |
The tax ID of the legal entity. |
company_chain |
The pharmacy or medical chain the HCO belongs to. |
company_main |
The name of the main (parent) HCO. |
isarchive |
Empty: the HCO is active. Text: the HCO is archived, and the text is the reason, for example Does not work. |
company_isshop |
1: a retail point (for example, a pharmacy). 0: not a retail point. |
company_morionid |
The HCO ID in the Axioma database. |
company_region |
The region. |
company_city |
The city. |
company_phone |
Phone numbers with their types, in one quoted field. "" means there are no phone numbers. Very long lists may be cut off. |
company_gps_lat |
The latitude, for example 50.482610. |
company_gps_lng |
The longitude, for example 30.631834. |
company_country |
The country. |
company_id |
The HCO ID in Proxima Cloud CRM. Use it in the ids filter. |
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 the request body has an ids filter. Remove arguments to get all HCOs. |
| Step 3 returns an error | The job may not be finished yet. Check the status (step 2) and wait for "status": 3. |
| 5xx | A server error. Try again later. If it repeats, contact technical support. |