Department API
The Department API is used to create and view hospital departments.
Backend folder:
app/departments/
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /department/ | Create department |
| GET | /department/ | Get all departments |
| GET | /department/{item_id} | Get department by ID |
Create Department
POST /department/
Creates a new hospital department.
Request Body
{
"name": "Cardiology",
"code": "CARD",
"description": "Department for heart-related treatment and diagnosis",
"icon_codes": [
"heart-pulse",
"stethoscope"
]
}
Field Notes
| Field | Type | Description |
|---|---|---|
name | string | Department name |
code | string | Short unique department code |
description | string | Short description of the department |
icon_codes | array | List of icon codes used to represent the department |
Response Example
{
"id": "2a3a24f6-fb3a-44e6-a84d-3cbe7f72a111",
"name": "Cardiology",
"code": "CARD",
"description": "Department for heart-related treatment and diagnosis",
"icon_codes": [
"heart-pulse",
"stethoscope"
]
}
Get All Departments
GET /department/
Returns all hospital departments.
Response Example
[
{
"id": "2a3a24f6-fb3a-44e6-a84d-3cbe7f72a111",
"name": "Cardiology",
"code": "CARD",
"description": "Department for heart-related treatment and diagnosis",
"icon_codes": [
"heart-pulse",
"stethoscope"
]
}
]
Get Department By ID
GET /department/{item_id}
Returns one department by UUID.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
item_id | UUID | Department ID |
Example Request
GET /department/2a3a24f6-fb3a-44e6-a84d-3cbe7f72a111
Response Example
{
"id": "2a3a24f6-fb3a-44e6-a84d-3cbe7f72a111",
"name": "Cardiology",
"code": "CARD",
"description": "Department for heart-related treatment and diagnosis",
"icon_codes": [
"heart-pulse",
"stethoscope"
]
}
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | Request successful |
| 201 | Department created successfully |
| 400 | Invalid request data |
| 401 | Not authenticated |
| 403 | Permission denied |
| 404 | Department not found |
| 422 | Validation error |