feat(health): 新增预约/随访单条查询 GET 端点
This commit is contained in:
@@ -88,6 +88,20 @@ where
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
pub async fn get_appointment<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<Json<ApiResponse<AppointmentResp>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
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<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
|
||||
@@ -61,6 +61,20 @@ where
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
pub async fn get_task<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<Json<ApiResponse<FollowUpTaskResp>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
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<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<AppointmentResp> {
|
||||
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,
|
||||
|
||||
@@ -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<FollowUpTaskResp> {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user