import {json} from '@utils/ajax.js';
import {COMM_SYMPTOMS,SET_SEARCH,GET_BIGDATAPUSH} from '../types/mainSuit'
import {getEMRParams} from '@utils/tools';

const host = '/api/icss/';
const api = {
  'getCommSymptoms': '/questionUsual/getQuestionUsual',
  'symptomPush':'/push/pushInner',
}


export const getCommSymptoms = ()=>{//获取常见症状
  return (dispatch,getState)=>{
    const state = getState();
    const {message} = state.patInfo;
    //从state中拿到门诊号
    const deptCode = message.selfDeptId;
    const params = {
      'deptId':deptCode,
      'age':message.patientAge,
      'sexType':message.sex,
      'type':1
    };
    json(api.getCommSymptoms,params).then((res)=>{
        let result = res.data;
        if(+result.code == 0){
          let data = result.data;
          dispatch({
            type:COMM_SYMPTOMS,
            data:data
          })
        }else{
          console.log(result.msg);
        }
      
    })
  }
}


export async function getCommSymptomPush(){//获取大数据推送症状
      const type = 1;
      const emrData = getEMRParams();
      const params = {
        "age": emrData.age,
        "featureType": type,//类型1：症状，4：查体，5：化验，6：辅检，7：诊断
        "diag": emrData.dis,
        "lis": emrData.lis,
        "other": emrData.other,
        "pacs": emrData.pacs,
        "sex": emrData.sex,
        "symptom": emrData.current + emrData.main
      };
    const bigData = await json(api.symptomPush,params);
    return bigData;
}