require('./../css/reset.css');
require('./../css/icssIndex.less');
require('./../css/popup.css');
require('./../images/empty.png')
require('./../images/loading.gif')
require('./../images/right.png')
// require('./popupEdit.js');
var Promise = require("bluebird");
let diagFirstImg = require('./../images/yszd.png')
let diagWarningImg = require('./../images/warning.png')
let diagPossibleImg = require('./../images/knzd.png')
let diagIdentifyImg = require('./../images/jianb.png')
let labAndPacsImg = require('./../images/inspect.png')
let physiExamImg = require('./../images/tgjc.png')
let medicalIndicationsImg = require('./../images/tips.png')


const $ = require("jquery");
const { post,config,getUrlArgObject,openNewWin } = require('./promise.js');
const { transConf } = require('./util.js');
const {renderWrapper, renderCaseStandard,renderWarning,renderRecommendInfo,renderMultRecommendInfo,renderRecommendConditTips} = require('./icssIndexDom.js')



let mrId = getUrlArgObject('mrId') 
const tipsMode = getUrlArgObject('tipsMode') || 1
let msg;

function getMRInfo() {
   return post(config.getMr2,{mrId:mrId})
}
$('.loading').css("display","block")
$('.empty').css("display","none")
getMRInfo().then(res =>{
    if(res.data.code == '0'){
        msg = res.data.data
        window.msg = msg
        getConf().then(res =>{
          if(res.data.code == '0'){
            const configArr = res.data.data.pushSetList || []

            getPageInfo(configArr)
          }
        })
        // getAnalyse().then(res =>{
        //   renderCaseStandard('CaseStandard', '病例书写规范', res.data.data.warning)
        // })
        // getHosptDeptUsal().then(res =>{
        //   console.log('ressss', res)
        //   const diagCommon = res.data.data
        //   renderRecommendInfo(5,'diagCommon', '常见症状', diagCommon, true,7,2);
        // })
      
    }
}).catch(function (err) {
    console.log(err);
})

// var msg = {
//     age: getUrlArgObject('age'),
//     sex: getUrlArgObject('sex') == '男'?1:(getUrlArgObject('sex') == '女'?2:(getUrlArgObject('sex') == '通用'?3:getUrlArgObject('sex'))),
//     symptom: getUrlArgObject('symptomJson'),
//     vital: getUrlArgObject('vitalJson'),
//     lis: getUrlArgObject('lisJson')? JSON.parse(getUrlArgObject('lisJson')) : [],
//     pacs: getUrlArgObject('pacsJson'),
//     diag: getUrlArgObject('diagJson'),
//     diseaseName: getUrlArgObject('diseaseName'),
//     other: getUrlArgObject('otherJson') + getUrlArgObject('pastJson'),
//     hosCode:getUrlArgObject('hospitalCode') || '',
//     plan:getUrlArgObject('plan') || '0',
// }//推送相关信息
// //   http://localhost:8082/indexVert.html?age=28&diseaseId=280&lisJson=&diagJson=%E6%80%A5%E6%80%A7%E8%83%B0%E8%85%BA%E7%82%8E&pastJson=%E6%97%A0%E5%BF%83%E8%84%8F%E7%97%85&otherJson=%E6%97%A0%E9%AB%98%E8%A1%80%E5%8E%8B&pacsJson=%E8%85%B9%E9%83%A8B%E8%B6%85:%E6%97%A0%E5%BC%82%E5%B8%B8,%20%E6%8A%A5%E5%91%8A%E6%97%A5%E6%9C%9F:2019-05-07&sex=%E7%94%B7&symptomJson=%E6%81%B6%E5%BF%83%E5%91%95%E5%90%90%E8%85%B0%E7%97%9B&vitalJson=%E8%A1%80%E5%8E%8B%E5%B7%A6%E4%B8%8A%E8%82%A213/12mmHg
// window.msg = msg
// window.pushMessage = {}
function getConf() {
  var msg = window.msg 
  return post(config.getPushSet,{mode:msg.mode})
}

function getPushInfo() {
  return  post(config.pushInner,Object.assign({featureType: '1,4,5,6,7,22',ruleType:config.ruleTypeMap['22']},msg))
  
}

function getAnalyse() {
  const param = getAnalyseParam()
  return  post(config.analyse,param)
  
}
function getHosptDeptUsal(){
  var msg = window.msg
  const param ={ 
    age: msg.age, 
    deptName: msg.deptName,
    hospitalCode: msg.hosCode,
    sexType: msg.sex,
    type: 1,
  }
  return  post(config.getHosptDeptUsal,param)
}

function getAnalyseParam() {
    var msg = window.msg 
    let diagStr = "",lisStr = "", lisList = msg.lis,pacStr = "", pasList = msg.pacs
 
    for(let i = 0; i < msg.diag.length; i++) {
      if(i == 0) {
        diagStr += msg.diag[i].name
      } else {
        diagStr += ',' + msg.diag[i].name
      }
    }
   for(let i = 0; i < lisList.length; i++){
      lisStr += `${lisList[i].name},${lisList[i].detailName},${lisList[i].value}${lisList[i].detailName};`
   }
   for(let i = 0; i < pasList.length; i++){
      pacStr += `${pasList[i].uniqueName}:${pasList[i].result},报告日期：${pasList[i].dateValue};`
    }
    
    let str = `姓名: ${msg.patientName || ""}
              性别：${msg.sex == '1' ? '男':'女'}
              年龄：${msg.age  || ""}
              主诉：${msg.chief  || ""}
              现病史：${msg.symptom  || ""}
              其他史：${msg.pasts  || ""}
              查体：${msg.vital  || ""}
              化验：${lisStr  || ""}
              辅检：${pacStr  || ""}
              诊断：${diagStr  || ""}
              `
    //let str = "姓　　名：姜** /r/n性 　 别：女/r/n年    龄：34岁/r/n民    族：汉族/r/n职    业：经商/r/n出 生 地：浙江省长兴县/r/n婚    姻：已婚/r/n联系地址：*** /r/n病史陈述者：患者本人/r/n入院日期：2019-12-04 10:12/r/n /r/n记录日期：2019-12-04 14:37/r/n /r/n主    诉: 腹痛1周 /r/n现 病 史: 患者1周前饮食辛辣食物后出现腹痛，主要为脐以上为主，呈持续性钝痛，无明显恶心呕吐，无肩背部疼痛，无咳嗽咳痰，无腹泻腹痛，无胸闷气促，无头晕头痛，无视物旋转，无异常阴道流血流液等情况，自诉近一周感下腹坠胀感，为求进一步诊治拟\"腹痛待查\"收住入院。/r/n患病来，神志清，精神软，胃纳差，睡眠一步，大小便如常，近期体重无明显改变。 /r/n既 往 史: 否认\"高血压，糖尿病，冠心病\"病史，否认\"肝炎，结核\"等传染病史，否认重大外伤史，否认手术史，否认输血史，既往存在头孢过敏，具体不详，否认长期药物使用史，否认药物成瘾，预防接种史不详。 /r/n个 人 史: 出生并生长于浙江省长兴县，经商，初中文化，否认疫区居住史，否认放射物、毒物、粉尘接触史，否认吸烟，否认饮酒，否认特殊嗜好，否认不洁性交史。 /r/n月 经 史: ，经量中等，颜色正常，无痛经，经期规律；白带量一般，性状无殊。 /r/n婚 育 史: 27岁结婚，否认近亲结婚，配偶健康状况良好，夫妻关系和睦,育有1女，均健康。/r/n家 族 史: 父亲体健，母已故（死因不详），有2哥，均体健，家族中无传染病及遗传病史,否认两系三代内遗传性、家族性疾病史，否认家族中有\"肝炎、结核\"等传染病史，否认两系三代内\"胃癌、肺癌\"等肿瘤病史，否认类似疾病史。 /r/n体格检查（一）/r/n /r/n一般状况：/r/n体温36.3℃，脉搏68次/分，呼吸19次/分，血压133/81mmHg。/r/n意识清晰，自主体位，面容无殊，体重56Kg，身高163cm，查体合作。 /r/n皮    肤：/r/n皮肤色泽正常，弹性好，未见明显水肿，未见皮疹，未见皮下出血，未见肝掌及蜘蛛痣。/r/n淋 巴 结：/r/n未触及明显浅表淋巴结肿大 /r/n头    部：/r/n外形大小正常，无畸形。听力粗测正常。眼睑正常，结膜正常，巩膜无黄染，瞳孔等大等圆，直径3mm，对光反射灵敏。鼻部外形正常，通气顺畅，副鼻窦区无压痛，乳突无压痛。口腔粘膜正常，扁桃体无肿大。/r/n颈　  部：/r/n颈软，无抵抗感，气管位置居中，颈静脉无怒张。/r/n胸　  部：/r/n外形正常，肋间隙正常，双侧乳房正常对称。/r/n肺    部：/r/n呼吸运动正常对称，双肺叩诊呈清音，呼吸音清晰，未闻及干、湿啰音。/r/n心    脏：/r/n心率68次/分，心律齐，心音有力，P2＜A2，各瓣膜听诊区未闻及杂音。 /r/n血    管：/r/n周围血管征阴性。 /r/n腹　　部：/r/n外形正常，未见肠形及蠕动波，腹壁松软，脐以上及下腹存在轻压痛，无反跳痛，/r/n包块未触及，肝脏肋下未触及，胆囊肋下未触及，脾脏肋下未触及，双肾区无叩痛，肠鸣音正常，3～5次/分，移动性浊音阴性。/r/n外生殖器：/r/n未见明显畸形 /r/n直肠肛门：/r/n未见明显畸形 /r/n四肢脊柱：/r/n脊柱无畸形，无压痛叩击痛，无放射痛，活动自如，四肢正常。/r/n神经系统：/r/n四肢肌张力正常，肌力V级，膝腱反射双侧正常，Babinski征双侧阴性。/r/n其    他：/r/n详见专科检查。/r/n/r/n体格检查（二）/r/n补 充 及 专 科 情 况/r/n体温36.3℃，脉搏68次/分，呼吸19次/分，血压133/81mmHg神志清，呼吸平稳，浅表淋巴结未及肿大，两肺呼吸音清，双下肺未闻及湿罗音，心率68次/分，律齐，未闻及病理性杂音，腹平软，脐以上及下腹存在轻压痛，无反跳痛，肝脾肋下未触及，双下肢无浮肿。/r/n /r/n /r/n心脏相对浊音界/r/n /r/n右界cm/r/n肋间/r/n左界cm/r/n/r/n 2/r/nⅡ/r/n 2/r/n/r/n 2/r/nⅢ/r/n 4/r/n/r/n 3/r/nⅣ/r/n 6/r/n/r/n /r/nⅤ/r/n 8/r/n/r/n左锁骨中线距胸骨中线  8 cm/r/n辅助检查: 2019-12-4 心电图未见明显异常。 /r/n /r/n初步诊断：1、腹痛待查 2.盆腔炎/r/n修正诊断：      /r/n       医师签名：李勇   /r/n                          /r/n2019-12-04         /r/n                /r/n补充诊断："
    let label = ["姓名","性别","年龄",
    "主诉","现病史","其他史","查体","化验","辅检",
    "诊断"]
    const param = {
      "cid":0,
      "medrec": 
      [
          {
            "content": {
             "content":str
            },
            "label": label,
            "title": "入院记录"
          }
       
      ],
        "token": ""
      }
    return param
  }



function getPageInfo(configArr) {
  let {confArr, showLabsNum, showPacsNum, labsAndPacMode} = transConf(configArr),
 
    diagWaring = [{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7},{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7},{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7},{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7},{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7}]
    // diagWaring = [],
    diagFirst = [],
    diagPossible = [],
    diagIdentify = [],
    labRecommend = [],
    pacsRecommend = [],
    physiExamRecommend = [],
    symptomRecommend = [],
    medicalIndications = [],
    diagCommon = [],
    CaseStandard = [],
    labAndPacsRecommend = [],
    disName=""
    const hasCaseStandard = confArr.findIndex(item => item.code == 'specification_show') > -1
    const hasCommon = confArr.findIndex(item => item.code == 'comsympto_show') > -1
    if(hasCommon){
      if(hasCaseStandard){
        Promise.all([getHosptDeptUsal(),getPushInfo(),getAnalyse()]).then(([res1, res2, res3]) =>{
          diagCommon = res1&&res.data&&res.data.data&&res.data.data || []
          diagWaring = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['警惕'] || []
          diagFirst = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['拟诊'] || []
          diagDetermine = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['确诊'] || []
          diagFirst = diagDetermine.concat (diagFirst)
          diagPossible = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['可能诊断'] || []
          diagIdentify = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['鉴别诊断'] || []
          labRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.lab || []
          pacsRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.pacs || []
          physiExamRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.vital || []
          symptomRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.symptom || []
          medicalIndications = res2&&res2.data&&res2.data.data&&res2.data.data.medicalIndications || []
          CaseStandard = res3&&res3.data&&res3.data.data&&res3.data.data.warning || []
          labAndPacsRecommend = [
            {
                title: '化验',
                className: 'labRecommend',
                data:  labRecommend,
                showNum: showLabsNum
            },
            {
                title: '辅检',
                className: 'pacsRecommend',
                data:  pacsRecommend,
                showNum: showPacsNum
            }
          ]
          window.pushMessage = medicalIndications;//计算的需要的相关数据
          renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications,diagCommon,CaseStandard);

        }).catch(function (err) {
          console.log(err);
        })
      } else{
        Promise.all([getHosptDeptUsal(),getPushInfo()]).then(([res1, res2]) =>{
          diagCommon = res1&&res1.data&&res1.data.data&&res1.data.data || []
          // diagWaring = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['警惕'] || []
          diagFirst = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['拟诊'] || []
          diagDetermine = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['确诊'] || []
          diagFirst = diagDetermine.concat (diagFirst)
          diagPossible = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['可能诊断'] || []
          diagIdentify = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['鉴别诊断'] || []
          labRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.lab || []
          pacsRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.pacs || []
          physiExamRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.vital || []
          symptomRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.symptom || []
          medicalIndications = res2&&res2.data&&res2.data.data&&res2.data.data.medicalIndications || []
          labAndPacsRecommend = [
            {
                title: '化验',
                className: 'labRecommend',
                data:  labRecommend,
                showNum: showLabsNum
            },
            {
                title: '辅检',
                className: 'pacsRecommend',
                data:  pacsRecommend,
                showNum: showPacsNum
            }
          ]
          window.pushMessage = medicalIndications;//计算的需要的相关数据
          renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications,diagCommon,CaseStandard);

        }).catch(function (err) {
          console.log(err);
        })
      }
    }else{
      if(hasCaseStandard){
        Promise.all([getAnalyse(), getPushInfo()]).then(([res1, res2]) =>{
          getPushData(res2)
          diagWaring = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['警惕'] || []
          diagFirst = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['拟诊'] || []
          diagDetermine = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['确诊'] || []
          diagFirst = diagDetermine.concat (diagFirst)
          diagPossible = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['可能诊断'] || []
          diagIdentify = res2&&res2.data&&res2.data.data&&res2.data.data.dis&&res2.data.data.dis['鉴别诊断'] || []
          labRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.lab || []
          pacsRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.pacs || []
          physiExamRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.vital || []
          symptomRecommend = res2&&res2.data&&res2.data.data&&res2.data.data.symptom || []
          medicalIndications = res2&&res2.data&&res2.data.data&&res2.data.data.medicalIndications || []
          CaseStandard = res1&&res1.data&&res1.data.data&&res1.data.data.warning || []
          labAndPacsRecommend = [
            {
                title: '化验',
                className: 'labRecommend',
                data:  labRecommend,
                showNum: showLabsNum
            },
            {
                title: '辅检',
                className: 'pacsRecommend',
                data:  pacsRecommend,
                showNum: showPacsNum
            }
          ]
          window.pushMessage = medicalIndications;//计算的需要的相关数据
          renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications,diagCommon,CaseStandard);

        }).catch(function (err) {
          console.log(err);
        })
      } else{
     
        getPushInfo().then(res =>{
          diagWaring = res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis['警惕'] || []
          diagFirst = res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis['拟诊'] || []
          diagDetermine = res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis['确诊'] || []
          diagFirst = diagDetermine.concat (diagFirst)
          diagPossible = res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis['可能诊断'] || []
          diagIdentify = res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis['鉴别诊断'] || []
          labRecommend = res&&res.data&&res.data.data&&res.data.data.lab || []
          pacsRecommend = res&&res.data&&res.data.data&&res.data.data.pacs || []
          physiExamRecommend = res&&res.data&&res.data.data&&res.data.data.vital || []
          symptomRecommend = res&&res.data&&res.data.data&&res.data.data.symptom || []
          medicalIndications = res&&res.data&&res.data.data&&res.data.data.medicalIndications || []
          labAndPacsRecommend = [
            {
                title: '化验',
                className: 'labRecommend',
                data:  labRecommend,
                showNum: showLabsNum
            },
            {
                title: '辅检',
                className: 'pacsRecommend',
                data:  pacsRecommend,
                showNum: showPacsNum
            }
          ]
          window.pushMessage = medicalIndications;//计算的需要的相关数据
          renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications,diagCommon,CaseStandard);
        }).catch(function (err) {
          console.log(err);
        })
      }
    }
  // Promise.all([getConf(),getPushInfo(),getTreatment(),getTipsInfo()]).then(([res1, res2, res3, res4]) =>{
  //   const configArr = res1&&res1.data&&res1.data.data.pushSetList || []
  //   const pushInfo = res2&&res2.data || {}
  //   const tipsInfo = res4&&res4.data || {}
  //   const {confArr, showLabsNum, showPacsNum, labsAndPacMode} = transConf(configArr)
  //   const pushResult = pushInfo.data || {};
  //   let tipsResult = []
  //   if(tipsInfo.data) {
  //     if(tipsMode == '2') {
  //         tipsResult = tipsInfo.data
  //     } else {
  //         tipsResult.push(tipsInfo.data)
  //     }
  //   }

  //   const diagPossible =  pushResult.dis&&pushResult.dis['可能诊断'] || []//可能
  //   const diagFirst = pushResult.dis&&pushResult.dis['拟诊'] || [] // 疑似
  //   const diagDeter = pushResult.dis&&pushResult.dis['确诊'] || []//确诊
  //   const diagIdentify = pushResult.dis&&pushResult.dis['鉴别诊断'] || []//确诊
  //   const diagWaring = pushResult.dis&&pushResult.dis['警惕'] || [{clientNames: null, conceptId: 531694,libType: 18,name: "糖尿病肾病",type: 7}] // 推荐警惕诊断
  //   const symptomRecommend = pushResult.symptom || []  //推荐问诊症状
  //   const physiExamRecommend  = pushResult.vital || [] //推荐体格检查
  //   const diagRecommend = diagDeter.concat(diagFirst, diagPossible) //推荐诊断
  //   const labRecommend = pushResult.lab || []
  //   const pacsRecommend = pushResult.pacs || []
  //   const medicalIndications = pushResult.medicalIndications || []
  //   const labAndPacsRecommend = [
  //     {
  //         title: '化验',
  //         className: 'labRecommend',
  //         data:  labRecommend,
  //         showNum: showLabsNum
  //     },
  //     {
  //         title: '辅检',
  //         className: 'pacsRecommend',
  //         data:  pacsRecommend,
  //         showNum: showPacsNum
  //     }
  //   ]
  //   window.pushMessage = medicalIndications;//计算的需要的相关数据

    
  //   renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications);
  // }).catch(function (err) {
  //   console.log(err);
  // })

}
function getPushData(res){
  if(res&&res.data&&res.data.data&&res.data.data.dis&&res.data.data.dis){
    let dis = res.data.data.dis;
    //急诊显示规则，主诊断有急诊优先显示，没有则显示推送的，推送也没有就不显示
    if(dis&&dis['页面急诊']&&(dis['页面急诊'].length>0)){
      let name = dis['页面急诊'][0].name || ''
      $(".allDis .disName").html(name)
      disName = name
      if(name){
        $(".singleDis").css("display","block")
      }
    }else if(dis&&dis['急诊']&&dis['急诊'].length>0){
      let name = dis['急诊'][0].name || ''
      $(".allDis .disName").html(name)
      disName = name
      if(name){
        $(".singleDis").css("display","block")
      }
    }
  }
}
let disName=""
function handleShow(){
  const newinConf = {
    width: '600',   //窗口的文档显示区的宽度。以像素计。
    height: '826',  //窗口文档显示区的高度。以像素计。
    left: '0',  //窗口的 x 坐标。以像素计。
    top: '0',    //窗口的 y 坐标。以像素计。
    openMode: "_blank"  //每次都是新窗口打开为_blank,打开同一窗口填写任意字符串
  }
  const newWindowLocation = `width=${newinConf.width}, height=${newinConf.height}, left=${newinConf.left}, top=${newinConf.top} scrollbars=yes`
  window.open('./emergency.html?disName='+disName, newinConf.openMode, newWindowLocation)
}
$(document).on('click',".allDis .allName",function(){
  handleShow()
})
$(document).on('click',".singleDis",function(){
  $(this).next().css("display","block")
  $(this).css("display","none")
})
$(document).on('click',".allDis .right,.allDis .secDis",function(){
  $(".allDis").css("display","none")
  $(".singleDis").css("display","block")
})
function renderPageData(confArr,diagWaring,diagFirst,diagPossible,diagIdentify,labAndPacsRecommend,physiExamRecommend,symptomRecommend,medicalIndications,diagCommon,CaseStandard){

  let renderNum = 0
    // renderWarning(5,'warning', '警惕', diagWaring, true,7,2)
    // renderRecommendInfo(5,'diagFirst', '初步诊断', diagFirst, true,7,2);
    // renderRecommendInfo(5,'diagPossible', '可能诊断', diagPossible, true,7,2);
    // renderRecommendInfo(5,'diagIdentify', '鉴别诊断', diagIdentify, true,7,2);
    // renderMultRecommendInfo('labAndPacsRecommend', '检验检查', labAndPacsRecommend, false)
    // renderRecommendInfo(10,'physiExamRecommend', '体格检查', physiExamRecommend, false);
    // renderRecommendInfo(10,'symptomRecommend', '问诊症状', symptomRecommend, false);
    // renderRecommendConditTips('conditTips','病情提示', medicalIndications || []);
    // renderCaseStandard('CaseStandard', '病例书写规范', CaseStandard)
    // renderRecommendInfo(5,'diagCommon', '常见症状', diagCommon, true,7,2);
    // $('.physiExamRecommend h4 img').attr('src',physiExamImg)
    // $('.diagFirst h4 img').attr('src',diagFirstImg)
    // $('.diagPossible h4 img').attr('src',diagPossibleImg)
    // $('.diagIdentify h4 img').attr('src',diagIdentifyImg)

    for(let i = 0; i < confArr.length; i++) {
   
      switch(confArr[i].code) {
        case "symptoms_show":  //问诊症状
          symptomRecommend.length > 0 && renderRecommendInfo(confArr[i].showNum,'symptomRecommend', '问诊症状', symptomRecommend, false)
           $('.symptomRecommend h4 img').attr('src',diagFirstImg)
          symptomRecommend.length > 0 && renderNum++
          break; 
        case "physical_show": //体格检查
          physiExamRecommend.length > 0 &&  renderRecommendInfo(5,'physiExamRecommend', '体格检查', physiExamRecommend, false)
             $('.physiExamRecommend h4 img').attr('src',physiExamImg)
          physiExamRecommend.length > 0 && renderNum++
          break;
        case "illness_show": //病情提示
          medicalIndications.length > 0 && renderRecommendConditTips('conditTips','病情提示', medicalIndications || []);
          medicalIndications.length > 0 && renderNum++;
          break;
        case "vigilant_show": //警惕诊断
          diagWaring.length > 0 && renderWarning(confArr[i].showNum,'warning', '警惕诊断', diagWaring, true,7,2);
          diagWaring.length > 0 &&  renderNum++;
          break;
        case "comsympto_show": //常见症状
          diagCommon.length > 0 && renderRecommendInfo(confArr[i].showNum,'commonSymp', '常见症状', diagCommon, true,7,2);
          diagCommon.length > 0 && renderNum++;
          break;
        case "specification_show": //病例书写规范
          CaseStandard.length > 0 &&  renderCaseStandard('CaseStandard', '病历书写规范提示', CaseStandard);
          CaseStandard.length > 0 && renderNum++;
          break;
        case "Inspush_show": //检验检查
          (labRecommend.length > 0 || pacsRecommend.length >0) && renderMultRecommendInfo('labAndPacsRecommend', '检验检查', labAndPacsRecommend, false);
          (labRecommend.length > 0 || pacsRecommend.length >0) && renderNum++
          break;
        case "diapush_show": //推荐诊断
          diagFirst.length>0 && renderRecommendInfo(5,'diagFirst', '初步诊断', diagFirst, true,7,2);
          diagFirst.length>0 && renderNum++
          diagPossible.length>0 && renderRecommendInfo(5,'diagPossible', '可能诊断', diagPossible, true,7,2);
          diagPossible.length>0 && renderNum++
          diagIdentify.length>0 && renderRecommendInfo(5,'diagIdentify', '鉴别诊断', diagIdentify, true,7,2);
          diagIdentify.length>0 && renderNum++;
           $('.diagFirst h4 img').attr('src',diagFirstImg);
           $('.diagPossible h4 img').attr('src',diagPossibleImg);
           $('.diagIdentify h4 img').attr('src',diagIdentifyImg);
          break;
        default:
          break;
      } 
    }
    $('.loading').css("display","none")
    if(renderNum > 0 || diagWaring.length > 0){
      $(".empty").css("display","none")
    }else{
      $(".empty").css("display","block")
    }
}



function moreInfo() {
  $('.moreInfo').click(function(){
    const name = $(this).attr('data-name')
    const type = $(this).attr('data-type')
    openNewWin(`information.html?type=${encodeURIComponent(type)}&position=0&name=${encodeURIComponent(name)}`)
  })
}

function getVersion() {
  post(config.getVersion, 'confArr').then((res) => {
    const data = res.data.data;
    const ver = localStorage.getItem('versionTime');
    const time = data.refreshTime;
    if(!ver||ver===time+"=new"||time!==ver.replace("=new","")){       //判断版本是否更新
      $(".version-tip").addClass('new-icon');
      localStorage.setItem('versionTime',time+"=new");     //保存版本更新时间
    }else{
      $(".version-tip").removeClass('new-icon');
    }
  })
}
  function getDisclaimer() {
    post(config.disclaimer, '').then((res) => {
      const data = res.data.data.find(item => item.disclaimerCode == '2');
      $(".responsibility").html(data.description);
      $('.iframeWrap').css({height: $(window).height()-115-$(".responsibility").height()+'px'})

    })
  }


$(function(){
  getDisclaimer(); //获取免责声明
  getVersion();   //获取版本信息
  $(".disclaimerInfo").on("click", function(){
    openNewWin("disclaimer.html")
  });
  $(".version-tip").on("click", function(){
    const ver = localStorage.getItem('versionTime');
    $(".version-tip").removeClass('new-icon');
    localStorage.setItem('versionTime',ver.replace("=new",""));
    openNewWin("version.html");
  });
});
