Files
hms/apps/miniprogram/src/services/consent.ts
iven 44bb31197e
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
feat(miniprogram): 实现知情同意页面 — 查看/撤回/签署
审计后续 H2: 对接后端 3 个知情同意 API 路由。

新增内容:
- services/consent.ts: 类型定义 + listConsents/grantConsent/revokeConsent
- 患者端知情同意列表页: 查看已签署同意书 + 撤回操作
- 路由注册 + "我的"菜单入口
2026-04-30 16:52:39 +08:00

49 lines
1.3 KiB
TypeScript

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<Consent>('/health/consents', data);
}
export async function revokeConsent(id: string, version: number, notes?: string) {
return api.put<Consent>(`/health/consents/${id}/revoke`, { version, notes });
}