health-index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. var dd = dialog({contentType:'load', skin:'bk-popup', content:'保存中...'});
  2. var d = dialog({contentType:'load', skin:'bk-popup'});
  3. function getNowDate() {
  4. var date = new Date();
  5. var year = date.getFullYear();
  6. var month = date.getMonth() + 1;
  7. var day = date.getDate();
  8. var hour = date.getHours();
  9. var minute = date.getMinutes();
  10. var second = date.getSeconds();
  11. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  12. }
  13. function toIntValue(value){
  14. if(parseInt(value) == value){
  15. return parseInt(value);
  16. }else{
  17. return Math.round(value*Math.pow(10, 1))/Math.pow(10, 1);
  18. }
  19. }
  20. /**
  21. * 获取多少天前的日期
  22. */
  23. function getDateBefore(days) {
  24. var now = new Date();
  25. var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
  26. var year = date.getFullYear();
  27. var month = date.getMonth() + 1;
  28. var day = date.getDate();
  29. var hour = date.getHours();
  30. var minute = date.getMinutes();
  31. var second = date.getSeconds();
  32. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  33. }
  34. /**
  35. * 添加健康指标到服务器
  36. * intervene 干预标志
  37. * time 记录时间
  38. * value1 血糖/收缩压/体重/腰围
  39. * value2 舒张压
  40. * point 血糖测量点标识
  41. * type 健康指标类型(1血糖,2血压,3体重,4腰围)
  42. */
  43. function addHealthIndex(intervene, operTime, value1, value2, value3, value4, value5, value6, value7, type, successFunction) {
  44. //拼请求内容
  45. var params = {};
  46. params.intervene = intervene;
  47. params.time = operTime;
  48. params.value1 = value1;
  49. params.value2 = value2;
  50. params.value3 = value3;
  51. params.value4 = value4;
  52. params.value5 = value5;
  53. params.value6 = value6;
  54. params.value7 = value7;
  55. params.type = type;
  56. dd.showModal();
  57. //发送ajax请求
  58. sendPost("patient/health_index/add", params, "json", "post", addHealthIndexFailed, successFunction);
  59. }
  60. /**
  61. * 健康指标添加失败处理方法
  62. */
  63. function addHealthIndexFailed(res) {
  64. dd.close();
  65. if (res && res.msg) {
  66. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  67. } else {
  68. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'保存失败'}).show();
  69. }
  70. }
  71. /**
  72. * 血压添加成功处理方法
  73. */
  74. function addBloodPressureSuccess(res) {
  75. if (res.status == 200) {
  76. dd.close();
  77. window.history.back();
  78. } else {
  79. //非200则为失败
  80. addHealthIndexFailed(res);
  81. }
  82. }
  83. /**
  84. * 血糖添加成功处理方法
  85. */
  86. function addBloodSugarSuccess(res) {
  87. if (res.status == 200) {
  88. //添加成功
  89. var record_date = document.getElementById("date").value;
  90. var type_str = document.getElementById("type").value;
  91. var val = document.getElementById("val").value;
  92. var type;
  93. switch (type_str) {
  94. case "空腹血糖":
  95. type = ".bb";
  96. break;
  97. case "早餐后血糖":
  98. type = ".ba";
  99. break;
  100. case "午餐前血糖":
  101. type = ".lb";
  102. break;
  103. case "午餐后血糖":
  104. type = ".la";
  105. break;
  106. case "晚餐前血糖":
  107. type = ".db";
  108. break;
  109. case "晚餐后血糖":
  110. type = ".da";
  111. break;
  112. case "睡前血糖":
  113. type = ".sb";
  114. break;
  115. }
  116. window.history.back();
  117. dd.close();
  118. } else {
  119. //非200则为失败
  120. addHealthIndexFailed(res);
  121. }
  122. }
  123. /**
  124. * 腰围添加成功处理方法
  125. */
  126. function addWaistlineSuccess(res) {
  127. if (res.status == 200) {
  128. dd.close();
  129. window.history.back();
  130. } else {
  131. //非200则为失败
  132. addHealthIndexFailed(res);
  133. }
  134. }
  135. /**
  136. * 体重添加成功处理方法
  137. */
  138. function addWeightSuccess(res) {
  139. if (res.status == 200) {
  140. dd.close();
  141. window.history.back();
  142. } else {
  143. //非200则为失败
  144. addHealthIndexFailed(res);
  145. }
  146. }
  147. /////////////////////////////////////////////////////////////////////////////////健康指标图表数据查询///////////////////////////////////////////////////////////////////////////
  148. /**
  149. * 查询健康指标图表
  150. * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
  151. * @param {Object} begin 记录开始时间
  152. * @param {Object} end 记录结束时间
  153. */
  154. function queryChatByType(type, begin, end, successFunction) {
  155. //拼请求内容
  156. var params = {};
  157. params.type = type;
  158. params.begin = begin+" 00:00:00";
  159. params.end = end+" 23:59:59";
  160. d.show();
  161. //发送ajax请求
  162. sendPost("patient/health_index/chart", params, "json", "post", queryChartFailed, successFunction);
  163. }
  164. /**
  165. * 健康指标图表查询失败处理方法
  166. */
  167. function queryChartFailed(res) {
  168. d.close();
  169. if (res && res.msg) {
  170. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  171. } else {
  172. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败'}).show();
  173. }
  174. }
  175. /////////////////////////////////////////////////////////////////////////////////健康指标历史记录查询///////////////////////////////////////////////////////////////////////////
  176. /**
  177. * 健康指标历史记录查询
  178. * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
  179. * @param {Object} page 当前分页
  180. * @param {Object} pagesize 分页大小
  181. */
  182. function queryListByType(type, sortDate, pagesize, successFunction) {
  183. //拼请求内容
  184. var params = {};
  185. params.type = type;
  186. params.sortDate = sortDate;
  187. params.pagesize = pagesize;
  188. d.show();
  189. //发送ajax请求
  190. sendPost("patient/health_index/list", params, "json", "post", queryListFailed, successFunction);
  191. }
  192. /**
  193. * 健康指标历史记录查询失败处理方法
  194. */
  195. function queryListFailed(res) {
  196. d.close();
  197. if (res && res.msg) {
  198. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  199. } else {
  200. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败'}).show();
  201. }
  202. }
  203. /**
  204. * 查询健康指标的预警标准
  205. */
  206. function queryWarning() {
  207. //拼请求内容
  208. var params = {};
  209. d.show();
  210. //发送ajax请求
  211. sendPost("patient/health_index/standard", params, "json", "post", queryListFailed, queryWarningSuccesss);
  212. }