Skip to main content

wellfare_core/
models.rs

1use chrono::{DateTime, FixedOffset};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct WeightRecord {
6    pub uuid: String,
7    pub weight: f64,
8    pub body_fat: Option<f64>,
9    pub muscle_mass: Option<f64>,
10    pub body_water: Option<f64>,
11    pub skeletal_muscle: Option<f64>,
12    pub bmi: f64,
13    pub start_datetime: DateTime<FixedOffset>,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct SleepRecord {
18    pub uuid: String,
19    pub sleep_duration: f64, // typically in minutes
20    pub efficiency: f64,     // percent
21    pub deep_sleep: Option<f64>,
22    pub rem_sleep: Option<f64>,
23    pub light_sleep: Option<f64>,
24    pub wake_up_count: Option<u32>,
25    pub start_datetime: DateTime<FixedOffset>,
26    pub end_datetime: DateTime<FixedOffset>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct HeartRateRecord {
31    pub uuid: String,
32    pub heart_rate: u32,
33    pub min: Option<u32>,
34    pub max: Option<u32>,
35    pub heart_rate_zone: Option<String>,
36    pub binning_data: Option<String>,
37    pub start_datetime: DateTime<FixedOffset>,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct StepRecord {
42    pub uuid: String,
43    pub count: u32,
44    pub calorie: f64,
45    pub distance: f64,
46    pub start_datetime: DateTime<FixedOffset>,
47    pub end_datetime: DateTime<FixedOffset>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
51pub enum PrivacyMode {
52    #[serde(rename = "MODE_A_RESTRICTED")]
53    ModeARestricted,
54    #[serde(rename = "MODE_B_PRIVILEGED")]
55    ModeBPrivileged,
56    #[serde(rename = "MODE_C_PUBLIC")]
57    ModeCPublic,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
61pub enum DiagnosticReportStatus {
62    #[serde(rename = "preliminary")]
63    Preliminary,
64    #[serde(rename = "final")]
65    Final,
66    #[serde(rename = "amended")]
67    Amended,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct PathologyObservation {
72    pub id: String,
73    pub test_name: String,
74    pub value: f64,
75    pub unit: String,
76    pub reference_range_low: Option<f64>,
77    pub reference_range_high: Option<f64>,
78    pub privacy_mode: PrivacyMode,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct DiagnosticReport {
83    pub id: String,
84    pub patient_id: String,
85    pub date_issued: DateTime<FixedOffset>,
86    pub status: DiagnosticReportStatus,
87    pub pdf_attachment_uri: String,
88    pub observations: Vec<PathologyObservation>,
89    pub privacy_mode: PrivacyMode,
90    pub recorded_by_proxy_id: Option<String>,
91}