API Documentation (Updated on 11/11/2024)

Register - POST /api/register

Registers a new patient user.

Parameters:

Response:

{
    "status": "success",
    "message": "User created successfully"
}

Register Psychologist - POST /api/register/psychologist

Registers a new psychologist.

Parameters:

Response:

{
    "status": "success",
    "message": "Psychologist created successfully"
}

Profile - GET /api/profile

Fetches the authenticated user's profile data.

Response:

{
    "status": "success",
    "message": "User details",
    "data": {
        "user_id": "user-id",
        "profile_picture": "url_to_profile_picture",
        "firstname": "John",
        "lastname": "Doe",
        "email": "johndoe@example.com",
        "phone_number": "123456789",
        "role": "psychologist",
        // Other profile fields depending on role
    }
}

Login - POST /api/login

Authenticates a user and returns an access token.

Parameters:

Response:

{
    "status": "success",
    "message": "Login successful",
    "data": {
        "user_id": "user-id",
        "access_token": "token",
        "token_type": "Bearer",
        "role": "patient"
    }
}

Logout - POST /api/logout

Logs out the authenticated user and deletes the access token.

Response:

{
    "status": "success",
    "message": "Logout successful"
}

Admin Dashboard Data - GET /api/admin/dashboard

Returns statistics for the admin dashboard.

Response:

{
    "status": "success",
    "message": "Admin dashboard data",
    "data": {
        "psychologists": 10,
        "total_patient": 100,
        "ongoing_appointments": 5,
        "completed_appointments": 50
    }
}

Daftar Psikolog Terverifikasi - GET /api/psychologists/verified

Fetches the list of verified psychologists.

Response:

{
    "status": "success",
    "message": "List of verified psychologists",
    "data": [
        {
            "id": 1,
            "user_id": 2,
            "profile_picture": "url_to_profile_picture",
            "firstname": "John",
            "lastname": "Doe",
            "gender": "male",
            "profesional_identification_number": "12345",
            "degree": "PhD",
            "specialization": "Clinical Psychology",
            "work_experience": 10,
            "is_verified": true,
            "detail_url": "api/psychologists/1/detail"
        }
    ]
}

Daftar Psikolog Belum Terverifikasi - GET /api/psychologists/not-verified

Fetches the list of unverified psychologists.

Response:

{
    "status": "success",
    "message": "List of unverified psychologists",
    "data": [
        {
            "id": 1,
            "user_id": 2,
            "profile_picture": "url_to_profile_picture",
            "firstname": "Jane",
            "lastname": "Smith",
            "profesional_identification_number": "67890",
            "degree": "MSc",
            "specialization": "Counseling",
            "work_experience": 5,
            "is_verified": false,
            "is_rejected": false,
            "approve_url": "/api/psychologists/2/approve",
            "reject_url": "/api/psychologists/2/reject",
            "detail_url": "/api/psychologists/2/detail"
        }
    ]
}

Approve Psikolog - POST /api/psychologists/{id}/approve

Approves a psychologist by ID.

Parameters:

Response:

{
    "status": "success",
    "message": "Psychologist approved successfully",
    "data": {
        "id": 1,
        "is_verified": true
    }
}

Error Response:

{
    "status": "error",
    "message": "Psychologist not found"
}

Reject Psikolog - POST /api/psychologists/{id}/reject

Rejects a psychologist by ID.

Parameters:

Response:

{
    "status": "success",
    "message": "Psychologist rejected successfully",
    "data": {
        "id": 1,
        "is_verified": false,
        "is_rejected": true
    }
}

Error Response:

{
    "status": "error",
    "message": "Psychologist not found"
}

Detail Psikolog - GET /api/psychologists/{id}/detail

Fetches details of a psychologist by ID.

Parameters:

Response:

{
    "status": "success",
    "message": "Psychologist details",
    "data": {
        "id": 1,
        "user_id": 2,
        "profile_picture": "url_to_profile_picture",
        "firstname": "John",
        "lastname": "Doe",
        "gender": "male",
        "profesional_identification_number": "12345",
        "degree": "PhD",
        "specialization": "Clinical Psychology",
        "work_experience": 10,
        "is_verified": true,
        "approve_url": "/api/psychologists/2/approve",
        "reject_url": "/api/psychologists/2/reject"
    }
}

Error Response:

{
    "status": "error",
    "message": "Psychologist not found"
}

Get Patient Appointments - GET /api/patients/appointments

Fetches a list of appointments for the authenticated patient.

Response:

{
  "status": "success",
  "data": {
    "upcoming_appointments": [
      {
        "id": 7,
        "channel_id": "channel_id_example",
        "date": "2024-11-10",
        "start_time": "14:00",
        "end_time": "15:00",
        "status": "waiting",
        "psychologist": {
          "id": 3,
          "user_id": "0ee04692-6935-4df4-9414-ac943203da51",
          "firstname": "John",
          "lastname": "Doe",
          "email": "johndoe@example.com",
          "phone_number": "1234567890"
        },
        "detail_url": "http://example.com/api/patients/appointments/7/detail"
      }
    ],
    "history": [
      {
        "id": 8,
        "channel_id": "channel_id_example",
        "date": "2024-10-10",
        "start_time": "14:00",
        "end_time": "15:00",
        "status": "completed",
        "psychologist": {
          "id": 3,
          "user_id": "0ee04692-6935-4df4-9414-ac943203da51",
          "firstname": "John",
          "lastname": "Doe",
          "email": "johndoe@example.com",
          "phone_number": "1234567890"
        },
        "detail_url": "http://example.com/api/patients/appointments/8/detail"
      }
    ]
  }
}

Get Appointment Details - GET /api/patients/appointments/{id}/detail

Fetches the details of a specific appointment for the patient.

Parameters:

Response:

{
  "status": "success",
  "message": "Appointment details",
  "data": {
    "id": 7,
    "channel_id": "channel_id_example",
    "date": "2024-11-10",
    "start_time": "14:00",
    "end_time": "15:00",
    "duration": "60 minutes",
    "status": "waiting",
    "note": "Make sure you have a stable internet connection and are in a quiet place during the consultation session.",
    "psychologist": {
      "user_id": "0ee04692-6935-4df4-9414-ac943203da51",
      "firstname": "John",
      "lastname": "Doe",
      "gender": "male",
      "email": "johndoe@example.com",
      "specialization": "Clinical Psychology",
      "work_experience": 5
    }
  }
}

Get Psychologists List - GET /api/patients/psychologists-list

Fetches a list of available psychologists for patients to view.

Response:

{
  "status": "success",
  "message": "List of Psychologists",
  "data": [
    {
      "id": 1,
      "user_id": "0ee04692-6935-4df4-9414-ac943203da51",
      "profile_picture": "url_to_profile_picture",
      "firstname": "John",
      "lastname": "Doe",
      "gender": "male",
      "specialization": "Clinical Psychology",
      "work_experience": 5,
      "is_verified": true,
      "detail_url": "http://example.com/api/patients/psychologists/1"
    }
  ]
}

Get Psychologist Detail - GET /api/patients/psychologists/{id}

Fetches detailed information for a specific psychologist by ID.

Parameters:

Response:

{
  "status": "success",
  "message": "Psychologist details",
  "data": {
    "id": 1,
    "user_id": "0ee04692-6935-4df4-9414-ac943203da51",
    "profile_picture": "url_to_profile_picture",
    "firstname": "John",
    "lastname": "Doe",
    "gender": "male",
    "specialization": "Clinical Psychology",
    "work_experience": 5,
    "is_verified": true,
    "upcoming_appointments": [
      {
        "date": "2024-11-10",
        "times": [
          { "start_time": "09:00", "end_time": "10:00" },
          { "start_time": "11:00", "end_time": "12:00" }
        ]
      }
    ]
  }
}

Book a Psychologist - POST /api/patients/psychologists/{id}/book

Books an appointment with a psychologist for the patient.

Parameters:

Response:

{
  "status": "success",
  "message": "Appointment booked successfully",
  "data": {
    "id": 7,
    "patient_id": 2,
    "psychologist_id": 1,
    "channel_id": "channel_id_example",
    "date": "2024-11-10",
    "start_time": "14:00",
    "end_time": "15:00",
    "status": "waiting"
  }
}

Get AI Analysis Results - GET /api/patients/ai-analysis

Fetches AI analysis results for the authenticated patient.

Response:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "complaint": "Feeling stressed at work",
      "stress": 0.8,
      "anxiety": 0.6,
      "depression": 0.3,
      "created_at": "2024-11-01T10:00:00Z",
      "updated_at": "2024-11-01T10:00:00Z",
      "patient_id": 1
    }
  ]
}