Skip to main content

Patients API

The Patients API is used to create, view, update, and delete patient records.

Backend folder:

app/patient/

Endpoints

MethodEndpointDescription
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

FieldTypeDescription
genderstringPatient gender
first_namestringPatient first name
middle_namestringPatient middle name
last_namestringPatient last name
phone_numberstringPrimary phone number
alt_phone_numberstringAlternative phone number
dobdatePatient date of birth
blood_groupstringPatient blood group (NOT_SET, A_POS, A_NEG, B_POS, B_NEG, AB_POS, AB_NEG, O_POS, O_NEG)
medical_conditionsarray of objectsPatient medical condition history
medical_conditions[].diagnozed_datedateDate when the condition was diagnosed
medical_conditions[].conditionstringName of the medical condition
medical_conditions[].descriptionstringExtra details about the condition
past_surgeriesarray of objectsPatient surgery history
past_surgeries[].surgerystringName of the surgery
past_surgeries[].datedateSurgery date
past_surgeries[].surgeonstringSurgeon name
past_surgeries[].hospitalstringHospital where the surgery was performed
current_medicationsarray of objectsCurrent medications used by the patient
current_medications[].medicationstringMedicine name
current_medications[].dosagestringMedicine dosage
current_medications[].frequencystringHow often the medicine is taken
current_medications[].prescribed_bystringDoctor who prescribed the medicine
addressesarray of objectsPatient address list
addresses[].address_typestringType of address, such as home or office
addresses[].streetstringStreet name or area
addresses[].citystringCity
addresses[].statestringState or province
addresses[].postal_codestringPostal code
addresses[].countrystringCountry

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

ParameterTypeDescription
idUUIDPatient 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

ParameterTypeDescription
idUUIDPatient 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

ParameterTypeDescription
idUUIDPatient 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

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