import { api } from './request'; // ── Types ───────────────────────────────────────────── export interface Consent { id: string; patient_id: string; consent_type: string; consent_scope: string; status: string; granted_at?: string; revoked_at?: string; expiry_date?: string; consent_method?: string; witness_name?: string; notes?: string; created_at: string; updated_at: string; version: number; } // ── Patient-facing API ──────────────────────────────── export async function listConsents( patientId: string, params?: { page?: number; page_size?: number }, ) { return api.get<{ data: Consent[]; total: number }>( `/health/patients/${patientId}/consents`, params, ); } export async function grantConsent(data: { patient_id: string; consent_type: string; consent_scope: string; expiry_date?: string; consent_method?: string; witness_name?: string; notes?: string; }) { return api.post('/health/consents', data); } export async function revokeConsent(id: string, version: number, notes?: string) { return api.put(`/health/consents/${id}/revoke`, { version, notes }); }