def inserirAtendimentoInicial(self, endereco, qtd_comodos, is_agua_encanada): if (not self.atendimento.is_primeiro): # Caso esse atendimento NAO seja inicial, nao deixa inserir return inicial = AtendimentoInicial() inicial.endereco = endereco inicial.qtd_comodos = qtd_comodos inicial.is_agua_encanada = is_agua_encanada db = Database() db.saveData(inicial) # Recupera o ultimo atendimento inicial salvo para recuperar o ID. id = db.Session().query(AtendimentoInicial).order_by(desc(AtendimentoInicial.id)).first().id self.atendimento.id_atendimento_inicial = id
def userAgendamentos(user_id): try: db = Database() session = db.Session() return session.query(Agendamento, Atendimento, Paciente).\ filter(Agendamento.id_atendimento == Atendimento.id, Agendamento.id_adm_saude == user_id, Atendimento.id_paciente == Paciente.id).\ order_by(Agendamento.data).\ with_entities(Atendimento.id.label('id'), Paciente.nome.label('nomePaciente'), Agendamento.data.label('diaAgendamento'), Atendimento.is_primeiro.label('primeiro'), Atendimento.data.label('diaAtendimento')).all() except Exception as e: print(e) return []