import {
  GET_PATIENT_MESSAGE,
  GET_HOSPITAL_MESSAGE,
  SETINITPATINFO,
  SETMEDICALNAME,
  CLEARMEDICALNAME,
  REINITPATINFO,
  CLEARINITPATINFO,
} from '../types/patInfo';
import {
  updatePatientMessage,
  updateHospitalMessage,
  setPatInfo,
  setMedicalName,
  clearMedicalName,
  reInitPatInfo,
} from '../actions/patInfo';
import { timesYMDTime } from '@utils/tools';

const initState = {
    message: {},
    hospitalMsg:{},
    patInfoData: [],  // 病历基本信息
    medicalName: '' //病历名称
};
export default function(state = initState,action){
  const res = Object.assign({}, state);
  switch (action.type) {
    case GET_PATIENT_MESSAGE:
      return updatePatientMessage(state, action);
    case GET_HOSPITAL_MESSAGE:
      return updateHospitalMessage(state, action);
    case SETINITPATINFO:
      return setPatInfo(state, action);
    case SETMEDICALNAME:
      return setMedicalName(state, action);
    case CLEARMEDICALNAME:
      return clearMedicalName(state, action);
    case REINITPATINFO:
      return reInitPatInfo(state, action);
    case CLEARINITPATINFO:
      res.patInfoData = [
        {
          label: 'patientIdNo',
          id: 'patientIdNo',
          value: '330127198912311234',
          title: '卡号',
        },
        {
          label: 'patientName',
          id: 'patientName',
          value: '王明明',
          title: '姓名',
        },
        {
          label: 'patientAge',
          id: 'patientAge',
          value: '50',
          title: '年龄',
        },
        {
          label: 'patientSex',
          id: 'patientSex',
          value: 2,
          title: '性别',
        },
        {
          label: 'systemTime',
          id: 'systemTime',
          value: timesYMDTime(new Date().getTime()),
          title: '就诊时间',
        },
        {
          label: 'hospitalDeptName',
          id: 'hospitalDeptName',
          value: '全科',
          title: '科室',
        },
        {
          label: 'doctorName',
          id: 'doctorName',
          value: '付医生',
          title: '医生',
        },
        {
          label: 'recordId',
          id: 'recordId',
          value: '4332',
          title: '门诊号',
        },
      ];
      return res;
    default:
      return state;
  }
};
