Nenhuma descrição

enfermeriaver.py 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. tabla += '{'
  34. modal_content += '{'
  35. tabla += '"Dia y hora":"'+str(q[7])+'"'
  36. modal_content += '"Nombre Enfermera":"'+(q[1])+' '+(q[2])+'"'
  37. tabla += ','
  38. modal_content += ','
  39. tabla += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
  40. modal_content += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
  41. tabla += ','
  42. modal_content += ','
  43. tabla += '"Razon":"'+(q[5])+'"'
  44. modal_content += '"Razon":"'+(q[5])+'"'
  45. modal_content += ','
  46. modal_content += '"Explicación":"'+(q[6])+'"'
  47. modal_content += ','
  48. modal_content += '"Dia y hora":"'+str(q[7])+'"'
  49. tabla += ','
  50. modal_content += ','
  51. tabla += '"user_id":"'+str(q[0])+'"'
  52. modal_content += '"user_id":"'+str(q[0])+'"'
  53. tabla += '}'
  54. modal_content += '}'
  55. if i < len_result:
  56. tabla += ','
  57. modal_content+= ','
  58. tabla += ']'
  59. modal_content += ']'
  60. ###### info
  61. info = '{'
  62. info += '"dash_name":"Enfermeria- Manejar Visitas"'
  63. info += ','
  64. info += '"dash_link":"/enfermeria/ver/"'
  65. info += ','
  66. info += '"dash_sub_name":"Visitas hechas"'
  67. info += ','
  68. info += '"add":"Anadir Visita"'
  69. info += ','
  70. info += '"add_link":"/enfermeria/forma/add/visitas_enfermeria/"'
  71. info += ','
  72. info += '"dir1":"#"'
  73. info += ','
  74. info += '"dir2":"/enfermeria/forma/edit/visitas_enfermeria/"'
  75. info += '}'
  76. ###### modal
  77. modal = '{'
  78. modal += '"infoName":"Ver informacion"'
  79. modal += ','
  80. modal += '"editName":"#"'
  81. modal += '}'
  82. result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
  83. # print(result)
  84. return(result)