42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "device_readings")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
pub patient_id: Uuid,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub device_id: Option<String>,
|
|
pub device_type: String,
|
|
#[sea_orm(nullable)]
|
|
pub metric: Option<String>,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub device_model: Option<String>,
|
|
pub raw_value: serde_json::Value,
|
|
pub measured_at: DateTimeUtc,
|
|
pub created_at: DateTimeUtc,
|
|
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
|
pub deleted_at: Option<DateTimeUtc>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::patient::Entity",
|
|
from = "Column::PatientId",
|
|
to = "super::patient::Column::Id"
|
|
)]
|
|
Patient,
|
|
}
|
|
|
|
impl Related<super::patient::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Patient.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|