feat: implement health statistics tracking (Phase 2.7 Task 2)
- Add HealthStatistics model with 10 stat types - Implement HealthStatisticsRepository - Create 6 health stats API endpoints - Add trend analysis with summary calculations - Follow medication repository pattern Status: 60% complete, needs compilation fixes
This commit is contained in:
parent
d673415bc6
commit
b59be78e4a
18 changed files with 2420 additions and 7 deletions
|
|
@ -78,6 +78,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
// Get the underlying MongoDB database for security services
|
||||
let database = db.get_database();
|
||||
let mongo_client = database.client().clone();
|
||||
|
||||
// Initialize security services (Phase 2.6)
|
||||
let audit_logger = security::AuditLogger::new(&database);
|
||||
|
|
@ -92,6 +93,12 @@ async fn main() -> anyhow::Result<()> {
|
|||
1440, // max_duration_minutes (24 hours)
|
||||
);
|
||||
|
||||
// Initialize health stats repository (Phase 2.7) - using Collection pattern
|
||||
let health_stats_collection = database.collection("health_statistics");
|
||||
let health_stats_repo = models::health_stats::HealthStatisticsRepository::new(
|
||||
health_stats_collection
|
||||
);
|
||||
|
||||
// Create application state
|
||||
let state = config::AppState {
|
||||
db,
|
||||
|
|
@ -100,8 +107,10 @@ async fn main() -> anyhow::Result<()> {
|
|||
audit_logger: Some(audit_logger),
|
||||
session_manager: Some(session_manager),
|
||||
account_lockout: Some(account_lockout),
|
||||
health_stats_repo: Some(health_stats_repo),
|
||||
mongo_client: Some(mongo_client),
|
||||
};
|
||||
|
||||
|
||||
eprintln!("Building router with security middleware...");
|
||||
|
||||
// Build public routes (no auth required)
|
||||
|
|
@ -146,6 +155,14 @@ async fn main() -> anyhow::Result<()> {
|
|||
.route("/api/medications/:id/delete", post(handlers::delete_medication))
|
||||
.route("/api/medications/:id/log", post(handlers::log_dose))
|
||||
.route("/api/medications/:id/adherence", get(handlers::get_adherence))
|
||||
|
||||
// Health statistics management (Phase 2.7)
|
||||
.route("/api/health-stats", post(handlers::create_health_stat))
|
||||
.route("/api/health-stats", get(handlers::list_health_stats))
|
||||
.route("/api/health-stats/trends", get(handlers::get_health_trends))
|
||||
.route("/api/health-stats/:id", get(handlers::get_health_stat))
|
||||
.route("/api/health-stats/:id", put(handlers::update_health_stat))
|
||||
.route("/api/health-stats/:id", delete(handlers::delete_health_stat))
|
||||
.layer(axum::middleware::from_fn_with_state(
|
||||
state.clone(),
|
||||
middleware::jwt_auth_middleware
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue