import { ADD_DIAGNOSTIC,  DEL_DIAGNOSTIC, UP_DIAGNOSTIC, DOWN_DIAGNOSTIC, SET_TREAT, GET_DIAGNOSTIC_STR, SET_DIAG_TO_MAINSUIT, 
            GET_IS_FIRST,CLEAR_ALL_DIAG, SET_CLICK_DIAG ,CLEAR_DIAGNOSE, SET_CHRONIC_MAG_ITEM, SHOW_REFER_RECORD, HIDE_REFER_RECORD, 
            SHOW_HISTORY_CASE,  HIDE_HISTORY_CASE} from '../types/diagnosticList';
import { addDiagnostic,  delDiagnostic, upDiagnostic, downDiagnostic, setTreat, getDiagnosticStr, setDiagToMainSuit, 
        getIsFirst,clearAllDiag, setClickDiag, setChronicMagItem, showReferRecord, hideReferRecord, showHistoryCase, hideHistoryCase} from '../actions/diagnosticList';

const initState = {
    isFirst: true,
    diagnosticList: [
        // {
        //     id: 1,
        //     name: '脑梗塞',
        //     type: 1
        // },
        // {
        //     id: 2,
        //     name: '高血压',
        //     type: 2
        // },
        // {
        //     id: 3,
        //     name: '慢性支气管炎',
        //     type: 1
        // },
        // {
        //     id: 4,
        //     name: '急性支气管炎',
        //     type: 2
        // },
        // {
        //     id: 5,
        //     name: '原发性高血压',
        //     type: 1
        // }
    ],
    mainSuitStr:'',
    diagnosticStrNoType:'',

}

export default function (state=initState, action) {
    const res = Object.assign({},state);
    switch(action.type) {
        case ADD_DIAGNOSTIC:
            return addDiagnostic(state, action);
        case DEL_DIAGNOSTIC: 
            return delDiagnostic(state, action);
        case UP_DIAGNOSTIC: 
            return upDiagnostic(state, action);
        case DOWN_DIAGNOSTIC: 
            return downDiagnostic(state, action);
        case SET_TREAT: 
            return setTreat(state, action);
        case GET_DIAGNOSTIC_STR:
            return getDiagnosticStr(state, action);
        case SET_DIAG_TO_MAINSUIT:
            return setDiagToMainSuit(state, action);
        case GET_IS_FIRST:
            return getIsFirst(state, action);
        case CLEAR_ALL_DIAG:
            return clearAllDiag(state, action);
        case SET_CLICK_DIAG: 
            return setClickDiag(state, action);
        case SET_CHRONIC_MAG_ITEM:
            return setChronicMagItem(state, action);
        case SHOW_REFER_RECORD: 
            return showReferRecord(state, action);
        case HIDE_REFER_RECORD: 
        return hideReferRecord(state, action);
        case SHOW_HISTORY_CASE: 
            return showHistoryCase(state, action);
        case HIDE_HISTORY_CASE: 
        return hideHistoryCase(state, action);
        case CLEAR_DIAGNOSE: 
            res.mainSuitStr = "";
            return res;
        default:
            return state;
    }
}
