|
@ -3,28 +3,88 @@
|
|
var request = getRequest(),
|
|
var request = getRequest(),
|
|
patient = request.patiCode || '';
|
|
patient = request.patiCode || '';
|
|
var tabIndex = 0,
|
|
var tabIndex = 0,
|
|
dayIndex = 0;
|
|
|
|
|
|
dayIndex = 0,
|
|
|
|
statusIndex = 1;
|
|
|
|
// 绘制折线图初始定义
|
|
|
|
var ctx = document.getElementById('canvas').getContext("2d");
|
|
|
|
var dataCanvas = {
|
|
|
|
labels : [],
|
|
|
|
datasets : [
|
|
|
|
{
|
|
|
|
fillColor : "rgba(220,220,220,0.5)",
|
|
|
|
strokeColor : "rgba(220,220,220,1)",
|
|
|
|
pointColor : "rgba(220,220,220,1)",
|
|
|
|
pointStrokeColor : "#fff",
|
|
|
|
data : []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fillColor : "rgba(151,187,205,0.5)",
|
|
|
|
strokeColor : "rgba(151,187,205,1)",
|
|
|
|
pointColor : "rgba(151,187,205,1)",
|
|
|
|
pointStrokeColor : "rgba(151,187,205,1)",
|
|
|
|
data : []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
defaults = {
|
|
|
|
scaleStartValue : 0,
|
|
|
|
scaleShowLabels : true,
|
|
|
|
datasetFill : false, // 是否填充数据集
|
|
|
|
animation : true, // 是否执行动画
|
|
|
|
animationSteps : 60, // 动画的时间
|
|
|
|
animationEasing : "easeOutQuart", // 动画的特效
|
|
|
|
onAnimationComplete : null // 动画完成时的执行函数
|
|
|
|
};
|
|
|
|
var myLineChart = null;
|
|
|
|
// new Chart(ctx).Line(dataCanvas, defaults);
|
|
|
|
|
|
$('.tab-record span').click(function() {
|
|
$('.tab-record span').click(function() {
|
|
tabIndex = $(this).index();
|
|
tabIndex = $(this).index();
|
|
dataCanvas.labels = [];
|
|
|
|
dataCanvas.datasets[0].data = [];
|
|
|
|
dataCanvas.datasets[1].data = [];
|
|
|
|
|
|
// 初始化数据
|
|
|
|
if(tabIndex == 1) {
|
|
|
|
statusIndex = 0;
|
|
|
|
$('.status-record').hide();
|
|
|
|
} else {
|
|
|
|
var ele = $('.status-record span').get(0);
|
|
|
|
indexHover(ele);
|
|
|
|
statusIndex = 1;
|
|
|
|
$('.status-record').show();
|
|
|
|
}
|
|
indexHover(this);
|
|
indexHover(this);
|
|
dayIndex = 0;
|
|
dayIndex = 0;
|
|
var ele = $('.day-record span').get(0)
|
|
|
|
|
|
var ele = $('.day-record span').get(0);
|
|
indexHover(ele);
|
|
indexHover(ele);
|
|
// 切换数据
|
|
|
|
getBodyRecord(tabIndex, dayIndex);
|
|
|
|
|
|
canvasDataDefault();
|
|
});
|
|
});
|
|
$('.day-record span').click(function() {
|
|
$('.day-record span').click(function() {
|
|
dayIndex = $(this).index();
|
|
dayIndex = $(this).index();
|
|
|
|
if(tabIndex == 0) {
|
|
|
|
var ele = $('.status-record span').get(0);
|
|
|
|
indexHover(ele);
|
|
|
|
statusIndex = 1;
|
|
|
|
}
|
|
indexHover(this);
|
|
indexHover(this);
|
|
// 切换数据
|
|
|
|
getBodyRecord(tabIndex, dayIndex);
|
|
|
|
|
|
canvasDataDefault();
|
|
|
|
|
|
});
|
|
});
|
|
|
|
$('.status-record span').click(function() {
|
|
|
|
statusIndex = $(this).index() + 1;
|
|
|
|
indexHover(this);
|
|
|
|
canvasDataDefault();
|
|
|
|
|
|
|
|
});
|
|
|
|
// 点击指示特效
|
|
function indexHover(ele) {
|
|
function indexHover(ele) {
|
|
$(ele).siblings().removeClass('f-hover');
|
|
$(ele).siblings().removeClass('f-hover');
|
|
$(ele).addClass('f-hover');
|
|
$(ele).addClass('f-hover');
|
|
|
|
};
|
|
|
|
// 绘图数据格式化
|
|
|
|
function canvasDataDefault() {
|
|
|
|
dataCanvas.labels = [];
|
|
|
|
dataCanvas.datasets[0].data = [];
|
|
|
|
dataCanvas.datasets[1].data = [];
|
|
|
|
// 切换数据
|
|
|
|
getBodyRecord(tabIndex, dayIndex, statusIndex);
|
|
}
|
|
}
|
|
// 时间推算
|
|
// 时间推算
|
|
function getDateFromCurrentDate(fromDate, dayInterval) {
|
|
function getDateFromCurrentDate(fromDate, dayInterval) {
|
|
@ -35,6 +95,19 @@
|
|
var day = curDate.getDate() < 10 ? "0" + curDate.getDate() : curDate.getDate();
|
|
var day = curDate.getDate() < 10 ? "0" + curDate.getDate() : curDate.getDate();
|
|
return year + "-" + month + "-" + day + " 00:00:00";
|
|
return year + "-" + month + "-" + day + " 00:00:00";
|
|
};
|
|
};
|
|
|
|
// 血糖标准
|
|
|
|
function getNormalLevel(index) {
|
|
|
|
return [
|
|
|
|
[],
|
|
|
|
[6.1, 3.9],
|
|
|
|
[7.8, 4.4],
|
|
|
|
[6.1, 3.9],
|
|
|
|
[7.8, 4.4],
|
|
|
|
[6.1, 3.9],
|
|
|
|
[7.8, 4.4],
|
|
|
|
[6.1, 3.9]
|
|
|
|
][index];
|
|
|
|
};
|
|
// 获取最后一条数据
|
|
// 获取最后一条数据
|
|
var dataLast = {patient: patient};
|
|
var dataLast = {patient: patient};
|
|
var lastXT = '',
|
|
var lastXT = '',
|
|
@ -48,50 +121,24 @@
|
|
lastXT = res.data.xt.recordDate;
|
|
lastXT = res.data.xt.recordDate;
|
|
lastXY = res.data.xy.recordDate;
|
|
lastXY = res.data.xy.recordDate;
|
|
// 初始化执行
|
|
// 初始化执行
|
|
getBodyRecord(tabIndex, dayIndex);
|
|
|
|
|
|
getBodyRecord(tabIndex, dayIndex, statusIndex);
|
|
}else{
|
|
}else{
|
|
showWarningMsg(res.msg)
|
|
showWarningMsg(res.msg)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
// 绘制折线图初始定义
|
|
|
|
var ctx = document.getElementById('canvas').getContext("2d");
|
|
|
|
var dataCanvas = {
|
|
|
|
labels : [],
|
|
|
|
datasets : [
|
|
|
|
{
|
|
|
|
fillColor : "rgba(220,220,220,0.5)",
|
|
|
|
strokeColor : "rgba(220,220,220,1)",
|
|
|
|
pointColor : "rgba(220,220,220,1)",
|
|
|
|
pointStrokeColor : "#fff",
|
|
|
|
data : []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fillColor : "rgba(151,187,205,0.5)",
|
|
|
|
strokeColor : "rgba(151,187,205,1)",
|
|
|
|
pointColor : "rgba(151,187,205,1)",
|
|
|
|
pointStrokeColor : "rgba(151,187,205,1)",
|
|
|
|
data : []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
var defaults = {
|
|
|
|
scaleStartValue : 0,
|
|
|
|
scaleShowLabels : true,
|
|
|
|
datasetFill : false, // 是否填充数据集
|
|
|
|
animation : true, // 是否执行动画
|
|
|
|
animationSteps : 60, // 动画的时间
|
|
|
|
animationEasing : "easeOutQuart", // 动画的特效
|
|
|
|
onAnimationComplete : null // 动画完成时的执行函数
|
|
|
|
}
|
|
|
|
var myLineChart = null;
|
|
|
|
// new Chart(ctx).Line(dataCanvas, defaults);
|
|
|
|
|
|
|
|
// 获取数据
|
|
// 获取数据
|
|
function getBodyRecord(tab, day) {
|
|
|
|
|
|
function getBodyRecord(tab, day, statu) {
|
|
if(!lastXT || !lastXY) {
|
|
if(!lastXT || !lastXY) {
|
|
showWarningMsg("该居民无体征记录");
|
|
showWarningMsg("该居民无体征记录");
|
|
return;
|
|
return;
|
|
}
|
|
|
|
|
|
};
|
|
|
|
var xtMax = getNormalLevel(statusIndex)[0],
|
|
|
|
xtMin = getNormalLevel(statusIndex)[1],
|
|
|
|
xyMax = [139, 89],
|
|
|
|
xymin = [90, 60],
|
|
|
|
toNormal = 0,
|
|
|
|
toHigh = 0,
|
|
|
|
toLow = 0;
|
|
$('.danwei').html(tab == 0 ? '单位(mmol/L)' : '单位(mmHg)');
|
|
$('.danwei').html(tab == 0 ? '单位(mmol/L)' : '单位(mmHg)');
|
|
var dayNum = 0;
|
|
var dayNum = 0;
|
|
switch(day) {
|
|
switch(day) {
|
|
@ -106,21 +153,28 @@
|
|
}
|
|
}
|
|
var type = (tab == 0 ? 1 : 2),
|
|
var type = (tab == 0 ? 1 : 2),
|
|
startdate = (tab == 0 ? lastXT : lastXY),
|
|
startdate = (tab == 0 ? lastXT : lastXY),
|
|
enddate = getDateFromCurrentDate(startdate, -dayNum),
|
|
|
|
gi_type = (tab == 0 ? 1 : 0);// 字段不清楚暂时不处理
|
|
|
|
$('.data-record').html(enddate.substr(0, 11) + '至' + startdate.substr(0,11));
|
|
|
|
|
|
enddate = getDateFromCurrentDate(startdate, -dayNum);
|
|
|
|
$('.data-record').html('<' + enddate.substr(0, 10) + '至' + startdate.substr(0,10) + '>');
|
|
var recordData = {
|
|
var recordData = {
|
|
type: type,
|
|
type: type,
|
|
begin: enddate,
|
|
begin: enddate,
|
|
end: startdate,
|
|
end: startdate,
|
|
gi_type: gi_type,
|
|
|
|
|
|
gi_type: statu,
|
|
patient: patient
|
|
patient: patient
|
|
}
|
|
|
|
|
|
};
|
|
// 获取体征记录
|
|
// 获取体征记录
|
|
bodyRecordApis.getBodyRecordData({data: recordData}).then(function(res){
|
|
bodyRecordApis.getBodyRecordData({data: recordData}).then(function(res){
|
|
|
|
if(myLineChart) {// 如果构造过,解析
|
|
|
|
myLineChart.destroy();
|
|
|
|
}
|
|
if(res.status == 200){
|
|
if(res.status == 200){
|
|
var list = res.list,
|
|
var list = res.list,
|
|
|
|
len = 0;
|
|
|
|
if(list) {
|
|
len = list.length;
|
|
len = list.length;
|
|
|
|
} else {
|
|
|
|
showWarningMsg("当前状态下无居民体征记录");return;
|
|
|
|
};
|
|
list.reverse();
|
|
list.reverse();
|
|
for(var i = 0; i < len; i++) {
|
|
for(var i = 0; i < len; i++) {
|
|
if(len == 1) {
|
|
if(len == 1) {
|
|
@ -132,18 +186,33 @@
|
|
}
|
|
}
|
|
if(tabIndex == 1) {
|
|
if(tabIndex == 1) {
|
|
if(len == 1) {
|
|
if(len == 1) {
|
|
dataCanvas.datasets[1].data = [null, list[i].value2];
|
|
|
|
|
|
dataCanvas.datasets[1].data = [null, list[i].value2];
|
|
} else {
|
|
} else {
|
|
dataCanvas.datasets[1].data[i] = list[i].value2;
|
|
dataCanvas.datasets[1].data[i] = list[i].value2;
|
|
}
|
|
}
|
|
|
|
// 血压判断
|
|
|
|
if(list[i].value1 > xyMax[0] || list[i].value2 > xyMax[1]) {
|
|
|
|
++toHigh;
|
|
|
|
} else if(list[i].value1 < xyMin[0] || list[i].value2 < xyMin[1]) {
|
|
|
|
++toLow;
|
|
|
|
} else {
|
|
|
|
++toNormal;
|
|
|
|
}
|
|
} else {
|
|
} else {
|
|
dataCanvas.datasets[1].data[i] = []
|
|
|
|
|
|
// 血糖判断
|
|
|
|
if(list[i].value1 > xtMax) {
|
|
|
|
++toHigh;
|
|
|
|
} else if(list[i].value1 < xtMin) {
|
|
|
|
++toLow;
|
|
|
|
} else {
|
|
|
|
++toNormal;
|
|
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$('.is-ok').html("正常:" + toNormal + "次");
|
|
|
|
$('.is-height').html("偏高:" + toHigh + "次");
|
|
|
|
$('.is-low').html("偏低:" + toLow + "次");
|
|
// 绘制图
|
|
// 绘制图
|
|
if(myLineChart) {// 如果构造过,解析
|
|
|
|
myLineChart.destroy();
|
|
|
|
}
|
|
|
|
myLineChart = new Chart(ctx).Line(dataCanvas, defaults);
|
|
myLineChart = new Chart(ctx).Line(dataCanvas, defaults);
|
|
}else{
|
|
}else{
|
|
showWarningMsg(res.msg)
|
|
showWarningMsg(res.msg)
|