health-index.js 7.2 KB

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