//! `Appointment` model — paired with `Patient` via a `patient_id`
//! foreign key. Together they show relation-driven lists, status
//! filtering, and the framework's audit-on-mutation pipeline across
//! two related tables.
//!
//! Rename, extend, or delete this freely — it is your project's code.
use rustio_admin::{DateTime, ModelAdmin, RustioAdmin, Utc};
// `#[derive(RustioAdmin)]` generates both the admin metadata and the
// `impl Model` ORM glue from these fields; `#[rustio(table = "…")]`
// pins the SQL table name.
#[derive(RustioAdmin)]
#[rustio(table = "appointments")]
pub struct Appointment {
pub id: i64,
pub patient_id: i64,
pub scheduled_for: DateTime<Utc>,
pub reason: String,
/// One of `scheduled` / `completed` / `cancelled`. Enforced by a
/// CHECK constraint in the migration; filterable in the list page.
pub status: String,
pub created_at: DateTime<Utc>,
}
impl ModelAdmin for Appointment {
fn list_display() -> &'static [&'static str] {
&["patient_id", "scheduled_for", "reason", "status"]
}
fn list_filter() -> &'static [&'static str] {
&["status"]
}
fn search_fields() -> &'static [&'static str] {
&["reason"]
}
fn ordering() -> &'static [&'static str] {
&["-scheduled_for"]
}
}