def conteo_jornada(self): """la funcion conteo devuelve el mayor nro de jornada en la base """ try: db = MiZODB('./Data.fs') dbroot = db.raiz nro = 1 fecha = None cont = True for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, JornadaModel): if cont: nro = obj.contador fecha = obj.fecha cont = False if obj.contador > nro: nro = obj.contador fecha = obj.fecha db.close() return (nro, fecha) except Exception as e: db.close() raise ('Error', e)
def cargar_jornada(self, obj): try: db = MiZODB('./Data.fs') dbroot = db.raiz dbroot[obj.contador] = obj transaction.commit() db.close() return ('Ok') except Exception as e: db.close() raise ('No se ha podido crear \n', e)
def cargar_orden(self, obj, nro_orden): try: db = MiZODB('./Data.fs') dbroot = db.raiz dbroot[nro_orden] = obj transaction.commit() db.close() return ('Orden de Analisis creado cod.: ', nro_orden) except Exception as e: db.close() raise ('No se ha podido crear \n', e)
def cargar_persona(self, obj, clave): try: db = MiZODB('./Data.fs') dbroot = db.raiz dbroot[clave] = obj transaction.commit() db.close() return ('Paciente creado!: ' + clave) except Exception as e: db.close() raise ('No se ha podido crear \n', e)
def cargar_analisis(self, ): try: db = MiZODB('./Data.fs') dbroot = db.raiz dbroot[clave] = obj transaction.commit() db.close() return ('Analisis creado!: ' + clave) except Exception as e: db.close() raise ('No se ha podido crear \n', e)
def buscar_orden_modif(self, codigo): try: db = MiZODB('./Data.fs') dbroot = db.raiz orden = None for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, OrdenModel): if key == codigo: orden = OrdenModel(obj.fecha, obj.id_orden, obj.codigo_paciente, obj.tipo, obj.cod_orden, obj.estado) db.close() return orden except Exception as e: db.close() raise ('Error', e)
def listar_persona(self): try: db = MiZODB('./Data.fs') dbroot = db.raiz result = [] for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, Paciente): paciente = Paciente(obj.nombre, obj.apellido, obj.cedula, obj.telefono, obj.email, obj.fecha_nac, obj.orden, obj.codigof) result.append(paciente) db.close() return result except Exception as e: db.close() raise ('Error al consultar la base', e)
def listar_ordenes_finalizadas(self): try: db = MiZODB('./Data.fs') dbroot = db.raiz result = [] for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, OrdenModel): if (obj.estado == 'Finalizado'): orden = OrdenModel(obj.fecha, obj.id_orden, obj.codigo_paciente, obj.tipo, obj.cod_orden, obj.estado) result.append(orden) db.close() return result except Exception as e: db.close() raise ('Error al consultar la base', e)
def buscar_orden(self, codigo): try: db = MiZODB('./Data.fs') dbroot = db.raiz orden = '' for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, OrdenModel): if key == codigo: orden = { 'codigo': obj.cod_orden, 'cod_paciente': obj.codigo_paciente, 'tipo': obj.tipo, 'estado': obj.estado } db.close() return orden except Exception as e: db.close() raise ('Error', e)
def buscar_persona(self, codigo): try: db = MiZODB('./Data.fs') dbroot = db.raiz persona = '' for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, Paciente): if obj.codigof == codigo: persona = { 'nombrecompleto': obj.nombre + ' ' + obj.apellido, 'codigo': obj.codigof, 'cedula': obj.cedula, 'orden': obj.orden } db.close() return persona except Exception as e: db.close() raise ('Error', e)
def buscar_nro_orden(self): """la funcion buscar devuelve el mayor nro de orden en la base""" try: db = MiZODB('./Data.fs') dbroot = db.raiz nro = 0 cont = True for key in dbroot.keys(): obj = dbroot[key] if isinstance(obj, OrdenModel): if cont: nro = obj.id_orden cont = False if obj.id_orden > nro: nro = obj.id_orden db.close() return nro except Exception as e: db.close() raise ('Error', e)