Departments

A complete guide to the Departments module — creating and managing clinic departments, assigning department heads, budgets, and linking staff, patients, and services.

Written By Dev010

Last updated 19 days ago

The Departments module organizes your clinic into distinct operational units. Departments act as a grouping layer across the platform — patients, services, staff, expenses, and lab tests can all be assigned to a department, giving you structured visibility into how each part of your clinic operates.

Accessing the Module

Sidebar → Departments

Direct URL:

https://yourdomain.com/dashboard/departments

Who can access:

Action

Admin

Doctor

Receptionist

Nurse

View departments

Create department

Edit department

Delete department

Only Admin accounts can create, edit, or delete departments. All other roles have view-only access.

Departments List

The main departments page shows a complete list of all clinic departments.

Each row displays:

  • Department name

  • Department code

  • Head of department

  • Location

  • Phone

  • Status badge (active / inactive)

  • Budget

  • Action buttons (edit, delete)

Creating a Department

Click the Add Department button on the departments list page. A dialog opens with the department creation form.

Required Fields

Field

Notes

Name

Department name — must be unique (e.g. General Medicine, Dental, Radiology)

Optional Fields

Identity:

Field

Notes

Code

Short department identifier (e.g. GEN, DENT, RAD) — useful for reports and references

Description

Brief description of the department's function

Location and Contact:

Field

Notes

Location

Room, floor, or wing (e.g. Floor 2, Wing B)

Phone

Department direct line

Email

Department contact email

Leadership:

Field

Notes

Head of Department

Free text name of the department head

Head ID

Optional — link to a user account in the system

Financial:

Field

Notes

Annual Budget

Total annual budget allocated to this department

Budget

Current period budget (can differ from annual)

Status:

Field

Notes

Active

Toggle — inactive departments are preserved but hidden from active dropdowns

Status

Text status field — active or inactive

Saving the Department

Click Save to create the department. It appears immediately in the departments list and becomes available as a department option across the platform — in patients, services, staff, expenses, and lab test categories.

Department names must be unique. Attempting to create two departments with the same name will return a validation error.

Editing a Department

Click the Edit button on any department row. The edit form opens with all existing values pre-filled.

Update any fields and click Save. Changes take effect immediately across all linked records.

Changing a department name updates the name everywhere it is displayed across the platform since all references use the department ID (UUID), not the name string.

Department Head Assignment

The department head can be recorded in two ways:

Option A — Free text (Head of Department): Enter the department head's name as plain text. This is a simple label with no system link.

Option B — Linked user (Head ID): Link the department head to an actual user account in the system by selecting from the users list.

Linking to a user account creates a formal FK relationship (departments.head_id → users.id) that can be used in reporting queries to identify which staff member leads each department.

Both fields can be used simultaneously — the free text name for display and the user ID for system queries. If the linked user is deleted, head_id is set to null automatically (ON DELETE SET NULL).

Budget Tracking

Each department has two budget fields:

Field

Purpose

annual_budget

Total budget allocated for the year

budget

Current period or operational budget

These are informational fields — CareNova does not automatically enforce spending limits against the budget values. They are used for reference and can be compared against actual expenses using the Expenses module.

Comparing Budget vs Actual Spend

To see how a department's actual expenses compare to its budget:

  1. Sidebar → Expenses

  2. Filter expenses by department

  3. Sum the expense amounts for the period

  4. Compare against the department's budget value in the Departments list

A future version of CareNova may include automatic budget vs expense reporting at the department level. For now this comparison is done manually.

Deactivating a Department

If a department is being closed or restructured but has existing records linked to it, deactivate it rather than deleting it.

Edit the department → toggle Active to off → Save.

Deactivated departments:

  • Are hidden from assignment dropdowns across the platform

  • Preserve all historical links to patients, services, staff, and expenses

  • Can be reactivated at any time

Deleting a Department

Click the Delete option from the department row action menu.

A confirmation dialog appears before deletion.

⚠️ Deleting a department sets department_id to null on all linked records — patients, services, staff, expenses, users, and test categories (ON DELETE SET NULL). The linked records themselves are preserved but lose the department reference. Deactivate instead of delete when historical records exist.

Department Dependencies

Departments are referenced across many modules. Before deleting or restructuring a department, be aware of what is linked to it:

Module

How Department Is Used

Patients

Patients can be assigned to a department

Services

Services can be assigned to a department

Staff

Staff members belong to a department

Users

User accounts can have a department

Expenses

Expenses are categorized by department

Test Categories

Lab test categories can link to a department

Departments

Head of department links to a user

Database Schema Reference

departments

Column

Type

Description

id

uuid

Unique department ID

name

text

Department name — unique

description

text

Department description

head_id

uuid

FK → users (set null on delete)

head_of_department

text

Free text department head name

code

varchar

Short department code

location

text

Physical location

phone

varchar

Contact phone

email

varchar

Contact email

budget

numeric

Current period budget

annual_budget

numeric

Annual budget

is_active

integer

1 = active, 0 = inactive

status

text

active / inactive

created_at

timestamptz

Creation timestamp

updated_at

timestamptz

Last updated timestamp

Relationship to Other Modules

Module

Relationship

Patients

Optional department assignment per patient

Services

Optional department assignment per service

Staff

Staff members assigned to a department

Users

User accounts optionally linked to a department

Expenses

Expenses tracked per department

Test Categories

Lab categories linked to a department

Workflow Examples

Setting up departments for a new multi-specialty clinic:

  1. Sidebar → Departments → Add Department

  2. Create: General Medicine

    • Code: GEN

    • Location: Floor 1

    • Annual Budget: 50,000

  3. Create: Dental

    • Code: DENT

    • Location: Floor 2

    • Annual Budget: 75,000

  4. Create: Radiology

    • Code: RAD

    • Location: Basement

    • Annual Budget: 40,000

  5. Create: Laboratory

    • Code: LAB

    • Location: Floor 1, Wing B

    • Annual Budget: 30,000

  6. Departments are now available for assignment across patients, services, and staff

Assigning a department head:

  1. Sidebar → Departments

  2. Find the department → Edit

  3. In Head of Department — enter the doctor's name

  4. In Head ID — select the doctor's user account

  5. Save — department head is now formally recorded

Reviewing department expenses against budget:

  1. Note the department's budget from the departments list

  2. Sidebar → Expenses

  3. Filter by the department

  4. Review total expenses for the current period

  5. Compare against budget to assess spending

Restructuring — merging two departments:

  1. Reassign all staff from the old department to the new one via Sidebar → Staff

  2. Reassign all patients via Sidebar → Patients

  3. Update services via Sidebar → Services

  4. Deactivate the old department — do not delete if historical expenses exist

Troubleshooting

Department name already exists error:

  • Department names must be unique across the system

  • Check the existing departments list for a duplicate name

  • Use a more specific name (e.g. "Dental - Pediatric" instead of "Dental")

Department not appearing in patient or service dropdowns:

  • Confirm the department is set to Active

  • Hard refresh the browser after activating a department

Cannot create or edit departments:

  • Department management is restricted to Admin role only

  • Doctor, Receptionist, and Nurse accounts have view-only access

Head ID dropdown is empty:

  • No user accounts exist in the system yet — create user accounts first via the signup flow or manually in Supabase

  • Confirm users have approved_at set — pending users may not appear in the dropdown

Deleting department causes missing department on records:

  • This is expected behavior — ON DELETE SET NULL removes the department reference from linked records when a department is deleted

  • Always deactivate rather than delete departments that have historical records attached

Next Step

Continue to the Inventory module guide to learn how to manage medical supplies, track stock levels, and handle low stock alerts in CareNova.