//心电图的历史数据
var hisArray = [];
var hisFlag = false;
var dataList = null;
layui.use(['layer', 'form', 'laydate', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var laydate = layui.laydate;
    var admin = layui.admin;
    var layer = layui.layer;

    // 让当前iframe弹层高度适应
    //admin.iframeAuto();

    //军人信息
    var ajax = new $ax(Feng.ctxPath + "/mmhc/madetail/" + Feng.getUrlParam("id"));
    var result = ajax.start();
    result.birthday = result.birthday.substring(0, 10);
    console.log(result.tsTime);
    $("#tsTime").val(result.tsTime);
    $("#xyTime").val(result.xyTime);
    form.val('militaryForm1', result);
    if (1 == result.isSurgery) {
        $('#is_surgery_code1').attr('checked', true);
        $("#is_surgery_code2").removeAttr('checked');
    } else if (2 == result.isSurgery) {
        $("#is_surgery_code1").removeAttr('checked');
        $('#is_surgery_code2').attr('checked', true);
    }
    var ajaxIndex = new $ax(Feng.ctxPath + "/index/indexDetail/" + Feng.getUrlParam("id"));
    var resultIndex = ajaxIndex.start();
    form.val('v_form', resultIndex.data);
    form.val('indexForm', resultIndex.data);
    form.render();

    // 渲染时间选择框
    laydate.render({
        elem: '#birthday',
        trigger: 'click', //添加这一行来处理
        done: function (value, date, endDate) {
            $self.form.birthday = value;
        }
    });

    var ajax1 = new $ax(Feng.ctxPath + "/project/list/");
    dataList = ajax1.start().data;


    var websocket = null;
//判断当前浏览器是否支持WebSocket
    if ('WebSocket' in window) {
        websocket = new WebSocket("ws://127.0.0.1:9002?userId=" + result.id);
        //websocket = new WebSocket("wss://zcpg.xazhcx.com/wss/?userId="+result.id);
        //websocket默认是传输字符串的，需要改为arraybuffer二进制传输类型
        //webOrTcpsocket.binaryType = "arraybuffer";
    } else {
        alert('当前浏览器 Not support websocket')
    }

//连接发生错误的回调方法
    websocket.onerror = function () {
        // setMessageInnerHTML("WebSocket连接发生错误");
    };

//连接成功建立的回调方法
    websocket.onopen = function () {
        setMessageInnerHTML("连接成功");
    };

    Highcharts.setOptions({
        global: {
            useUTC: false
        }
    });

    var staticData = [];
    // var _this = this;
    var timer1, timer2;
    // clearInterval(timer1)

    //接收到消息的回调方法
    websocket.onmessage = function (event) {
        // setMessageInnerHTML(event.data);
        var data = JSON.parse(event.data);
        if (data.length === 10) {
            for (var i = 0; i < data.length; i++) {
                staticData.push(data[i]);
                if (hisFlag && hisArray.length <= 600){
                    hisArray.push(data[i]);
                }else {
                    hisFlag = false;
                }
            }
        } else {
            var tw = data[4];//体温
            var hx = data[3];//呼吸
            var xl = data[0];//心率值
            var sy = data[7];
            var zy = data[8];
            var av = data[9];
            var xybh = data[1];
            var nl = $("#indexNl").val();
            var nly = 60;
            if (nl != null) {
                nly = nl;
            }
            $("#tw").html((tw + 280) / 10);
            $("#indexHx").val(hx);
            $("#xl").html(xl);
            $("#avgmy").html(Math.round((sy - zy) / 3 + zy));
            $("#ngzy").html(Math.abs(Math.round((sy - zy) / 3 + zy) - nly));
            $("#dmfy").val(xybh);
        }

        //将接收到的二进制数据转为字符串
        //var unit8Arr = new Uint8Array(event.data) ;
        //setMessageInnerHTML(byteToString(unit8Arr));
        //

    };

    function setMessageInnerHTML(datas) {
        console.log(datas);

    }

    var myChart = echarts.init(document.getElementById('container'));

    function randomData(val) {
        now = new Date(+now + oneDay);
        value = val ? val : 128;
        return {
            name: now.toString(),
            value: [
                [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
                // time,
                // Math.round(value)
                value
            ]
        }
    }

    var data = [];
    var now = +new Date(1997, 9, 3);
    var oneDay = 24 * 3600 * 1000;
    var value = Math.random() * 1000;
    for (var i = 0; i < 1000; i++) {
        data.push(randomData());
    }

    option = {
        title: {
            text: '心电图数据'
        },
        tooltip: {
            trigger: 'axis',
            formatter: function (params) {
                params = params[0];
                var date = new Date(params.name);
                return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
            },
            axisPointer: {
                animation: false
            }
        },
        xAxis: {
            type: 'time',
            splitLine: {
                show: false
            }
        },
        yAxis: {
            type: 'value',
            boundaryGap: [0, '100%'],
            splitLine: {
                show: false
            }
        },
        series: [{
            name: '模拟数据',
            type: 'line',
            showSymbol: false,
            hoverAnimation: false,
            data: data
        }]
    };

    setInterval(function () {
        //console.log(staticData);
        if(staticData.length > 0){
            for(var i=0;i<staticData.length;i++){
                data.shift();
                data.push(randomData(staticData[i]));
                staticData.shift()
            }
        }


    //
    //     for (var i = 0; i < 8; i++) {
    //         data.shift();
    //         data.push(randomData());
    //     }
    //
        myChart.setOption({
            series: [{
                data: data
            }]
        });
    }, 1000);

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);

//连接关闭的回调方法
    websocket.onclose = function () {
        //setMessageInnerHTML("WebSocket连接关闭");
    };

//监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
    window.onbeforeunload = function () {
        closeWebSocket();
    };


    function activeLastPointToolip(chart) {
        var points = chart.series[0].points;
        chart.tooltip.refresh(points[points.length - 1]);
    }

//关闭WebSocket连接
    function closeWebSocket() {
        websocket.close();
    }

//发送消息
    function send() {
        var message = document.getElementById('text').value;

        //将字符串转换为byte数组
        var bytesArr = stringToByte(message);
        var bytes = new Uint8Array(bytesArr.length);
        for (var i = 0; i < bytes.length; i++) {
            bytes[i] = bytesArr[i];
        }
        console.log(bytes)
        websocket.send(bytes);
    }


//将字符串转为 Array byte数组
    function stringToByte(str) {
        var bytes = new Array();
        var len, c;
        len = str.length;
        for (var i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if (c >= 0x010000 && c <= 0x10FFFF) {
                bytes.push(((c >> 18) & 0x07) | 0xF0);
                bytes.push(((c >> 12) & 0x3F) | 0x80);
                bytes.push(((c >> 6) & 0x3F) | 0x80);
                bytes.push((c & 0x3F) | 0x80);
            } else if (c >= 0x000800 && c <= 0x00FFFF) {
                bytes.push(((c >> 12) & 0x0F) | 0xE0);
                bytes.push(((c >> 6) & 0x3F) | 0x80);
                bytes.push((c & 0x3F) | 0x80);
            } else if (c >= 0x000080 && c <= 0x0007FF) {
                bytes.push(((c >> 6) & 0x1F) | 0xC0);
                bytes.push((c & 0x3F) | 0x80);
            } else {
                bytes.push(c & 0xFF);
            }
        }
        return bytes;


    }

//byte数组转字符串
    function byteToString(arr) {
        if (typeof arr === 'string') {
            return arr;
        }
        var str = '',
            _arr = arr;
        for (var i = 0; i < _arr.length; i++) {
            var one = _arr[i].toString(2),
                v = one.match(/^1+?(?=0)/);
            if (v && one.length == 8) {
                var bytesLength = v[0].length;
                var store = _arr[i].toString(2).slice(7 - bytesLength);
                for (var st = 1; st < bytesLength; st++) {
                    store += _arr[st + i].toString(2).slice(2);
                }
                str += String.fromCharCode(parseInt(store, 2));
                i += bytesLength - 1;
            } else {
                str += String.fromCharCode(_arr[i]);
            }
        }
        return str;
    }

});

function butAdd() {
    var indexMovement = $("#indexMovement").val();
    var tongReflect = $("#tongReflect").val();
    var tongChange = $("#tongChange").val();
    var indexXz = $("#indexXz").val();
    var indexNzx = $("#indexNzx").val();
    var indexZwm = $("#indexZwm").val();
    var indexHckd = $("#indexHckd").val();
    var indexXt = $("#indexXt").val();
    var xl = $("#xl").html();
    var tw = $("#tw").html();
    var hx = $("#indexHx").val();
    var nl = $("#indexNl").val();
    var avgmy = $("#avgmy").html();
    var ngzy = $("#ngzy").html();
    var dmfy = $("#dmfy").val();
    var crl = $("#v0").val();

    //根据出生日期计算出年龄
    var birthday = $("#birthday").val();
    var birthday_time=birthday.split("-");
    var birthYear = birthday_time[0];
    var dTime= new Date();
    var nowYear=dTime.getFullYear();
    var ag=nowYear-birthYear;

    //获取是否手术
    var surgery = $("input[name='isSurgery']:checked").val();

    //既往慢性病史
    var medicalHistory = $("#medicalHistory").val();

    var pf = 0;
    //console.log(dataList);
    //var list = JSON.parse(dataList);
    var score = dataList[0];//分值
    var age = dataList[1];//年龄
    var bs = dataList[2];//既往慢性病史
    var ss = dataList[3];//是否手术
    var yd = dataList[4];//运动
    var tkfs = dataList[5];//瞳孔反射
    var tkbh = dataList[6];//瞳孔变化
    var xztj = dataList[7];//血肿体积
    var nzx = dataList[8];//脑中线偏移距离（cm）
    var zwm = dataList[9];//蛛网膜下腔出血
    var hcpj = dataList[10];//环池平均宽度（mm）
    var xt = dataList[11];//血糖（mmol/l）
    var cr = dataList[12];//出入（mmol/l）
    var lny = dataList[13];//颅内压（mmHg）
    var pjmy = dataList[14];//平均动脉压（mmHg）
    var ngy = dataList[15];//脑低灌注压（mmHg）
    var tww = dataList[16];//体温（℃）
    var xll = dataList[17];//心率（bpm）
    var xybh = dataList[18];//血氧饱和度
    var hxx = dataList[19];//呼吸

    var su = '';
    if (surgery === 1){
        su = '无'
    }else {
        su = '有'
    }
    if (su === ss.value1) {
        pf += 1;
    } else if (su === ss.value3) {
        pf += 3;
    }

    if (medicalHistory !== ''){
        pf += 3;
    }else {
        pf += 1;
    }

    if (ag !== '') {
        for (var ageObj in age){
            if (age[ageObj] !== ''){
                if (ageObj === 'value1'){
                    if (eval('ag' + age[ageObj])){
                        pf += Number(score[ageObj]);
                        break;
                    }
                }
                if (ageObj === 'value2'){
                    if (eval('ag' + age[ageObj])){
                        pf += Number(score[ageObj]);
                        break;
                    }
                }

                if (ageObj === 'value4'){
                    if (eval('ag' + age[ageObj])){
                        pf += Number(score[ageObj]);
                        break;
                    }
                }
                if (ageObj === 'value6'){
                    if (eval('ag' + age[ageObj])){
                        pf += Number(score[ageObj]);
                        break;
                    }
                }
            }


        }
    }

    if (indexMovement === yd.value1) {
        pf += Number(score.value1);
    } else if (indexMovement === yd.value2) {
        pf += Number(score.value2);
    } else if (indexMovement === yd.value3) {
        pf += Number(score.value3);
    } else if (indexMovement === yd.value4) {
        pf += Number(score.value4);
    } else if (indexMovement === yd.value5) {
        pf += Number(score.value5);
    }
    if (tongReflect === tkfs.value1) {
        pf += Number(score.value1);
    } else if (tongReflect === tkfs.value2) {
        pf += Number(score.value2);
    } else if (tongReflect === tkfs.value3) {
        pf += Number(score.value3);
    }

    if (tongChange === tkbh.value1) {
        pf += Number(score.value1);
    } else if (tongChange === tkbh.value3) {
        pf += Number(score.value3);
    } else if (tongChange === tkbh.value5) {
        pf += Number(score.value5);
    }


    if (indexXz !== '') {
        for (var xztjObj in xztj){
            if (xztj[xztjObj] !== ''){
                if (xztjObj === 'value5'){
                    if (eval('indexXz' + xztj[xztjObj])){
                        pf += Number(score[xztjObj]);
                        break;
                    }
                }
                if (xztjObj === 'value4'){
                    if (eval('indexXz' + xztj[xztjObj])){
                        pf += Number(score[xztjObj]);
                        break;
                    }
                }
                if (xztjObj === 'value3'){
                    if (eval('indexXz' + xztj[xztjObj])){
                        pf += Number(score[xztjObj]);
                        break;
                    }
                }
                if (xztjObj === 'value2'){
                    if (eval('indexXz' + xztj[xztjObj])){
                        pf += Number(score[xztjObj]);
                        break;
                    }
                }
                if (xztjObj === 'value1'){
                    if (eval('indexXz' + xztj[xztjObj])){
                        pf += Number(score[xztjObj]);
                        break;
                    }
                }
            }


        }
    }

    if (indexNzx !== '') {
        for (var nzxObj in nzx){
            if (nzx[nzxObj] !== ''){
                if (nzxObj === 'value5'){
                    if (eval('indexNzx' + nzx[nzxObj])){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (nzxObj === 'value4'){
                    if (eval('indexNzx' + nzx[nzxObj])){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (nzxObj === 'value3'){
                    if (eval('indexNzx' + nzx[nzxObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (nzxObj === 'value2'){
                    if (eval('indexNzx' + nzx[nzxObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (nzxObj === 'value1'){
                    if (eval('indexNzx' + nzx[nzxObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }


        }
    }


    if (indexZwm === zwm.value1) {
        pf += Number(score.value1);
    } else if (indexZwm === zwm.value2) {
        pf += Number(score.value2);
    }

    if (indexHckd !== '') {
        for (var hcpjObj in hcpj){
            if (hcpj[hcpjObj] !== ''){
                if (hcpjObj === 'value3'){
                    if (eval('indexHckd' + hcpj[hcpjObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (hcpjObj === 'value2'){
                    if (eval('indexHckd' + hcpj[hcpjObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (hcpjObj === 'value1'){
                    if (eval('indexHckd' + hcpj[hcpjObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }



        }
    }

    if (indexXt !== '') {
        for (var xtObj in xt){
            var oValue = null;
            var rValue = null;
            if (xt[xtObj].indexOf('or') > 0){
                var o = xt[xtObj].indexOf('o');
                var r = xt[xtObj].indexOf('r');
                oValue = xt[xtObj].substring(0, o);
                rValue = xt[xtObj].substring(r+1, xt[xtObj].length);
            }
            if (xt[xtObj].indexOf('and') > 0){
                var a = xt[xtObj].indexOf('a');
                var d = xt[xtObj].indexOf('d');
                oValue = xt[xtObj].substring(0, a);
                rValue = xt[xtObj].substring(d+1, xt[xtObj].length);
            }
            if (xt[xtObj] !== ''){
                if (xtObj === 'value6'){
                    if (eval('indexXt' + xt[xtObj])){
                        pf += Number(score.value6);
                        break;
                    }
                }
                if (xtObj === 'value5'){
                    if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (xtObj === 'value4'){
                    if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (xtObj === 'value3'){
                    if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (xtObj === 'value2'){
                    if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (xtObj === 'value1'){
                    if (eval('indexXt' + oValue) && eval('indexXt' + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }


        }
    }


    if (nl !== '') {
        for (var lnyObj in lny){
            if (lny[lnyObj] !== ''){
                if (lnyObj === 'value4'){
                    if (eval('nl' + lny[lnyObj])){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (lnyObj === 'value3'){
                    if (eval('nl' + lny[lnyObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (lnyObj === 'value2'){
                    if (eval('nl' + lny[lnyObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (lnyObj === 'value1'){
                    if (eval('nl' + lny[lnyObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }


    if (avgmy !== '') {
        for (var pjmyObj in pjmy){
            var oValue = null;
            var rValue = null;
            if (pjmy[pjmyObj].indexOf('or') > 0){
                var o = pjmy[pjmyObj].indexOf('o');
                var r = pjmy[pjmyObj].indexOf('r');
                oValue = pjmy[pjmyObj].substring(0, o);
                rValue = pjmy[pjmyObj].substring(r+1, pjmy[pjmyObj].length);

                if (pjmyObj === 'value4'){
                    if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (pjmyObj === 'value3'){
                    if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (pjmyObj === 'value2'){
                    if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (pjmyObj === 'value1'){
                    if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }


        }
    }


    if (ngzy !== '') {
        for (var ngyObj in ngy){
            if (ngy[ngyObj] !== ''){
                if (ngyObj === 'value4'){
                    if (eval('ngzy' + ngy[ngyObj])){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (ngyObj === 'value3'){
                    if (eval('ngzy' + ngy[ngyObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (ngyObj === 'value2'){
                    if (eval('ngzy' + ngy[ngyObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (ngyObj === 'value1'){
                    if (eval('ngzy' + ngy[ngyObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }


    if (dmfy !== '') {
        for (var xybhObj in xybh){
            var oValue = null;
            var rValue = null;
            if (xybh[xybhObj].indexOf('or') > 0){
                var o = xybh[xybhObj].indexOf('o');
                var r = xybh[xybhObj].indexOf('r');
                oValue = xybh[xybhObj].substring(0, o);
                rValue = xybh[xybhObj].substring(r+1, xybh[xybhObj].length);

                if (xybhObj === 'value4'){
                    if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (xybhObj === 'value3'){
                    if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (xybhObj === 'value2'){
                    if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (xybhObj === 'value1'){
                    if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }

    if (xl !== '') {
        for (var xllObj in xll){
            var oValue = null;
            var rValue = null;
            if (xll[xllObj].indexOf('or') > 0){
                var o = xll[xllObj].indexOf('o');
                var r = xll[xllObj].indexOf('r');
                oValue = xll[xllObj].substring(0, o);
                rValue = xll[xllObj].substring(r+1, xll[xllObj].length);

                if (xllObj === 'value5'){
                    if (eval('xl' + xll[xllObj])){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (xllObj === 'value4'){
                    if (eval('xl' + xll[xllObj])){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (xllObj === 'value3'){
                    if (eval('xl' + oValue) || eval('xl' + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (xllObj === 'value2'){
                    if (eval('xl' + oValue) || eval('xl' + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (xllObj === 'value1'){
                    if (eval('xl' + oValue) || eval('xl' + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }

    if (tw !== '') {
        for (var twwObj in tww){
            if (tww[twwObj] !== ''){
                if (twwObj === 'value3'){
                    if (eval('tw' + tww[twwObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (twwObj === 'value2'){
                    if (eval('tw' + tww[twwObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (twwObj === 'value1'){
                    if (eval('tw' + tww[twwObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }


    if (hx !== '') {
        for (var hxxObj in hxx){
            if (hxx[hxxObj] !== ''){
                if (hxxObj === 'value3'){
                    if (eval('hx' + hxx[hxxObj])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (hxxObj === 'value2'){
                    if (eval('hx' + hxx[hxxObj])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (hxxObj === 'value1'){
                    if (eval('hx' + hxx[hxxObj])){
                        pf += Number(score.value1);
                        break;
                    }
                }
            }

        }
    }

    if (crl !== ''){
        for (var c in cr){
            var oValue = null;
            var rValue = null;
            if (cr[c].indexOf('and') > 0){
                var a = cr[c].indexOf('a');
                var d = cr[c].indexOf('d');
                oValue = cr[c].substring(0, a);
                rValue = cr[c].substring(d+1, cr[c].length);
                if (c === 'value1'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
                if (c === 'value2'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (c === 'value3'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (c === 'value4'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (c === 'value5'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (c === 'value6'){
                    if (eval('crl' + oValue) && eval('crl' + rValue)){
                        pf += Number(score.value6);
                        break;
                    }
                }
            }
        }
    }



    var v1 = $('#v1').val();
    var v1_score = dataList[20];
    if (v1 !== ''){
        for (var v1_value in v1_score){
            if (v1_score[v1_value] !== ''){
                if (v1_value === 'value1'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value1);
                        break;
                    }
                }
                if (v1_value === 'value2'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (v1_value === 'value3'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (v1_value === 'value4'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (v1_value === 'value5'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (v1_value === 'value6'){
                    if (eval('v1' + v1_score[v1_value])){
                        pf += Number(score.value6);
                        break;
                    }
                }
            }

        }
    }

    var t = $('#v_form').serializeArray();

    for (var i=21; i < dataList.size; i++){
        var object = dataList[i];
        var index = t[i];
        for (var ob in object){
            var oValue = null;
            var rValue = null;

            if (object[ob].indexOf('and') > 0){
                var a = object[ob].indexOf('a');
                var d = object[ob].indexOf('d');
                oValue = object[ob].substring(0, a);
                rValue = object[ob].substring(d+1, object[ob].length);
                if (xtObj === 'value1'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value1);
                        break;
                    }
                }
                if (xtObj === 'value2'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value2);
                        break;
                    }
                }
                if (xtObj === 'value3'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value3);
                        break;
                    }
                }
                if (xtObj === 'value4'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value4);
                        break;
                    }
                }
                if (xtObj === 'value5'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value5);
                        break;
                    }
                }
                if (xtObj === 'value6'){
                    if (eval(index.value + oValue) && eval(index.value + rValue)){
                        pf += Number(score.value6);
                        break;
                    }
                }
            }else {
                if (object[ob] !== ''){
                    if (xtObj === 'value1'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                    if (xtObj === 'value2'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                    if (xtObj === 'value3'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                    if (xtObj === 'value4'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                    if (xtObj === 'value5'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                    if (xtObj === 'value6'){
                        if (eval(index.value + object[ob])){
                            pf += Number(score[xtObj]);
                            break;
                        }
                    }
                }

            }


        }
    }

    $("#pf").html(pf);
    var sumValue = $("#pf").html();
    //console.log(JSON.stringify(t));
    $.ajax({
        url: Feng.ctxPath + '/index/add?hisId=' + Feng.getUrlParam("id"),
        type: 'post',
        dataType: 'json',
        data: {
            indexMovement: indexMovement,
            tongReflect: tongReflect,
            tongChange: tongChange,
            indexXz: indexXz,
            indexNzx: indexNzx,
            indexZwm: indexZwm,
            indexHckd: indexHckd,
            indexXt: indexXt,
            tw: tw,
            indexHx: hx,
            indexNl: nl,
            avgmy: avgmy,
            ngzy: ngzy,
            indexDmy: dmfy,
            sumValue : pf,
            age : ag,
            surgery : surgery,
            medicalHistory : medicalHistory,
            v1 : v1,
            v0 : crl,
            sData : JSON.stringify(t)
        },
        success: function (result) {
            Feng.success("保存成功");
        }
    });
}

//定时器执行
var timer;

function setTime(flag) {
    var tsTime = $("#tsTime").val() === '' ? 2 : $("#tsTime").val();
    //alert(Number(tsTime));
    var indexMovement = $("#indexMovement").val();
    var tongReflect = $("#tongReflect").val();
    var tongChange = $("#tongChange").val();
    var indexXz = $("#indexXz").val();
    var indexNzx = $("#indexNzx").val();
    var indexZwm = $("#indexZwm").val();
    var indexHckd = $("#indexHckd").val();
    var indexXt = $("#indexXt").val();
    var xl = $("#xl").html();
    var tw = $("#tw").html();
    var hx = $("#indexHx").val();
    var nl = $("#indexNl").val();
    var avgmy = $("#avgmy").html();
    var ngzy = $("#ngzy").html();
    var dmfy = $("#dmfy").val();

    var crl = $("#v0").val();

    //根据出生日期计算出年龄
    var birthday = $("#birthday").val();
    var birthday_time=birthday.split("-");
    var birthYear = birthday_time[0];
    var dTime= new Date();
    var nowYear=dTime.getFullYear();
    var ag=nowYear-birthYear;

    //获取是否手术
    var surgery = $("input[name='isSurgery']:checked").val();

    //既往慢性病史
    var medicalHistory = $("#medicalHistory").val();

    var pf = 0;
    //console.log(dataList);
    //var list = JSON.parse(dataList);
    var t = $('#v_form').serializeArray();
    if (dataList !== null){
        var score = dataList[0];//分值
        var age = dataList[1];//年龄
        var bs = dataList[2];//既往慢性病史
        var ss = dataList[3];//是否手术
        var yd = dataList[4];//运动
        var tkfs = dataList[5];//瞳孔反射
        var tkbh = dataList[6];//瞳孔变化
        var xztj = dataList[7];//血肿体积
        var nzx = dataList[8];//脑中线偏移距离（cm）
        var zwm = dataList[9];//蛛网膜下腔出血
        var hcpj = dataList[10];//环池平均宽度（mm）
        var xt = dataList[11];//血糖（mmol/l）
        var cr = dataList[12];//出入（mmol/l）
        var lny = dataList[13];//颅内压（mmHg）
        var pjmy = dataList[14];//平均动脉压（mmHg）
        var ngy = dataList[15];//脑低灌注压（mmHg）
        var tww = dataList[16];//体温（℃）
        var xll = dataList[17];//心率（bpm）
        var xybh = dataList[18];//血氧饱和度
        var hxx = dataList[19];//呼吸

        var su = '';
        if (surgery === 1){
            su = '无'
        }else {
            su = '有'
        }
        if (su === ss.value1) {
            pf += 1;
        } else if (su === ss.value3) {
            pf += 3;
        }

        if (medicalHistory !== ''){
            pf += 3;
        }else {
            pf += 1;
        }

        if (ag !== '') {
            for (var ageObj in age){
                if (age[ageObj] !== ''){
                    if (ageObj === 'value1'){
                        if (eval('ag' + age[ageObj])){
                            pf += Number(score[ageObj]);
                            break;
                        }
                    }
                    if (ageObj === 'value2'){
                        if (eval('ag' + age[ageObj])){
                            pf += Number(score[ageObj]);
                            break;
                        }
                    }

                    if (ageObj === 'value4'){
                        if (eval('ag' + age[ageObj])){
                            pf += Number(score[ageObj]);
                            break;
                        }
                    }
                    if (ageObj === 'value6'){
                        if (eval('ag' + age[ageObj])){
                            pf += Number(score[ageObj]);
                            break;
                        }
                    }
                }


            }
        }

        if (indexMovement === yd.value1) {
            pf += Number(score.value1);
        } else if (indexMovement === yd.value2) {
            pf += Number(score.value2);
        } else if (indexMovement === yd.value3) {
            pf += Number(score.value3);
        } else if (indexMovement === yd.value4) {
            pf += Number(score.value4);
        } else if (indexMovement === yd.value5) {
            pf += Number(score.value5);
        }
        if (tongReflect === tkfs.value1) {
            pf += Number(score.value1);
        } else if (tongReflect === tkfs.value2) {
            pf += Number(score.value2);
        } else if (tongReflect === tkfs.value3) {
            pf += Number(score.value3);
        }

        if (tongChange === tkbh.value1) {
            pf += Number(score.value1);
        } else if (tongChange === tkbh.value3) {
            pf += Number(score.value3);
        } else if (tongChange === tkbh.value5) {
            pf += Number(score.value5);
        }


        if (indexXz !== '') {
            for (var xztjObj in xztj){
                if (xztj[xztjObj] !== ''){
                    if (xztjObj === 'value5'){
                        if (eval('indexXz' + xztj[xztjObj])){
                            pf += Number(score[xztjObj]);
                            break;
                        }
                    }
                    if (xztjObj === 'value4'){
                        if (eval('indexXz' + xztj[xztjObj])){
                            pf += Number(score[xztjObj]);
                            break;
                        }
                    }
                    if (xztjObj === 'value3'){
                        if (eval('indexXz' + xztj[xztjObj])){
                            pf += Number(score[xztjObj]);
                            break;
                        }
                    }
                    if (xztjObj === 'value2'){
                        if (eval('indexXz' + xztj[xztjObj])){
                            pf += Number(score[xztjObj]);
                            break;
                        }
                    }
                    if (xztjObj === 'value1'){
                        if (eval('indexXz' + xztj[xztjObj])){
                            pf += Number(score[xztjObj]);
                            break;
                        }
                    }
                }


            }
        }

        if (indexNzx !== '') {
            for (var nzxObj in nzx){
                if (nzx[nzxObj] !== ''){
                    if (nzxObj === 'value5'){
                        if (eval('indexNzx' + nzx[nzxObj])){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (nzxObj === 'value4'){
                        if (eval('indexNzx' + nzx[nzxObj])){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (nzxObj === 'value3'){
                        if (eval('indexNzx' + nzx[nzxObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (nzxObj === 'value2'){
                        if (eval('indexNzx' + nzx[nzxObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (nzxObj === 'value1'){
                        if (eval('indexNzx' + nzx[nzxObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }


            }
        }


        if (indexZwm === zwm.value1) {
            pf += Number(score.value1);
        } else if (indexZwm === zwm.value2) {
            pf += Number(score.value2);
        }

        if (indexHckd !== '') {
            for (var hcpjObj in hcpj){
                if (hcpj[hcpjObj] !== ''){
                    if (hcpjObj === 'value3'){
                        if (eval('indexHckd' + hcpj[hcpjObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (hcpjObj === 'value2'){
                        if (eval('indexHckd' + hcpj[hcpjObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (hcpjObj === 'value1'){
                        if (eval('indexHckd' + hcpj[hcpjObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }



            }
        }

        if (indexXt !== '') {
            for (var xtObj in xt){
                var oValue = null;
                var rValue = null;
                if (xt[xtObj].indexOf('or') > 0){
                    var o = xt[xtObj].indexOf('o');
                    var r = xt[xtObj].indexOf('r');
                    oValue = xt[xtObj].substring(0, o);
                    rValue = xt[xtObj].substring(r+1, xt[xtObj].length);
                }
                if (xt[xtObj].indexOf('and') > 0){
                    var a = xt[xtObj].indexOf('a');
                    var d = xt[xtObj].indexOf('d');
                    oValue = xt[xtObj].substring(0, a);
                    rValue = xt[xtObj].substring(d+1, xt[xtObj].length);
                }
                if (xt[xtObj] !== ''){
                    if (xtObj === 'value6'){
                        if (eval('indexXt' + xt[xtObj])){
                            pf += Number(score.value6);
                            break;
                        }
                    }
                    if (xtObj === 'value5'){
                        if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (xtObj === 'value4'){
                        if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (xtObj === 'value3'){
                        if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (xtObj === 'value2'){
                        if (eval('indexXt' + oValue) || eval('indexXt' + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (xtObj === 'value1'){
                        if (eval('indexXt' + oValue) && eval('indexXt' + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }


            }
        }


        if (nl !== '') {
            for (var lnyObj in lny){
                if (lny[lnyObj] !== ''){
                    if (lnyObj === 'value4'){
                        if (eval('nl' + lny[lnyObj])){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (lnyObj === 'value3'){
                        if (eval('nl' + lny[lnyObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (lnyObj === 'value2'){
                        if (eval('nl' + lny[lnyObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (lnyObj === 'value1'){
                        if (eval('nl' + lny[lnyObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }


        if (avgmy !== '') {
            for (var pjmyObj in pjmy){
                var oValue = null;
                var rValue = null;
                if (pjmy[pjmyObj].indexOf('or') > 0){
                    var o = pjmy[pjmyObj].indexOf('o');
                    var r = pjmy[pjmyObj].indexOf('r');
                    oValue = pjmy[pjmyObj].substring(0, o);
                    rValue = pjmy[pjmyObj].substring(r+1, pjmy[pjmyObj].length);

                    if (pjmyObj === 'value4'){
                        if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (pjmyObj === 'value3'){
                        if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (pjmyObj === 'value2'){
                        if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (pjmyObj === 'value1'){
                        if (eval('avgmy' + oValue) || eval('avgmy' + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }


            }
        }


        if (ngzy !== '') {
            for (var ngyObj in ngy){
                if (ngy[ngyObj] !== ''){
                    if (ngyObj === 'value4'){
                        if (eval('ngzy' + ngy[ngyObj])){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (ngyObj === 'value3'){
                        if (eval('ngzy' + ngy[ngyObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (ngyObj === 'value2'){
                        if (eval('ngzy' + ngy[ngyObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (ngyObj === 'value1'){
                        if (eval('ngzy' + ngy[ngyObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }


        if (dmfy !== '') {
            for (var xybhObj in xybh){
                var oValue = null;
                var rValue = null;
                if (xybh[xybhObj].indexOf('or') > 0){
                    var o = xybh[xybhObj].indexOf('o');
                    var r = xybh[xybhObj].indexOf('r');
                    oValue = xybh[xybhObj].substring(0, o);
                    rValue = xybh[xybhObj].substring(r+1, xybh[xybhObj].length);

                    if (xybhObj === 'value4'){
                        if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (xybhObj === 'value3'){
                        if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (xybhObj === 'value2'){
                        if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (xybhObj === 'value1'){
                        if (eval('dmfy' + oValue) || eval('dmfy' + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }

        if (xl !== '') {
            for (var xllObj in xll){
                var oValue = null;
                var rValue = null;
                if (xll[xllObj].indexOf('or') > 0){
                    var o = xll[xllObj].indexOf('o');
                    var r = xll[xllObj].indexOf('r');
                    oValue = xll[xllObj].substring(0, o);
                    rValue = xll[xllObj].substring(r+1, xll[xllObj].length);

                    if (xllObj === 'value5'){
                        if (eval('xl' + xll[xllObj])){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (xllObj === 'value4'){
                        if (eval('xl' + xll[xllObj])){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (xllObj === 'value3'){
                        if (eval('xl' + oValue) || eval('xl' + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (xllObj === 'value2'){
                        if (eval('xl' + oValue) || eval('xl' + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (xllObj === 'value1'){
                        if (eval('xl' + oValue) || eval('xl' + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }

        if (tw !== '') {
            for (var twwObj in tww){
                if (tww[twwObj] !== ''){
                    if (twwObj === 'value3'){
                        if (eval('tw' + tww[twwObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (twwObj === 'value2'){
                        if (eval('tw' + tww[twwObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (twwObj === 'value1'){
                        if (eval('tw' + tww[twwObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }


        if (hx !== '') {
            for (var hxxObj in hxx){
                if (hxx[hxxObj] !== ''){
                    if (hxxObj === 'value3'){
                        if (eval('hx' + hxx[hxxObj])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (hxxObj === 'value2'){
                        if (eval('hx' + hxx[hxxObj])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (hxxObj === 'value1'){
                        if (eval('hx' + hxx[hxxObj])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                }

            }
        }

        if (crl !== ''){
            for (var c in cr){
                var oValue = null;
                var rValue = null;
                if (cr[c].indexOf('and') > 0){
                    var a = cr[c].indexOf('a');
                    var d = cr[c].indexOf('d');
                    oValue = cr[c].substring(0, a);
                    rValue = cr[c].substring(d+1, cr[c].length);
                    if (c === 'value1'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                    if (c === 'value2'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (c === 'value3'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (c === 'value4'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (c === 'value5'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (c === 'value6'){
                        if (eval('crl' + oValue) && eval('crl' + rValue)){
                            pf += Number(score.value6);
                            break;
                        }
                    }
                }
            }
        }



        var v1 = $('#v1').val();
        var v1_score = dataList[20];
        if (v1 !== ''){
            for (var v1_value in v1_score){
                if (v1_score[v1_value] !== ''){
                    if (v1_value === 'value1'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                    if (v1_value === 'value2'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (v1_value === 'value3'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (v1_value === 'value4'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (v1_value === 'value5'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (v1_value === 'value6'){
                        if (eval('v1' + v1_score[v1_value])){
                            pf += Number(score.value6);
                            break;
                        }
                    }
                }

            }
        }


        for (var i=21; i < dataList.size; i++){
            var object = dataList[i];
            var index = t[i];
            for (var ob in object){
                var oValue = null;
                var rValue = null;

                if (object[ob].indexOf('and') > 0){
                    var a = object[ob].indexOf('a');
                    var d = object[ob].indexOf('d');
                    oValue = object[ob].substring(0, a);
                    rValue = object[ob].substring(d+1, object[ob].length);
                    if (xtObj === 'value1'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value1);
                            break;
                        }
                    }
                    if (xtObj === 'value2'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value2);
                            break;
                        }
                    }
                    if (xtObj === 'value3'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value3);
                            break;
                        }
                    }
                    if (xtObj === 'value4'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value4);
                            break;
                        }
                    }
                    if (xtObj === 'value5'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value5);
                            break;
                        }
                    }
                    if (xtObj === 'value6'){
                        if (eval(index.value + oValue) && eval(index.value + rValue)){
                            pf += Number(score.value6);
                            break;
                        }
                    }
                }else {
                    if (object[ob] !== ''){
                        if (xtObj === 'value1'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                        if (xtObj === 'value2'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                        if (xtObj === 'value3'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                        if (xtObj === 'value4'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                        if (xtObj === 'value5'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                        if (xtObj === 'value6'){
                            if (eval(index.value + object[ob])){
                                pf += Number(score[xtObj]);
                                break;
                            }
                        }
                    }

                }


            }
        }
    }

    $("#pf").html(pf);
    var sumValue = $("#pf").html();
    if (flag) {
        var hisStr = null;
        hisFlag = true;
        setTimeout(function () {
            if (hisArray.length > 0){
                hisStr = hisArray;
                hisArray = [];
            }
            $.ajax({
                url: Feng.ctxPath + '/index/add?hisId=' + Feng.getUrlParam("id"),
                type: 'post',
                dataType: 'json',
                data: {
                    indexMovement: indexMovement,
                    tongReflect: tongReflect,
                    tongChange: tongChange,
                    indexXz: indexXz,
                    indexNzx: indexNzx,
                    indexZwm: indexZwm,
                    indexHckd: indexHckd,
                    indexXt: indexXt,
                    tw: tw,
                    indexHx: hx,
                    indexNl: nl,
                    avgmy: avgmy,
                    ngzy: ngzy,
                    indexDmy: dmfy,
                    sumValue : pf,
                    hisXlStr : hisStr,
                    age : ag,
                    surgery : surgery,
                    medicalHistory : medicalHistory,
                    v1 : v1,
                    v0 : crl,
                    sData : JSON.stringify(t)
                },
                success: function (result) {
                    //Feng.success("保存成功");
                }
            });
        }, 6000);



    }


    timer = setTimeout(function () {
        setTime(true)
    }, 1000 * 60 * tsTime);
}


setTime();

function timeAdd() {
    var tsTime = $("#tsTime").val();
    var id = $("#id").val();
    $.ajax({
        url: Feng.ctxPath + '/mmhc/updateTs',
        type: 'post',
        dataType: 'json',
        data: {
            id : id,
            tsTime : tsTime
        },
        success: function (result) {
            Feng.success("保存成功");
        }
    });

}

function xyTimeAdd() {
    var xyTime = $("#xyTime").val();
    var id = $("#id").val();
    $.ajax({
        url: Feng.ctxPath + '/mmhc/updateTs',
        type: 'post',
        dataType: 'json',
        data: {
            id : id,
            xyTime : xyTime
        },
        success: function (result) {
            Feng.success("保存成功");
        }
    });
}