Duplicate Detection Service
Component Detail
Service Layer
medium complexity
backend
2
Dependencies
2
Dependents
5
Entities
0
Integrations
Description
Backend service that performs a lightweight duplicate check against the activities table when called from the activity wizard summary step. Queries for existing records matching the same peer_mentor_id, contact_id, activity_date (within a configurable ±1 day fuzzy window), and activity_type_id scoped to the same local_association_id. Returns a boolean flag and optionally the conflicting activity ID. All detections are logged for coordinator audit review.
duplicate-detection-service
Responsibilities
- Query activities table for potential duplicates using peer mentor, contact, date, and activity type
- Apply configurable fuzzy date window (±1 day) for detection
- Scope detection to the same local_association_id to support NHF's multi-coordinator environment
- Return conflict flag and conflicting activity ID for display
- Log all duplicate detections for coordinator audit review
Interfaces
checkForDuplicate(params: DuplicateCheckParams): Promise<DuplicateCheckResult>
getDuplicateCheckConfig(): DuplicateCheckConfig
setFuzzyWindowDays(days: number)
getDuplicateAuditLog(organizationId: string): Promise<DuplicateAuditEntry[]>
logDuplicateDetection(detection: DuplicateDetectionEvent): Promise<void>
Relationships
Dependencies (2)
Components this component depends on
Dependents (2)
Components that depend on this component
Related Data Entities (5)
Data entities managed by this component