fix(health): 患者摘要列表按 user_id 过滤
小程序 loadPatients() 现在只获取当前登录用户关联的患者, 不再返回整个租户的所有患者。修复 wx_7141 上传数据写到 错误 patient 记录下的问题。 - PatientListParams 增加 user_id 可选参数 - list_summaries 增加 user_id 过滤条件 - 小程序 getPatientSummaries 传入 userId - auth store loadPatients 传入当前 user.id
This commit is contained in:
@@ -68,7 +68,9 @@ export interface PatientSummary {
|
||||
}
|
||||
|
||||
/** 获取患者摘要列表(字段最小化,替代 getPatients) */
|
||||
export async function getPatientSummaries() {
|
||||
const res = await api.get<PaginatedData<PatientSummary>>('/health/patients/summary');
|
||||
export async function getPatientSummaries(userId?: string) {
|
||||
const params: Record<string, string> = {};
|
||||
if (userId) params.user_id = userId;
|
||||
const res = await api.get<PaginatedData<PatientSummary>>('/health/patients/summary', { params });
|
||||
return Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : []);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
|
||||
loadPatients: async () => {
|
||||
try {
|
||||
const summaries = await authApi.getPatientSummaries();
|
||||
const userId = get().user?.id;
|
||||
const summaries = await authApi.getPatientSummaries(userId);
|
||||
const patients: authApi.PatientInfo[] = summaries.map((p) => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
|
||||
Reference in New Issue
Block a user