feat(health): 护士工作台 Phase 1 后端 — 用户范围过滤 + 班次患者端点
- ActionInboxQuery 新增 assigned_to_me 和 patient_id 过滤参数 - list_action_items 支持按 user_id 过滤随访任务段 - get_workbench_stats 支持用户范围随访统计 - 新增 get_nurse_patients: 今日分配给护士的患者列表 - 新增 GET /health/action-inbox/my-patients 端点 - handler 从 TenantContext 提取 user_id 实现无感过滤
This commit is contained in:
@@ -5,7 +5,8 @@ use erp_core::rbac::require_permission;
|
||||
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
|
||||
|
||||
use crate::service::action_inbox_service::{
|
||||
self, ActionInboxQuery, ActionItem, TeamOverview, ThreadResponse, WorkbenchStats,
|
||||
self, ActionInboxQuery, ActionItem, NursePatientSummary, TeamOverview, ThreadResponse,
|
||||
WorkbenchStats,
|
||||
};
|
||||
use crate::state::HealthState;
|
||||
|
||||
@@ -19,8 +20,13 @@ where
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.action-inbox.list")?;
|
||||
let user_id = if query.assigned_to_me.unwrap_or(false) {
|
||||
Some(ctx.user_id)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let result =
|
||||
action_inbox_service::list_action_items(&state.db, ctx.tenant_id, &query).await?;
|
||||
action_inbox_service::list_action_items(&state.db, ctx.tenant_id, user_id, &query).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
@@ -45,17 +51,28 @@ where
|
||||
pub async fn get_workbench_stats<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Query(params): Query<WorkbenchStatsQuery>,
|
||||
) -> Result<Json<ApiResponse<WorkbenchStats>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.action-inbox.list")?;
|
||||
let user_id = if params.assigned_to_me.unwrap_or(false) {
|
||||
Some(ctx.user_id)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let result =
|
||||
action_inbox_service::get_workbench_stats(&state.db, ctx.tenant_id).await?;
|
||||
action_inbox_service::get_workbench_stats(&state.db, ctx.tenant_id, user_id).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct WorkbenchStatsQuery {
|
||||
pub assigned_to_me: Option<bool>,
|
||||
}
|
||||
|
||||
pub async fn get_team_overview<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
@@ -69,3 +86,18 @@ where
|
||||
action_inbox_service::get_team_overview(&state.db, ctx.tenant_id).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
/// 获取护士班次患者列表 — 今日分配给当前护士的患者
|
||||
pub async fn get_nurse_patients<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
) -> Result<Json<ApiResponse<Vec<NursePatientSummary>>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.action-inbox.list")?;
|
||||
let result =
|
||||
action_inbox_service::get_nurse_patients(&state.db, ctx.tenant_id, ctx.user_id).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user