Spaces:
Paused
Paused
File size: 1,067 Bytes
823a3a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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() |