def check(self, tipo=None, nro_control=None, titulo=None, id_msj=None): with _db_session: if nro_control: return _select(msg for msg in _Mensaje if int(nro_control)==msg.nro_control and int(tipo)==msg.tipo and msg.activo==True).exists() else: if id_msj: tmp = _Mensaje.select(lambda msg: id_msj!=msg.id_msj and msg.titulo==titulo and msg.activo==True).count() return False if tmp==0 else True else: return _select(msg for msg in _Mensaje if titulo==msg.titulo and int(tipo)==msg.tipo and msg.activo==True).exists()
def v_ci(self, ci): try: with _db_session: return _select(pr for pr in _Persona if pr.ci==ci).exists() except Exception, e: #raise e return False
def v_telf(self, telf): try: with _db_session: return _select(pr for pr in _Persona if pr.telf==telf).exists() except Exception, e: #raise e return False
def v_login(self, login): try: with _db_session: return _select(us for us in _Usuario if us.login==login).exists() except Exception, e: print e return False
def v_login(self, login): try: with _db_session: return _select(us for us in _Usuario if us.login == login).exists() except Exception, e: print e return False
def get_All(cls): return _select(tn for tn in _Comunidad)
def getbyChild(cls, id_rcn): return _select(ct for ct in _Control if ct.recien_nacido.id_rcn==id_rcn).order_by(lambda ct: (ct.nro_con, ct.fecha_con))
def getbyPregnancy(cls, id_emb): return _select(ct for ct in _Control if ct.embarazo.id_emb==id_emb).order_by(lambda ct: (ct.nro_con, ct.fecha_con))
def get_All(self, status=True): return _select(pr for pr in _Persona if pr.activo==status and not pr.defuncion).order_by(lambda pr: (pr.nombres, pr.apellidos))
def get_All(self): return _select(cm for cm in _Comunidad).order_by(lambda cm: (cm.municipio, cm.nombre))
def get_All(self): return _select(cm for cm in _Comunidad).order_by( lambda cm: (cm.municipio, cm.nombre))
def get_all(self, id_per): return _select(em for em in _Embarazo if em.embarazada.id_per==id_per).order_by(lambda em: (_desc(em.parto_prob),))
def get_All(cls): # return _select(tn for tn in _Comunidad) return _select(tn for tn in _Municipio).order_by(lambda tn: (tn.dpto, tn.nombre))
def prenants_by_community(self, id_com): return _select(pr for pr in _Per if pr.sexo=='f' and pr.comunidad.id_com==id_com)
def get_All(cls): return _select(nt for nt in _Red_Salud).order_by(lambda nt: (nt.nombre, ))
def get_All(cls): return _select(nt for nt in _Red_Salud).order_by(lambda nt: (nt.nombre,))