📋 UC08: Arranged Status
USE CASE UC08: "ARRANGED" STATUS OF A REQUEST
This document explains how the "arranged" status of
care requests works and who can modify it.
The terms "ARRANGED" and "PLANNED" are SYNONYMS.
There is NO difference between these two terms.
In the application, only one status exists: "arranged".
1. Understanding Statuses
The status is determined by the combination of several fields.
Fields Used
A) active (bool):
- true: active request
- false: completed or cancelled request
B) arrangedForPatient (bool?):
- null: not yet arranged
- false: not arranged (equivalent to null)
- true: request ARRANGED for the patient
C) arrangedForCareGiver (Map
- Empty map {}: no caregiver has arranged
- { "uuid-caregiver": DateTime }: this caregiver has arranged
Terminology
The terms "arranged" and "planned" are SYNONYMS - there is no difference.
In the code: arrangedForPatient = true means care is organized.
2. Possible Request States
File: lib/core/presentation/controllers/request_card_controller.dart
1. IN PROGRESS (Ongoing):
- arrangedForPatient != true (null or false)
- active = true
- createdAt < 24h
-> The request was just created, waiting for response
2. Arranged:
- arrangedForPatient = true
- active = true
-> A caregiver has been found, care is scheduled
3. Cancelled:
- active = false
- arrangedForPatient != true
-> The request was cancelled before being arranged
4. Completed:
- active = false
- arrangedForPatient = true
-> Care has been provided and is finished
3. Who Can Mark A Request As "Arranged"?
A) THE PATIENT (or the person who created the request)
USE CASE:
- The patient has found a caregiver (via the app or otherwise)
- They want to indicate that care is now organized
ACTION:
- "Mark as arranged" button on their request detail
- Sets arrangedForPatient = true
Source Code
lib/modules/home/presentation/controllers/request_detail_screen_controller.dart
```dart
Future
required String uuid,
bool? arrangedForPatient,
Map
}) async {
// ...
if (arrangedForCareGiver == null) {
// Patient marking as arranged
await arrangedRepo.call(requestId: uuid, arrangedForPatient: true);
// ...
B) THE NURSE (Caregiver)
USE CASE:
- The nurse has contacted the patient
- They have agreed to take care of the patient
- They want to indicate they have "arranged" this request
ACTION:
- "I have organized the care" button on request detail
- Adds their UUID to arrangedForCareGiver
Source Code
```dart
if (arrangedForCareGiver != null) {
await arrangedRepo.call(
requestId: uuid,
arrangedForCareGiver: arrangedForCareGiver,
// ...
Important Difference
- The patient sets arrangedForPatient = true (global status)
- The nurse adds their UUID to arrangedForCareGiver (their personal arrangement)
4. Conditions For Marking As "Arranged"
For The Patient
- Must be the request creator (userUuid matches)
- Request must be active (active = true)
- Request must not already be arranged
For The Nurse
- Must have an active account (status = active)
- Request must be in their activity area
- Request must be active
- Nurse must have contacted the patient (have credits or active plan)
5. Visible Changes For Users
WHEN THE PATIENT MARKS AS "ARRANGED":
For the patient:
- The request changes from "In progress" to "Arranged"
- The icon/color changes in the list
- The request remains visible in their requests
For nurses:
- The request may no longer appear in available requests
(depending on defined business rules)
- Nurses who had already arranged are notified (potentially)
WHEN THE NURSE MARKS AS "ARRANGED":
For the nurse:
- The request goes to their "Arranged requests"
- They can continue to see details
- They can cancel their arrangement if needed
For the patient:
- They can see that a nurse has taken over
- They can confirm by marking as "arranged" on their side
6. Cancelling An Arrangement
The Patient Can
- Cancel the request completely (active = false)
- This ends the request
- Nurses no longer see it
The Nurse Can
- Cancel their arrangement (remove their UUID from arrangedForCareGiver)
- The request becomes available again to other nurses
- The patient is notified (potentially)
Source Code
lib/modules/home/presentation/controllers/request_detail_screen_controller.dart
- cancelRequestPatient(): cancels the patient's request
- cancelRequestCaregiver(): removes the nurse's arrangement
7. Complete Use Case: Lifecycle
1. CREATION (Patient)
- active = true
- arrangedForPatient = null
- arrangedForCareGiver = {}
-> Status: IN PROGRESS
2. NURSE ARRANGES (optional)
- arrangedForCareGiver = { "uuid-nurse": DateTime }
-> The nurse has arranged on their side
-> The patient has not yet confirmed
3. Patient Confirms
- arrangedForPatient = true
-> Status: ARRANGED
4. CARE COMPLETED (eventually)
- active = false
- arrangedForPatient = true (remains)
-> Status: COMPLETED
Or Cancellation
3bis. PATIENT CANCELS
- active = false
- arrangedForPatient remains null/false
-> Status: CANCELLED
8. Technical References
Entity:
- lib/modules/carerequest/domain/entities/carerequest_entity.dart
- arrangedForPatient: bool?
- arrangedForCareGiver: Map
- active: bool
Use Case:
- lib/modules/carerequest/domain/usecases/update_carerequest_arranged_use_case.dart
Controllers:
- lib/modules/home/presentation/controllers/request_detail_screen_controller.dart
- lib/core/presentation/controllers/request_card_controller.dart
Repository:
- lib/modules/carerequest/domain/repositories/carerequest_repository.dart
- updateCareRequestAsArranged()
Providers:
- availableCareRequestsForCaregiverProvider (non-arranged requests)
- arrangedCareRequestsForCaregiverProvider (requests arranged by nurse)