Receive Real-Time Duplicate Activity Warning During Registration
When a coordinator submits an activity registration — either for themselves or on behalf of a peer mentor — the system should run a duplicate check before final submission. If a matching activity is found (same participant, overlapping date/time, same activity type), a warning bottom sheet or dialog must appear showing the conflicting record side-by-side. The coordinator can then choose to proceed, cancel, or mark the submission as intentionally distinct with a reason.
User Story
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.
Components
- Duplicate Warning Bottom Sheet ui
- Duplicate Comparison Panel ui
- Duplicate Detection Service service
- Duplicate Check Repository data
- Duplicate Reviewed Flag Middleware infrastructure
- Duplicate Detection BLoC infrastructure
- Duplicate Activity Warning Dialog ui
- Duplicate Activity Detection Service service
- Duplicate Activity Detector infrastructure