| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 | 
							- var dd = dialog({contentType:'load', skin:'bk-popup', content:'保存中...'});
 
- var d = dialog({contentType:'load', skin:'bk-popup'});
 
- var userAgent = JSON.parse(window.localStorage.getItem(agentName));
 
- function getNowDate() {
 
- 	var date = new Date();
 
- 	var year = date.getFullYear();
 
- 	var month = date.getMonth() + 1;
 
- 	var day = date.getDate();
 
- 	var hour = date.getHours();
 
- 	var minute = date.getMinutes();
 
- 	var second = date.getSeconds();
 
- 	return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
 
- }
 
- /**
 
-  * 获取多少天前的日期
 
-  */
 
- function getDateBefore(days) {
 
- 	var now = new Date();
 
- 	var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
 
- 	var year = date.getFullYear();
 
- 	var month = date.getMonth() + 1;
 
- 	var day = date.getDate();
 
- 	var hour = date.getHours();
 
- 	var minute = date.getMinutes();
 
- 	var second = date.getSeconds();
 
- 	return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
 
- }
 
- function editHealthData ( successFun, type, id, operTime, value1, value2, value3, value4) {
 
- 	//拼请求内容
 
- 	var params = {};
 
- 	params.id = id;
 
- 	switch (type) {
 
- 		case 1:
 
- 			params.recordDate = operTime + ':00';
 
- 			params.value1 = value2;
 
- 			params.value2 = value1;
 
- 			break;
 
- 		case 2:
 
- 			params.recordDate = operTime + ':00';
 
- 			params.value1 = value1;
 
- 			params.value2 = value2;
 
- 			break;
 
- 		case 3:
 
- 			params.recordDate = operTime + ' 00:00:00';
 
- 			params.value1 = value1;
 
- 			break;
 
- 		case 4:
 
- 			arams.recordDate = operTime + ' 00:00:00';
 
- 			params.value1 = value1;
 
- 			break;
 
- 	}
 
- 	dd.showModal();
 
- 	//发送ajax请求
 
- 	sendPost("/patient/health_index/modify", params, "json", "post", addHealthIndexFailed, successFun);
 
- }
 
- /**
 
-  * 添加健康指标到服务器
 
-  * intervene	干预标志
 
-  * time	记录时间
 
-  * value1 血糖/收缩压/体重/腰围
 
-  * value2 舒张压
 
-  * point 血糖测量点标识
 
-  * type	健康指标类型(1血糖,2血压,3体重,4腰围)
 
-  */		
 
- function addHealthIndex(intervene, operTime, value1, value2, value3, value4, value5, value6, value7, type, successFunction) {
 
- 	//拼请求内容
 
- 	var params = {};
 
- 	params.intervene = intervene;
 
- 	var data = {};
 
- 	if(type==1){
 
- 		data.gi = value1+"";
 
- 		data.gi_type = value2+"";
 
- //		data.time = operTime+" 00:00:00";
 
- 		data.time = operTime + ':00';
 
- 	}
 
- 	if(type==2){
 
- 		data.sys = value1+"";
 
- 		data.dia = value2+"";
 
- 		data.time = operTime;
 
- 	}
 
- 	if(type==3){
 
- 		data.weight = value1+"";
 
- 		data.height = value2+"";
 
- 		data.time = operTime+":00";   
 
- 	}
 
- 	if(type==4){
 
- 		var data = {};
 
- 		data.waistline = value1+"";  
 
- 		data.time = operTime+ ':00'; 
 
- 	}
 
- 	params.data = JSON.stringify(data);
 
- 	params.type = type+"";
 
- 	params.patient = $('#member').data('code');//被代理人的code
 
- 	dd.showModal();
 
- 	//发送ajax请求
 
- 	sendPost("/patient/health_index/addPatientHealthIndex", params, "json", "post", addHealthIndexFailed, successFunction);
 
- }
 
- /** 
 
-  * 健康指标添加失败处理方法
 
-  */
 
- function addHealthIndexFailed(res) {
 
- 	dd.close();
 
- 	if (res && res.msg) {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
 
- 	} else {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show();
 
- 	}
 
- }
 
- function toIntValue(value){
 
- 		if(parseInt(value) == value){
 
- 			return parseInt(value);
 
- 		}else{
 
- 			return Math.round(value*Math.pow(10, 1))/Math.pow(10, 1);
 
- 		}
 
- }
 
- /**
 
-  * 血压添加成功处理方法
 
-  */
 
- function addBloodPressureSuccess(res) {
 
- 	if (res.status == 200) {
 
- 		dd.close();
 
- 		window.location.href='health-record.html?charType=2&'+$.now();
 
- 	} else {
 
- 		//非200则为失败
 
- 		addHealthIndexFailed(res);
 
- 	}
 
- }
 
- /**
 
-  * 血糖添加成功处理方法
 
-  */
 
- function addBloodSugarSuccess(res) {
 
- 	if (res.status == 200) {
 
- 		//添加成功
 
- 		var record_date = document.getElementById("date").value;
 
- 		var type_str = document.getElementById("type").value;
 
- 		var val = document.getElementById("val").value;
 
- 		var type;
 
- 		switch (type_str) {
 
- 			case "空腹血糖":
 
- 				type = ".bb";
 
- 				break;
 
- 			case "早餐后血糖":
 
- 				type = ".ba";
 
- 				break;
 
- 			case "午餐前血糖":
 
- 				type = ".lb";
 
- 				break;
 
- 			case "午餐后血糖":
 
- 				type = ".la";
 
- 				break;
 
- 			case "晚餐前血糖":
 
- 				type = ".db";
 
- 				break;
 
- 			case "晚餐后血糖":
 
- 				type = ".da";
 
- 				break;
 
- 			case "睡前血糖":
 
- 				type = ".sb";
 
- 				break;
 
- 		}
 
- 		window.location.href='health-record.html?charType=1&'+$.now();
 
- 		dd.close();
 
- 	} else {
 
- 		//非200则为失败
 
- 		addHealthIndexFailed(res);
 
- 	}
 
- }
 
- /**
 
-  * 腰围添加成功处理方法
 
-  */
 
- function addWaistlineSuccess(res) {
 
- 	if (res.status == 200) {
 
- 		dd.close();
 
- 		window.location.href='health-record.html?charType=4&'+$.now();
 
- 	} else {
 
- 		//非200则为失败
 
- 		addHealthIndexFailed(res);
 
- 	}
 
- }
 
- /**
 
-  * 体重添加成功处理方法
 
-  */
 
- function addWeightSuccess(res) {
 
- 	if (res.status == 200) {
 
- 		dd.close();
 
- 		window.location.href='health-record.html?charType=3&'+$.now();
 
- 	} else {
 
- 		//非200则为失败
 
- 		addHealthIndexFailed(res);
 
- 	}
 
- }
 
- /////////////////////////////////////////////////////////////////////////////////健康指标图表数据查询///////////////////////////////////////////////////////////////////////////
 
- /**
 
-  * 查询健康指标图表
 
-  * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
 
-  * @param {Object} begin 记录开始时间
 
-  * @param {Object} end 记录结束时间
 
-  */
 
- function queryChatByType(type, begin, end, successFunction) {
 
- 	//拼请求内容
 
- 	var params = {};
 
- 	params.type = type;
 
- 	params.begin = begin;
 
- 	params.end = end;
 
- 	d.show();
 
- 	//发送ajax请求
 
- 	sendPost("patient/health_index/chart", params, "json", "post", queryChartFailed, successFunction);
 
- }
 
- /**
 
-  * 健康指标图表查询失败处理方法
 
-  */
 
- function queryChartFailed(res) {
 
- 	d.close();
 
- 	if (res && res.msg) {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
 
- 	} else {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
 
- 	}
 
- }
 
- /////////////////////////////////////////////////////////////////////////////////健康指标历史记录查询///////////////////////////////////////////////////////////////////////////
 
- /**
 
-  * 健康指标历史记录查询
 
-  * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
 
-  * @param {Object} page 当前分页
 
-  * @param {Object} pagesize 分页大小
 
-  */
 
- function queryListByType(type, page, pagesize, successFunction,begindate,enddate) {
 
- 	//拼请求内容
 
- 	var params = {};
 
- 	params.type = type; 
 
- 	params.page = page;
 
- 	params.pagesize = pagesize;
 
- 	params.start = begindate+" 00:00:00";
 
- 	params.end = enddate+" 23:59:59";
 
- 	d.show();
 
- 	//发送ajax请求
 
- 	sendPost("patient/health_index/list", params, "json", "post", queryListFailed, successFunction);
 
- }
 
- /**
 
-  * 健康指标历史记录查询失败处理方法
 
-  */
 
- function queryListFailed(res) {
 
- 	d.close();
 
- 	if (res && res.msg) {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
 
- 	} else {
 
- 		dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
 
- 	}
 
- }
 
- /**
 
-  * 查询健康指标的预警标准
 
-  */
 
- function queryWarning() {
 
- 	//拼请求内容
 
- 	var params = {};
 
- 	d.show();
 
- 	//发送ajax请求
 
- 	sendPost("patient/health_index/standard", params, "json", "post", queryListFailed, queryWarningSuccesss);
 
- }
 
 
  |