mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
feat(mental-health): accept client source + externalId with durable dedup
The screener POST hardcoded source=WEB and ignored any client-supplied externalId, so the native client could not tag provenance and an outbox replay beyond the 24h idempotency-key window minted duplicate administrations plus duplicate trend points. Accept an optional closed source enum (WEB|IOS, default WEB) and an optional bounded externalId, and persist both. Deduplicate on (userId, externalId) when present: the route returns the existing administration on replay, and a partial unique index over (user_id, external_id) WHERE external_id IS NOT NULL (migration 0221) backstops a concurrent insert race (P2002 resolved to the winner). The derived *_SCORE measurement keeps its stable per-assessment externalId, so dedup at the assessment level prevents duplicate trend points. Item answers stay encrypted and out of AI/MCP/export. Regenerate OpenAPI.
This commit is contained in:
1 parent
e93f74381e
commit
930cb227eb
6 files changed
+250
-32
No files matched your search
@@ -8137,6 +8137,16 @@ paths:
|
||||
locale:
|
||||
type: string
|
||||
maxLength: 16
|
||||
source:
|
||||
default: WEB
|
||||
type: string
|
||||
enum:
|
||||
- WEB
|
||||
- IOS
|
||||
externalId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 120
|
||||
required:
|
||||
- instrument
|
||||
- items
|
||||
|
||||
Reference in new issue
Block a user