Skip to main content

Department API

The Department API is used to create and view hospital departments.

Backend folder:

app/departments/

Endpoints

MethodEndpointDescription
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

FieldTypeDescription
namestringDepartment name
codestringShort unique department code
descriptionstringShort description of the department
icon_codesarrayList 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

ParameterTypeDescription
item_idUUIDDepartment 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 CodeMeaning
200Request successful
201Department created successfully
400Invalid request data
401Not authenticated
403Permission denied
404Department not found
422Validation error