feat(health+mp): S2-3 Patient DTO 最小化
后端: - 新增 PatientSummary DTO(id/name/gender/birth_date/status 5 字段) - 新增 GET /health/patients/summary 端点(权限 health.patient.list) - patient_service::list_summaries 仅查询非敏感字段 前端: - 新增 PatientSummary 类型 + getPatientSummaries() API - auth store loadPatients 改用 summary 端点 - setCurrentPatient 仅存储非敏感字段到 secureSet
This commit is contained in:
@@ -222,16 +222,30 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
},
|
||||
|
||||
setCurrentPatient: (patient) => {
|
||||
secureSet('current_patient_id', patient.id);
|
||||
secureSet('current_patient', JSON.stringify(patient));
|
||||
setCachedPatientId(patient.id);
|
||||
const safePatient: authApi.PatientInfo = {
|
||||
id: patient.id,
|
||||
name: patient.name,
|
||||
gender: patient.gender,
|
||||
birth_date: patient.birth_date,
|
||||
relation: patient.relation,
|
||||
};
|
||||
secureSet('current_patient_id', safePatient.id);
|
||||
secureSet('current_patient', JSON.stringify(safePatient));
|
||||
setCachedPatientId(safePatient.id);
|
||||
clearRequestCache();
|
||||
set({ currentPatient: patient });
|
||||
set({ currentPatient: safePatient });
|
||||
},
|
||||
|
||||
loadPatients: async () => {
|
||||
try {
|
||||
const patients = await authApi.getPatients();
|
||||
const summaries = await authApi.getPatientSummaries();
|
||||
const patients: authApi.PatientInfo[] = summaries.map((p) => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
gender: p.gender,
|
||||
birth_date: p.birth_date,
|
||||
relation: 'self',
|
||||
}));
|
||||
set({ patients });
|
||||
if (patients.length > 0 && !get().currentPatient) {
|
||||
get().setCurrentPatient(patients[0]);
|
||||
|
||||
Reference in New Issue
Block a user