Patients API
The Patients API is used to create, view, update, and delete patient records.
Backend folder:
app/patient/
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /patient/ | Create patient |
| GET | /patient/ | Get all patients |
| GET | /patient/{id} | Get patient by ID |
| PUT | /patient/{id} | Update patient |
| DELETE | /patient/{id} | Delete patient |
| GET | /patient/reg_number/{reg_number} | Get patient by registration number |
Create Patient
POST /patient/
Creates a new patient record.
Request Body
{
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"alt_phone_number": "+9779811111111",
"dob": "2000-01-01",
"blood_group": "O_POS",
"medical_conditions": [
{
"diagnozed_date": "2024-08-30",
"condition": "Asthma",
"description": "Mild breathing difficulty during cold weather"
}
],
"past_surgeries": [
{
"surgery": "Appendectomy",
"date": "2025-03-14",
"surgeon": "Dr. Anil Sharma",
"hospital": "Green Valley Hospital"
}
],
"current_medications": [
{
"medication": "Aspirin",
"dosage": "100mg",
"frequency": "Once a day",
"prescribed_by": "Dr. Smith"
}
],
"addresses": [
{
"address_type": "home",
"street": "Baneshwor",
"city": "Kathmandu",
"state": "Bagmati",
"postal_code": "44600",
"country": "Nepal"
}
]
}
Field Notes
| Field | Type | Description |
|---|---|---|
gender | string | Patient gender |
first_name | string | Patient first name |
middle_name | string | Patient middle name |
last_name | string | Patient last name |
phone_number | string | Primary phone number |
alt_phone_number | string | Alternative phone number |
dob | date | Patient date of birth |
blood_group | string | Patient blood group (NOT_SET, A_POS, A_NEG, B_POS, B_NEG, AB_POS, AB_NEG, O_POS, O_NEG) |
medical_conditions | array of objects | Patient medical condition history |
medical_conditions[].diagnozed_date | date | Date when the condition was diagnosed |
medical_conditions[].condition | string | Name of the medical condition |
medical_conditions[].description | string | Extra details about the condition |
past_surgeries | array of objects | Patient surgery history |
past_surgeries[].surgery | string | Name of the surgery |
past_surgeries[].date | date | Surgery date |
past_surgeries[].surgeon | string | Surgeon name |
past_surgeries[].hospital | string | Hospital where the surgery was performed |
current_medications | array of objects | Current medications used by the patient |
current_medications[].medication | string | Medicine name |
current_medications[].dosage | string | Medicine dosage |
current_medications[].frequency | string | How often the medicine is taken |
current_medications[].prescribed_by | string | Doctor who prescribed the medicine |
addresses | array of objects | Patient address list |
addresses[].address_type | string | Type of address, such as home or office |
addresses[].street | string | Street name or area |
addresses[].city | string | City |
addresses[].state | string | State or province |
addresses[].postal_code | string | Postal code |
addresses[].country | string | Country |
Response Example
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"reg_number": "PAT-001",
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"alt_phone_number": "+9779811111111",
"dob": "2000-01-01",
"blood_group": "O_POS",
"medical_conditions": [
{
"diagnozed_date": "2024-08-30",
"condition": "Asthma",
"description": "Mild breathing difficulty during cold weather"
}
],
"past_surgeries": [
{
"surgery": "Appendectomy",
"date": "2025-03-14",
"surgeon": "Dr. Anil Sharma",
"hospital": "Green Valley Hospital"
}
],
"current_medications": [
{
"medication": "Aspirin",
"dosage": "100mg",
"frequency": "Once a day",
"prescribed_by": "Dr. Smith"
}
],
"addresses": [
{
"address_type": "home",
"street": "Baneshwor",
"city": "Kathmandu",
"state": "Bagmati",
"postal_code": "44600",
"country": "Nepal"
}
]
}
Get All Patients
GET /patient/
Returns all patient records.
Response Example
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"reg_number": "PAT-001",
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"alt_phone_number": "+9779811111111",
"dob": "2000-01-01",
"blood_group": "O_POS"
}
]
Get Patient By ID
GET /patient/{id}
Returns a single patient by UUID.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
id | UUID | Patient ID |
Example Request
GET /patient/550e8400-e29b-41d4-a716-446655440000
Response Example
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"reg_number": "PAT-001",
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"alt_phone_number": "+9779811111111",
"dob": "2000-01-01",
"blood_group": "O_POS"
}
Update Patient
PUT /patient/{id}
Updates an existing patient record by UUID.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
id | UUID | Patient ID |
Example Request
PUT /patient/550e8400-e29b-41d4-a716-446655440000
Request Body
{
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"alt_phone_number": "+9779811111111",
"dob": "2000-01-01",
"blood_group": "O_POS",
"medical_conditions": [
{
"diagnozed_date": "2024-08-30",
"condition": "Asthma",
"description": "Mild breathing difficulty during cold weather"
}
],
"past_surgeries": [
{
"surgery": "Appendectomy",
"date": "2025-03-14",
"surgeon": "Dr. Anil Sharma",
"hospital": "Green Valley Hospital"
}
],
"current_medications": [
{
"medication": "Aspirin",
"dosage": "100mg",
"frequency": "Once a day",
"prescribed_by": "Dr. Smith"
}
],
"addresses": [
{
"address_type": "home",
"street": "Baneshwor",
"city": "Kathmandu",
"state": "Bagmati",
"postal_code": "44600",
"country": "Nepal"
}
]
}
Response Example
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"reg_number": "PAT-001",
"message": "Patient updated successfully"
}
Delete Patient
DELETE /patient/{id}
Deletes a patient record by UUID.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
id | UUID | Patient ID |
Example Request
DELETE /patient/550e8400-e29b-41d4-a716-446655440000
Response Example
{
"message": "Patient deleted successfully"
}
Get Patient By Registration Number
GET /patient/reg_number/{reg_number}
Returns a patient using their registration number.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
reg_number | string | Patient registration number |
Example Request
GET /patient/reg_number/PAT-001
Response Example
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"reg_number": "PAT-001",
"gender": "Male",
"first_name": "Ram",
"middle_name": "Bahadur",
"last_name": "Sharma",
"phone_number": "+9779800000000",
"dob": "2000-01-01",
"blood_group": "O_POS"
}
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | Request successful |
| 201 | Patient created successfully |
| 400 | Invalid request data |
| 401 | Not authenticated |
| 403 | Permission denied |
| 404 | Patient not found |
| 422 | Validation error |