import { timesYMDTime } from '@utils/tools';
export const updatePatientMessage=(state,action)=>{
    const res=Object.assign({},state);
    // const mock = {
      // doctorCode: "YS001",
      // doctorId: 1,
      // doctorName: "付",
      // hospitalCode: "A001",
      // hospitalDeptCode: "D01",
      // hospitalDeptId: 1,
      // hospitalDeptName: "全科",
      // hospitalId: 1,
      // hospitalName: "浙二医院",
      // modeClassify: 0,
      // modeValue: 1,
      // patientAge: 25,
      // patientCode: "1600",
      // patientId: 1,
      // patientIdNo: "9696969",
      // patientName: "沈强",
      // patientSex: "女",
      // recordId: "44",
      // selfDeptId: 5,
      // systemTime: "2018-12-20 11:52",
      // idNo: "9696969",
      // name: "沈强",
      // sex: 2
    // };
    res.message = action.data;
    /*if(!action.data.selfDeptId){    //selfDeptId这个参数是跟外部对接用的
        res.message = {};
    }*/
    return res;
};
export const updateHospitalMessage=(state,action)=>{
    const res=Object.assign({},state);
    let tmpObj = {
      lis:{},
      pacs:{},
      connect:{}
    };
    for(let i = 0;i < action.data.length;i++){
      if(action.data[i].code == 'import_way_lis'){//检验数据
        tmpObj.lis=action.data[i]
      }else if(action.data[i].code == 'import_way_pacs'){//检查数据
        tmpObj.pacs=action.data[i]
      }else if(action.data[i].code == 'connect'){//是否对接
        tmpObj.connect=action.data[i]
      }
    }
    res.hospitalMsg = tmpObj || {};
    return res;
};

// 获取设置病历信息
export const setPatInfo = (state,action) => {
  const res = Object.assign({}, state);
  res.patInfoData = action.params
  return res
}

// 设置病历名称
export const setMedicalName = (state, action) => {
  const res = Object.assign({}, state);
  res.medicalName = action.params
  return res
}

// clearMedicalName
export const clearMedicalName = (state, action) => {
  const res = Object.assign({}, state);
  res.medicalName = ''
  return res
}

// reInitPatInfo
export const reInitPatInfo = (state, action) => {
  const res = Object.assign({}, state);
  console.log(action.params, 'action.params');
  res.patInfoData[0].value = action.params && action.params.cardNo;
  res.patInfoData[1].value = action.params && action.params.patName;
  res.patInfoData[2].value = action.params && action.params.age;
  res.patInfoData[3].value = action.params && action.params.sex;
  // res.patInfoData[4].value = action.params && action.params.inquiryDate;   //2020/9/14
  res.patInfoData[4].value = timesYMDTime(new Date().getTime());  
  res.patInfoData[5].value = action.params && action.params.deptName;
  res.patInfoData[6].value = action.params && action.params.doctorName;
  res.patInfoData[7].value = action.params && action.params.inquiryCode;
  return res;
};