Certification Status Derivation Service
Component Detail
Description
Pure service that derives a MentorStatus enum (active, expiring_soon, expired, paused) from a peer mentor's raw certification expiry date and pause flag stored in Supabase. Encapsulates HLF-specific business rules for certification validity windows and suppression logic.
certification-status-service
Summaries
This service enforces the HLF certification compliance rules that protect both mentors and the organizations they serve. By centralizing validity logic, it ensures that expired or lapsing mentors are automatically surfaced to administrators and hidden from public listings before compliance violations occur. This reduces legal and reputational risk for partner organizations while improving the quality and trustworthiness of mentor listings visible to end users. The configurable warning window allows organizations to proactively re-certify mentors, reducing certification lapses and the disruption they cause to ongoing peer support relationships.
A low-complexity, zero-dependency pure service that can be built, tested, and delivered independently of any repository or UI work. No external dependencies means no scheduling risk from third-party delays. Unit test coverage is straightforward: boundary cases around the 30-day warning threshold, null expiry handling, pause flag override, and HLF-specific suppression logic. Because this service is stateless and pure, it can be reviewed and signed off early in the sprint, freeing capacity for higher-risk BLoC and repository work.
No deployment steps beyond including it in the app build.
A stateless pure Dart service with no constructor dependencies, making it trivially injectable and testable. Core method deriveStatus() evaluates isPaused first (short-circuit override), then computes days until expiry via computeDaysUntilExpiry() to classify as active, expiring_soon, or expired. The thresholdDays parameter on isWithinWarningWindow() defaults to 30 but is overridable per call site for future configurability. shouldSuppressFromPublicListing() gates on both MentorStatus and the isHlf flag, encoding the HLF-specific business rule explicitly rather than via generic conditions.
No async operations; all methods are synchronous for predictable performance in the UI render path.
Responsibilities
- Derive MentorStatus from expiry date with configurable warning threshold (default 30 days)
- Apply pause flag override regardless of certification state
- Determine whether mentor should be suppressed from public-facing listings (HLF expired rule)
- Return days-remaining value for UI countdown display
Interfaces
deriveStatus({DateTime? expiryDate, required bool isPaused})
shouldSuppressFromPublicListing({required MentorStatus status, required bool isHlf})
computeDaysUntilExpiry(DateTime expiryDate)
isWithinWarningWindow(DateTime expiryDate, {int thresholdDays = 30})
Relationships
Dependents (1)
Components that depend on this component
Related Data Entities (1)
Data entities managed by this component