- Apply rustfmt to all Rust source files in backend/ - Fix trailing whitespace inconsistencies - Standardize formatting across handlers, models, and services - Improve code readability with consistent formatting These changes are purely stylistic and do not affect functionality. All CI checks now pass with proper formatting.
82 lines
2.2 KiB
Rust
82 lines
2.2 KiB
Rust
//! Interaction Models
|
|
//!
|
|
//! Database models for drug interactions
|
|
|
|
use mongodb::bson::{oid::ObjectId, DateTime};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DrugInteraction {
|
|
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
|
pub id: Option<ObjectId>,
|
|
#[serde(rename = "drug1")]
|
|
pub drug1: String,
|
|
#[serde(rename = "drug2")]
|
|
pub drug2: String,
|
|
#[serde(rename = "severity")]
|
|
pub severity: InteractionSeverity,
|
|
#[serde(rename = "description")]
|
|
pub description: String,
|
|
#[serde(rename = "source")]
|
|
pub source: InteractionSource,
|
|
#[serde(rename = "createdAt")]
|
|
pub created_at: DateTime,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum InteractionSeverity {
|
|
Mild,
|
|
Moderate,
|
|
Severe,
|
|
Unknown,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum InteractionSource {
|
|
OpenFDA,
|
|
UserProvided,
|
|
ProfessionalDatabase,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct MedicationIngredient {
|
|
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
|
pub id: Option<ObjectId>,
|
|
#[serde(rename = "medicationName")]
|
|
pub medication_name: String,
|
|
#[serde(rename = "ingredientName")]
|
|
pub ingredient_name: String,
|
|
#[serde(rename = "region")]
|
|
pub region: String, // "EU" or "US"
|
|
#[serde(rename = "createdAt")]
|
|
pub created_at: DateTime,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct UserAllergy {
|
|
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
|
pub id: Option<ObjectId>,
|
|
#[serde(rename = "userId")]
|
|
pub user_id: String,
|
|
#[serde(rename = "allergen")]
|
|
pub allergen: String,
|
|
#[serde(rename = "allergyType")]
|
|
pub allergy_type: AllergyType,
|
|
#[serde(rename = "severity")]
|
|
pub severity: String,
|
|
#[serde(rename = "notes")]
|
|
pub notes: Option<String>,
|
|
#[serde(rename = "createdAt")]
|
|
pub created_at: DateTime,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum AllergyType {
|
|
Drug,
|
|
Food,
|
|
Environmental,
|
|
Other,
|
|
}
|