health-index.js 6.3 KB

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