Developer docs

Organizations and clinics

An organization groups sub-organizations and clinics. A clinic is where patients, providers and orders live. Both are managed with the same endpoints.

How they fit together

  • There are two kinds: organization and clinic. The kind field says which one an item is.
  • An organization can contain sub-organizations and clinics, to any depth. A clinic contains nothing: it holds the patients, providers and orders.
  • parentId is the organization above (or null for the top), and level is how deep the item is (0 at the top).
  • A person who works in an organization can see and work in everything beneath it. Reading from an organization combines the data of all the clinics beneath it; to write, choose one clinic (see Choosing a clinic).
  • Owners and admins of an organization can create clinics beneath it. Creating an organization needs a permission, canCreateOrganizations, that only a super admin can give. A super admin can always create organizations.

The clinic object

Fields of an organization or clinic
FieldTypeDescription
idstringThe id.
namestringThe display name.
kindstringorganization or clinic.
parentIdstring or nullThe organization above this one.
levelintegerDepth in the tree. 0 is the top.
statusstringapproved, or pending for a clinic that registered itself and awaits approval.
organizationstringA free-text organization name, set at registration.
city, state, address, addressLine2, zipstringThe address. state is two letters.
timezonestringA time zone name. Defaults to America/New_York.
legalName, taxId, description, tagline, website, phone, email, supportEmailstringProfile details. Only fields that are set appear.
logoUrl, iconUrl, brandColor, accentColorstringBranding. The colours are #rrggbb.

List organizations and clinics

GET/v1/clinics

Returns everything you can see, as a tree: parents come before their children and siblings are sorted by name. A person sees the organizations and clinics they belong to and everything beneath them; a super admin sees everything. The full list adds owners and counts; ?brief=1 returns names and the tree only and is much cheaper, so use it for pickers.

Who can call it

Any signed-in role.

Query parameters

NameTypeDescription
briefstringSend 1 for names and the tree only (no owners or counts).

Response

200 A list of items. In the full list each item adds owners (people with the owner or admin role), subOrganizations (how many organizations are directly beneath it) and counts (patients, providers and orders30, the orders of the last 30 days in the chosen environment).

Example response
{
  "data": [
    {
      "id": "6aeb0da3503a52507f605e76",
      "name": "HomelyMd",
      "kind": "clinic",
      "organization": "Ola Digital Health",
      "city": "Tampa",
      "state": "FL",
      "address": "10575 Bloomingdale Ridge Dr, Riverview, FL 33578",
      "timezone": "America/New_York",
      "status": "approved",
      "parentId": null,
      "level": 0,
      "owners": [
        { "id": "6afe9b3c3a44248dcd845972", "name": "Rohit Suthar", "email": "[email protected]", "role": "owner", "canCreateOrganizations": false }
      ],
      "subOrganizations": 0,
      "counts": { "patients": 9, "providers": 1, "orders30": 14 }
    }
  ]
}

Errors

StatusCodeWhen it happens
401unauthenticatedThere is no session.

Examples

curl
curl -b cookies.txt "https://app-api.homelyrx.com/v1/clinics?brief=1"

Get one organization or clinic

GET/v1/clinics/:id

Returns one item you are allowed to see.

Who can call it

Any signed-in role.

Response

200 The item, with the fields above.

Example response
{
  "id": "6b0430e6cc8f4730ebbf8a8c",
  "name": "Docs Example Org",
  "kind": "organization",
  "city": "Tampa",
  "state": "FL",
  "timezone": "America/New_York",
  "status": "approved",
  "parentId": null,
  "level": 0
}

Errors

StatusCodeWhen it happens
400validationThe id is not a valid id.
404notFoundThe item does not exist or is outside what you can see.

Examples

curl
curl -b cookies.txt "https://app-api.homelyrx.com/v1/clinics/ORG_ID"

Create an organization or clinic

POST/v1/clinics

Creates an organization or a clinic. A super admin can create one anywhere, or at the top when parentId is left out. Everyone else creates beneath the organization they are working in, or beneath parentId if you give one they can see. You can hand it to a person in the same call: with owner a new owner account is made, or, when that email already has an account, the new item is added to theirs.

Who can call it

super_admin, owner, admin. Creating an organization also needs the canCreateOrganizations permission (a super admin always has it).

Request body

NameTypeRequiredDescription
namestringRequiredAt least 2 characters.
kindstringOptionalorganization or clinic. Defaults to clinic.
parentIdstringOptionalThe organization to create it under. It must be an organization you can see.
city, state, address, timezone, organizationstringOptionalOptional details. state is exactly 2 letters.
ownerobjectOptionalHands the new item to a person. Fields: name (at least 2 characters, required), email (required), password (at least 12 characters, required unless the email already has an account) and canCreateOrganizations (boolean, super admin only).

Response

201 The new item.

Example response
{
  "id": "6b0430e6cc8f4730ebbf8a8c",
  "name": "Docs Example Org",
  "kind": "organization",
  "city": "Tampa",
  "state": "FL",
  "timezone": "America/New_York",
  "status": "approved",
  "parentId": null,
  "level": 0
}

Errors

StatusCodeWhen it happens
400validationA field is invalid.
400passwordRequiredowner is a new person but has no password.
400parentMustBeOrganizationparentId is a clinic.
403forbiddenYour role cannot create, or you may not create organizations.
404notFoundparentId is not something you can see.
409emailTakenThe owner's email belongs to a super admin.

Examples

curl
curl -b cookies.txt -X POST "https://app-api.homelyrx.com/v1/clinics" \
  -H "content-type: application/json" \
  -d '{"name":"Docs Example Org","kind":"organization","city":"Tampa","state":"FL","owner":{"name":"Docs Owner","email":"[email protected]","password":"a-long-password-123"}}'

Update an organization or clinic

PATCH/v1/clinics/:id

Changes the profile of an item you can see. Send only the fields you want to change. Sending an empty string clears a field (except name). Unknown fields are rejected.

Who can call it

super_admin, owner, admin.

Request body

NameTypeRequiredDescription
namestringOptional2 to 120 characters.
legalName, organization, taglinestringOptionalText up to 200 characters (tagline 160).
taxIdstringOptionalUp to 40 characters.
descriptionstringOptionalUp to 1000 characters.
timezonestringOptionalA time zone name.
logoUrl, iconUrl, websitestringOptionalA full link starting with https://.
brandColor, accentColorstringOptionalA colour like #4a1470.
email, supportEmailstringOptionalA valid email address.
phone, address, addressLine2, city, zipstringOptionalText.
statestringOptionalExactly 2 letters; stored in capitals.

Response

200 The updated item.

Example response
{
  "id": "6b0430e6cc8f4730ebbf8a8c",
  "name": "Docs Example Org",
  "kind": "organization",
  "city": "Tampa",
  "state": "FL",
  "timezone": "America/New_York",
  "status": "approved",
  "parentId": null,
  "level": 0
}

Errors

StatusCodeWhen it happens
400validationA field is invalid, or the body contains a field that cannot be changed.
403forbiddenYour role cannot edit.
404notFoundThe item is not something you can see.

Examples

curl
curl -b cookies.txt -X PATCH "https://app-api.homelyrx.com/v1/clinics/ORG_ID" \
  -H "content-type: application/json" \
  -d '{"tagline":"Care at home","brandColor":"#4a1470","website":"https://example.com"}'

Allow someone to create organizations

PATCH/v1/clinics/:id/members/:userId

Switches the canCreateOrganizations permission on or off for an owner or admin who works in the organization.

Who can call it

super_admin only.

Request body

NameTypeRequiredDescription
canCreateOrganizationsbooleanRequiredtrue to allow, false to withdraw.

Response

200 The person and their permission.

Example response
{ "data": { "id": "6b0430e6cc8f4730ebbf8a8e", "canCreateOrganizations": true } }

Errors

StatusCodeWhen it happens
400validationThe body is not exactly canCreateOrganizations as a boolean.
403forbiddenYou are not a super admin.
404notFoundNo owner or admin with this id works in this organization.

Examples

curl
curl -b cookies.txt -X PATCH "https://app-api.homelyrx.com/v1/clinics/ORG_ID/members/USER_ID" \
  -H "content-type: application/json" \
  -d '{"canCreateOrganizations":true}'