Patient Backend

Patient Endpoints

Patient User Type:
Patients are individuals in need of blood who can post blood requests, check the blood inventory of different organizations, and manage their account details.

1. Register Patient

  • URL: /register
  • Method: POST
  • Description: Creates a new patient account.
  • Request Body Example:
    {
      "name": "Jane Smith",
      "email": "janesmith@example.com",
      "password": "patientPassword123",
      "phoneNo": "1122334455"
    }
  • Response Example:
    {
      "message": "Patient registered successfully",
      "data": []
    }

2. Login Patient

  • URL: /login
  • Method: POST
  • Description: Authenticates a patient and returns an access token for future requests.
  • Request Body Example:
    {
      "email": "janesmith@example.com",
      "password": "patientPassword123"
    }
  • Response Example:
    {
      "message": "Patient login successful",
      "token": "Bearer eyJhbGciOiJIUzI1..."
    }

3. Send OTP (Patient)

  • URL: /sendOtpPatient
  • Method: POST
  • Description: Sends an OTP to the patient’s registered email for password reset.
  • Request Body Example:
    {
      "email": "janesmith@example.com"
    }
  • Response Example:
    {
      "message": "OTP sent successfully",
      "data": []
    }

4. Verify OTP (Patient)

  • URL: /verifyOtpPatient
  • Method: POST
  • Description: Validates the OTP provided by the patient.
  • Request Body Example:
    {
      "email": "janesmith@example.com",
      "otp": "654321"
    }
  • Response Example:
    {
      "message": "OTP verified successfully",
      "data": []
    }

5. Reset Password (Patient)

  • URL: /resetPassPatient
  • Method: POST
  • Description: Resets the patient’s password using the provided new password and, if applicable, an OTP.
  • Request Body Example:
    {
      "email": "janesmith@example.com",
      "newPassword": "newPatientPassword456"
    }
  • Response Example:
    {
      "message": "Password reset successful",
      "data": []
    }

6. Get Patient Data

  • URL: /patient/getPatientData
  • Method: GET
  • Middleware: PatientMiddleware
  • Description: Retrieves the profile details of the authenticated patient. The patient’s ID is extracted from the JWT token.
  • Request Example:
    GET /patient/getPatientData HTTP/1.1
    Host: your-api-domain.com
    Authorization: Bearer eyJhbGciOiJIUzI1...
  • Response Example:
    {
      "message": "Patient user found successfully",
      "patient": {
        "id": "603dcd9a2e8b2b3d1c8ab234",
        "name": "Jane Smith",
        "email": "janesmith@example.com",
        "phoneNo": "1122334455",
        "createdAt": "2025-01-01T10:00:00Z",
        "updatedAt": "2025-01-01T10:00:00Z"
      }
    }

7. Post Patient Survey

  • URL: /patient/postPatientSurvey
  • Method: POST
  • Middleware: PatientMiddleware
  • Description: Submits a survey for a patient. The survey data is stored in the patientSurvey collection.
  • Request Example:
    POST /patient/postPatientSurvey HTTP/1.1
    Host: your-api-domain.com
    Authorization: Bearer eyJhbGciOiJIUzI1...
    Content-Type: application/json
    {
      "symptoms_illness": "Headache and nausea",
      "recent_medical_procedures": "None",
      "travel_history": "Local travel only",
      "medical_conditions": "None",
      "high_risk_exposure": "No",
      "other_issues": ["hypertension"]
    }
  • Response Example:
    {
      "message": "Survey added successfully"
    }