Skip to content

Latest commit

 

History

History
270 lines (225 loc) · 6.12 KB

File metadata and controls

270 lines (225 loc) · 6.12 KB

API Endpoints Testing Guide

Base URL: http://localhost:9000


1. AUTH (No Auth Required)

1.1 Signup — Patient

  • Method: POST
  • URL: /api/auth/signup
  • Body (JSON):
{
  "accountType": "PATIENT",
  "firstName": "Ahmed",
  "lastName": "Hassan",
  "email": "ahmed@test.com",
  "password": "password123",
  "phone": "+201234567890"
}

1.2 Signup — Doctor

  • Method: POST
  • URL: /api/auth/signup
  • Body (JSON):
{
  "accountType": "DOCTOR",
  "firstName": "Sara",
  "lastName": "Ali",
  "email": "sara@doctor.com",
  "password": "password123",
  "phone": "+201987654321"
}

1.3 Verify Email

  • Method: GET
  • URL: /api/auth/verify-email?token=THE_TOKEN_FROM_CONSOLE
  • Body: None

1.4 Login

  • Method: POST
  • URL: /api/auth/login
  • Body (JSON):
{
  "email": "ahmed@test.com",
  "password": "password123"
}
  • Response: Returns token — save it for all endpoints below

2. USERS (Auth Required)

Add header to all requests below: Authorization: Bearer <TOKEN>

2.1 Get My Profile

  • Method: GET
  • URL: /api/users/me
  • Body: None

2.2 Update My Profile

  • Method: PATCH
  • URL: /api/users/me
  • Body (JSON):
{
  "firstName": "Ahmed Updated",
  "lastName": "Hassan Updated",
  "phone": "+201112223333"
}

2.3 Get All Patients

  • Method: GET
  • URL: /api/users/patients?page=1&limit=10&search=Ahmed
  • Body: None

2.4 Get Patient By ID

  • Method: GET
  • URL: /api/users/patients/<PATIENT_USER_ID>
  • Body: None

2.5 Assign Patient to Doctor

  • Method: POST
  • URL: /api/users/patients/<PATIENT_USER_ID>/assign
  • Body (JSON):
{
  "doctorId": "<DOCTOR_USER_ID>"
}

2.6 Get All Doctors

  • Method: GET
  • URL: /api/users/doctors?page=1&limit=10
  • Body: None

2.7 Get My Patient Details

  • Method: GET
  • URL: /api/users/profile/patient-details
  • Body: None

2.8 Update My Patient Details

  • Method: POST
  • URL: /api/users/profile/patient-details
  • Body (JSON):
{
  "chronicDiseases": "None",
  "medications": "Ibuprofen",
  "previousSurgeries": "Appendectomy 2020",
  "bloodPressure": "120/80",
  "diabetesStatus": "Negative"
}

3. APPOINTMENTS (Auth Required)

3.1 Check Doctor Availability

  • Method: GET
  • URL: /api/appointments/doctor/<DOCTOR_USER_ID>/availability?date=2026-06-28
  • Body: None

3.2 Get My Appointments

  • Method: GET
  • URL: /api/appointments?page=1&limit=10
  • Body: None

3.3 Create Appointment

  • Method: POST
  • URL: /api/appointments
  • Body (JSON):
{
  "doctorId": "<DOCTOR_USER_ID>",
  "date": "2026-06-28T10:00:00.000Z",
  "notes": "First consultation"
}

3.4 Get Appointment By ID

  • Method: GET
  • URL: /api/appointments/<APPOINTMENT_ID>
  • Body: None

3.5 Update Appointment

  • Method: PATCH
  • URL: /api/appointments/<APPOINTMENT_ID>
  • Body (JSON):
{
  "status": "COMPLETED",
  "notes": "Follow-up needed"
}

3.6 Delete Appointment

  • Method: DELETE
  • URL: /api/appointments/<APPOINTMENT_ID>
  • Body: None

4. CHAT (Auth Required)

4.1 Get My Chats

  • Method: GET
  • URL: /api/chat?page=1&limit=10
  • Body: None

4.2 Create Chat

  • Method: POST
  • URL: /api/chat
  • Body (JSON):
{
  "title": "Brain MRI Questions"
}

4.3 Get Chat By ID

  • Method: GET
  • URL: /api/chat/<CHAT_ID>
  • Body: None

4.4 Send Message

  • Method: POST
  • URL: /api/chat/<CHAT_ID>/messages
  • Body (JSON):
{
  "content": "What does a brain tumor look like on MRI?"
}

4.5 Delete Chat

  • Method: DELETE
  • URL: /api/chat/<CHAT_ID>
  • Body: None

5. REPORTS

5.1 Generate Report

  • Method: POST
  • URL: /api/reports/generate
  • Content-Type: multipart/form-data
  • Body (form-data):
    • Key: scan — Type: File — Value: Select an MRI image
    • Key: type — Type: Text — Value: BRAIN_SCAN

5.2 Get My Reports

  • Method: GET
  • URL: /api/reports/my-reports
  • Body: None

5.3 Get Report By ID

  • Method: GET
  • URL: /api/reports/<REPORT_ID>
  • Body: None

5.4 Download PDF

  • Method: GET
  • URL: http://localhost:8000/download/pdf/<REPORT_NAME>.pdf
  • Body: None

Testing Flow (Step by Step)

1. POST   /api/auth/signup           → Create patient account
2. POST   /api/auth/signup           → Create doctor account
3. GET    /api/auth/verify-email     → Verify both emails (check console for tokens)
4. POST   /api/auth/login            → Login as patient → save token
5. POST   /api/auth/login            → Login as doctor → save token
6. PATCH  /api/users/me              → Update profile (patient token)
7. POST   /api/users/profile/patient-details → Add medical details (patient token)
8. GET    /api/users/doctors         → List doctors (patient token)
9. POST   /api/users/patients/:id/assign     → Assign patient to doctor (patient token)
10. GET    /api/appointments/doctor/:id/availability → Check slots (patient token)
11. POST   /api/appointments         → Book appointment (patient token)
12. GET    /api/appointments         → List appointments (patient token)
13. PATCH  /api/appointments/:id     → Complete appointment (doctor token)
14. POST   /api/chat                 → Create chat (patient token)
15. POST   /api/chat/:id/messages    → Send message (patient token)
16. GET    /api/chat/:id             → Get chat with messages (patient token)
17. POST   /api/reports/generate     → Upload MRI scan (any token)
18. GET    /api/reports/my-reports   → List reports

Notes

  • Replace <TOKEN> with the JWT token from login response
  • Replace <PATIENT_USER_ID>, <DOCTOR_USER_ID>, etc. with actual IDs from signup/login responses
  • Patient details endpoint uses the authenticated user's ID from the token
  • All protected endpoints return 401 if token is missing or invalid
  • Email must be verified before login works