This commit implements the complete medication management system, which is a critical MVP feature for Normogen. Features Implemented: - 7 fully functional API endpoints for medication CRUD operations - Dose logging system (taken/skipped/missed) - Real-time adherence calculation with configurable periods - Multi-person support for families managing medications together - Comprehensive security (JWT authentication, ownership verification) - Audit logging for all operations API Endpoints: - POST /api/medications - Create medication - GET /api/medications - List medications (by profile) - GET /api/medications/:id - Get medication details - PUT /api/medications/:id - Update medication - DELETE /api/medications/:id - Delete medication - POST /api/medications/:id/log - Log dose - GET /api/medications/:id/adherence - Calculate adherence Security: - JWT authentication required for all endpoints - User ownership verification on every request - Profile ownership validation - Audit logging for all CRUD operations Multi-Person Support: - Parents can manage children's medications - Caregivers can track family members' meds - Profile-based data isolation - Family-focused workflow Adherence Tracking: - Real-time calculation: (taken / total) × 100 - Configurable time periods (default: 30 days) - Tracks taken, missed, and skipped doses - Actionable health insights Files Modified: - backend/src/handlers/medications.rs - New handler with 7 endpoints - backend/src/handlers/mod.rs - Added medications module - backend/src/models/medication.rs - Enhanced with repository pattern - backend/src/main.rs - Added 7 new routes Phase: 2.7 - Task 1 (Medication Management) Status: Complete and production-ready Lines of Code: ~550 lines
65 lines
1.4 KiB
Text
65 lines
1.4 KiB
Text
# Multi-stage build for smaller, more secure image
|
|
# Stage 1: Build
|
|
FROM rust:1.93-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
pkg-config \
|
|
libssl-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy manifests first (better layer caching)
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
# Create dummy main.rs to cache dependencies
|
|
RUN mkdir src && \
|
|
echo "fn main() {}" > src/main.rs && \
|
|
cargo build --release && \
|
|
rm -rf src
|
|
|
|
# Copy actual source
|
|
COPY src ./src
|
|
|
|
# Build application
|
|
RUN cargo build --release
|
|
|
|
# Stage 2: Runtime
|
|
FROM debian:bookworm-slim
|
|
|
|
# Install runtime dependencies only
|
|
RUN apt-get update && apt-get install -y \
|
|
ca-certificates \
|
|
libssl3 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& apt-get clean
|
|
|
|
# Create non-root user
|
|
RUN useradd -m -u 1000 normogen && \
|
|
mkdir -p /app && \
|
|
chown -R normogen:normogen /app
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /app/target/release/normogen-backend /app/normogen-backend
|
|
|
|
# Set permissions
|
|
RUN chmod +x /app/normogen-backend && \
|
|
chown normogen:normogen /app/normogen-backend
|
|
|
|
# Switch to non-root user
|
|
USER normogen
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health || exit 1
|
|
|
|
# Run with proper signal handling
|
|
ENTRYPOINT ["/app/normogen-backend"]
|
|
CMD []
|