import {CHANGE_ASSAY, CHANGE_CHECK, BILLING_ADVICE, ADD_SCHEME, SET_TIPS,  SET_TIPS_DETAILS, 
        SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, ADD_BILLING,
        CLEAR_ALL_PUSH_MESSAGE,SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS, SET_COMMONTREATMENT, IS_FIRST_MAIN_DIAG, 
        SET_ADVICE_INPUT ,SET_CHRONIC_TABLELIST,SHOW_TABLE_LIST,SET_SCALE_INFO,SET_CHRONIC_PUSHS,
        SAVE_TABLE_RESULT, SAVE_FOLLOW_UP, DEL_FOLLOW_UP} from '../types/pushMessage';
import {changeAssay, changeCheck, setAdvice, addScheme, setTips, setTipsDetails, setChangeAdviceTreatment, 
        setChangeAdviceAssay, setChangeAdviceCheck, addBilling, clearAllPushMessage, showTipsDetails, hideTipsDetails, 
        setCommontreatment, isFirstMainDiag, setAdviceInput, saveFollowUp, delFollowUp } from '../actions/pushMessage';

const initState = {
  vigilant: [],
  doubt: [],
  possible: [],
  assay: [],
  determine: [],
  check: [ //辅检
  ],
  tips: {},
  advice: {
    // assay: '', 
    // check: '',
    // scheme: [],
    // adviceStr: '' 
  },
  AdviceStr: '',
  tmpFlg:'',
  tableList:[],
  formulaResult:{},
  scaleInfo:{},
  showHide:{},
  calcuResult:{}
};
export default function(state = initState, action) {
  let res = Object.assign({},state);
  switch (action.type) {
    case CHANGE_ASSAY:
      return changeAssay(state, action);
    case CHANGE_CHECK:
      return changeCheck(state, action);
    case BILLING_ADVICE:  //获取右侧推断信息
      return setAdvice(state, action);
    case ADD_SCHEME: 
      return addScheme(state, action);
    case SET_TIPS: 
      return setTips(state, action);
    case SET_TIPS_DETAILS:
      return setTipsDetails(state,action)
    case SET_CHANGE_ADVICE_TREATMENT:
      return setChangeAdviceTreatment(state, action);
    case SET_CHANGE_ADVICE_ASSAY: 
      return setChangeAdviceAssay(state, action);
    case SET_CHANGE_ADVICE_CHECK: 
      return setChangeAdviceCheck(state, action);
    case ADD_BILLING: 
      return addBilling(state, action);
    case CLEAR_ALL_PUSH_MESSAGE: 
      return clearAllPushMessage(state, action);
    case SHOW_TIPS_DETAILS: 
      return showTipsDetails(state, action);
    case HIDE_TIPS_DETAILS:
      return hideTipsDetails(state, action);
    case SET_COMMONTREATMENT:
      return setCommontreatment(state, action);
    case IS_FIRST_MAIN_DIAG:
      return isFirstMainDiag(state, action);
    case SET_ADVICE_INPUT:
      return setAdviceInput(state, action);
    case SAVE_FOLLOW_UP: 
      return saveFollowUp(state, action);
    case DEL_FOLLOW_UP: 
      return delFollowUp(state, action);
    case SET_CHRONIC_TABLELIST://量表列表数据
      res.tableList = action.data;
      return res;
    case SHOW_TABLE_LIST://显示、隐藏量表列表
      res.showHide = Object.assign({},res.showHide,{[action.name]:action.value});
      return res;
    case SET_CHRONIC_PUSHS:
      res.chronicPushItems = action.data;
      if(action.id){
        res.calcuResult[action.id] = action.result;
      }
      return res;
    case SET_SCALE_INFO://量表内容-量表id
      res.scaleInfo = Object.assign({},res.scaleInfo,{[action.id]:action.data});
      return res;
    case SAVE_TABLE_RESULT://量表计算结果-量表id
      res.formulaResult = Object.assign({},res.formulaResult,{[action.id]:action.data});
      return res;
    default:
      return state;
  }
}
