from django.db import models from django.contrib.auth.models import User class CheckIn(models.Model): """Stores a single mental health assessment session.""" user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) # Aggregated Results primary_indicator = models.CharField(max_length=50) primary_percentage = models.FloatField() risk_level = models.CharField(max_length=50) # Raw Data and Distributions (PostgreSQL JSONField recommended) responses = models.JSONField() distribution = models.JSONField() def __str__(self): return f"Check-in {self.id} - {self.primary_indicator} ({self.created_at.date()})" class SentenceAnalysis(models.Model): """Granular sentence-level analysis for the UI.""" checkin = models.ForeignKey(CheckIn, related_name='sentences', on_delete=models.CASCADE) text = models.TextField() label = models.CharField(max_length=50) confidence = models.FloatField()