项目概览、参与者管理初步优化(未接入真实数据)

This commit is contained in:
Cheng Zhou
2026-01-13 10:10:28 +08:00
parent 1338fa7e2b
commit b3cd8e03f2
37 changed files with 1785 additions and 118 deletions
+7 -7
View File
@@ -42,7 +42,7 @@ async def create_subject(
entity_type="subject",
entity_id=subject.id,
action="CREATE_SUBJECT",
detail=f"受试{subject.subject_no} 已创建",
detail=f"参与{subject.subject_no} 已创建",
operator_id=current_user.id,
operator_role=current_user.role,
)
@@ -81,7 +81,7 @@ async def get_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
return subject
@@ -100,7 +100,7 @@ async def update_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
old_status = subject.status
updated = await subject_crud.update_subject(db, subject, subject_in)
# auto-generate visits when enrolled
@@ -108,14 +108,14 @@ async def update_subject(
await subject_crud.generate_default_visits(db, updated)
detail = None
if subject_in.status and subject_in.status != old_status:
detail = f"受试{updated.subject_no} 状态 {old_status} -> {subject_in.status}"
detail = f"参与{updated.subject_no} 状态 {old_status} -> {subject_in.status}"
await audit_crud.log_action(
db,
study_id=study_id,
entity_type="subject",
entity_id=subject_id,
action="SUBJECT_STATUS_CHANGE" if detail else "UPDATE_SUBJECT",
detail=detail or "受试者已更新",
detail=detail or "参与者已更新",
operator_id=current_user.id,
operator_role=current_user.role,
)
@@ -136,7 +136,7 @@ async def delete_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
await subject_crud.delete_subject(db, subject)
await audit_crud.log_action(
db,
@@ -144,7 +144,7 @@ async def delete_subject(
entity_type="subject",
entity_id=subject_id,
action="DELETE_SUBJECT",
detail=f"受试{subject_id} 已删除",
detail=f"参与{subject_id} 已删除",
operator_id=current_user.id,
operator_role=current_user.role,
)