Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CaioDuart3 committed Dec 6, 2023
2 parents acbe31f + 4ca8067 commit 47224c7
Show file tree
Hide file tree
Showing 44 changed files with 5,273 additions and 5,186 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,8 @@ cython_debug/

# End of https://www.toptal.com/developers/gitignore/api/django
*.pyc

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
9 changes: 8 additions & 1 deletion inicial/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ class ListandoDados(admin.ModelAdmin):

admin.site.register(Hospital, ListandoHospitais)
admin.site.register(Avaliacao, ListandoAvaliacoes)
admin.site.register(Dados, ListandoDados)
admin.site.register(Dados, ListandoDados)
admin.site.register(Doencas)
admin.site.register(Sintomas)
admin.site.register(Diagnostico)
admin.site.register(Cirurgia)
admin.site.register(Internacao)
admin.site.register(Condicao_familiar)
admin.site.register(Medicamento)
Binary file removed inicial/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
110 changes: 100 additions & 10 deletions inicial/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Meta:
uti_pediatrico = models.IntegerField(null=False, blank=False, default=0)
uti_neonatal = models.IntegerField(null=False, blank=False, default=0)
uti_queimado = models.IntegerField(null=False, blank=False, default=0)
atualizacao = models.DateTimeField(null=False, blank=False, default=timezone.now)

def __str__(self):
return self.nome
Expand All @@ -84,7 +85,7 @@ class Meta:

usuario = models.CharField(max_length=100, null=False, blank=False, default="")
numero = models.IntegerField(null=False, blank=False, default=1)
data = models.DateField(null=False, blank=False, default=timezone.now)
data = models.DateTimeField(null=False, blank=False, default=timezone.now)
hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE)
risco = models.CharField(max_length=100, null=False, blank=False, default="NAO_URGENTE", choices=RISCO)
horario_entrada = models.DateTimeField(null=False, blank=False, default=timezone.now)
Expand All @@ -103,10 +104,14 @@ class Meta:
verbose_name = "dados"
verbose_name_plural = "Dados"

SEXO = [
("femininino", "Feminino"),
("masculino", "Masculino"),
("na","Não informado")
GENERO = [
("na","Não informado"),
("homem-cis", "Homem cis"),
("homem-trans", "Homem trans"),
("mulher-cis", "Mulher cis"),
("mulher-trans", "Mulher trans"),
("nao-binario", "Não-binário"),
("outro", "Outro")
]

TIPO_SANGUINIO = [
Expand All @@ -118,7 +123,7 @@ class Meta:
("AB-","AB-"),
("O+","O+"),
("O-","O-"),
("na","Não informado")
("na","Não informado/Não sabe")
]

FREQUENCIA = [
Expand All @@ -130,9 +135,8 @@ class Meta:
]

usuario = models.OneToOneField(User,on_delete=models.CASCADE, primary_key=True)
nome = models.CharField(max_length=200, null=False, blank=False, default="Não informado")
idade = models.IntegerField(null=False, blank=False, default=0)
sexo = models.CharField(max_length=20, null=False, blank=False, default="na", choices=SEXO)
data_nascimento = models.DateField(null=False, blank=False, default=timezone.now)
genero = models.CharField(max_length=20, null=False, blank=False, default="na", choices=GENERO)
profissao = models.CharField(max_length=200, null=False, blank=False, default="Não informada")
endereco = models.CharField(max_length=200, null=False, blank=False, default="Não informado")
telefone = models.CharField(max_length=20, null=False, blank=False, default="Não informado")
Expand All @@ -144,4 +148,90 @@ class Meta:
exercicio_frequencia = models.CharField(max_length=200, null=False, blank=False, default="n", choices=FREQUENCIA)

def __str__(self):
return self.usuario.username
return self.usuario.username

class Doencas(models.Model):

class Meta:
verbose_name = "doença"
verbose_name_plural = "Doenças"

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="doencas")
doenca = models.CharField(max_length=200, null=False, blank=False, default="N/A")

def __str__(self):
return self.doenca

class Sintomas(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="sintomas")
sintoma = models.CharField(max_length=200, null=False, blank=False, default="N/A")

def __str__(self):
return self.sintoma

class Diagnostico(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="diagnosticos")
diagnostico = models.CharField(max_length=200, null=False, blank=False, default="N/A")

def __str__(self):
return self.diagnostico

class Cirurgia(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="cirurgias")
cirurgia = models.CharField(max_length=200, null=False, blank=False, default="N/A")
data = models.DateField(null=False, blank=False, default=timezone.now)

def __str__(self):
return self.cirurgia

class Internacao(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="internacoes")
internacao = models.CharField(max_length=200, null=False, blank=False, default="N/A")
tempo = models.IntegerField(null=False, blank=False, default=0)
data = models.DateField(null=False, blank=False, default=timezone.now)

def __str__(self):
return self.internacao

class Condicao_familiar(models.Model):

GRAU_PARENTESCO = [
("1", "1° Grau"),
("2", "2° Grau"),
("3", "3° Grau")
]

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="condicao_familiar")
condicao = models.CharField(max_length=200, null=False, blank=False, default="N/A")
grau_parentesco = models.CharField(max_length=10, null=False, blank=False, default="1", choices=GRAU_PARENTESCO)

def __str__(self):
return self.condicao

class Medicamento(models.Model):

TIPO_MEDICAMENTO = [
("1", "Medicamento com prescrição"),
("2", "Medicamento sem prescrição")
]

FREQUENCIA = [
("n","Não"),
("d","Diariamente"),
("s","Semanalmente"),
("m","Mensalmente"),
("a","Anualmente")
]

user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="medicamentos")
tipo = models.CharField(max_length=200, null=False, blank=False, default="1", choices=TIPO_MEDICAMENTO)
medicamento = models.CharField(max_length=200, null=False, blank=False, default="N/A")
frequencia = models.CharField(max_length=200, null=False, blank=False, default="n", choices=FREQUENCIA)
numero_frequencia = models.IntegerField(null=False, blank=False, default=0)

def __str__(self):
return self.medicamento
10 changes: 3 additions & 7 deletions inicial/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.dispatch import receiver
from django.db.models import Avg
from django.contrib.auth.models import User
from django.utils import timezone
from .models import *
from datetime import timedelta

Expand All @@ -12,7 +13,7 @@ def update_time(sender, instance, created, **kwargs):
risco = instance.risco
duracao = Avaliacao.objects.filter(hospital=hospital).filter(risco=risco).aggregate(Avg("duracao", default=timedelta(minutes=0)))
minutos = round(duracao["duracao__avg"].seconds / 60)

avaliacao = Avaliacao.objects.filter(hospital=hospital).aggregate(Avg("avaliacao", default=0))
nota = avaliacao["avaliacao__avg"]
hospital.nota = nota
Expand All @@ -32,10 +33,5 @@ def update_time(sender, instance, created, **kwargs):
if risco == "NAO_URGENTE":
hospital.tempo_nao_urgente = minutos

hospital.atualizacao = timezone.now()
hospital.save()

@receiver(post_save, sender=User)
def create_data(sender, instance, created, **kwargs):
if created:
dados = Dados(usuario=instance)
dados.save()
Loading

0 comments on commit 47224c7

Please sign in to comment.