📋 UC01: Patient Account
Use Case Uc01 Patient Account Creation
USE CASE NAME: Patient Account Creation
PRIMARY ACTOR: Individual seeking home nursing care
Business Objective
Allow an individual to create an account on the CareDeal application
to submit and manage care requests.
Preconditions
- The user has installed the CareDeal application
- The user has a valid mobile phone number
- The user does not already have an account with this phone number
NOMINAL SCENARIO (Happy Path)
1
Role Selection
- The user launches the application
- The user selects "Patient" (or "I'm looking for care")
2
Phone Number Entry
- The screen requests the phone number
- The user selects their country (Belgium +32 by default)
- The user enters their phone number (without leading zero)
- Example: 0478 12 34 56 → entered as 478123456
- The system verifies the number is not already in use
3
SMS Code Sending
- The system sends an SMS with a 6-digit verification code
- The system uses Firebase Auth for verification
4
SMS Code Confirmation
- The user receives the SMS
- The user enters the 6-digit code
- The system verifies the code with Firebase Auth
5
Account Validation and Creation
- The system creates the Firebase Auth account
- The system creates the User entity with:
- phoneNumber: the verified number
- userRole: "patient"
- createdAt: current date
- The user is redirected to the home page
ALTERNATIVE SCENARIOS / ERRORS
A1: Phone number already used (Step 2)
- The system detects that an account exists with this number
- Message: "An account already exists with this number"
- A link to the login screen is offered
A2: SMS not received (Step 3)
- The user waits but receives no SMS
- The user can press "Resend code"
- A 60-second timer limits resend requests
- After 3 attempts, temporary block with waiting message
A3: Incorrect code (Step 4)
- The entered code does not match
- Message: "Incorrect code. Please try again."
- The user can retry entry
- After 5 incorrect attempts, the code is invalidated
A4: Expired code (Step 4)
- The code has expired (validity: 5 minutes)
- Message: "Expired code"
- The user must request a new code
A5: Network connection lost
- At any step, the connection can be lost
- Message: "Check your internet connection"
- The user can retry once the connection is restored
On success:
- A Firebase Auth account is created
- A User entity is created with userRole = "patient"
- The user is automatically logged in
- The user is redirected to the main screen
- The user can now create care requests
Screen files:
- lib/modules/auth/presentation/screens/phone_input_screen.dart
- lib/modules/auth/presentation/screens/otp_verification_screen.dart
Controllers:
- lib/modules/auth/presentation/controllers/phone_auth_controller.dart
Use Cases:
- lib/modules/user/domain/usecases/create_user.dart
Entities:
- lib/modules/user/domain/entities/user_entity.dart
External services:
- Firebase Authentication (Phone Auth)