Example #1
0
    def buscaGulosa(self, verticeInicio: Vertice, verticeDestino: Vertice):
        heuristicasNaoValidas = Util.grafo_sem_eurisitica(self)
        if heuristicasNaoValidas:
            raise HeuristicaException(
                "Existem vertices no grafo com valor de heuristica invalido. Busca gulosa nao pode ser realizada"
            )

        verticeInicio = self.procurarVertice(verticeInicio)
        if not verticeInicio:
            raise VerticeInexistenteException(
                "Foi informado um vertice de inicio que não existe no grafo. Não foi possivel realizar a busca de custo uniforme.",
                [verticeInicio])

        fronteira = Fronteira()
        fronteira.add_caminho(Caminho(verticeInicio))
        ultimoVerticeAtual = verticeInicio

        while (not fronteira.fronteira_vazia()):
            caminhoMenorHeuristica = fronteira.retorna_caminho(
                Caminho(ultimoVerticeAtual))
            print(caminhoMenorHeuristica)
            fronteira.remove_caminho(caminhoMenorHeuristica)
            if caminhoMenorHeuristica.vertice_final == verticeDestino and caminhoMenorHeuristica.vertice_final.heuristica == 0:
                return Util.montar_mensagem_busca_gulosa(
                    verticeInicio, verticeDestino, caminhoMenorHeuristica)
            novoCaminhoMenorHeuristica = Util.retorna_menor_caminho_por_heuristica(
                caminhoMenorHeuristica)
            if novoCaminhoMenorHeuristica:
                fronteira.add_caminho(novoCaminhoMenorHeuristica)
                ultimoVerticeAtual = novoCaminhoMenorHeuristica.vertice_final

        return Util.montar_mensagem_busca_gulosa(verticeInicio, verticeDestino)
Example #2
0
class ControladorMedico():
    """Clase Controlador de los Medicos"""

    def __init__(self):
        self.var = Medico('', '', 0, '', '', '', '', '')
        #self.view = View()
        self.util = Util()

    def cargar_medico(self, medico):
        self.var = medico
        codigo = self.util.genera_codigo(self.var.nombre, self.var.apellido, self.var.cedula)
        existe=self.var.buscar_persona(codigo)
        if existe != None and len(existe) !=0:
            raise Exception('El medico {} ya esta existe en la base'.format(codigo))
            #self.view.mostrar_msg_med(msg)
        else:
            self.var.carga_datos(codigo)
            msg = self.var.cargar_persona(self.var,codigo)
            #self.view.mostrar_msg_med(msg)

    def listar_medico(self):
        return self.var.listar_persona()
        #self.view.listar_medicos(ob)

    def buscar_medico(self , codigo):
        #codigo = self.view.solicitar_codigo_med()
        return self.var.buscar_persona(codigo)
class ControladorPaciente():
    """Clase Controlador de los Pacientes"""
    def __init__(self):
        self.var = Paciente('', '', 0, '', '', '', '', '')
        #self.view = View()
        self.util = Util()

    def cargar_paciente(self, paciente):
        self.var = paciente
        codigo = self.util.genera_codigo(self.var.nombre, self.var.apellido,
                                         self.var.cedula)
        existe = self.var.buscar_persona(codigo)
        if existe != None and len(existe) != 0:
            raise Exception(
                'El paciente {} ya esta existe en la base'.format(codigo))
            #self.view.mostrar_msg_pac(msg)
        else:
            self.var.carga_datos(codigo)
            msg = self.var.cargar_persona(self.var, codigo)
            ##self.view.mostrar_msg_pac(msg)

    def listar_paciente(self):
        return self.var.listar_persona()
        #self.view.listar_pacientes(ob)

    def buscar_paciente(self, codigo):
        #codigo = self.view.solicitar_codigo_pac()
        return self.var.buscar_persona(codigo)
        #self.view.mostrar_resultado_pac(paciente)

    def solicitar_oa(self):
        '''Se encarga de crear una orden de trabajo nueva'''
 def remover_arestas_entrada(self):
     for verticeId in self.arestas:
         arestasAtual = self.arestas[verticeId]
         for aresta in arestasAtual:
             try:
                 aresta.vertice_fim.remove_aresta(
                     Util.inverterSentidoArestas(aresta))
             except Exception:
                 continue
Example #5
0
 def remover_aresta(self, aresta: Aresta):
     vertice_procurado_inicio = self.procurarVertice(aresta.vertice_inicio)
     vertice_procurado_fim = self.procurarVertice(aresta.vertice_fim)
     if vertice_procurado_inicio and vertice_procurado_fim:
         vertice_procurado_inicio.remove_aresta(aresta)
         if not self.orientado:
             vertice_procurado_fim.remove_aresta(
                 Util.inverterSentidoArestas(aresta))
     else:
         raise VerticeInexistenteException(
             "Foram inseridos vertices inexistentes na aresta a ser removida do grafo",
             [vertice_procurado_inicio, vertice_procurado_fim])
Example #6
0
 def __init__(self):
     self.util = Util()
     self.x = ControladorFuncionario()
     self.p = ControladorPaciente()
     self.m = ControladorMedico()
     self.con = OrdenController()
     self.jornada = JornadaController()
     self.promtp = '~golab >>> '
     self.funcionario_view = FuncionarioView()
     self.medico_view = MedicoView()
     self.paciente_view = PacienteView()
     self.orden_view = OrdenPaciente()
Example #7
0
    def buscaCustoUniforme(self, verticeInicio: Vertice,
                           verticeDestino: Vertice):
        verticeVisitados = []
        menoresCaminhosEncontrados = []
        verticeInicio = self.procurarVertice(verticeInicio)
        if not verticeInicio:
            raise VerticeInexistenteException(
                "Foi informado um vertice de inicio que não existe no grafo. Não foi possivel realizar a busca de custo uniforme.",
                [verticeInicio])
        fronteira = Fronteira()
        fronteira.add_caminho(Caminho(verticeInicio))

        while (not fronteira.fronteira_vazia()):
            menorCaminhoAtual = Util.retorna_menor_caminho_fronteira_por_distancia(
                fronteira)
            fronteira.remove_caminho(menorCaminhoAtual)
            if menorCaminhoAtual.vertice_final == verticeDestino:
                return Util.montar_mensagem_busca_custo_uniforme(
                    verticeInicio, verticeDestino, [menorCaminhoAtual])
            if menorCaminhoAtual.distancia != 0:
                menoresCaminhosEncontrados.append(menorCaminhoAtual)
            verticeVisitados.append(menorCaminhoAtual.vertice_final)
            caminhosNaoVisitados = Util.retorna_menor_caminhos_nao_visitados_por_peso(
                menorCaminhoAtual, verticeVisitados)
            #Verificando se existe algum caminho na fronteira que possui vertice final igual a algum dos novos caminhos nao visitados
            for caminho in caminhosNaoVisitados:
                try:
                    caminhoFronteira = fronteira.retorna_caminho(caminho)
                    # Caso ja exista na fronteira um caminho que possua vertice final igual ao caminho atual,
                    # somente sera substituido se possuir uma distancia menor do que o ja existente
                    if caminho.distancia < caminhoFronteira.distancia:
                        fronteira.remove_caminho(caminhoFronteira)
                        fronteira.add_caminho(caminho)
                except CaminhoInexistenteException:
                    fronteira.add_caminho(caminho)

        return Util.montar_mensagem_busca_custo_uniforme(
            verticeInicio, verticeDestino, menoresCaminhosEncontrados)
Example #8
0
 def add_aresta(self, aresta: Aresta):
     vertice_procurado_inicio = self.procurarVertice(aresta.vertice_inicio)
     vertice_procurado_fim = self.procurarVertice(aresta.vertice_fim)
     if vertice_procurado_inicio and vertice_procurado_fim:
         arestaNova = Aresta(vertice_procurado_inicio,
                             vertice_procurado_fim, aresta.peso, aresta.id)
         vertice_procurado_inicio.add_aresta(arestaNova)
         if not self.orientado:
             vertice_procurado_fim.add_aresta(
                 Util.inverterSentidoArestas(arestaNova))
     else:
         raise VerticeInexistenteException(
             "Foram inseridos vertices inexistentes na aresta a ser adicionada no grafo",
             [vertice_procurado_inicio, vertice_procurado_fim])
Example #9
0
class ControladorFuncionario():
    """Clase Controlador de los Funcionarios"""
    def __init__(self):
        self.fun = Funcionario('', '', 0, '', '', '', '', '')
        #self.view = View()
        self.util = Util()

#    def mostrar_formulario_funcionario(self):
#        self.view.cargar_funcionario()

    def cargar_func(self, funcionario):
        try:
            self.fun = funcionario
            codigo = self.util.genera_codigo(self.fun.nombre,
                                             self.fun.apellido,
                                             self.fun.cedula)
            existe = self.fun.buscar_persona(codigo)
            if existe != None and len(existe) != 0:
                raise Exception(
                    'El funcionario {} ya existe en la base'.format(codigo))
                self.view.mostrar_msg(msg)
            else:
                self.fun.carga_datos(codigo)
                msg = self.fun.cargar_persona(self.fun, codigo)
                #self.view.mostrar_msg(msg)
        except KeyboardInterrupt as e:
            raise Exception('Carga interrumpida.')
        except Exception as ex:
            raise Exception(ex)

    def listar_funcionarios(self):
        return self.fun.listar_persona()
        #self.view.listar_funcionarios(ob)

    def buscar_funcionarios(self, codigo):
        #codigo = self.view.solicitar_codigo()
        return self.fun.buscar_persona(codigo)
Example #10
0
 def __init__(self):
     self.util = Util()
     self.view = View()
     self.controller = OrdenController()
Example #11
0
class OrdenPaciente:
    def __init__(self):
        self.util = Util()
        self.view = View()
        self.controller = OrdenController()

    def solicitar_datos(self):
        self.view.busqueda_cedula_pac(self)
        #return (cedula)

    def cargar_orden(self, cliente, ahora, nro, tipo):

        ordenes_registrar = tkinter.Tk()
        ordenes_registrar.title("CARGAR ORDEN")
        ordenes_registrar.geometry("800x500")

        def volver():
            ordenes_registrar.destroy()
            ordenes_registrar.eval('::ttk::CancelRepeat')

        def guardar():
            def cerrar_exp():
                ordenes_registrar.destroy()
                ordenes_registrar.eval('::ttk::CancelRepeat')
                #pacientes.eval('::ttk::CancelRepeat')
                #self.cargar_paciente()

            try:
                #ACA VA A IR TODA LA LÓGICA DE CARGA

                cod_o = 'OT_' + str(nro)
                new_paciente = OrdenModel(ahora, nro, cliente['codigo'],
                                          str(tipo.get()), cod_o)
                exit = self.controller.model.cargar_orden(new_paciente, cod_o)

            except Exception as e:
                alerta = tkinter.Message(
                    ordenes_registrar,
                    relief='raised',
                    text='NO SE PUDO CARGAR LA ORDEN\nError: ' + str(e),
                    width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
            else:
                alerta = tkinter.Message(ordenes_registrar,
                                         relief='raised',
                                         text='ORDEN CARGADA CON EXITO',
                                         width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(ordenes_registrar,
                               font='Arial',
                               text="DATOS DE LA ORDEN")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_fecha = tkinter.Label(ordenes_registrar,
                                  font='Arial',
                                  text="Fecha",
                                  justify='left')
        lbl_fecha.place(bordermode='outside', height=20, width=300, x=50, y=55)
        lbl_nro_orden = tkinter.Label(ordenes_registrar,
                                      font='Arial',
                                      text="Orden de Analisis Nro",
                                      justify='left')
        lbl_nro_orden.place(bordermode='outside',
                            height=20,
                            width=300,
                            x=50,
                            y=80)
        lbl_nombre = tkinter.Label(ordenes_registrar,
                                   font='Arial',
                                   text="Paciente",
                                   justify='left')
        lbl_nombre.place(bordermode='outside',
                         height=20,
                         width=300,
                         x=50,
                         y=105)
        lbl_codigo = tkinter.Label(ordenes_registrar,
                                   font='Arial',
                                   text="Código",
                                   justify='left')
        lbl_codigo.place(bordermode='outside',
                         height=20,
                         width=300,
                         x=50,
                         y=130)
        lbl_tipo = tkinter.Label(ordenes_registrar,
                                 font='Arial',
                                 text="Tipo de analisis a realizar")
        lbl_tipo.place(bordermode='outside', height=20, width=300, x=50, y=155)

        # lbl_orden = tkinter.Label(ordenes_registrar, font='Arial', text="Orden", justify='left')
        # lbl_orden.place(bordermode='outside', height=20, width=300, x=50, y=155)

        # Campos de Texto
        fecha_result = tkinter.Label(ordenes_registrar,
                                     font='Arial',
                                     text=ahora,
                                     justify='left')
        fecha_result.place(bordermode='outside',
                           height=20,
                           width=300,
                           x=350,
                           y=55)
        nro_orden_identidad_result = tkinter.Label(ordenes_registrar,
                                                   font='Arial',
                                                   text=nro,
                                                   justify='left')
        nro_orden_identidad_result.place(bordermode='outside',
                                         height=20,
                                         width=300,
                                         x=350,
                                         y=80)
        nombre_result = tkinter.Label(ordenes_registrar,
                                      font='Arial',
                                      text=cliente['nombrecompleto'],
                                      justify='left')
        nombre_result.place(bordermode='outside',
                            height=20,
                            width=300,
                            x=350,
                            y=105)
        codigo_result = tkinter.Label(ordenes_registrar,
                                      font='Arial',
                                      text=cliente['codigo'],
                                      justify='left')
        codigo_result.place(bordermode='outside',
                            height=20,
                            width=300,
                            x=350,
                            y=130)
        tipo = ttk.Combobox(ordenes_registrar, value=tipo, state='readonly')
        tipo.place(bordermode='outside', height=20, width=300, x=350, y=155)

        # orden_result = tkinter.Label(ordenes_registrar, font='Arial', text=dato['orden'], justify='left')
        # orden_result.place(bordermode='outside', height=20, width=300, x=350, y=155)

        # Campos de Texto
        #codigo = tkinter.Entry(ordenes_registrar, font='times')
        #codigo.place(bordermode='outside', height=20, width=300, x=350, y=30)

        guardar = tkinter.Button(ordenes_registrar,
                                 text="Guardar",
                                 command=guardar)
        guardar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(ordenes_registrar,
                                text="Volver",
                                command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        ordenes_registrar.mainloop()

        #print('\n-> Fecha:', ahora)
        #print('-> Orden de Analisis Nro: ',nro)
        #print('-> Paciente: ',cliente['nombrecompleto'],' codigo: ',cliente['codigo'])
        #print('-> Tipo de analisis a realizar')
        #for i,tp in enumerate(tipo):

    #print('\t',i+1,'- ',tp)
    #etipo = self.util.leer_entero('',1)
    #validacion = self.util.leer_cadena('Confirmar "S" :: Cancelar "N" ',True)
    #print('\n')
    #return (validacion,etipo)

    def solicitar_codigo(self):
        print('-> Busqueda Orden de Analisis')
        codigo = self.util.leer_cadena('Codigo: ', True)
        codigo = codigo.upper()
        return (codigo)

    def listar_ordenes(self):
        def cerrar_exp():
            ordenes.destroy()
            #ordenes.eval('::ttk::CancelRepeat')
            #self.cargar_paciente()

        ordenes = tkinter.Tk()
        ordenes.title("LISTADO DE ORDENES")
        ordenes.geometry("1000x500")

        def volver():
            ordenes.destroy()

        mylistbox = tkinter.Listbox(ordenes,
                                    height=12,
                                    width=100,
                                    font=('times', 13))
        mylistbox.place(x=32, y=110)
        orden = self.controller.listar_orden()
        if orden != None and len(orden) != 0:
            for values in orden:
                mylistbox.insert(
                    'end', '* Nro. Orden: ' + str(values.id_orden) +
                    ', Cod. Paciente: ' + str(values.codigo_paciente) +
                    ', Estado: ' + str(values.estado) + ', Fecha: ' +
                    str(values.fecha) + ', Tipo: ' + str(values.tipo))
            titulo = tkinter.Label(ordenes,
                                   font='Arial',
                                   text="LISTADO DE ORDENES")
            titulo.place(bordermode='outside',
                         height=20,
                         width=600,
                         x=100,
                         y=30)
            volver = tkinter.Button(ordenes, text="Volver", command=volver)
            volver.place(bordermode='outside',
                         height=40,
                         width=100,
                         x=40,
                         y=400)
            ordenes.mainloop()
        else:
            alerta = tkinter.Message(ordenes,
                                     relief='raised',
                                     text='NO EXISTEN REGISTROS ',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=150,
                         width=200,
                         y=30,
                         x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def listar_ordenes_pendientes(self):
        def cerrar_exp():
            ordenes.destroy()
            #ordenes.eval('::ttk::CancelRepeat')
            #self.cargar_paciente()

        ordenes = tkinter.Tk()
        ordenes.title("LISTADO DE ORDENES PENDIENTES")
        ordenes.geometry("1000x500")

        def volver():
            ordenes.destroy()

        mylistbox = tkinter.Listbox(ordenes,
                                    height=12,
                                    width=100,
                                    font=('times', 13))
        mylistbox.place(x=32, y=110)
        orden = self.controller.orden_list('pen')
        if orden != None and len(orden) != 0:
            for values in orden:
                mylistbox.insert(
                    'end', '* Cod. Orden: ' + str(values.cod_orden) +
                    ', Cod. Paciente: ' + str(values.codigo_paciente) +
                    ', Estado: ' + str(values.estado) + ', Fecha: ' +
                    str(values.fecha) + ', Tipo: ' + str(values.tipo))
            titulo = tkinter.Label(ordenes,
                                   font='Arial',
                                   text="LISTADO DE ORDENES")
            titulo.place(bordermode='outside',
                         height=20,
                         width=600,
                         x=100,
                         y=30)
            volver = tkinter.Button(ordenes, text="Volver", command=volver)
            volver.place(bordermode='outside',
                         height=40,
                         width=100,
                         x=40,
                         y=400)
            ordenes.mainloop()
        else:
            alerta = tkinter.Message(ordenes,
                                     relief='raised',
                                     text='NO EXISTEN REGISTROS ',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=150,
                         width=200,
                         y=30,
                         x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def listar_ordenes_finalizadas(self):
        def cerrar_exp():
            ordenes.destroy()
            #ordenes.eval('::ttk::CancelRepeat')
            #self.cargar_paciente()

        ordenes = tkinter.Tk()
        ordenes.title("LISTADO DE ORDENES FINALIZADAS")
        ordenes.geometry("1000x500")

        def volver():
            ordenes.destroy()

        mylistbox = tkinter.Listbox(ordenes,
                                    height=12,
                                    width=100,
                                    font=('times', 13))
        mylistbox.place(x=32, y=110)
        orden = self.controller.orden_list('fin')
        if orden != None and len(orden) != 0:
            for values in orden:
                mylistbox.insert(
                    'end', '* Cod. Orden: ' + str(values.cod_orden) +
                    ', Cod. Paciente: ' + str(values.codigo_paciente) +
                    ', Estado: ' + str(values.estado) + ', Fecha: ' +
                    str(values.fecha) + ', Tipo: ' + str(values.tipo))
            titulo = tkinter.Label(ordenes,
                                   font='Arial',
                                   text="LISTADO DE ORDENES")
            titulo.place(bordermode='outside',
                         height=20,
                         width=600,
                         x=100,
                         y=30)
            volver = tkinter.Button(ordenes, text="Volver", command=volver)
            volver.place(bordermode='outside',
                         height=40,
                         width=100,
                         x=40,
                         y=400)
            ordenes.mainloop()
        else:
            alerta = tkinter.Message(ordenes,
                                     relief='raised',
                                     text='NO EXISTEN REGISTROS ',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=150,
                         width=200,
                         y=30,
                         x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def mostrar_resultado(self, dato):
        if dato != None and len(dato) > 0:
            print('\n-> Orden Buscada Cod: ', dato['codigo'])
            print('* Codigo Paciente: ', dato['cod_paciente'])
            print('* Tipo de Analisis: ', dato['tipo'])
            print('* Estado: ', dato['estado'] + '\n')

        else:
            print('\n-> Orden no encontrada')
        self.util.pause()

    def reg_cliente(self):
        print('\n')
        print('-> Desea registrar al paciente ?')
        consulta = self.util.leer_cadena('Confirmar "S" :: Cancelar "N" ',
                                         True)
        print('\n')
        return consulta

    def cargar_otro(self):
        print('\n')
        print('-> Desea cargar otra Orden?')
        consulta = self.util.leer_cadena('Confirmar "S" :: Cancelar "N" ',
                                         True)
        print('\n')
        return consulta

    def mostrar_msg(self, msg):
        print('\n', msg[0], msg[1], '\n')
        self.util.pause()

    def mostrar_msg2(self, msg):
        print('\n', msg + '\n')
        self.util.pause()

    def registrar_orden(self):

        access = self.controller.verificador_cupos()
        loop = True
        try:

            def cerrar_exp():
                ordenes.destroy()
                # ordenes.eval('::ttk::CancelRepeat')
                #self.cargar_paciente()

            if (access):
                self.solicitar_datos()
                #print (cedula)

            else:
                ordenes = tkinter.Tk()
                ordenes.title("CARGAR PACIENTE")
                ordenes.geometry("500x300")
                alerta = tkinter.Message(
                    ordenes,
                    relief='raised',
                    text='No hay mas cupos disponibles para hoy',
                    width=200)
                alerta.place(bordermode='outside',
                             height=250,
                             width=400,
                             y=30,
                             x=50)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
                #msg = 'No hay mas cupos disponibles para hoy'
                #self.orden.mostrar_msg2(msg)

        except Exception as e:

            ordenes = tkinter.Tk()
            ordenes.title("CARGAR PACIENTE")
            ordenes.geometry("500x300")
            alerta = tkinter.Message(ordenes,
                                     relief='raised',
                                     text=str(e),
                                     width=200)
            alerta.place(bordermode='outside',
                         height=250,
                         width=400,
                         y=30,
                         x=50)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def gestionar_orden(self, cedula):
        cliente = self.controller.pac.buscar_persona_cedula(cedula)

        if cliente == '':

            def cerrar_exp():
                ordenes.destroy()
                self.solicitar_confirmacion(cedula)

            def no_exp():
                ordenes.destroy()
                # ordenes.eval('::ttk::CancelRepeat')
                #self.cargar_paciente()

            ordenes = tkinter.Tk()
            ordenes.title("CONFIRMAR")
            ordenes.geometry("500x300")
            alerta = tkinter.Message(ordenes,
                                     relief='raised',
                                     text='DESEA REGISTRAR PACIENTE',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=250,
                         width=400,
                         y=30,
                         x=50)
            ok = tkinter.Button(alerta, text="SI", command=cerrar_exp)

            ok.place(bordermode='outside', height=40, width=40, y=180, x=120)
            #ok.pack(side="bottom")
            no = tkinter.Button(alerta, text="NO", command=no_exp)
            no.place(bordermode='outside', height=40, width=40, y=180, x=200)
            #no.pack(side="bottom")
            #msg = 'No hay mas cupos disponibles para hoy'
            #self.orden.mostrar_msg2(msg)

        else:
            nro = self.controller.model.buscar_nro_orden()
            if nro == 0:
                nro = 1
            else:
                nro += 1
            ahora = date.today().strftime('%d/%b/%Y')
            tipo = self.controller.model.tipos_analisis()
            retorno = self.cargar_orden(cliente, ahora, nro, tipo)

            #consulta = self.cargar_otro().upper()
            #if (consulta == 'S' or consulta == 'SI'):
            #    self.registrar_orden()

    def solicitar_confirmacion(self, cedula):
        self.view.registrar_paciente_orden(self, cedula)
        #return (cedula)

    def atender_orden(self):

        ordenes_registrar = tkinter.Tk()
        ordenes_registrar.title("ATENDER ORDEN")
        ordenes_registrar.geometry("800x500")

        def volver():
            ordenes_registrar.destroy()
            ordenes_registrar.eval('::ttk::CancelRepeat')

        def cerrar_exp():
            ordenes_registrar.destroy()
            ordenes_registrar.eval('::ttk::CancelRepeat')
            #pacientes.eval('::ttk::CancelRepeat')
            #self.cargar_paciente()

        def guardar():

            try:
                self.controller.atender_orden(str(pedidos_pendientes.get()))
                #ACA VA A IR TODA LA LÓGICA DE CARGA
                #print('\n')
                #cod_o = 'OT_' + str(nro)
                #new_paciente = OrdenModel(ahora, nro, cliente['codigo'], str(tipo.get()), cod_o)
                #exit = self.controller.model.cargar_orden(new_paciente, cod_o)

            except Exception as e:
                alerta = tkinter.Message(
                    ordenes_registrar,
                    relief='raised',
                    text='NO SE PUDO MODIFICAR LA ORDEN\nError: ' + str(e),
                    width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
            else:
                alerta = tkinter.Message(ordenes_registrar,
                                         relief='raised',
                                         text='ORDEN MODIFICADA CON EXITO',
                                         width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(ordenes_registrar,
                               font='Arial',
                               text="SELECCIONE LA ORDEN A ATENDER")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_pedidos_pendientes = tkinter.Label(ordenes_registrar,
                                               font='Arial',
                                               text="Pedidos pendientes")
        lbl_pedidos_pendientes.place(bordermode='outside',
                                     height=20,
                                     width=300,
                                     x=50,
                                     y=55)

        # lbl_orden = tkinter.Label(ordenes_registrar, font='Arial', text="Orden", justify='left')
        # lbl_orden.place(bordermode='outside', height=20, width=300, x=50, y=155)

        # Campos de Texto
        lista_pedidos_pendientes = self.controller.orden_list('pen')

        if lista_pedidos_pendientes != None and len(
                lista_pedidos_pendientes) != 0:

            pedidos = []
            for pedido in lista_pedidos_pendientes:
                pedidos.append(pedido.cod_orden)

            pedidos_pendientes = ttk.Combobox(ordenes_registrar,
                                              value=pedidos,
                                              state='readonly')
            pedidos_pendientes.place(bordermode='outside',
                                     height=20,
                                     width=300,
                                     x=350,
                                     y=55)

            # orden_result = tkinter.Label(ordenes_registrar, font='Arial', text=dato['orden'], justify='left')
            # orden_result.place(bordermode='outside', height=20, width=300, x=350, y=155)

            # Campos de Texto
            # codigo = tkinter.Entry(ordenes_registrar, font='times')
            # codigo.place(bordermode='outside', height=20, width=300, x=350, y=30)

            guardar = tkinter.Button(ordenes_registrar,
                                     text="Guardar",
                                     command=guardar)
            guardar.place(bordermode='outside',
                          height=40,
                          width=100,
                          x=40,
                          y=210)
            volver = tkinter.Button(ordenes_registrar,
                                    text="Volver",
                                    command=volver)
            volver.place(bordermode='outside',
                         height=40,
                         width=100,
                         x=140,
                         y=210)
            ordenes_registrar.mainloop()
        else:
            alerta = tkinter.Message(ordenes_registrar,
                                     relief='raised',
                                     text='NO EXISTEN REGISTROS ',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=150,
                         width=200,
                         y=30,
                         x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

        #print('\n-> Fecha:', ahora)
        #print('-> Orden de Analisis Nro: ',nro)
        #print('-> Paciente: ',cliente['nombrecompleto'],' codigo: ',cliente['codigo'])
        #print('-> Tipo de analisis a realizar')
        #for i,tp in enumerate(tipo):

    #print('\t',i+1,'- ',tp)
    #etipo = self.util.leer_entero('',1)
    #validacion = self.util.leer_cadena('Confirmar "S" :: Cancelar "N" ',True)
    #print('\n')
    #return (validacion,etipo)

    def buscar_orden(self):

        funcionarios = tkinter.Tk()
        funcionarios.title("BUSCAR ORDENES")
        funcionarios.geometry("800x500")

        def volver():
            funcionarios.destroy()

        def buscar():
            def cerrar_exp():
                funcionarios.destroy()
                #funcionarios.eval('::ttk::CancelRepeat')
                self.buscar_orden()

            dato = self.controller.buscar_orden(
                self.util.validar_cadena(str(codigo.get()), True))

            if dato != None and len(dato) > 0:

                lbl_codigo = tkinter.Label(funcionarios,
                                           font='Arial',
                                           text="Código",
                                           justify='left')
                lbl_codigo.place(bordermode='outside',
                                 height=20,
                                 width=300,
                                 x=50,
                                 y=55)
                lbl_nombre = tkinter.Label(funcionarios,
                                           font='Arial',
                                           text="Codigo Paciente",
                                           justify='left')
                lbl_nombre.place(bordermode='outside',
                                 height=20,
                                 width=300,
                                 x=50,
                                 y=80)
                lbl_documento_identidad = tkinter.Label(
                    funcionarios,
                    font='Arial',
                    text="Tipo de Analisis",
                    justify='left')
                lbl_documento_identidad.place(bordermode='outside',
                                              height=20,
                                              width=300,
                                              x=50,
                                              y=105)
                lbl_cargo = tkinter.Label(funcionarios,
                                          font='Arial',
                                          text="Estado",
                                          justify='left')
                lbl_cargo.place(bordermode='outside',
                                height=20,
                                width=300,
                                x=50,
                                y=130)

                codigo_result = tkinter.Label(funcionarios,
                                              font='Arial',
                                              text=dato['codigo'],
                                              justify='left')
                codigo_result.place(bordermode='outside',
                                    height=20,
                                    width=300,
                                    x=350,
                                    y=55)
                nombre_result = tkinter.Label(funcionarios,
                                              font='Arial',
                                              text=dato['cod_paciente'],
                                              justify='left')
                nombre_result.place(bordermode='outside',
                                    height=20,
                                    width=300,
                                    x=350,
                                    y=80)
                documento_identidad_result = tkinter.Label(funcionarios,
                                                           font='Arial',
                                                           text=dato['tipo'],
                                                           justify='left')
                documento_identidad_result.place(bordermode='outside',
                                                 height=20,
                                                 width=300,
                                                 x=350,
                                                 y=105)
                cargo_result = tkinter.Label(funcionarios,
                                             font='Arial',
                                             text=dato['estado'],
                                             justify='left')
                cargo_result.place(bordermode='outside',
                                   height=20,
                                   width=300,
                                   x=350,
                                   y=130)
            else:

                alerta = tkinter.Message(funcionarios,
                                         relief='raised',
                                         text='Orden no encontrada',
                                         width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(funcionarios,
                               font='Arial',
                               text="DATOS DE LA ORDER")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_codigo = tkinter.Label(funcionarios,
                                   font='Arial',
                                   text="Código de la ORDEN",
                                   justify='left')
        lbl_codigo.place(bordermode='outside',
                         height=20,
                         width=300,
                         x=50,
                         y=30)

        # Campos de Texto
        codigo = tkinter.Entry(funcionarios, font='times')
        codigo.place(bordermode='outside', height=20, width=300, x=350, y=30)

        buscar = tkinter.Button(funcionarios, text="Buscar", command=buscar)
        buscar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(funcionarios, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        funcionarios.mainloop()
Example #12
0
 def __init__(self):
     self.fun = Funcionario('', '', 0, '', '', '', '', '')
     #self.view = View()
     self.util = Util()
Example #13
0
 def __init__(self):
     self.var = Medico('', '', 0, '', '', '', '', '')
     #self.view = View()
     self.util = Util()
Example #14
0
 def __init__(self):
     self.util=Util()
     self.controller = ControladorPaciente()
Example #15
0
class View:
    def __init__(self):
        self.util=Util()
        self.controller = ControladorPaciente()



    def cargar_paciente(self):
        pacientes = tkinter.Tk()
        pacientes.title("CARGAR PACIENTE")
        pacientes.geometry("800x500")

        def volver():
            pacientes.destroy()

        def cargar():
            def cerrar_exp():
                pacientes.destroy()
                #pacientes.eval('::ttk::CancelRepeat')
                self.cargar_paciente()

            try:

                nombre_pac = self.util.validar_cadena(str(nombre.get()), True)
                apellido_pac = self.util.validar_cadena(str(apellido.get()), True)
                cedula_pac = self.util.validar_entero(str(documento_identidad.get()), 1)
                telefono_pac = self.util.validar_cadena(str(telefono.get()), False)
                email_pac = self.util.validar_cadena(str(email.get()), False)
                fecha_pac = self.util.validar_fecha(str(fecha_nacimiento.get()))

                #contenedor = Medico(nombre, apellido, cedula, telefono, email, fecha, cargo, '')

                contenedor = Paciente(nombre_pac, apellido_pac, cedula_pac, telefono_pac, email_pac, fecha_pac, '')

                self.controller.cargar_paciente(contenedor)

            except Exception as e:
                alerta = tkinter.Message(pacientes, relief='raised',
                                         text='NO SE PUDO CARGAR EL PACIENTE\nError: ' + str(e), width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
            else:
                alerta = tkinter.Message(pacientes, relief='raised', text='PACIENTE CARGADO CON EXITO', width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(pacientes, font='Arial', text="DATOS DEL NUEVO PACIENTE")
        titulo.place(bordermode='outside', height=20, width=600, x=100)
        # Etiquetas
        lbl_nombre = tkinter.Label(pacientes, font='Arial', text="Nombres", justify='left')
        lbl_nombre.place(bordermode='outside', height=20, width=300, x=50, y=30)
        lbl_apellido = tkinter.Label(pacientes, font='Arial', text="Apellidos")
        lbl_apellido.place(bordermode='outside', height=20, width=300, x=50, y=55)
        lbl_documento_identidad = tkinter.Label(pacientes, font='Arial', text="Documento de identidad")
        lbl_documento_identidad.place(bordermode='outside', height=20, width=300, x=50, y=80)
        lbl_telefono = tkinter.Label(pacientes, font='Arial', text="Télefono")
        lbl_telefono.place(bordermode='outside', height=20, width=300, x=50, y=105)
        lbl_email = tkinter.Label(pacientes, font='Arial', text="Email")
        lbl_email.place(bordermode='outside', height=20, width=300, x=50, y=130)
        lbl_fecha_nacimiento = tkinter.Label(pacientes, font='Arial', text="Fecha de Nacimiento")
        lbl_fecha_nacimiento.place(bordermode='outside', height=20, width=200, x=50, y=155)

        # Campos de Texto
        nombre = tkinter.Entry(pacientes, font='times')
        nombre.place(bordermode='outside', height=20, width=300, x=350, y=30)
        apellido = tkinter.Entry(pacientes, font='times')
        apellido.place(bordermode='outside', height=20, width=300, x=350, y=55)
        documento_identidad = tkinter.Entry(pacientes, font='times')
        documento_identidad.place(bordermode='outside', height=20, width=300, x=350, y=80)
        telefono = tkinter.Entry(pacientes, font='times')
        telefono.place(bordermode='outside', height=20, width=300, x=350, y=105)
        email = tkinter.Entry(pacientes, font='times')
        email.place(bordermode='outside', height=20, width=300, x=350, y=130)
        fecha_nacimiento = tkinter.Entry(pacientes, font='times')
        fecha_nacimiento.place(bordermode='outside', height=20, width=300, x=350, y=155)


        cargar = tkinter.Button(pacientes, text="Cargar", command=cargar)
        cargar.place(bordermode='outside', height=40, width=100, x=240, y=210)
        volver = tkinter.Button(pacientes, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=340, y=210)
        pacientes.mainloop()


    def buscar_paciente(self):
        pacientes = tkinter.Tk()
        pacientes.title("BUSCAR PACIENTES")
        pacientes.geometry("800x500")

        def volver():
            pacientes.destroy()

        def buscar():

            def cerrar_exp():
                pacientes.destroy()
                #pacientes.eval('::ttk::CancelRepeat')
                self.buscar_paciente()

            dato = self.controller.buscar_paciente(self.util.validar_cadena(str(codigo.get()), True))

            if dato != None and len(dato) > 0:

                lbl_codigo = tkinter.Label(pacientes, font='Arial', text="Código", justify='left')
                lbl_codigo.place(bordermode='outside', height=20, width=300, x=50, y=55)
                lbl_nombre = tkinter.Label(pacientes, font='Arial', text="Nombre Completo", justify='left')
                lbl_nombre.place(bordermode='outside', height=20, width=300, x=50, y=80)
                lbl_documento_identidad = tkinter.Label(pacientes, font='Arial', text="Documento de identidad", justify='left')
                lbl_documento_identidad.place(bordermode='outside', height=20, width=300, x=50, y=105)
                lbl_orden = tkinter.Label(pacientes, font='Arial', text="Orden", justify='left')
                lbl_orden.place(bordermode='outside', height=20, width=300, x=50, y=130)

                codigo_result = tkinter.Label(pacientes, font='Arial', text=dato['codigo'], justify='left')
                codigo_result.place(bordermode='outside', height=20, width=300, x=350, y=55)
                nombre_result = tkinter.Label(pacientes, font='Arial', text=dato['nombrecompleto'], justify='left')
                nombre_result.place(bordermode='outside', height=20, width=300, x=350, y=80)
                documento_identidad_result = tkinter.Label(pacientes, font='Arial', text=dato['cedula'], justify='left')
                documento_identidad_result.place(bordermode='outside', height=20, width=300, x=350, y=105)
                orden_result = tkinter.Label(pacientes, font='Arial', text=dato['orden'], justify='left')
                orden_result.place(bordermode='outside', height=20, width=300, x=350, y=130)
            else:

                alerta = tkinter.Message(pacientes, relief='raised', text='Paciente no encontrado', width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")



        titulo = tkinter.Label(pacientes, font='Arial', text="DATOS DEL PACIENTE")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_codigo = tkinter.Label(pacientes, font='Arial', text="Código del Paciente", justify='left')
        lbl_codigo.place(bordermode='outside', height=20, width=300, x=50, y=30)

        # Campos de Texto
        codigo = tkinter.Entry(pacientes, font='times')
        codigo.place(bordermode='outside', height=20, width=300, x=350, y=30)

        buscar = tkinter.Button(pacientes, text="Buscar", command=buscar)
        buscar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(pacientes, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        pacientes.mainloop()

    def listar_pacientes(self):
        def cerrar_exp():
            pacientes.destroy()
            #pacientes.eval('::ttk::CancelRepeat')
            self.cargar_paciente()

        pacientes = tkinter.Tk()
        pacientes.title("LISTADO DE PACIENTES")
        pacientes.geometry("1000x500")

        def volver():
            pacientes.destroy()

        mylistbox = tkinter.Listbox(pacientes, height=12, width=100, font=('times', 13))
        mylistbox.place(x=32, y=110)
        paciente = self.controller.listar_paciente()
        if paciente != None and len(paciente) != 0:
            for values in paciente:
                mylistbox.insert('end', '* Codigo: '+ values.codigof+ ', Nombre: '+ values.nombre+' '+values.apellido )
            titulo = tkinter.Label(pacientes, font='Arial', text="LISTADO DE PACIENTES")
            titulo.place(bordermode='outside', height=20, width=600, x=100, y=30)
            volver = tkinter.Button(pacientes, text="Volver", command=volver)
            volver.place(bordermode='outside', height=40, width=100, x=40, y=400)
            pacientes.mainloop()
        else:
            alerta = tkinter.Message(pacientes, relief='raised',
                                     text='NO EXISTEN REGISTROS ' , width=200)
            alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def solicitar_datos_pac(self):
        print('-> Datos del nuevo Paciente')
        nombre = self.util.leer_cadena('Nombre: ',True)
        apellido = self.util.leer_cadena('Apellido: ',True)
        cedula = self.util.leer_entero('Cedula: ',1)
        telefono = self.util.leer_cadena('Telefono: ',False)
        email = self.util.leer_cadena('Email: ',False)
        fecha = self.util.leer_fecha('Fecha de Nacimiento dd/mm/yyyy: ')
        contenedor = Paciente(nombre,apellido,cedula,telefono,email,fecha,'','')
        return (contenedor)

    def solicitar_codigo_pac(self):
        print('-> Busqueda Paciente')
        codigo = self.util.leer_cadena('Codigo: ',True)
        codigo = codigo.upper()
        return (codigo)

    def busqueda_cedula_pac(self, orden):
        pacientes = tkinter.Tk()
        pacientes.title("BUSCAR PACIENTES")
        pacientes.geometry("800x500")

        def volver():
            pacientes.destroy()

        def buscar():
            def cerrar_exp():
                pacientes.destroy()
                # pacientes.eval('::ttk::CancelRepeat')
                #self.buscar_paciente()

            try:

                codigo = self.util.validar_entero(str(cedula.get()), 1)
                pacientes.destroy()
                orden.gestionar_orden(codigo)
                # return (codigo)

            except Exception as e:
                alerta = tkinter.Message(pacientes, relief='raised',
                                         text='NO SE PUDO REALIZAR LA BUSQUEDA\nError: ' + str(e), width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(pacientes, font='Arial', text="DATOS DEL PACIENTE")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_codigo = tkinter.Label(pacientes, font='Arial', text="Nro. de Cédula", justify='left')
        lbl_codigo.place(bordermode='outside', height=20, width=300, x=50, y=30)

        # Campos de Texto
        cedula = tkinter.Entry(pacientes, font='times')
        cedula.place(bordermode='outside', height=20, width=300, x=350, y=30)

        buscar = tkinter.Button(pacientes, text="Buscar", command=buscar)
        buscar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(pacientes, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        pacientes.mainloop()


    def listar_pacientes_old(self, lista):
        if lista != None and len(lista) != 0:
            print('\n-> Listado de Pacientes: \n')
            for paciente in lista:
                print ('* Codigo: ', paciente.codigof, ', Nombre: ', paciente.nombre+' '+paciente.apellido, ', Cedula: ',paciente.cedula)
        else:
            print('\n-> No existen registros')
        self.util.pause()

    def mostrar_resultado_pac(self,dato):
        if(dato != None and len(dato)!=0):
            print('\n-> Paciente Buscado Codigo: ',dato['codigo'])
            print('* Nombre Completo: ',dato['nombrecompleto'])
            print('* Cedula: ',dato['cedula'])
            print('* orden: ',dato['orden']+'\n')
        else:
            print('\n-> Paciente no encontrado')
        self.util.pause()

    def mostrar_msg_pac(self,msg):
        print('\n',msg+'\n\n')


    def registrar_paciente_orden(self,orden, cedula):
        pacientes = tkinter.Tk()
        pacientes.title("CARGAR PACIENTE")
        pacientes.geometry("800x500")

        def volver():
            pacientes.destroy()

        def cargar():
            def cerrar_exp():
                pacientes.destroy()
                #pacientes.eval('::ttk::CancelRepeat')
                self.cargar_paciente()
            def ok_exp():
                pacientes.destroy()
                #pacientes.eval('::ttk::CancelRepeat')
                orden.gestionar_orden(cedula)

            try:

                nombre_pac = self.util.validar_cadena(str(nombre.get()), True)
                apellido_pac = self.util.validar_cadena(str(apellido.get()), True)
                cedula_pac = self.util.validar_entero(cedula, 1)
                telefono_pac = self.util.validar_cadena(str(telefono.get()), False)
                email_pac = self.util.validar_cadena(str(email.get()), False)
                fecha_pac = self.util.validar_fecha(str(fecha_nacimiento.get()))

                #contenedor = Medico(nombre, apellido, cedula, telefono, email, fecha, cargo, '')

                contenedor = Paciente(nombre_pac, apellido_pac, cedula_pac, telefono_pac, email_pac, fecha_pac, '')

                self.controller.cargar_paciente(contenedor)

            except Exception as e:
                alerta = tkinter.Message(pacientes, relief='raised',
                                         text='NO SE PUDO CARGAR EL PACIENTE\nError: ' + str(e), width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
            else:
                alerta = tkinter.Message(pacientes, relief='raised', text='PACIENTE CARGADO CON EXITO', width=200)
                alerta.place(bordermode='outside', height=150, width=200, y=30, x=150)
                ok = tkinter.Button(alerta, text="Ok", command=ok_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(pacientes, font='Arial', text="DATOS DEL NUEVO PACIENTE")
        titulo.place(bordermode='outside', height=20, width=600, x=100)
        # Etiquetas
        lbl_nombre = tkinter.Label(pacientes, font='Arial', text="Nombres", justify='left')
        lbl_nombre.place(bordermode='outside', height=20, width=300, x=50, y=30)
        lbl_apellido = tkinter.Label(pacientes, font='Arial', text="Apellidos")
        lbl_apellido.place(bordermode='outside', height=20, width=300, x=50, y=55)
        lbl_documento_identidad = tkinter.Label(pacientes, font='Arial', text="Documento de identidad")
        lbl_documento_identidad.place(bordermode='outside', height=20, width=300, x=50, y=80)
        lbl_telefono = tkinter.Label(pacientes, font='Arial', text="Télefono")
        lbl_telefono.place(bordermode='outside', height=20, width=300, x=50, y=105)
        lbl_email = tkinter.Label(pacientes, font='Arial', text="Email")
        lbl_email.place(bordermode='outside', height=20, width=300, x=50, y=130)
        lbl_fecha_nacimiento = tkinter.Label(pacientes, font='Arial', text="Fecha de Nacimiento")
        lbl_fecha_nacimiento.place(bordermode='outside', height=20, width=300, x=50, y=155)

        # Campos de Texto
        nombre = tkinter.Entry(pacientes, font='times')
        nombre.place(bordermode='outside', height=20, width=300, x=350, y=30)
        apellido = tkinter.Entry(pacientes, font='times')
        apellido.place(bordermode='outside', height=20, width=300, x=350, y=55)

        documento_identidad_result = tkinter.Label(pacientes, font='Arial', text=cedula)
        documento_identidad_result.place(bordermode='outside', height=20, width=300, x=350, y=80)
        #documento_identidad = tkinter.Entry(pacientes, font='times')
        #documento_identidad.place(bordermode='outside', height=20, width=300, x=350, y=80)

        telefono = tkinter.Entry(pacientes, font='times')
        telefono.place(bordermode='outside', height=20, width=300, x=350, y=105)
        email = tkinter.Entry(pacientes, font='times')
        email.place(bordermode='outside', height=20, width=300, x=350, y=130)
        fecha_nacimiento = tkinter.Entry(pacientes, font='times')
        fecha_nacimiento.place(bordermode='outside', height=20, width=300, x=350, y=155)


        cargar = tkinter.Button(pacientes, text="Cargar", command=cargar)
        cargar.place(bordermode='outside', height=40, width=100, x=240, y=210)
        volver = tkinter.Button(pacientes, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=340, y=210)
        pacientes.mainloop()
 def __init__(self):
     self.var = Paciente('', '', 0, '', '', '', '', '')
     #self.view = View()
     self.util = Util()
Example #17
0
 def __init__(self):
     self.util = Util()
     self.controller = ControladorFuncionario()
Example #18
0
class View:
    def __init__(self):
        self.util = Util()
        self.controller = ControladorFuncionario()

    def solicitar_datos(self):
        print('-> Datos del nuevo Funcionario')
        nombre = self.util.leer_cadena('Nombre: ', True)
        apellido = self.util.leer_cadena('Apellido: ', True)
        cedula = self.util.leer_entero('Cedula: ', 1)
        telefono = self.util.leer_cadena('Telefono: ', False)
        email = self.util.leer_cadena('Email: ', False)
        fecha = self.util.leer_fecha('Fecha de Nacimiento dd/mm/yyyy: ')
        cargo = self.util.leer_cadena('Cargo: ', False)

        contenedor = Funcionario(nombre, apellido, cedula, telefono, email,
                                 fecha, cargo, '')
        return (contenedor)

    def cargar_funcionario(self):
        funcionarios = tkinter.Tk()
        funcionarios.title("CARGAR FUNCIONARIOS")
        funcionarios.geometry("800x500")

        def volver():
            funcionarios.destroy()

        def cargar():
            def cerrar_exp():
                funcionarios.destroy()
                #funcionarios.eval('::ttk::CancelRepeat')
                self.cargar_funcionario()

            try:

                nombre_fun = self.util.validar_cadena(str(nombre.get()), True)
                apellido_fun = self.util.validar_cadena(
                    str(apellido.get()), True)
                cedula_fun = self.util.validar_entero(
                    str(documento_identidad.get()), 1)
                telefono_fun = self.util.validar_cadena(
                    str(telefono.get()), False)
                email_fun = self.util.validar_cadena(str(email.get()), False)
                fecha_fun = self.util.validar_fecha(str(
                    fecha_nacimiento.get()))
                cargo_fun = self.util.validar_cadena(str(cargo.get()), False)

                contenedor = Funcionario(nombre_fun, apellido_fun, cedula_fun,
                                         telefono_fun, email_fun, fecha_fun,
                                         cargo_fun, '')

                self.controller.cargar_func(contenedor)

            except Exception as e:
                alerta = tkinter.Message(
                    funcionarios,
                    relief='raised',
                    text='NO SE PUDO CARGAR AL FUNCIONARIO\nError: ' + str(e),
                    width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")
            else:
                alerta = tkinter.Message(funcionarios,
                                         relief='raised',
                                         text='FUNCIONARIO CARGADO CON EXITO',
                                         width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(funcionarios,
                               font='Arial',
                               text="DATOS DEL NUEVO FUNCIONARIO")
        titulo.place(bordermode='outside', height=20, width=300, x=100)
        # Etiquetas
        lbl_nombre = tkinter.Label(funcionarios,
                                   font='Arial',
                                   text="Nombres",
                                   justify='left')
        lbl_nombre.place(bordermode='outside',
                         height=20,
                         width=200,
                         x=50,
                         y=30)
        lbl_apellido = tkinter.Label(funcionarios,
                                     font='Arial',
                                     text="Apellidos")
        lbl_apellido.place(bordermode='outside',
                           height=20,
                           width=200,
                           x=50,
                           y=55)
        lbl_documento_identidad = tkinter.Label(funcionarios,
                                                font='Arial',
                                                text="Documento de identidad")
        lbl_documento_identidad.place(bordermode='outside',
                                      height=20,
                                      width=200,
                                      x=50,
                                      y=80)
        lbl_telefono = tkinter.Label(funcionarios,
                                     font='Arial',
                                     text="Télefono")
        lbl_telefono.place(bordermode='outside',
                           height=20,
                           width=200,
                           x=50,
                           y=105)
        lbl_email = tkinter.Label(funcionarios, font='Arial', text="Email")
        lbl_email.place(bordermode='outside',
                        height=20,
                        width=200,
                        x=50,
                        y=130)
        lbl_fecha_nacimiento = tkinter.Label(funcionarios,
                                             font='Arial',
                                             text="Fecha de Nacimiento")
        lbl_fecha_nacimiento.place(bordermode='outside',
                                   height=20,
                                   width=200,
                                   x=50,
                                   y=155)
        lbl_cargo = tkinter.Label(funcionarios, font='Arial', text="Cargo")
        lbl_cargo.place(bordermode='outside',
                        height=20,
                        width=200,
                        x=50,
                        y=180)

        # Campos de Texto
        nombre = tkinter.Entry(funcionarios, font='times')
        nombre.place(bordermode='outside', height=20, width=200, x=250, y=30)
        apellido = tkinter.Entry(funcionarios, font='times')
        apellido.place(bordermode='outside', height=20, width=200, x=250, y=55)
        documento_identidad = tkinter.Entry(funcionarios, font='times')
        documento_identidad.place(bordermode='outside',
                                  height=20,
                                  width=200,
                                  x=250,
                                  y=80)
        telefono = tkinter.Entry(funcionarios, font='times')
        telefono.place(bordermode='outside',
                       height=20,
                       width=200,
                       x=250,
                       y=105)
        email = tkinter.Entry(funcionarios, font='times')
        email.place(bordermode='outside', height=20, width=200, x=250, y=130)
        fecha_nacimiento = tkinter.Entry(funcionarios, font='times')
        fecha_nacimiento.place(bordermode='outside',
                               height=20,
                               width=200,
                               x=250,
                               y=155)
        cargo = tkinter.Entry(funcionarios, font='times')
        cargo.place(bordermode='outside', height=20, width=200, x=250, y=180)

        cargar = tkinter.Button(funcionarios, text="Cargar", command=cargar)
        cargar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(funcionarios, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        funcionarios.mainloop()

    def solicitar_codigo(self):

        funcionarios = tkinter.Tk()
        funcionarios.title("BUSCAR FUNCIONARIOS")
        funcionarios.geometry("800x500")

        def volver():
            funcionarios.destroy()

        def buscar():
            def cerrar_exp():
                funcionarios.destroy()
                #funcionarios.eval('::ttk::CancelRepeat')
                self.solicitar_codigo()

            dato = self.controller.buscar_funcionarios(
                self.util.validar_cadena(str(codigo.get()), True))

            if dato != None and len(dato) > 0:

                lbl_codigo = tkinter.Label(funcionarios,
                                           font='Arial',
                                           text="Código",
                                           justify='left')
                lbl_codigo.place(bordermode='outside',
                                 height=20,
                                 width=300,
                                 x=50,
                                 y=55)
                lbl_nombre = tkinter.Label(funcionarios,
                                           font='Arial',
                                           text="Nombre Completo",
                                           justify='left')
                lbl_nombre.place(bordermode='outside',
                                 height=20,
                                 width=300,
                                 x=50,
                                 y=80)
                lbl_documento_identidad = tkinter.Label(
                    funcionarios,
                    font='Arial',
                    text="Documento de identidad",
                    justify='left')
                lbl_documento_identidad.place(bordermode='outside',
                                              height=20,
                                              width=300,
                                              x=50,
                                              y=105)
                lbl_cargo = tkinter.Label(funcionarios,
                                          font='Arial',
                                          text="Cargo",
                                          justify='left')
                lbl_cargo.place(bordermode='outside',
                                height=20,
                                width=300,
                                x=50,
                                y=130)

                codigo_result = tkinter.Label(funcionarios,
                                              font='Arial',
                                              text=dato['codigo'],
                                              justify='left')
                codigo_result.place(bordermode='outside',
                                    height=20,
                                    width=300,
                                    x=350,
                                    y=55)
                nombre_result = tkinter.Label(funcionarios,
                                              font='Arial',
                                              text=dato['nombrecompleto'],
                                              justify='left')
                nombre_result.place(bordermode='outside',
                                    height=20,
                                    width=300,
                                    x=350,
                                    y=80)
                documento_identidad_result = tkinter.Label(funcionarios,
                                                           font='Arial',
                                                           text=dato['cedula'],
                                                           justify='left')
                documento_identidad_result.place(bordermode='outside',
                                                 height=20,
                                                 width=300,
                                                 x=350,
                                                 y=105)
                cargo_result = tkinter.Label(funcionarios,
                                             font='Arial',
                                             text=dato['cargo'],
                                             justify='left')
                cargo_result.place(bordermode='outside',
                                   height=20,
                                   width=300,
                                   x=350,
                                   y=130)
            else:

                alerta = tkinter.Message(funcionarios,
                                         relief='raised',
                                         text='Funcionario no encontrado',
                                         width=200)
                alerta.place(bordermode='outside',
                             height=150,
                             width=200,
                             y=30,
                             x=150)
                ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
                ok.pack(side="bottom")

        titulo = tkinter.Label(funcionarios,
                               font='Arial',
                               text="DATOS FUNCIONARIO")
        titulo.place(bordermode='outside', height=20, width=300, x=100)

        # Etiquetas
        lbl_codigo = tkinter.Label(funcionarios,
                                   font='Arial',
                                   text="Código del Funcionario",
                                   justify='left')
        lbl_codigo.place(bordermode='outside',
                         height=20,
                         width=300,
                         x=50,
                         y=30)

        # Campos de Texto
        codigo = tkinter.Entry(funcionarios, font='times')
        codigo.place(bordermode='outside', height=20, width=300, x=350, y=30)

        buscar = tkinter.Button(funcionarios, text="Buscar", command=buscar)
        buscar.place(bordermode='outside', height=40, width=100, x=40, y=210)
        volver = tkinter.Button(funcionarios, text="Volver", command=volver)
        volver.place(bordermode='outside', height=40, width=100, x=140, y=210)
        funcionarios.mainloop()

    def listar_funcionarios(self):
        def cerrar_exp():
            funcionarios.destroy()
            #funcionarios.eval('::ttk::CancelRepeat')
            self.cargar_funcionario()

        funcionarios = tkinter.Tk()
        funcionarios.title("LISTADO DE FUNCIONARIOS")
        funcionarios.geometry("1000x500")

        def volver():
            funcionarios.destroy()

        mylistbox = tkinter.Listbox(funcionarios,
                                    height=12,
                                    width=100,
                                    font=('times', 13))
        mylistbox.place(x=32, y=110)
        fun = self.controller.listar_funcionarios()
        if fun != None and len(fun) != 0:
            for values in fun:
                mylistbox.insert(
                    'end', '* Codigo: ' + values.codigof + ', Nombre: ' +
                    values.nombre + ' ' + values.apellido + ', Cargo: ' +
                    values.cargo)
            titulo = tkinter.Label(funcionarios,
                                   font='Arial',
                                   text="LISTADO DE FUNCIONARIOS")
            titulo.place(bordermode='outside',
                         height=20,
                         width=600,
                         x=100,
                         y=30)
            volver = tkinter.Button(funcionarios,
                                    text="Volver",
                                    command=volver)
            volver.place(bordermode='outside',
                         height=40,
                         width=100,
                         x=40,
                         y=400)
            funcionarios.mainloop()

            #print('\n-> Listado de Funcionarios en la base de datos: \n')
            #for funcionario in lista:
            #    print ('* Codigo: ', funcionario.codigof, ', Nombre: ', funcionario.nombre+' '+funcionario.apellido, ', Cargo: ',funcionario.cargo)
            #self.util.pause()
        else:
            alerta = tkinter.Message(funcionarios,
                                     relief='raised',
                                     text='NO EXISTEN REGISTROS ',
                                     width=200)
            alerta.place(bordermode='outside',
                         height=150,
                         width=200,
                         y=30,
                         x=150)
            ok = tkinter.Button(alerta, text="Ok", command=cerrar_exp)
            ok.pack(side="bottom")

    def mostrar_resultado(self, dato):
        if dato != None and len(dato) > 0:
            print('\n-> Funcionario Buscado Codigo: ', dato['codigo'])
            print('* Nombre Completo: ', dato['nombrecompleto'])
            print('* Cedula: ', dato['cedula'])
            print('* Cargo: ', dato['cargo'] + '\n')
        else:
            print('\n-> Funcionario no encontrado')
        self.util.pause()

    def mostrar_msg(self, msg):
        print('\n', msg + '\n\n')
Example #19
0
 def __init__(self):
     self.util = Util()
     self.controller = ControladorMedico()