def actualizarTablaPacientes(self): myConnection = connect() cur = myConnection.cursor() cur.execute("SELECT count(*) from agendamiento.paciente") suma1 = cur.fetchall()[0][0] self._cr.execute("SELECT count(*) from hrz_paciente") suma2 = self._cr.fetchall()[0][0] if suma1 != suma2: #raise osv.except_osv('Esto es un Mesaje!', str(suma1) +' - '+ str(suma2)) #print(a) print( str(suma1) + ' ------------------------------- ' + str(suma2)) cur.execute( "SELECT '(' ||id|| ',''' || COALESCE(primer_apellido,' ')|| ' ' || COALESCE(segundo_apellido,' ') || ' ' || COALESCE(primer_nombre,' ') || ' ' ||COALESCE(segundo_nombre,' ') ||''',''' ||COALESCE(cedula,'S/D')|| ''',''' ||COALESCE(numero_archivo,'0')|| ''')' FROM agendamiento.paciente order by id" ) a = cur.fetchall() valores = ",".join(map(lambda x: x[0], a)) #for i in a: # valores+= i[0] #valores+='-' #valores = valores.replace(',-','') #raise osv.except_osv('Esto es un Mesaje!', 'llego2') self._cr.execute("DELETE from hrz_paciente") #raise osv.except_osv('Esto es un Mesaje!', "INSERT INTO hrz_paciente (id) VALUES "+ valores) self._cr.execute( "INSERT INTO hrz_paciente (id,name,cedula,numero_archivo) values " + valores) return True
def actualizarMedicos(self): self.env['hrz.especialidad'].actualizarEspecialidad() myConnection = connect() cur = myConnection.cursor() cur.execute("SELECT count(*) from agendamiento.medico") suma1 = cur.fetchall()[0][0] self._cr.execute("SELECT count(*) from hrz_medico") suma2 = self._cr.fetchall()[0][0] if suma1 != suma2: print( str(suma1) + ' ------------------------------- ' + str(suma2)) SqlConsulta = """SELECT '(' ||p.idper|| ',''' || nom1|| ' ' ||nom2|| ' ' ||ape1|| ' ' ||ape2 ||''',''' ||COALESCE(ci,'S/D')|| ''',''' ||COALESCE(tel1,'S/D')|| ''',' ||pr.idespecialidad|| ')' FROM inventario.persona p,inventario.personaxrol pr, inventario.rol r where p.idper = pr.idper and pr.idrol = r.idrol and r.nrol = 'MEDICO' order by p.idper""" #cur.execute( "SELECT '(' ||idper|| ',''' || nom1|| ' ' ||nom2|| ' ' ||ape1|| ' ' ||ape2 ||''',''' ||COALESCE(ci,'S/D')|| ''',''' ||COALESCE(tel1,'S/D')|| ''',' ||COALESCE(idespecialidad,'0')|| ')' FROM inventario.persona order by idper") cur.execute(SqlConsulta) a = cur.fetchall() valores = ",".join(map(lambda x: x[0], a)) self._cr.execute("DELETE from hrz_medico") #raise osv.except_osv('Esto es un Mesaje!', "INSERT INTO hrz_paciente (id) VALUES "+ valores) self._cr.execute( "INSERT INTO hrz_medico (id,name,cedula,telefono,especialidad_id) values " + valores) return True
def _getEmail(self): myConnection = connect() cur = myConnection.cursor() cur.execute("SELECT mail FROM inventario.persona where ci = '" + str(self.cedula) + "'") resp = cur.fetchall() self.correo = resp[0][0] return True
def _getOtherFields(self): print( ' ------------------------------456879---------------------------- ' ) self.actualizarPacientes() myConnection = connect() cur = myConnection.cursor() cur.execute( "SELECT nom1|| ' ' ||nom2|| ' ' ||ape1|| ' ' ||ape2,ci,tel1 FROM inventario.persona where idper = " + str(self.id)) resp = cur.fetchall() self.name = resp[0][0] self.cedula = resp[0][1] self.telefono = resp[0][2] #self.titulo = resp[0][3] return True
def _getOtherFields(self): print( ' ------------------------------456879---------------------------- ' ) self.actualizarPacientes() myConnection = connect() cur = myConnection.cursor() cur.execute( "SELECT COALESCE(primer_apellido,' ')|| ' ' ||COALESCE(segundo_apellido,' ') || ' ' || COALESCE(primer_nombre,' '), numero_archivo,cedula,telefono,celular,direccion,alergia FROM agendamiento.paciente where id = " + str(self.id)) resp = cur.fetchall() self.name = resp[0][0] self.numero_archivo = resp[0][1] self.cedula = resp[0][2] self.telefono = resp[0][3] self.celular = resp[0][4] self.direccion = resp[0][5] self.alergia = resp[0][6] return True
def actualizarEspecialidad(self): myConnection = connect() cur = myConnection.cursor() cur.execute("SELECT count(*) from agendamiento.especialidadmedica") suma1 = cur.fetchall()[0][0] self._cr.execute("SELECT count(*) from hrz_especialidad") suma2 = self._cr.fetchall()[0][0] if suma1 != suma2: print( str(suma1) + ' ------------------------------- ' + str(suma2)) cur.execute( "SELECT '(' ||idespecialidad|| ',''' ||COALESCE(especialidad,' ')|| ''')' FROM agendamiento.especialidadmedica order by idespecialidad" ) a = cur.fetchall() valores = ",".join(map(lambda x: x[0], a)) self._cr.execute("DELETE from hrz_especialidad") #raise osv.except_osv('Esto es un Mesaje!', "SELECT '(' ||idespecialidad|| ',''' ||COALESCE(especialidad,' ')|| ''')' FROM agendamiento.especialidadmedica order by idespecialidad") self._cr.execute("INSERT INTO hrz_especialidad (id,name) values " + valores) return True
def actualizarPacientes(self): myConnection = connect() cur = myConnection.cursor() cur.execute("SELECT MAX(id) from agendamiento.paciente") ultimo1 = cur.fetchall()[0][0] self._cr.execute("SELECT MAX(id) from hrz_paciente") ultimo2 = self._cr.fetchall()[0][0] if ultimo2 == None or ultimo2 > ultimo1: self.actualizarTablaPacientes() pass elif ultimo1 != ultimo2 and ultimo2 != None: print( str(ultimo1) + ' ------------------------------- ' + str(ultimo2)) #raise osv.except_osv('Esto es un Mesaje!', "SELECT '(' ||id|| ',''' || COALESCE(primer_apellido,' ')|| ' ' || COALESCE(segundo_apellido,' ') || ' ' || COALESCE(primer_nombre,' ') || ' ' ||COALESCE(segundo_nombre,' ') ||''',''' ||COALESCE(cedula,'S/D')|| ''',''' ||COALESCE(numero_archivo,'0')|| ''')' FROM agendamiento.paciente where id > "+str(ultimo2)+" order by id") cur.execute( "SELECT '(' ||id|| ',''' || COALESCE(primer_apellido,' ')|| ' ' || COALESCE(segundo_apellido,' ') || ' ' || COALESCE(primer_nombre,' ') || ' ' ||COALESCE(segundo_nombre,' ') ||''',''' ||COALESCE(cedula,'S/D')|| ''',''' ||COALESCE(numero_archivo,'0')|| ''')' FROM agendamiento.paciente where id > " + str(ultimo2) + " order by id") a = cur.fetchall() valores = ",".join(map(lambda x: x[0], a)) #raise osv.except_osv('Esto es un Mesaje!', valores) #for i in a: # valores+= i[0] #valores+='-' #valores = valores.replace(',-','') #print(valores) #self._cr.execute("DELETE from hrz_paciente" ) #raise osv.except_osv('Esto es un Mesaje!', "INSERT INTO hrz_paciente (id) VALUES "+ valores) self._cr.execute( "INSERT INTO hrz_paciente (id,name,cedula,numero_archivo) values " + valores) return True