From 2dc280a4012f75628cead1c3b9d15dcb8ae2c73e Mon Sep 17 00:00:00 2001 From: iven Date: Fri, 24 Apr 2026 12:22:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(health):=20=E6=96=B0=E5=A2=9E=E9=A2=84?= =?UTF-8?q?=E7=BA=A6/=E9=9A=8F=E8=AE=BF=E5=8D=95=E6=9D=A1=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20GET=20=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/handler/appointment_handler.rs | 14 ++++++++++++ .../src/handler/follow_up_handler.rs | 14 ++++++++++++ crates/erp-health/src/module.rs | 7 +++++- .../src/service/appointment_service.rs | 22 +++++++++++++++++++ .../src/service/follow_up_service.rs | 22 +++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/crates/erp-health/src/handler/appointment_handler.rs b/crates/erp-health/src/handler/appointment_handler.rs index b32bbe2..4b68193 100644 --- a/crates/erp-health/src/handler/appointment_handler.rs +++ b/crates/erp-health/src/handler/appointment_handler.rs @@ -88,6 +88,20 @@ where Ok(Json(ApiResponse::ok(result))) } +pub async fn get_appointment( + State(state): State, + Extension(ctx): Extension, + Path(id): Path, +) -> Result>, AppError> +where + HealthState: FromRef, + S: Clone + Send + Sync + 'static, +{ + require_permission(&ctx, "health.appointment.list")?; + let result = appointment_service::get_appointment(&state, ctx.tenant_id, id).await?; + Ok(Json(ApiResponse::ok(result))) +} + pub async fn update_appointment_status( State(state): State, Extension(ctx): Extension, diff --git a/crates/erp-health/src/handler/follow_up_handler.rs b/crates/erp-health/src/handler/follow_up_handler.rs index 410a013..4fc0813 100644 --- a/crates/erp-health/src/handler/follow_up_handler.rs +++ b/crates/erp-health/src/handler/follow_up_handler.rs @@ -61,6 +61,20 @@ where Ok(Json(ApiResponse::ok(result))) } +pub async fn get_task( + State(state): State, + Extension(ctx): Extension, + Path(id): Path, +) -> Result>, AppError> +where + HealthState: FromRef, + S: Clone + Send + Sync + 'static, +{ + require_permission(&ctx, "health.follow-up.list")?; + let result = follow_up_service::get_task(&state, ctx.tenant_id, id).await?; + Ok(Json(ApiResponse::ok(result))) +} + pub async fn create_task( State(state): State, Extension(ctx): Extension, diff --git a/crates/erp-health/src/module.rs b/crates/erp-health/src/module.rs index a7f5830..2ff85e3 100644 --- a/crates/erp-health/src/module.rs +++ b/crates/erp-health/src/module.rs @@ -132,6 +132,10 @@ impl HealthModule { "/health/appointments/{id}/status", axum::routing::put(appointment_handler::update_appointment_status), ) + .route( + "/health/appointments/{id}", + axum::routing::get(appointment_handler::get_appointment), + ) .route( "/health/doctor-schedules", axum::routing::get(appointment_handler::list_schedules) @@ -153,7 +157,8 @@ impl HealthModule { ) .route( "/health/follow-up-tasks/{id}", - axum::routing::put(follow_up_handler::update_task) + axum::routing::get(follow_up_handler::get_task) + .put(follow_up_handler::update_task) .delete(follow_up_handler::delete_task), ) .route( diff --git a/crates/erp-health/src/service/appointment_service.rs b/crates/erp-health/src/service/appointment_service.rs index c132ab9..49debcf 100644 --- a/crates/erp-health/src/service/appointment_service.rs +++ b/crates/erp-health/src/service/appointment_service.rs @@ -64,6 +64,28 @@ pub async fn list_appointments( Ok(PaginatedResponse { data, total, page, page_size: limit, total_pages }) } +pub async fn get_appointment( + state: &HealthState, + tenant_id: Uuid, + appointment_id: Uuid, +) -> HealthResult { + let m = appointment::Entity::find() + .filter(appointment::Column::Id.eq(appointment_id)) + .filter(appointment::Column::TenantId.eq(tenant_id)) + .filter(appointment::Column::DeletedAt.is_null()) + .one(&state.db) + .await? + .ok_or(HealthError::AppointmentNotFound)?; + + Ok(AppointmentResp { + id: m.id, patient_id: m.patient_id, doctor_id: m.doctor_id, + appointment_type: m.appointment_type, appointment_date: m.appointment_date, + start_time: m.start_time, end_time: m.end_time, + status: m.status, cancel_reason: m.cancel_reason, notes: m.notes, + created_at: m.created_at, updated_at: m.updated_at, version: m.version, + }) +} + pub async fn create_appointment( state: &HealthState, tenant_id: Uuid, diff --git a/crates/erp-health/src/service/follow_up_service.rs b/crates/erp-health/src/service/follow_up_service.rs index f540eee..752192c 100644 --- a/crates/erp-health/src/service/follow_up_service.rs +++ b/crates/erp-health/src/service/follow_up_service.rs @@ -59,6 +59,28 @@ pub async fn list_tasks( Ok(PaginatedResponse { data, total, page, page_size: limit, total_pages }) } +pub async fn get_task( + state: &HealthState, + tenant_id: Uuid, + task_id: Uuid, +) -> HealthResult { + let m = follow_up_task::Entity::find() + .filter(follow_up_task::Column::Id.eq(task_id)) + .filter(follow_up_task::Column::TenantId.eq(tenant_id)) + .filter(follow_up_task::Column::DeletedAt.is_null()) + .one(&state.db) + .await? + .ok_or(HealthError::FollowUpTaskNotFound)?; + + Ok(FollowUpTaskResp { + id: m.id, patient_id: m.patient_id, assigned_to: m.assigned_to, + follow_up_type: m.follow_up_type, planned_date: m.planned_date, + status: m.status, content_template: m.content_template, + related_appointment_id: m.related_appointment_id, + created_at: m.created_at, updated_at: m.updated_at, version: m.version, + }) +} + pub async fn create_task( state: &HealthState, tenant_id: Uuid,