Beispiel #1
0
	def update(cls, id_emb, parto_prob):
		try:
			parto_prob = _to_yymmdd(parto_prob)
			pp = _to_date(parto_prob) - _timedelta(days=280)
			ctrls = _PreNatal(pp.year, pp.month, pp.day)
			if not ctrls.check_range():
				return (False, list())
			promos = _PrePromotional(pp.year, pp.month, pp.day).controls_dates()
			agendas_ids = list()
			with _db_session:
				pregnancy = cls.get_byId(id_emb=id_emb)
				pregnancy.set(parto_prob=parto_prob)
				_controlsCrt.delete_controls(pregnancy)
				agendas_ids = _agendasCrt.delete_agendas(pregnancy.embarazada)
				pregnancy.controles += [_Control(embarazo=pregnancy, nro_con=ctrl[0], fecha_con=ctrl[1]) for ctrl in ctrls.controls_dates()]
				_flush()
				for cn in pregnancy.controles:
					msg = _messagesCrt.get_byNumbControl(nro_control=cn.nro_con)
					_agendasCrt.save(persona=pregnancy.embarazada, mensaje=msg, fecha_con=cn.fecha_con, days=7)
				for cn in promos:
					msg = _messagesCrt.get_byNumbControl(nro_control=cn[0], tipo=3)
					_agendasCrt.save(persona=pregnancy.embarazada, mensaje=msg, fecha_con=cn[1])
				_commit()
			return (True, agendas_ids)
		except Exception, e:
			#raise e
			print 'Error: {}'.format(e)
			return (False, list())
Beispiel #2
0
	def update(self, form):
		try:
			with _db_session:
				us = _Usuario.get(persona=form.persona)
				if us:
					if form.has_key('ci'):
						us.persona.set(nombres=form.nombres, apellidos=form.apellidos, ci=form.ci, telf=form.telf); _flush()
						del form.nombres; del form.apellidos; del form.ci; del form.telf
						f_usuario = form
					else:
						us.set(alcance=None, red_salud=None, municipio=None, centro_salud=None, activo=True); _flush()
						f_usuario = _user_form(form)
					if len(f_usuario.passwd):
						f_usuario.passwd = f_usuario.passwd.encode('hex').encode('base64').replace('\n','')
					else:
						del f_usuario.passwd
					#print f_usuario
					us.set(**f_usuario)
					_commit()
				else:
					return False
			return True
		except Exception, e:
			print e
			return False
	def delete_controls(cls, obj):
		check_date = lambda dt: True if dt>=_utc.now().date() else False
		with _db_session:
			for cnt in obj.controles:
				if not cnt.asistido and check_date(cnt.fecha_con):
					cnt.delete()
			_commit()
Beispiel #4
0
	def childbirth(self, obj):
		try:
			pinst = _to_date(_to_yymmdd(obj.get_argument('parto_inst')))
			ctrls = _PostNatal(pinst.year, pinst.month, pinst.day).controls_dates()
			#f_emb = lambda: dict(parto_inst=obj.get_argument('parto_inst'),tipo=obj.get_argument('tipo'),observacion=obj.get_argument('observacion'))
			f_emb = lambda: dict(parto_inst=_to_yymmdd(obj.get_argument('parto_inst')),tipo=obj.get_argument('tipo'))
			pesos, nombres, apellidos = obj.get_arguments('peso'), obj.get_arguments('nombres'), obj.get_arguments('apellidos')
			sexos = [obj.get_argument('sexo{}'.format(s)) for s in xrange(len(nombres))] if len(nombres)>1 else [obj.get_argument('sexo0')]
			agendas_ids = list()
			with _db_session:
				em = _Embarazo.get(id_emb=obj.get_argument('id_emb'))
				em.set(activo=False, **f_emb()); _flush()
				_controlsCrt.delete_controls(em)
				agendas_ids = _agendasCrt.delete_agendas(em.embarazada)
				controls = lambda: [_Control(tipo=u'Post-Natal', nro_con=ctrl[0], fecha_con=ctrl[1]) for ctrl in ctrls]
				em.recien_nacidos += [_NewBorn(embarazo=em,peso=nb[0],sexo=nb[1],nombres=nb[2],apellidos=nb[3],controles=controls()) for nb in zip(pesos,sexos,nombres,apellidos)]
				_flush()
				for rn in em.recien_nacidos:
					for cn in rn.controles:
						msg = _messagesCrt.get_byNumbControl(nro_control=cn.nro_con, tipo=2)
						_agendasCrt.save(persona=em.embarazada, mensaje=msg, fecha_con=cn.fecha_con)
					break
				#em.controles += [_Control(embarazo=em, tipo=u'Post-Natal', nro_con=ctrl[0], fecha_con=ctrl[1]) for ctrl in ctrls.controls_dates()]
				_commit()
			return (True, agendas_ids)
		except Exception, e:
			#raise e
			print e
			return (False, list())
	def update(self, id_per, telf, nombres, apellidos, id_com, id_etn, f_nac, ci, c_telf, c_sexo, c_nombres=None, c_apellidos=None, c_id_per=None):
		f_nac = _to_yymmdd(f_nac); activo = True
		preg_form = dict([(k,v) for k,v in locals().iteritems() if not(k.startswith('_') or k.startswith('c_') or k.startswith('self') or k in ['id_com','id_etn','id_per'])])
		try:
			with _db_session:
				com = _Comunidad.get(id_com=id_com)
				etn = _Etnia.get(id_etn=id_etn)
				pregnant = _Persona.get(id_per=id_per)
				pregnant.set(comunidad=com, etnia=etn,**preg_form)
				if not(c_id_per is None):
					contact = _Persona.get(id_per=c_id_per)
					contact.set(sexo=c_sexo); _flush()
					if c_nombres is None:
						pregnant.contacto = contact; _flush()
					else:
						tmp = self.get_byCellphone(c_telf)
						if tmp:
							assert(tmp.id_per==pregnant.contacto.id_per)
						contact.set(telf=c_telf, nombres=c_nombres, apellidos=c_apellidos); _flush()
						pregnant.contacto = contact; _flush()
				else:
					contact = _Persona(telf=c_telf, nombres=c_nombres, apellidos=c_apellidos, sexo=c_sexo, tipos=[_Tipo.get(id_tip=2)])
					pregnant.contacto = contact
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
Beispiel #6
0
	def delete_agendas(self, obj):
		check_date = lambda dt: True if dt>=_utc.now().date() else False
		with _db_session:
			for ags in obj.agendas:
				if not ags.enviado and check_date(ags.fecha_msj):
					ags.delete()
			_commit()
Beispiel #7
0
 def update(self,
            id_per,
            telf,
            cobertura,
            nombres,
            apellidos,
            id_com,
            id_etn,
            f_nac,
            ci,
            relacion,
            centro_salud,
            c_telf,
            c_sexo,
            c_nombres=None,
            c_apellidos=None,
            c_id_per=None):
     f_nac = _to_yymmdd(f_nac)
     activo = True
     preg_form = dict([
         (k, v) for k, v in locals().iteritems()
         if not (k.startswith('_') or k.startswith('c_') or k.startswith(
             'self') or k in ['id_com', 'id_etn', 'id_per'])
     ])
     try:
         with _db_session:
             com = _Comunidad.get(id_com=id_com)
             etn = _Etnia.get(id_etn=id_etn)
             pregnant = _Persona.get(id_per=id_per)
             pregnant.set(comunidad=com, etnia=etn, **preg_form)
             if not (c_id_per is None):
                 contact = _Persona.get(id_per=c_id_per)
                 contact.set(sexo=c_sexo)
                 _flush()
                 if c_nombres is None:
                     pregnant.contacto = contact
                     _flush()
                 else:
                     tmp = self.get_byCellphone(c_telf)
                     if tmp:
                         assert (tmp.id_per == pregnant.contacto.id_per)
                     contact.set(telf=c_telf,
                                 nombres=c_nombres,
                                 apellidos=c_apellidos)
                     _flush()
                     pregnant.contacto = contact
                     _flush()
             else:
                 contact = _Persona(telf=c_telf,
                                    nombres=c_nombres,
                                    apellidos=c_apellidos,
                                    sexo=c_sexo,
                                    tipos=[_Tipo.get(id_tip=2)])
                 pregnant.contacto = contact
             _commit()
         return True
     except Exception, e:
         #raise e
         print e
         return False
	def save(self, form, id_user, default=True):
		flag = self.check(nro_control=form.nro_control,tipo=form.tipo) if hasattr(form,'nro_control') else self.check(titulo=form.titulo,tipo=form.tipo)
		#print flag
		if not flag:
			with _db_session:
				user = _Usuario.get(persona=id_user)
				msg = _Mensaje(usuario=user, **form); _commit()
		return not flag if default else msg
Beispiel #9
0
	def del_risk(cls, id_emb):
		try:
			with _db_session:
				emb = cls.get_byId(id_emb); emb.set(riesgo=None)
				_commit()
				return True
		except Exception, e:
			raise e
			return False
Beispiel #10
0
	def delete(self, id_tip):
		try:
			with _db_session:
				tp = _Tipo.get(id_tip=id_tip)
				tp.set(activo=False)
				_commit()
			return False
		except Exception, e:
			return True
Beispiel #11
0
	def risk_status(cls, id_emb, riesgo):
		try:
			with _db_session:
				emb = cls.get_byId(id_emb); emb.set(riesgo=riesgo)
				_commit()
				return True
		except Exception, e:
			raise e
			return False
Beispiel #12
0
 def delete(self, id_tip):
     try:
         with _db_session:
             tp = _Tipo.get(id_tip=id_tip)
             tp.set(activo=False)
             _commit()
         return False
     except Exception, e:
         return True
Beispiel #13
0
	def save(self, nombre, descrip):
		try:
			with _db_session:
				if self.check(nombre)[0]==True:
					return False
				_Prestacion(nombre=nombre, descrip=descrip); _commit()
			return True
		except Exception, e:
			return False
Beispiel #14
0
 def delete(self, id_com):
     try:
         with _db_session:
             com = _Comunidad.get(id_com=id_com)
             com.set(activo=False)
             _commit()
         return False
     except Exception, e:
         #raise e
         return True
Beispiel #15
0
 def update(self, id_com, nombre, telf):
     try:
         with _db_session:
             com = _Comunidad.get(id_com=id_com)
             com.set(nombre=nombre, telf=telf, activo=True)
             _commit()
         return True
     except Exception, e:
         #raise e
         return False
Beispiel #16
0
	def delete_death(cls, id_def):
		try:
			with _db_session:
				death = _Death.get(id_def=id_def)
				death.delete()
				_commit()
			return False
		except Exception, e:
			raise e
			return True
	def save(self, township, communities):
		try:
			with _db_session:
				township = _Municipio(**township)
				township.comunidades += [_Comunidad(municipio=township, **com) for com in communities]
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
	def del_interrupt(self, id_def):
		try:
			with _db_session:
				interr = _Defuncion.get(id_def=id_def)
				interr.delete()
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
Beispiel #19
0
	def delete(cls, id_mup):
		try:
			with _db_session:
				mup = _Municipio.get(id_mup=id_mup)
				mup.set(activo=False)
				_commit()
			return False
		except Exception, e:
			#raise e
			return True
 def update(self, id_rcn, nombres, apellidos, sexo, peso):
     try:
         with _db_session:
             child = _newBorn.get(id_rcn=id_rcn)
             child.set(nombres=nombres, apellidos=apellidos, sexo=sexo, peso=peso)
             _commit()
         return True
     except Exception, e:
         raise e
         return False
	def delete(self, id_com):
		try:
			with _db_session:
				com = _Comunidad.get(id_com=id_com)
				com.set(activo=False)
				_commit()
			return False
		except Exception, e:
			#raise e
			return True
	def delete(cls, id_mup):
		try:
			with _db_session:
				mup = _Municipio.get(id_mup=id_mup)
				mup.set(activo=False)
				_commit()
			return False
		except Exception, e:
			#raise e
			return True
 def delete_death(self, id_def):
     try:
         with _db_session:
             death = _Death.get(id_def=id_def)
             death.delete()
             _commit()
         return False
     except Exception, e:
         raise e
         return True
	def update(self, id_mup, nombre, dpto):
		try:
			with _db_session:
				mup = _Municipio.get(id_mup=id_mup)
				mup.set(nombre=nombre, dpto=dpto, activo=True)
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
Beispiel #25
0
	def update(cls, id_rcn, nombres, apellidos, sexo, peso):
		try:
			with _db_session:
				child = _newBorn.get(id_rcn=id_rcn)
				child.set(nombres=nombres, apellidos=apellidos, sexo=sexo, peso=peso)
				_commit()
			return True
		except Exception, e:
			raise e
			return False
	def update(self, id_com, nombre, telf):
		try:
			with _db_session:
				com = _Comunidad.get(id_com=id_com)
				com.set(nombre=nombre, telf=telf, activo=True)
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
Beispiel #27
0
	def delete(self, persona):
		try:
			with _db_session:
				us = _Usuario.get(persona=persona)
				if us:
					us.set(activo=False); _commit()
			return False
		except Exception, e:
			print e
			return True
	def save(self, nombre):
		try:
			with _db_session:
				if self.check(nombre)[0]==True:
					return False
				_Etnia(nombre=nombre); _commit()
			return True
		except Exception, e:
			#raise e
			return False
	def save(self, form, user_id):
		try:
			#print _to_yymmdd(form.parto_prob)
			form.parto_prob = _to_yymmdd(form.parto_prob); form.f_nac = _to_yymmdd(form.f_nac)
			pp = _to_date(form.parto_prob) - _timedelta(days=280)
			#print 'origin: {}'.format(pp)
			ctrls = _PreNatal(pp.year, pp.month, pp.day)
			if not ctrls.check_range():
				return False
			promos = _PrePromotional(pp.year, pp.month, pp.day).controls_dates()
			check_pregnant = lambda: len([i for i in form.keys() if not i.startswith('c_')]) 
			check_contact = lambda: len([i for i in form.keys() if i.startswith('c_')])
			#print check_pregnant()
			#print check_contact()
			if check_pregnant()>5:
				em_fields = {k:v for k,v in form.iteritems() if not k.startswith('c_') and k not in ['id_com','id_etn','parto_prob']}
				#print em_fields
			cn_fields = lambda: {k.replace('c_',''):v for k,v in form.iteritems() if k.startswith('c_')}
			#print cn_fields()
			with _db_session:
				tipos = [_Tipo.get(id_tip=1), _Tipo.get(id_tip=2)]
				com = _Comunidad.get(id_com=form.id_com)
				em_etn = _Etnia.get(id_etn=form.id_etn)
				if check_pregnant()>5:
					em = _Persona(comunidad=com, etnia=em_etn, tipos=[tipos[0]], **em_fields)
					_flush()
				else:
					em = _Persona.get(telf=form.telf)
					em.set(f_nac=form.f_nac, comunidad=com, etnia=em_etn)
					em.tipos += [tipos[0]]
					_flush()
				embarazo = _Embarazo(embarazada=em, parto_prob=form.parto_prob)
				embarazo.controles += [_Control(embarazo=embarazo, nro_con=ctrl[0], fecha_con=ctrl[1]) for ctrl in ctrls.controls_dates()]
				_flush()
				for cn in embarazo.controles:
					msg = _messagesCrt.get_byNumbControl(nro_control=cn.nro_con)
					_agendasCrt.save(persona=em, mensaje=msg, fecha_con=cn.fecha_con, days=7)
				for cn in promos:
					msg = _messagesCrt.get_byNumbControl(nro_control=cn[0], tipo=3)
					_agendasCrt.save(persona=em, mensaje=msg, fecha_con=cn[1])
				if check_contact()==1:
					contacto = _Persona.get(telf=form.c_telf)
					contacto.embarazadas += [em]
					if tipos[1] not in contacto.tipos:
						contacto.tipos += [tipos[1]]
					_flush()
				elif check_contact()>=5:
					cnt = _Persona(comunidad=com, tipos=[tipos[1]], **cn_fields()); _flush()
					cnt.embarazadas += [em]
				_commit()
			return True
		except Exception, e:
			#raise e
			print e
			return False
 def confirm_death(self, id_def, f_conf, obs_conf):
     try:
         with _db_session:
             death = _Death.get(id_def=id_def)
             death.set(f_conf=_to_yymmdd(f_conf), obs_conf=obs_conf)
             _controlsCrt.delete_controls(death.recien_nacido)
             _commit()
         return True
     except Exception, e:
         raise e
         return False
	def delete(self, id_pst):
		try:
			with _db_session:
				pr = _Prestacion.get(id_pst=id_pst)
				pr.set(activo=False)
				if not pr.centros_salud.is_empty():
					pr.centros_salud.clear()
				_commit()
			return False
		except Exception, e:
			return True
Beispiel #32
0
	def del_interrupt(self, id_def):
		try:
			with _db_session:
				interr = _Defuncion.get(id_def=id_def)
				interr.delete()
				_commit()
			return True
		except Exception, e:
			#raise e
			print e
			return False
Beispiel #33
0
 def save(self, nombre):
     try:
         with _db_session:
             if self.check(nombre)[0] == True:
                 return False
             _Etnia(nombre=nombre)
             _commit()
         return True
     except Exception, e:
         #raise e
         return False
Beispiel #34
0
	def delete(self, id_pst):
		try:
			with _db_session:
				pr = _Prestacion.get(id_pst=id_pst)
				pr.set(activo=False)
				if not pr.centros_salud.is_empty():
					pr.centros_salud.clear()
				_commit()
			return False
		except Exception, e:
			return True
Beispiel #35
0
 def delete_agendas(self, obj):
     #check_date = lambda dt: True if dt>=_utc.now().date() else False
     agendas_ids = list()
     with _db_session:
         for ags in obj.agendas:
             #if not(ags.sms_estado and ags.lmd_estado) and check_date(ags.fecha_msj):
             if not (ags.sms_estado or ags.lmd_estado or ags.rad_estado):
                 agendas_ids += [ags.id_agd]
                 ags.delete()
         _commit()
     return agendas_ids
Beispiel #36
0
	def update(self, id_per, nombres, apellidos, telf, sexo):
		form = _getLocals(locals())
		try:
			with _db_session:
				pr = _Persona.get(id_per=id_per); del form.id_per
				pr.set(**form)
				_commit()
			return True
		except Exception, e:
			#raise e
			return False
Beispiel #37
0
 def delete(self, persona):
     try:
         with _db_session:
             us = _Usuario.get(persona=persona)
             if us:
                 us.set(activo=False)
                 _commit()
         return False
     except Exception, e:
         print e
         return True
	def delete_agendas(self, obj):
		#check_date = lambda dt: True if dt>=_utc.now().date() else False
		agendas_ids = list()
		with _db_session:
			for ags in obj.agendas:
				#if not(ags.sms_estado and ags.lmd_estado) and check_date(ags.fecha_msj):
				if not(ags.sms_estado or ags.lmd_estado or ags.rad_estado):
					agendas_ids += [ags.id_agd]
					ags.delete()
			_commit()
		return agendas_ids
Beispiel #39
0
 def del_death(self, id_def):
     try:
         with _db_session:
             death = _Defuncion.get(id_def=id_def)
             death.delete()
             _commit()
         return True
     except Exception, e:
         #raise e
         print e
         return False
	def del_death(self, id_def):
		try:
			with _db_session:
				death = _Defuncion.get(id_def=id_def)
				death.delete()
				_commit()
			return True
		except Exception, e:
			#raise e
			print e
			return False
	def delete(self, id_per):
		try:
			with _db_session:
				pr = _Persona.get(id_per=id_per)
				pr.activo = False
				if not pr.agendas.is_empty():
					_agendasCrt.delete_agendas(pr)
				_commit()
			return False
		except Exception, e:
			#raise e
			return True
	def update_status(self, id_agd, sms_estado=None, lmd_estado=None, rad_estado=None, user_login=None):
		with _db_session:
			ag, user = self.get_byID(id_agd=id_agd), None
			if user_login:
				user = _User.get(login=user_login)
			if ag and sms_estado:
				ag.sms_estado = True
			if ag and lmd_estado:
				ag.lmd_estado = True
			if ag and rad_estado:
				ag.rad_estado = True
			ag.set(usuario=user); _commit()
Beispiel #43
0
	def update(self, id_pst, nombre, descrip):
		try:
			with _db_session:
				flag = self.check(nombre)
				if flag[0]==True and flag[1]!=int(id_pst):
					return False
				pr = _Prestacion.get(id_pst=id_pst)
				pr.set(nombre=nombre, descrip=descrip, activo=True)
				_commit()
			return True
		except Exception, e:
			return False
Beispiel #44
0
 def update(self, id_tip, nombre, descrip):
     try:
         with _db_session:
             flag = self.check(nombre)
             if flag[0] == True and flag[1] != int(id_tip):
                 return False
             tp = _Tipo.get(id_tip=id_tip)
             tp.set(nombre=nombre, descrip=descrip, activo=True)
             _commit()
         return True
     except Exception, e:
         return False
	def update(self, id_pst, nombre, descrip):
		try:
			with _db_session:
				flag = self.check(nombre)
				if flag[0]==True and flag[1]!=int(id_pst):
					return False
				pr = _Prestacion.get(id_pst=id_pst)
				pr.set(nombre=nombre, descrip=descrip, activo=True)
				_commit()
			return True
		except Exception, e:
			return False
Beispiel #46
0
	def confirm_death(cls, id_def, f_conf, obs_conf):
		try:
			agendas_ids = list()
			with _db_session:
				death = _Death.get(id_def=id_def)
				death.set(f_conf=_to_yymmdd(f_conf), obs_conf=obs_conf)
				_controlsCrt.delete_controls(death.recien_nacido)
				agendas_ids = _agendasCrt.delete_agendas(death.recien_nacido.embarazo.embarazada)
				_commit()
			return (True, agendas_ids)
		except Exception, e:
			raise e
			return (False, list())
Beispiel #47
0
 def update(self, id_etn, nombre):
     try:
         with _db_session:
             flag = self.check(nombre)
             if flag[0] == True and flag[1] != int(id_etn):
                 return False
             et = _Etnia.get(id_etn=id_etn)
             et.set(activo=True, nombre=nombre)
             _commit()
         return True
     except Exception, e:
         #raise e
         return False
Beispiel #48
0
 def delete(self, id_per):
     try:
         agendas_ids = list()
         with _db_session:
             pr = _Persona.get(id_per=id_per)
             pr.activo = False
             if not pr.agendas.is_empty():
                 agendas_ids = _agendasCrt.delete_agendas(pr)
             _commit()
         return (False, agendas_ids)
     except Exception, e:
         #raise e
         print e
         return (True, list())
Beispiel #49
0
	def save(cls, township, communities=[]):
		try:
			with _db_session:
				if not cls.exists(township.nombre, township.dpto):
					mp = _Municipio(**township); _flush()
					for cm in communities:
						cm.municipio = mp.id_mup
						_communitiesCrt.save(community=cm)
					_commit()
					return True
				return False
		except Exception, e:
			raise e
			return False
Beispiel #50
0
 def save(cls, form):
     try:
         with _db_session:
             if not cls.exists(nombre=form.nombre):
                 red = _Red_Salud(nombre=form.nombre)
                 _flush()
                 for mp in form.municipios:
                     mp.red_salud = red.id_red
                     _townshipsCrt.save(township=mp)
                 _commit()
                 return True
             return False
     except Exception, e:
         raise e
         return False
Beispiel #51
0
 def save(cls, hospital, communities=[], capabilities=[]):
     print "Hospital", hospital, communities, capabilities
     try:
         with _db_session:
             if not cls.exists(nombre=hospital.nombre,
                               ubicado=hospital.ubicado):
                 hp = _Hospital(**hospital)
                 _flush()
                 cls().set_hospitals_and_capabilities(
                     hp, communities, capabilities)
                 _commit()
                 return True
             return False
     except Exception, e:
         raise e
         return False
Beispiel #52
0
	def update(cls, id_mup, nombre, dpto):
		try:
			with _db_session:
				mup = _Municipio.get(id_mup=id_mup)
				if mup.nombre==nombre.upper() and mup.dpto==dpto.upper():
					mup.set(activo=True); _commit()
					return True
				else:
					if not cls.exists(nombre, dpto):
						mup.set(nombre=nombre, dpto=dpto, activo=True); _commit()
						return True
					return False
			return True
		except Exception, e:
			raise e
			return False
Beispiel #53
0
 def save(self, community, hospitals=[]):
     try:
         with _db_session:
             if not self.exists(id_mup=community.municipio,
                                nombre=community.nombre):
                 com = _Comunidad(**community)
                 _flush()
                 for hp in hospitals:
                     hp.ubicado = com.id_com
                     _hospitalsCrt.save(hospital=hp,
                                        communities=[com.id_com])
                 _commit()
                 return True
             return False
     except Exception, e:
         raise e
         return False
Beispiel #54
0
 def update(cls, id_red, nombre):
     try:
         with _db_session:
             red = _Red_Salud.get(id_red=id_red)
             if red.nombre == nombre.upper():
                 red.set(activo=True)
                 _commit()
                 return True
             else:
                 if not cls.exists(nombre):
                     red.set(nombre=nombre, activo=True)
                     _commit()
                     return True
                 return False
     except Exception, e:
         raise e
         return False