Anti-doping system-integration
I korthet
Anti-doping system-integration connects Petanque Life to WADA ADAMS and per-nation NADOs (RF Antidoping, AFLD, NADA, UKAD, USADA, NADOF, plus generic providers) for athlete-pool export, quarterly whereabouts upload, test-result import with DopingTest creation, bidirectional TUE sync with field-level conflict detection, and signature-verified inbound webhooks — all idempotent, tenant-scoped, and exercisable in sandbox mode before any record reaches a real anti-doping authority.
Så fungerar det
AdamsIntegrationConfig holds the ADAMS connection — display_name, an AdamsCredentialRefs block (api_key_ref, api_secret_ref, signing_key_ref, endpoint_url), organisation_code, sport_code, athlete pool ids (registered_testing_pool_ids, testing_pool_ids), and per-capability toggles (enable_athlete_export, enable_whereabouts_sync, enable_test_result_import, enable_tue_sync) plus sandbox_mode. AdamsExportJob runs entity exports (athlete_profile, whereabouts, test_result, tue_application, sanction) with dry-run, AdamsExportStatistics (total/succeeded/failed/skipped), and per-row AdamsExportResult; idempotency is achieved through hash-based change detection so re-runs only push deltas. WhereaboutsRecord captures quarterly whereabouts with a list of WhereaboutsEntry rows (slot_date, slot_type ∈ overnight/training/competition/other/sixty_minute, start_time and end_time validated as HH:MM, address, city, country_code auto-uppercased) and a draft→submitted→confirmed/rejected/expired/cancelled lifecycle, with adams_submission_id stamped on confirmation.
TestResultImport ingests sample-collection records from configured NADO providers with a TestResultDetail block (sample_code, sample_type, collection_date, lab_name, lab_code, substances_detected, result_code, b_sample_requested, b_sample_result), runs received→validated→processed/failed/rejected lifecycle, and on processing creates a DopingTest with the correct result mapping (negative or adverse → positive/atypical/pending) — all keyed on idempotency_key. TueSyncRecord pushes lokal TUEs to ADAMS and pulls ADAMS-decisions back, with conflict_field/local_value/remote_value diffs when both sides change. NadoConfig captures per-nation NADO settings (provider, country_code auto-uppercased, contact info, optional API endpoint and key reference, code_version, whereabouts_required flag, tue_committee_email, notification triggers for adverse findings and whereabouts failures) with shipped defaults for SE, FR, and DE; GET /defaults returns the standard configurations as templates for quick onboarding.
AntiDopingWebhookEvent verifies provider-specific HMAC-SHA256 signatures against the configured signing secret, deduplicates inbound notifications by idempotency_key, and dispatches verified events to typed handlers (test_result.*, tue.*, whereabouts.*) with an audit log retained for compliance and dispute resolution.
Centrala funktioner
- AdamsIntegrationConfig with capability toggles and sandbox mode
- AdamsExportJob with dry-run, statistics, and hash-based idempotent re-runs
- WhereaboutsRecord with quarterly entries, slot validation, and submit/confirm/reject lifecycle
- TestResultImport with NADO provider mapping and DopingTest creation
- TueSyncRecord with bidirectional sync and field-level conflict diffs
- NadoConfig per nation with default templates for SE, FR, DE
- AntiDopingWebhookEvent with per-provider signature verification and audit log
I praktiken
A national federation's medical officer connects ADAMS in sandbox first. They create an AdamsIntegrationConfig with sandbox_mode=true, validate credentials, then enable enable_whereabouts_sync and enable_test_result_import. A registered athlete files Q2 whereabouts in the player app — a WhereaboutsRecord is created in draft and submitted.
The next AdamsExportJob (entity_type=whereabouts, dry_run=true) shows 47 athletes ready to push; they re-run without dry-run and the hash-based change detection skips 32 unchanged records, pushing only the 15 with diffs. A week later the lab reports an adverse finding via the NADO webhook; the signature is verified, the TestResultImport lands as received, the medical officer validates and processes it, and a DopingTest is created with result=positive — automatically triggering the disciplinary workflow.
Features i detta subsystem
5| ID | Status | Funktioner |
|---|---|---|
| F14.12.01 | Levererad | WADA ADAMS export — AdamsIntegrationConfig-samling tenant-scopad med display_name/credentials (AdamsCredentialRefs api_key_ref/api_secret_ref/signing_key_ref/endpoint_url)/organisation_code/sport_code/enable_athlete_export/enable_whereabouts_sync/enable_test_result_import/enable_tue_sync/registered_testing_pool_ids/testing_pool_ids/sandbox_mode; CRUD /anti-doping/adams-configs/ med enable/disable-endpoints; AdamsExportJob-samling tenant-scopad med config_id/entity_type (athlete_profile/whereabouts/test_result/tue_application/sanction)/status (pending/exporting/completed/completed_with_errors/failed/cancelled)/dry_run/statistics (AdamsExportStatistics total/succeeded/failed/skipped)/results[AdamsExportResult]; CRUD /anti-doping/export-jobs/ med run/cancel-endpoints; hashbaserad ändringsdetektering för idempotent export ✅ PL-F1412 |
| F14.12.02 | Levererad | Whereabouts upload — WhereaboutsRecord-samling tenant-scopad med player_id/adams_athlete_id/quarter_year/quarter_number/entries[WhereaboutsEntry slot_date/slot_type (overnight/training/competition/other/sixty_minute)/start_time/end_time/address/city/country_code]/status (draft/submitted/confirmed/rejected/expired/cancelled)/submitted_at/confirmed_at/rejected_reason/adams_submission_id/sync_hash; CRUD /anti-doping/whereabouts/ med submit/confirm/reject-livscykel; tidsvalidering HH:MM, auto-uppercase country_code ✅ PL-F1412 |
| F14.12.03 | Levererad | Test result import — TestResultImport-samling tenant-scopad med player_id/adams_test_id/source_provider (NadoProvider)/source_reference/detail (TestResultDetail sample_code/sample_type/collection_date/lab_name/lab_code/substances_detected/result_code/b_sample_requested/b_sample_result)/test_type/competition_id/status (received/validated/processed/failed/rejected)/linked_doping_test_id/idempotency_key; CRUD /anti-doping/test-results/ med validate/process-livscykel; process skapar DopingTest-record med korrekt resultatmappning (negative/adverse→positive/atypical/pending); idempotens via idempotency_key ✅ PL-F1412 |
| F14.12.04 | Levererad | TUE application sync — TueSyncRecord-samling tenant-scopad med tue_application_id/player_id/direction (push/pull)/status (pending/syncing/synced/failed/conflict)/adams_tue_id/adams_status/sync_hash/conflict_field/local_value/remote_value; CRUD /anti-doping/tue-syncs/ med execute-endpoint; push exporterar lokal TUE till ADAMS, pull hämtar ADAMS-beslut och uppdaterar lokalt; konfliktdetektering ✅ PL-F1412 |
| F14.12.05 | Levererad | Per-nation anti-doping-byrå-koppling — NadoConfig-samling tenant-scopad med provider (rf_antidoping/afld/nada_de/ukad/usada/nadof/nada_at/wada/other)/country_code (auto-uppercase)/contact (NadoContactInfo organisation_name/website/email/phone/address/dco_contact_email/reporting_portal_url)/has_api/api_key_ref/api_endpoint_url/code_version/whereabouts_required/tue_committee_email/notify_on_adverse_finding/notify_on_whereabouts_failure; CRUD /anti-doping/nado-configs/ med enable/disable-endpoints; GET /defaults returnerar standardkonfigurationer för SE/FR/DE; AntiDopingWebhookEvent-samling med HMAC-SHA256-signaturverifiering per provider, idempotens-kontroll, dispatch till handlers (test_result.*/tue.*/whereabouts.*); POST /anti-doping/webhooks/{provider} + GET /anti-doping/webhooks/events audit-logg ✅ PL-F1412 |
Relaterade subsystem
Intressenter som behöver detta subsystem
Förekommer i 2 intressentanalyser