<commit_before>from django.db import models

from samples.custom import models as cmodels


class Patient(models.Model):
    name = models.CharField(
        verbose_name="Nome do paciente",
        max_length=255,
    )

    def __str__(self):
        return self.name


class AdmissionNote(models.Model):
    patient = models.ForeignKey(
        Patient,
        null=True,
    )
    observed_symptoms = models.ManyToManyField(
        'Symptom',
        through='ObservedSymptom',
    )
    id_gal_origin = models.CharField(
        verbose_name="ID Gal Origem",
        max_length=255,
    )

    def __str__(self):
        return "ID Gal: {}".format(self.id_gal_origin)


class FluVaccine(models.Model):
    was_applied = cmodels.YesNoIgnoredField(
        verbose_name="Recebeu vacina contra gripe?",
    )
    date_applied = models.DateField(
        verbose_name="Data de aplicação",
        null=True,
        blank=True,
    )
    admission_note = models.OneToOneField(
        AdmissionNote,
        on_delete=models.CASCADE,
    )

    def __str__(self):
        return "Vacina contra gripe"


class CollectionType(models.Model):
    method_name = models.CharField(
        verbose_name="Método de coleta",
        max_length=255,
    )
    is_primary = models.BooleanField(
        verbose_name="Principal?",
        default=True,
    )

    def __str__(self):
        return self.method_name


class CollectedSample(models.Model):
    collection_date = models.DateField(
        verbose_name="Data de coleta",
        null=True,
        blank=False,
    )
    admission_note = models.ForeignKey(
        AdmissionNote,
    )
    collection_type = models.ForeignKey(
        CollectionType,
        verbose_name="Método de coleta",
        on_delete=models.SET_NULL,
        null=True,
        blank=False,
    )

    def __str__(self):
        return "Amostra coletada"


class Symptom(models.Model):
    name = models.CharField(
        verbose_name="Nome do sintoma",
        max_length=255,
    )
    is_primary = models.BooleanField(
        verbose_name="Principal?",
        default=True,
    )

    def __str__(self):
        return self.name


class ObservedSymptom(models.Model):
    symptom = models.ForeignKey(
        Symptom,
        on_delete=models.CASCADE,
    )
    admission_note = models.ForeignKey(
        AdmissionNote,
        on_delete=models.CASCADE,
    )
    observed = models.NullBooleanField(
        verbose_name="Apresenta sintoma?",
        default=None,
    )

    class Meta:
        unique_together = (
            ('symptom', 'admission_note'),
        )<commit_msg>:memo: Should have been added with migration<commit_after>from django.db import models

from samples.custom import models as cmodels


class Patient(models.Model):
    name = models.CharField(
        verbose_name="Nome do paciente",
        max_length=255,
    )

    def __str__(self):
        return self.name


class AdmissionNote(models.Model):
    patient = models.ForeignKey(
        Patient,
        null=True,
    )
    observed_symptoms = models.ManyToManyField(
        'Symptom',
        through='ObservedSymptom',
    )
    id_gal_origin = models.CharField(
        verbose_name="ID Gal Origem",
        max_length=255,
    )

    def __str__(self):
        return "ID Gal: {}".format(self.id_gal_origin)


class FluVaccine(models.Model):
    was_applied = cmodels.YesNoIgnoredField(
        verbose_name="Recebeu vacina contra gripe?",
    )
    date_applied = models.DateField(
        verbose_name="Data de aplicação",
        null=True,
        blank=True,
    )
    admission_note = models.OneToOneField(
        AdmissionNote,
        on_delete=models.CASCADE,
    )

    def __str__(self):
        return "Vacina contra gripe"


class CollectionType(models.Model):
    method_name = models.CharField(
        verbose_name="Método de coleta",
        max_length=255,
    )
    is_primary = models.BooleanField(
        verbose_name="Principal?",
        default=True,
    )

    def __str__(self):
        return self.method_name


class CollectedSample(models.Model):
    collection_date = models.DateField(
        verbose_name="Data de coleta",
        null=True,
        blank=False,
    )
    admission_note = models.ForeignKey(
        AdmissionNote,
    )
    collection_type = models.ForeignKey(
        CollectionType,
        verbose_name="Método de coleta",
        on_delete=models.SET_NULL,
        null=True,
        blank=False,
    )

    def __str__(self):
        return "Amostra coletada"


class Symptom(models.Model):
    name = models.CharField(
        verbose_name="Nome do sintoma",
        max_length=255,
    )
    is_primary = models.BooleanField(
        verbose_name="Principal?",
        default=True,
    )

    def __str__(self):
        return self.name


class ObservedSymptom(models.Model):
    symptom = models.ForeignKey(
        Symptom,
        on_delete=models.CASCADE,
        verbose_name="Sintoma principal"
    )
    admission_note = models.ForeignKey(
        AdmissionNote,
        on_delete=models.CASCADE,
    )
    observed = cmodels.YesNoIgnoredField(
        verbose_name="Apresenta sintoma?",
        default=None,
    )

    class Meta:
        unique_together = (
            ('symptom', 'admission_note'),
        )
{'fraction_non_alphanumeric': 0.0944214097248398, 'fraction_numerical': 0.004523181304183943, 'mean_word_length': 2.382409177820268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2177645', 'n_tokens_mistral': 1730, 'n_tokens_neox': 1633, 'n_words': 302}