Skip to content

Patient

1. Patient Registration

  • EndpointPOST /patient/register
  • Description: Register a new patient.
  • Request Body (Example):

    {
      "firstName": "John",
      "lastName": "Doe",
      "fullName": "John Doe",
      "email": "john.doe@example.com",
      "nic": "123456789V",
      "password": "password123",
      "phoneNumber": "+1234567890",
      "address": "123 Main St, City",
      "dateOfBirth": "1990-01-01"
    }
    
  • Success Response:

    {
      "message": "Patient created successfully",
      "patientId": "PA11234"
    }
    
    • Status Code201 Created
    • Errors:
    • 400 Bad Request: Missing required fields.
    • 409 Conflict: NIC/Email already exists.
    • 500 Internal Server Error: Server error.

2. Update Patient Profile

  • EndpointPOST /patient/profile
  • HeadersAuthorization: Bearer <JWT>
  • Description: Update patient profile (excludes email, NIC, password, etc.).
  • Request Body (Example):

    {
      "height": 180,
      "weight": 75,
      "bmi": 23.1,
      "bloodType": "O+",
      "medicationAllergies": ["Penicillin", "Aspirin"],
      "guardianName": "Jane Doe",
      "guardianContactNumber": "+0987654321",
      "guardianEmail": "jane.doe@example.com",
      "profilePic": "profilepic.jpg"
    }
    
  • Success Response:

    { "message": "Patient profile updated successfully" }
    
    • Status Code200 OK
    • Errors:
    • 401 Unauthorized: Invalid/missing token.
    • 500 Internal Server Error: Server error

3. Get Patient Profile

  • EndpointGET /patient/profile
  • HeadersAuthorization: Bearer <JWT>
  • Description: Retrieve patient profile (excludes password).
  • Success Response (Example):

    {
      "patientId": "PA11234",
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "phoneNumber": "+1234567890",
      "address": "123 Main St, City",
      "bloodType": "O+"
    }
    
    • Status Code200 OK
    • Errors:
    • 401 Unauthorized: Invalid/missing token.
    • 404 Not Found: Patient not found.

3. Get Patient Homepage Data

  • EndpointGET /patient/home
  • HeadersAuthorization: Bearer <JWT>
  • Description: Retrieve patient profile (excludes password).

Status Code200 OK - Errors: - 401 Unauthorized: Invalid/missing token. - 404 Not Found: Patient not found.

4. Add a Laboratory

  • EndpointPOST /laboratory
  • HeadersAuthorization: Bearer <JWT>
  • Description: Link a laboratory to the patient.
  • Request Body (Example):

    { "labId": "LAB123" }
    
  • Success Response:

    { "message": "Lab added successfully" }
    
    • Status Code201 Created
    • Errors:
    • 400 Bad Request: Missing labId.
    • 404 Not Found: Lab does not exist.
    • 409 Conflict: Lab already added.
    • 500 Internal Server Error: Server error.

4. Add a Pharmacy

  • EndpointPOST /pharmacy
  • HeadersAuthorization: Bearer <JWT>
  • Description: Link a pharmacy to the patient.
  • Request Body (Example):

    { "pharmacyId": "PH123" }
    
  • Success Response:

    { "message": "Pharmacy added successfully" }
    
    • Status Code201 Created
    • Errors:
    • 400 Bad Request: Missing labId.
    • 404 Not Found: Lab does not exist.
    • 409 Conflict: Lab already added.
    • 500 Internal Server Error: Server error.