Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 95 additions & 47 deletions versioned_docs/version-3.1/concepts/facility/facility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,106 @@ sidebar_position: 1

# Facility

A **facility** in Care is a single care site — a hospital, clinic, lab, or telemedicine endpoint — and the boundary that everything inside a deployment is scoped to. Patients are registered, staff are organized, locations and devices are added, and billing is configured all within one facility.

## What it represents

In Care's FHIR-aligned model, a facility maps to the **Organization** resource, specialized as a physical or virtual care site. It captures:

- **Identity** — a name, description, and a facility type (Private Hospital, Primary Health Centres, Govt Labs, TeleMedicine, and many more)
- **Place** — address, pincode, latitude/longitude, and a contact number
- **Capabilities** — what the site can offer, such as CT Scan, Maternity Care, X-Ray, Neonatal Care, Operation Theater, or Blood Bank
- **Geographic placement** — the government/administrative region it sits under, which is how deployments roll facilities up into districts and states
- **Billing** — its own discount codes, tax components, and invoice-number format

A facility is not a department or a ward — those are [locations](../../references/facility/location.mdx) and [facility organizations](../access-governance/facility-organization.mdx) *within* it. The facility is the outer container; the same [patient](../clinical/patient) can be seen across many facilities while remaining one person, but staff roles, inventory, and invoices never cross the facility line.

## Lifecycle

A facility comes with its administrative scaffolding pre-built — you never assemble the hierarchy by hand.

```text
Create → Administration org provisioned → Active → (soft) Deleted
```

- **Create** — the record is created with its name, type, address, and the geographic region it belongs under
- **Administration org provisioned** — Care automatically creates a root `Administration` organization inside the facility and grants the creator the Facility Admin role over it, so the site has a working tree from day one
- **Active** — patients are registered, staff are assigned, locations and devices are added, and encounters happen
- **Deleted** — removal is a soft delete; the facility and its child organizations are kept for history and audit, never erased

## How it connects

The facility is the hub most other primitives hang off of:

- **People** — staff gain access through the facility's organizations; every role and permission is scoped to a facility
- **Places & equipment** — [locations](../../references/facility/location.mdx) (wards, beds, rooms), [healthcare services](../../references/facility/healthcare-service.mdx), and [devices](../../references/facility/device.mdx) are registered under it
- **Care delivery** — [encounters](../clinical/encounter.mdx) take place at a facility, anchoring where care was given
- **Geography** — each facility sits under a geographic [organization](../access-governance/organization.mdx), the bridge that connects it to the wider administrative map
- **Billing** — discounts, taxes, and invoice numbering are set per facility (see [Facility config](../../references/facility/facility-config.mdx))
## Definition

A **facility** in Care is a hospital, clinic, health center, or other place that provides care to patients. . The facility is the top-level unit that holds departments, users, patients, and encounters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues on this line. There is a stray double period: to patients. . The facility. Also, per the concept skill the page opens with the H1 followed directly by a 1–2 sentence definition and then ## What it represents — a ## Definition heading is not part of the structure. Suggested: delete the ## Definition heading and fix to ...that provides care to patients. The facility is the top-level unit....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two problems on this line. There is a stray double period: provides care to patients. . The facility. Also, the concept skill's structure is # <Title> followed directly by the 1–2 sentence definition, then ## What it represents — a ## Definition heading is not part of it. Suggested: delete the ## Definition heading and write A **facility** in Care is a hospital, clinic, health center, or other place that provides care to patients.


## Key Attributes

| Components | What it captures |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ## Key Attributes field table is reference-layer content. The concept skill says a concept is "not a technical reference: do not dump fields, types, or API schemas (that is the reference layer's job)", and the required section here is ## What it represents — FHIR resource, categorised bullets, and one clarifying insight. Please move the field table to references/facility/facility.mdx and restore the conceptual sections.

| --- | --- |
| Facility Name | The name of the facility. This is required. |
| Description | A description of the facility. This is optional, and it supports formatted text. |
| Facility Type | The kind of facility. This is required. |
| Features | The services or capabilities available at the facility. This is optional, and you can choose any number of them. |
| Phone Number | The contact number of the facility. This is required. |
| Address | The street address of the facility. This is required. |
| PIN Code | The 6-digit postal code of the facility. This is required. |
| Geo Organization | The government administrative area that the facility belongs to. This is required. |
| Latitude | The map coordinate of the facility from north to south. This is optional. |
| Longitude | The map coordinate of the facility from west to east. This is optional. |
| Make this facility public | Whether the facility appears in the public facility directory. This is optional. |
| Cover Photo | An image that Care shows on the page of the facility. This is optional. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## Key Attributes is a field table — that is reference-layer content (references/facility/facility.mdx), not a concept. The concept skill asks for ## What it represents with categorised bullets plus one clarifying insight, not a field-by-field required/optional table. Suggest replacing this table with prose and linking the reference for the field detail.


{/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This large {/* ... */} block (lines 28–86) is commented-out content shipped into the published page. Per the conventions, pages carry no leftover placeholders or template comments. Either restore Facility Type / Features / Geo Organization as real sections, or delete the block.


### Facility Type

Facility Type records the kind of facility. Select one of these values:

- Educational Inst
- Private Hospital
- Other
- Hostel
- Hotel
- Lodge
- TeleMedicine
- Govt Labs
- Private Labs
- Primary Health Centres
- Family Health Centres
- Community Health Centres
- Taluk Hospitals
- Women and Child Health Centres
- District Hospitals
- Govt Medical College Hospitals
- Co-operative hospitals
- Autonomous healthcare facility
- COVID-19 Domiciliary Care Center
- First Line Treatment Centre
- Second Line Treatment Center
- Shifting Centre
- Covid Management Center
- Request Approving Center
- Request Fulfilment Center
- District War Room
- Clinical Non Governmental Organization
- Non Clinical Non Governmental Organization
- Community Based Organization

### Features

Features record the services and capabilities that the facility gives to patients. Select any number of these values:

- CT Scan Facility
- Maternity Care
- X-Ray Facility
- Neonatal Care
- Operation Theater
- Blood Bank

### Geo Organization

Geo Organization records the government administrative area that the facility belongs to. Select a specific area. If the area you select still has sub-areas under it, select one of those sub-areas.

### Latitude and Longitude

Latitude and Longitude record the position of the facility on a map. You can type the coordinates. You can also select **Get Current Location**, and Care fills in the coordinates for you.

### Make this facility public

Select **Make this facility public** to show the facility in the public facility directory. Anyone can browse the public facility directory without a sign-in.
*/}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block is commented out with {/* ... */} — a large block of dead content in a merged doc is a leftover, not a deliberate section. Either restore it as real content (as ## Types / ## Features conceptual sections) or delete it. Leaving ~58 commented lines in the file is a hard finding.


## Permissions

Access to a facility is governed by a small set of permissions, granted to staff through their facility organization roles.

| Permission | Description | System Roles |
| --- | --- | --- |
| `can_create_facility` | Create a new facility | Administrator, Admin, Facility Admin |
| `can_update_facility` | Edit a facility's details and configuration, including its cover image, monetary config, and invoice expression | Facility Admin, Administrator, Admin, Staff |
| Permission | What it allows |
| --- | --- |
| Can Create on Facility | Create a new facility. |
| Can Update on Facility | Edit the details of a facility. |
| Can Create Facility Organizations | Create departments or teams in a facility. |
| Can Manage Facility Organizations | Rename or edit the departments or teams of a facility. |
| Can Delete Facility Organizations | Delete the departments or teams of a facility. |
| Can List Users in a Facility Organizations | See the users in a department of a facility. |
| Can Manage Users in a Facility Organization | Add a user to a department of a facility, remove a user from it, or change the role of a user in it. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Five of these seven rows are facility-organization permissions, not facility permissions. care/security/permissions/facility.py defines only can_create_facility, can_read_facility and can_update_facility. The org rows belong in the Facility organization concept; Can Read on Facility is missing here. The table also drops the System Roles column the concept skill requires.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table lists five facility-organization permissions that FacilityViewSet never checks. Per the concept skill, document what the viewset actually authorizes: care/emr/api/viewsets/facility.py checks only can_create_facility (create) and can_update_facility_obj (update, cover image, monetary config, invoice expression). The organization permissions belong on the facility-organization concept. The dropped System Roles column should also come back — the skill requires | Permission | Description | System Roles |.


Reading a facility is not gated by a dedicated permission — the list and retrieve endpoints return only the facilities a user can reach through their organization memberships. Deleting a facility is restricted to super admins.
Note: Only a system administrator can delete a facility. Deletion does not use one of the permissions above.

Permissions cascade down the organization tree: a role held at a parent organization applies to the facilities and sub-organizations beneath it.
Note: When you create a facility, Care creates a default Administration department for it. Care also adds you to that department as its Facility Admin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Lifecycle and How it connects sections were removed with no replacement, so the page no longer explains that a facility is the outer container versus locations and facility organizations, or that deletion is a soft delete. EMRModelViewSet.perform_destroy in ohcnetwork/care sets deleted = True, so line 100 plus "The action is permanent" in the delete flow both overstate what happens. Please restore a short lifecycle/connections section and say deletion hides the facility rather than erasing it.


## Related

- Reference: [Facility (technical)](../../references/facility/facility.mdx)
- Reference: [Facility config](../../references/facility/facility-config.mdx)
- Concept: [Organization](../access-governance/organization.mdx)
- Flow: [Create a facility](../../flows/facility/create-facility.mdx)
- Flow: [View a facility](../../flows/facility/view-facility.mdx)
- Flow: [Update facility details](../../flows/facility/update-facility-details.mdx)
- Flow: [Delete a facility](../../flows/facility/delete-facility.mdx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Related block lost every link the previous version carried: the technical reference (../../references/facility/facility.mdx), Facility config, and the Organization concept. The concept skill requires the matching reference link plus 2–4 related concepts; flows alone are not enough.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ## Related block now links only flows. The concept skill requires the technical reference plus 2–4 closely-related concepts; the removed links to ../../references/facility/facility.mdx, ../../references/facility/facility-config.mdx and ../access-governance/organization.mdx should be restored alongside the new flow links.

5 changes: 5 additions & 0 deletions versioned_docs/version-3.1/flows/facility/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Facility",
"position": 2,
"key": "facility-flows"
}
74 changes: 74 additions & 0 deletions versioned_docs/version-3.1/flows/facility/create-facility.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
sidebar_position: 1
---

# Create a facility

## Overview

This flow describes how to create a new [facility](../../concepts/facility/facility.mdx) in Care.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirroring gap (applies to this whole PR). The shared conventions keep version-3.0 and version-3.1 byte-identical. This PR touches only 3.1, so versioned_docs/version-3.0/flows/facility/ (all four flows plus _category_.json), the 3.0 facility concept, and the Facility category in versioned_sidebars/version-3.0-sidebars.json are all missing. Also note the double space in [facility](...) in Care.


## Pre-requisites

- You are signed in to Care.
- You can access the organization that the facility belongs to.
- You have the permission listed below.

## Permissions

| Permission | Access |
| --- | --- |
| Can Create on Facility | Lets you create a facility for an organization. |

## Steps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow section headings do not match the flow skill, which specifies :::info Prerequisite (linking the concept), ## Before you start (permission in plain words plus prior records), ## Steps, and ## After <the task> as a | Next step | When | table. This page uses ## Overview, ## Pre-requisites, ## Permissions and ## Expected Outcome. The same applies to the other three new flows — please align all four.


### 1. Open the organization

Open the organization that the facility belongs to. Go to its **Facilities** section.

### 2. Start a new facility

Select **Add Facility**. Care shows this option only if you have the permission listed above.

Care opens the **Add New Facility** form.

### 3. Fill in the Facility Information

| Components | What it captures |
| --- | --- |
| Facility Type (required) | The type of the facility. Choose one type from the list. |
| Facility Name (required) | The name of the facility. |
| Description (optional) | More details about the facility. This field supports formatted text. |
| Features (optional) | The capabilities of the facility. Choose any number of features. |
| Phone Number (required) | The contact number of the facility. |
| PIN Code (required) | The 6-digit PIN code of the facility. |
| Geo Organization (required) | The government administrative area of the facility. |
| Address (required) | The address of the facility. |
| Latitude (optional) | The latitude of the facility. |
| Longitude (optional) | The longitude of the facility. |

To fill latitude and longitude from your browser, select **Get Current Location**.

To show the facility in the public facility directory, select **Make this facility public**. Anyone can browse this directory without a sign-in.

### 4. Save the facility

Select **Create Facility**.

## Expected Outcome

- Care creates the facility for the organization.
- Care creates a default **Administration** department for the facility.
- Care adds you to the **Administration** department as its Facility Admin.

## Related

Concepts:

- [Facility](../../concepts/facility/facility.mdx)

Flows:

- [View a facility](./view-facility.mdx)
- [Update facility details](./update-facility-details.mdx)
- [Delete a facility](./delete-facility.mdx)
51 changes: 51 additions & 0 deletions versioned_docs/version-3.1/flows/facility/delete-facility.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
sidebar_position: 4
---

# Delete a facility

## Overview

This flow describes how a system administrator deletes a [facility](../../concepts/facility/facility.mdx) in Care.

## Pre-requisites

- The facility is registered in Care.
- You are a system administrator in Care.

## Permissions

| Permission | Access |
| --- | --- |
| Super Admin | Super admin access to the instance. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Super Admin" is not a permission — authorize_destroy in care/emr/api/viewsets/facility.py checks request.user.is_superuser directly, bypassing the permission system. A permission table with no permission in it is misleading. Suggested: drop the table and state in ## Before you start: "Only a super administrator of the instance can delete a facility. No role permission grants this."


## Steps

### 1. Open the facility settings

Open the facility. Select **Settings**. Select **General**.

### 2. Start the deletion

Go to the **Danger Zone** section. Select **Delete Facility**.

### 3. Confirm the facility name

Care asks you to type the facility name to confirm. Type the word Delete, then a space, then the facility name. Type the text exactly. Confirm the action.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe the confirmation with the real string rather than in the abstract. src/components/Facility/FacilityDeleteDialog.tsx sets confirmationText = \Delete ${facility.name}`. Suggested: "Type Delete ` exactly, then select Delete Facility."


## Expected Outcome

- Care removes the facility.
- The action is permanent. Care no longer shows the records of the facility.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is factually wrong. FacilityViewSet inherits perform_destroy from care/emr/api/viewsets/base.py, which sets instance.deleted = True — the delete is a soft delete, and the records are kept for history and audit. Suggested: "Care removes the facility from Care. Care keeps the records of the facility for history and audit."


## Related

Concepts:

- [Facility](../../concepts/facility/facility.mdx)

Flows:

- [Create a facility](./create-facility.mdx)
- [View a facility](./view-facility.mdx)
- [Update facility details](./update-facility-details.mdx)
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
sidebar_position: 3
---

# Update facility details

## Overview

This flow describes how to change the details and the cover photo of a [facility](../../concepts/facility/facility.mdx) in Care.

## Pre-requisites

- The facility is registered in Care, and you have access to it.
- You have the permissions listed below.

## Permissions

| Permission | Access |
| --- | --- |
| Can Update on Facility | Lets you change the details and the cover photo of the facility. |

## Steps

### 1. Open the facility settings

Open the facility. Select **Settings**. Select **General**.

### 2. Edit facility details

Select **Edit Facility Details**.

Care opens a form with the title **Edit Facility**. The form shows the current details of the facility.

### 3. Change the details

Change any of these fields:

| Components | What it captures |
| --- | --- |
| Facility Type | The type of the facility. |
| Facility Name | The name of the facility. |
| Description | A short description of the facility. |
| Features | The services that the facility gives. |
| Phone Number | The contact number of the facility. |
| PIN Code | The postal code of the facility. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 5 sends the reader back to a page they are already on and the wording is vague. Suggested, as a single instruction per sentence: "Go to Settings, then General. Select Edit Cover Photo. Upload the new image." Also, the flow skill uses | Field | Notes | for form-field tables; | Components | What it captures | is used across all four new flows and should be aligned.

| Geo Organization | The government administrative area of the facility. |
| Address | The address of the facility. |
| Latitude | The latitude of the facility location. |
| Longitude | The longitude of the facility location. |
| Make this facility public | Whether the facility appears in the public facility directory. |

### 4. Save the changes

Select **Update Facility**.

Note: Care keeps this button disabled until you change a field.

### 5. Change the cover photo

Go back to **Settings**, then **General**. Select **Edit Cover Photo**. Change the cover image of the facility.

## Expected Outcome

- Care saves the new details of the facility.
- Care shows the new details and the new cover photo on the facility page.

## Related

Concepts:

- [Facility](../../concepts/facility/facility.mdx)

Flows:

- [Create a facility](./create-facility.mdx)
- [View a facility](./view-facility.mdx)
- [Delete a facility](./delete-facility.mdx)
Loading
Loading