- 风险评分引擎 load_patient_data 实装(体征+化验异常)
- refresh_all_patients 高风险自动创建洞察+事件推送
- erp-message 订阅 copilot.insight.created 推送医护通知
- 每日 cron 增加洞察过期清理+建议过期清理
- POST /ai/suggestions/{id}/feedback 建议反馈端点
- SuggestionFeedbackService 反馈服务层
- 小程序健康页建议卡片增加采纳/忽略/咨询医生按钮
45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
use crate::entity::ai_suggestion_feedback;
|
|
use erp_core::error::AppResult;
|
|
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
|
|
use uuid::Uuid;
|
|
|
|
pub struct SuggestionFeedbackService;
|
|
|
|
impl SuggestionFeedbackService {
|
|
pub async fn submit_feedback(
|
|
db: &sea_orm::DatabaseConnection,
|
|
tenant_id: Uuid,
|
|
suggestion_id: Uuid,
|
|
user_id: Uuid,
|
|
action: String,
|
|
feedback_text: Option<String>,
|
|
) -> AppResult<Uuid> {
|
|
let id = Uuid::now_v7();
|
|
let now = chrono::Utc::now();
|
|
let model = ai_suggestion_feedback::ActiveModel {
|
|
id: Set(id),
|
|
tenant_id: Set(tenant_id),
|
|
suggestion_id: Set(suggestion_id),
|
|
user_id: Set(user_id),
|
|
action: Set(action),
|
|
feedback_text: Set(feedback_text),
|
|
created_at: Set(now),
|
|
};
|
|
model.insert(db).await?;
|
|
Ok(id)
|
|
}
|
|
|
|
pub async fn list_feedback(
|
|
db: &sea_orm::DatabaseConnection,
|
|
tenant_id: Uuid,
|
|
suggestion_id: Uuid,
|
|
) -> AppResult<Vec<ai_suggestion_feedback::Model>> {
|
|
let items = ai_suggestion_feedback::Entity::find()
|
|
.filter(ai_suggestion_feedback::Column::TenantId.eq(tenant_id))
|
|
.filter(ai_suggestion_feedback::Column::SuggestionId.eq(suggestion_id))
|
|
.all(db)
|
|
.await?;
|
|
Ok(items)
|
|
}
|
|
}
|