No Description

enfermeriaver.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. from connect import connection
  2. import sqlalchemy as db
  3. def visitas():
  4. query ='SELECT t1.id, t2.nombres e_nombre, t2.apellidos e_apellido,\
  5. t1.nombres p_nombre, t1.apellidos p_apellido, t1.razon, t1.acciones, t1.fecha\
  6. FROM (SELECT v.id, u.nombres, u.apellidos,v.razon, v.acciones, v.fecha\
  7. FROM visitas_enfermeria v, usuarios u\
  8. WHERE v.estudiante_id = u.id) t1,\
  9. (SELECT v.id, u.nombres, u.apellidos\
  10. FROM visitas_enfermeria v, usuarios u\
  11. WHERE v.enfermera_id = u.id) t2\
  12. WHERE t1.id=t2.id'
  13. result_db = connection.execute(query).fetchall()
  14. ###### headers
  15. headers = '['
  16. headers += '{"nombre":"Dia y hora"}'
  17. headers += ','
  18. headers += '{"nombre":"Nombre Estudiante"}'
  19. headers += ','
  20. headers += '{"nombre":"Razon"}'
  21. headers += ','
  22. headers += '{"nombre":"Informacion"}'
  23. headers += ','
  24. headers += '{"nombre":"Editar"}'
  25. headers += ']'
  26. ###### tabla
  27. modal_content = '['
  28. tabla = '['
  29. i = 0
  30. len_result = len(result_db)
  31. for q in result_db:
  32. i = i+1
  33. dia = str(q[7]).split(' ')[0]
  34. hora = str(q[7]).split(' ')[1]
  35. hora = hora.split(':')
  36. hora = hora[0]+':'+hora[1]
  37. dia_hora = dia + ' ' + hora
  38. tabla += '{'
  39. modal_content += '{'
  40. tabla += '"Dia y hora":"'+dia_hora+'"'
  41. modal_content += '"Nombre Enfermera":"'+(q[1])+' '+(q[2])+'"'
  42. tabla += ','
  43. modal_content += ','
  44. tabla += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
  45. modal_content += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
  46. tabla += ','
  47. modal_content += ','
  48. tabla += '"Razon":"'+(q[5])+'"'
  49. modal_content += '"Razon":"'+(q[5])+'"'
  50. modal_content += ','
  51. modal_content += '"Explicación":"'+(q[6])+'"'
  52. modal_content += ','
  53. modal_content += '"Dia y hora":"'+dia_hora+'"'
  54. tabla += ','
  55. modal_content += ','
  56. tabla += '"user_id":"'+str(q[0])+'"'
  57. modal_content += '"user_id":"'+str(q[0])+'"'
  58. tabla += '}'
  59. modal_content += '}'
  60. if i < len_result:
  61. tabla += ','
  62. modal_content+= ','
  63. tabla += ']'
  64. modal_content += ']'
  65. ###### info
  66. info = '{'
  67. info += '"dash_name":"Enfermeria- Manejar Visitas"'
  68. info += ','
  69. info += '"dash_link":"/enfermeria/ver/"'
  70. info += ','
  71. info += '"dash_sub_name":"Visitas hechas"'
  72. info += ','
  73. info += '"add":"Anadir Visita"'
  74. info += ','
  75. info += '"add_link":"/enfermeria/forma/add/visitas_enfermeria/"'
  76. info += ','
  77. info += '"bot1":"Ver Mas"' #texto del primer boton en una fila
  78. info += ','
  79. info += '"bot2":"Editar"' #texto del segundo boton en una fila
  80. info += ','
  81. info += '"dir2":"/enfermeria/forma/edit/visitas_enfermeria/"'
  82. info += '}'
  83. ###### modal
  84. modal = '{'
  85. modal += '"infoName":"Ver informacion"'
  86. modal += ','
  87. modal += '"editName":"#"'
  88. modal += '}'
  89. result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
  90. # print(result)
  91. return(result)