feat: 医护仪表盘增强 + 患者端文章分类浏览
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

- DoctorDashboard 增加 pending_dialysis_review/pending_lab_review/today_appointments
- 医护小程序首页增加「健康审核」区块(待审透析/化验/今日预约)
- 患者端文章列表增加分类 tabs 横向滚动筛选
- article service 增加 listCategories + category_id 筛选
This commit is contained in:
iven
2026-04-26 14:25:06 +08:00
parent c9bf5f6139
commit 7a9054c914
7 changed files with 188 additions and 14 deletions

View File

@@ -244,9 +244,13 @@ where
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "health.consultation.list")?;
let result = consultation_service::get_doctor_dashboard(
let mut result = consultation_service::get_doctor_dashboard(
&state, ctx.tenant_id, ctx.user_id,
)
.await?;
consultation_service::enrich_doctor_dashboard_health(
&state, ctx.tenant_id, ctx.user_id, &mut result,
)
.await?;
Ok(Json(ApiResponse::ok(result)))
}

View File

@@ -426,6 +426,9 @@ pub struct DoctorDashboard {
pub unread_messages: i64,
pub pending_follow_ups: i64,
pub today_consultations: i64,
pub pending_dialysis_review: i64,
pub pending_lab_review: i64,
pub today_appointments: i64,
}
/// 获取指定医生的仪表盘数据。
@@ -456,6 +459,9 @@ pub async fn get_doctor_dashboard(
unread_messages: 0,
pending_follow_ups: 0,
today_consultations: 0,
pending_dialysis_review: 0,
pending_lab_review: 0,
today_appointments: 0,
});
}
};
@@ -525,5 +531,51 @@ pub async fn get_doctor_dashboard(
unread_messages,
pending_follow_ups: pending_follow_ups as i64,
today_consultations: today_consultations as i64,
pending_dialysis_review: 0,
pending_lab_review: 0,
today_appointments: 0,
})
}
/// 补充医生仪表盘中的健康数据计数。
/// 由 consultation_service 调用,因为 DoctorDashboard 定义在此模块。
pub async fn enrich_doctor_dashboard_health(
state: &HealthState,
tenant_id: Uuid,
doctor_user_id: Uuid,
dashboard: &mut DoctorDashboard,
) -> HealthResult<()> {
use crate::entity::{dialysis_record, lab_report, appointment};
// 待审核透析记录doctor_id 通过患者关联,这里取全租户待审核)
let pending_dialysis = dialysis_record::Entity::find()
.filter(dialysis_record::Column::TenantId.eq(tenant_id))
.filter(dialysis_record::Column::DeletedAt.is_null())
.filter(dialysis_record::Column::Status.eq("draft"))
.count(&state.db)
.await?;
dashboard.pending_dialysis_review = pending_dialysis as i64;
// 待审核化验报告
let pending_lab = lab_report::Entity::find()
.filter(lab_report::Column::TenantId.eq(tenant_id))
.filter(lab_report::Column::DeletedAt.is_null())
.filter(lab_report::Column::Status.eq("pending"))
.count(&state.db)
.await?;
dashboard.pending_lab_review = pending_lab as i64;
// 今日预约
let today = chrono::Utc::now().date_naive();
let today_appts = appointment::Entity::find()
.filter(appointment::Column::TenantId.eq(tenant_id))
.filter(appointment::Column::DeletedAt.is_null())
.filter(appointment::Column::AppointmentDate.eq(today))
.filter(appointment::Column::DoctorId.eq(doctor_user_id))
.filter(appointment::Column::Status.is_in(["confirmed", "pending"]))
.count(&state.db)
.await?;
dashboard.today_appointments = today_appts as i64;
Ok(())
}