HIGH story-duplicate-activity-detection-peer-mentor-001 8 pts
8
Story Points
High
Priority
Duplicate Activity Detection
Feature

User Story

As a Peer Mentor (Likeperson)
I want to be warned immediately when I attempt to register an activity that appears to duplicate one already registered by another coordinator or peer mentor
So that I can avoid submitting redundant records that would inflate Bufdir reporting figures and create administrative cleanup work

Audience Summaries

Duplicate activity registrations are a direct financial and compliance risk. Bufdir uses submitted activity data to allocate public funding, and over-reported participant counts — even unintentional ones — can trigger grant clawbacks, audit findings, and reputational damage with the funding body. This story eliminates the root cause by surfacing conflicts at the moment of submission, when the coordinator has full context to resolve ambiguity in seconds. The alternative — quarterly audit cleanup — is costly in staff time, prone to human error after the fact, and may not catch issues before a reporting deadline.

By implementing a real-time warning with a clear 'submit anyway with reason' escape hatch, the organization maintains both data integrity and operational flexibility. This is a high-priority capability that directly underpins the trustworthiness of all statistical outputs generated by the platform.

This is a high-priority story with no blocking dependencies, making it an early candidate for sprint scheduling. The core delivery work spans three areas: the duplicate detection query logic (backend), the warning dialog UI (frontend), and the duplicate-reviewed flag handling in downstream reporting and export pipelines. The side-by-side comparison panel in the warning dialog is the most design-intensive element and will require close collaboration between the developer and UX. Testing must cover: exact-match detection, overlapping-but-not-identical time windows, the 'cancel' path (no record written), the 'submit anyway' path (record written with flag), and correct exclusion of flagged duplicates from Bufdir exports unless explicitly marked as distinct.

Regression risk to existing submission flows is moderate. Recommend a feature flag for staged rollout. Stakeholder sign-off from the compliance or reporting team is advisable before release given the Bufdir reporting implications.

The duplicate check must execute server-side immediately before the activity record is committed, querying for records matching on: participant ID, activity type, and a date/time overlap within the configured threshold window (initially same-day as default). The check must be atomic with the submission to prevent race conditions where two coordinators submit simultaneously. The warning response payload should include the full conflicting record so the client can render the side-by-side duplicate-comparison-panel without a second round-trip. The bottom sheet/dialog component needs three exit paths: cancel (no write), submit-anyway (write with duplicate_reviewed: true flag), and potentially 'edit' to return to the wizard.

The duplicate_reviewed flag must be stored on the activity record and respected in all aggregation queries and Bufdir export logic — flagged records should be deduplicated unless explicitly marked as distinct events. Consider adding an index on (participant_id, activity_type, activity_date) to keep the lookup performant at scale.

Acceptance Criteria

  • Given a coordinator submits an activity registration, When the system detects a record with the same participant and overlapping date/time window and same activity type, Then a duplicate-warning-bottom-sheet appears before the record is saved
  • Given the warning dialog is shown, When the coordinator views it, Then both the new activity and the conflicting existing activity are displayed side by side in a duplicate-comparison-panel with date, time, type, and registrant
  • Given the warning dialog is shown, When the coordinator selects 'Cancel', Then no record is saved and the wizard returns to the previous step
  • Given the warning dialog is shown, When the coordinator selects 'Submit Anyway', Then the activity is saved with a duplicate-reviewed flag set to true
  • Given a duplicate-reviewed flag is set, When the record appears in statistics or Bufdir exports, Then it is included only once unless the coordinator explicitly marked it as a distinct event

Business Value

Duplicate registrations directly corrupt Bufdir reporting, which is used to allocate public funding. A single false duplicate can cause an organization to over-report participant counts, risking compliance issues and potential clawback of grants. By surfacing conflicts at submission time rather than during quarterly audit cleanup, coordinators resolve ambiguity in seconds instead of hours, and the integrity of the organization's funding application is protected.