require('./css/index.css');
require('./css/reset.css');
require('./css/popup.css');
require('./js/popup');
const $ = require("jquery");
const { post,config,getUrlArgObject } = require('./js/promise.js');

const {bqtsFun,ybzlFun,cyywFun,knzdFun,jtFun,tjwzFun,tjtgFun,tjhyFun,tjfjFun,yszdFun} = require('./js/indexDom.js');
//   symptom: "恶心呕吐腰痛", //胸痛，背痛，恶心，呕吐     //恶心呕吐腰痛   //牙周袋形成

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') || ''
}//推送相关信息

window.msg = msg
window.pushMessage = {}

post(config.pushInner,Object.assign({featureType: '1,4,5,6,7,22',ruleType:config.ruleTypeMap['22']},msg)).then((res)=>{
  var data = res.data
  if(data.code == 0){
    var result = data.data;
    if(result.medicalIndications && result.medicalIndications.length>0){//病情提示
      window.pushMessage = result.medicalIndications;//计算的需要的相关数据
      bqtsFun(result.medicalIndications)
    }
    if(result.dis){
      var proB = result.dis['可能诊断'] || []//可能
      var proY = result.dis['确诊'] || []//确诊
      var proWaring = result.dis['警惕'] || []
      yszdFun(proY)//疑似
      knzdFun(proB)//可能
      jtFun(proWaring)//警惕
      if(proY.length == 0){
        $(".conditionHintMay").css("display","none")
      }else{
        $(".conditionHintMayNull").css("display","none")
      }
    }
    if(result.symptom && result.symptom.length > 0){//推荐问诊症状
      $(".conditionHintWzNull").css("display","none")
      tjwzFun(result.symptom)
    }
    if(result.vital && result.vital.length > 0){//体格检查
      $(".conditionHintTgNull").css("display","none")
      tjtgFun(result.vital)
    }
    if(result.pacs && result.lab.length > 0){
      $(".conditionHintAssistLis").css({
        "border-top":"1px solid #D1D1D1"
      })
    }
    if(result.lab && result.lab.length > 0){//化验
      $(".conditionHintInspectNull").css("display","none")
      $(".conditionHintAssistNull").css("display","none")
      tjhyFun(result.lab)
    }
    if(result.pacs && result.pacs.length > 0){//辅检
      $(".conditionHintInspectNull").css("display","none")
      $(".conditionHintAssistNull").css("display","none")
      tjfjFun(result.pacs)
    }
  }
})

post(config.pushTreatment,Object.assign({featureType: '8',ruleType:config.ruleTypeMap['8']},msg)).then((res)=>{
  var data = res.data
  if(data.code == 0){
    var result = data.data;
    var num = 0;
    if(result.commonTreatment && result.commonTreatment.content){
      ++num
      ybzlFun(result.commonTreatment.content)//一般治疗
    }
    if(result.treatment && result.treatment.length>0){
      ++num
      cyywFun(result.treatment)//常用药物
    }
    if(num == 0){
      $(".conditionHintZhiliaoNull").css("display","block")
    }
  }else{
    $(".conditionHintZhiliaoNull").css("display","block")
    $(".treatMedicine").css("display","none")
  }
})

