import React from 'react';
import { connect } from 'react-redux';
import DiagnosticItem from '@components/DiagnosticItem';
import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR } from '@store/types/diagnosticList'; 
import {  SHOW_SEARCH,  HIDE_SEARCH,HIDE_TCM_SEARCH, SET_SEARCH_VALUE } from '@store/types/diagnosticSearch';
import { isChronicMag, isAddMainSuit } from'@store/async-actions/diagnosticList.js';
import { addDiagnostic } from '@store/async-actions/treat';
import { getSearchResult } from '@store/async-actions/diagnosticSearch';
import {billing, getConceptDetail} from '../store/async-actions/pushMessage';


function mapStateToProps(state) {
    return {
        diagnosticList: state.diagnosticList.diagnosticList,
        tcmList: state.diagnosticList.tcmList,
        symList: state.diagnosticList.symList,
        mode:state.typeConfig.mode,
        EMRScrollCont:state.inspect.context.scrollArea,             //滚动条对象
    }
}

function mapDispatchToProps(dispatch) {
    return{
        addDiagnostic: (item,isTcm,showSym) => {
            
            dispatch({
                type: ADD_DIAGNOSTIC,
                item: item,
                isTcm,
                isSym:showSym,      //是否是中医症候
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR,
                isTcm
            });
            dispatch(isAddMainSuit())
        },
        showSearch:()=>{
            dispatch({
                type: SHOW_SEARCH
            })
        },
        hideSearch:()=>{
            dispatch({
                type: HIDE_SEARCH
            })
            dispatch({
                type: HIDE_TCM_SEARCH
            })
            dispatch({
                type: 'SHOW_SYM_SEARCH',
                show:false
            })
        },
        getTips: (diagItem) => {
            dispatch(getConceptDetail(diagItem))
        },
        isChronicMag: (item) =>{
            dispatch(isChronicMag(item))
        }
    }
}

const DiagnosticItemContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(DiagnosticItem);

export default DiagnosticItemContainer;