Epic: Patient controls consent per data category in real time
F01-001
Toggle individual consent category on/off
Patient5 SP
As a patient, I want to toggle each data category (Diagnoses, Medications, Labs, Imaging, Wearable, Genetic, Social Determinants) on or off independently so that I control exactly which types of my health data are available to buyers and clinicians.
Acceptance Criteria
Given I am on the My Data tab and all categories are toggled ON, When I click the Medications toggle, Then the toggle visually switches to OFF and a confirmation toast appears within 1 second.
Given I have toggled Medications OFF, When I navigate to the Data Value section, Then the Medications row shows "$0.00" and the total data value is recalculated excluding Medications.
Given I have toggled Medications OFF, When a marketplace buyer submits an Rx Utilization query, Then my data is excluded from the query results.
F01-002
View consent audit history
Patient3 SP
As a patient, I want to view a timestamped log of every consent change I've made so that I have a verifiable record of when I granted or revoked access to each data category.
Acceptance Criteria
Given I am on the My Data tab, When I click "Consent History," Then I see a chronological list showing category, action (granted/revoked), timestamp, and IP address.
Given I toggled Labs OFF 5 minutes ago, When I open Consent History, Then the most recent entry shows "Labs — Revoked — [timestamp]."
F01-003
Bulk consent grant/revoke all categories
Patient2 SP
As a patient, I want to grant or revoke all data categories at once with a single action so that I can quickly opt in or fully withdraw without toggling each category individually.
Acceptance Criteria
Given I am on the My Data tab with mixed consent states, When I click "Revoke All," Then all toggles switch to OFF, a confirmation dialog appears, and upon confirming, all categories are revoked and downstream systems are notified.
Given all categories are OFF, When I click "Grant All," Then all toggles switch to ON and the data value recalculates to include all categories.
F01-004
Consent expiration and auto-renewal
Patient5 SP
As a patient, I want to set an expiration date on each consent grant so that my consent automatically revokes after a time period I choose, and I'm prompted to renew.
Acceptance Criteria
Given I am granting consent for Diagnoses, When I select "Expires in 12 months," Then the consent record includes an expiration timestamp and a renewal reminder is scheduled for 30 days prior.
Given a consent is 30 days from expiration, When the scheduled check runs, Then I receive an email and in-app notification prompting me to renew or let it expire.
Given a consent has expired, When the expiration timestamp is reached, Then the category is automatically revoked and downstream systems are notified within 60 seconds.
Epic: State-specific consent rules auto-applied for jurisdictional validity
F01-005
Auto-detect patient jurisdiction from address
Compliance3 SP
As a compliance officer, I want the system to auto-detect the patient's jurisdiction from their registered address so that the correct state-specific consent rules are applied without manual configuration.
Acceptance Criteria
Given a patient registers with a Texas address, When their profile is created, Then the consent engine applies TX HB 300 rules (explicit written consent required for electronic disclosure of PHI).
Given a patient registers with a California address, When their profile is created, Then CMIA rules are applied (consent must specify the nature and purpose of disclosure).
F01-006
Enforce HIPAA minimum necessary standard
Compliance5 SP
As a compliance officer, I want every data access request validated against the HIPAA minimum necessary standard so that buyers and clinicians only receive the specific data elements their use case requires.
Acceptance Criteria
Given a buyer submits a Cohort query for "Diabetes prevalence by age," When the query is processed, Then only Diagnoses and Demographics data is included — Medications, Labs, and other categories are excluded even if consented.
Given a clinician opens a patient record, When the access is logged, Then the audit record includes the minimum necessary justification (treatment, payment, or operations).
F01-007
Consent rule version management
Compliance3 SP
As a compliance officer, I want consent rule versions tracked so that when state laws change, new rules apply to future consents while existing consents remain valid under the version they were granted so that we maintain legal defensibility.
Acceptance Criteria
Given Texas updates HB 300, When I publish a new rule version, Then all new TX consents use the updated rules and existing consents show which rule version they were granted under.
Given an audit request, When I pull a patient's consent record, Then each consent entry shows the rule version, jurisdiction, and effective date.
Epic: Consent events propagate instantly to all downstream systems
F01-008
Real-time consent propagation to marketplace
Operator5 SP
As a platform operator, I want consent revocations to propagate to the marketplace query engine within 30 seconds so that revoked data is never included in buyer query results after the patient withdraws.
Acceptance Criteria
Given a patient revokes Medications consent, When a buyer submits an Rx query within 30 seconds, Then that patient's Rx data is not included in the results.
Given a consent revocation event fires, When the event bus processes it, Then a propagation receipt is logged with timestamp, affected systems, and confirmation from each downstream consumer.
F01-009
Real-time consent propagation to clinician portal
Operator5 SP
As a platform operator, I want consent changes to immediately update clinician portal access so that if a patient revokes a specific provider's access, Door 4 restricts that provider's view within 30 seconds.
Acceptance Criteria
Given a patient revokes clinician access, When the clinician refreshes the patient record, Then they see a "Patient has restricted access" message instead of clinical data.
Given a clinician has a patient record open, When the patient revokes access, Then a real-time notification appears and the data is hidden without requiring a page refresh.
F01-010
Real-time consent propagation to payouts engine
Operator3 SP
As a platform operator, I want consent revocations to stop future payout accruals for revoked categories so that patients only earn from data they've actively consented to share.
Acceptance Criteria
Given a patient revokes Labs consent, When a buyer query includes Labs data, Then that patient earns $0 from that query even if other categories are still consented.
Given a revocation occurs mid-billing-cycle, When the monthly earnings are calculated, Then the patient's earnings reflect the pro-rated amount up to the revocation date.
F01-011
Consent propagation failure handling
Operator5 SP
As a platform operator, I want failed consent propagations to retry with exponential backoff and alert ops if unresolved so that no revocation is silently dropped.
Acceptance Criteria
Given a consent event fails to propagate to the marketplace, When the first retry fails, Then it retries at 1s, 5s, 30s, 120s intervals before escalating to the ops dashboard.
Given a propagation has been in retry for 5 minutes, When the escalation threshold is hit, Then an ops alert fires and the affected data categories are temporarily blocked in the marketplace as a safety measure.
F01-012
Consent event email and SMS confirmation
Patient2 SP
As a patient, I want to receive an email and optional SMS confirmation every time I grant or revoke consent so that I have out-of-band proof that my consent action was recorded.
Acceptance Criteria
Given I toggle Diagnoses OFF, When the consent is recorded, Then I receive an email within 60 seconds with subject "Consent Updated: Diagnoses Revoked" and a summary of all current consent states.
Given I have SMS notifications enabled, When I revoke a category, Then I also receive an SMS reading "Moonlitic: You revoked access to [Category] on [Date]. Reply HELP for support."