public IActionResult RxDrugSave(long?id) { ViewBag.FuncId = 19; var user = GetUserSelf(); var customers = _rxSvr.GetNeedAddCustomers(user.StationId, user.DoctorId); var customer = new RxUserViewModel(); if (id != null) { customer = _rxSvr.GetRxUser(id.Value, user.DoctorId); } if (customer.SendDrugMan.IsEmpty()) { customer.SendDrugMan = user.LoginExtName; } if (customer.SendTime == new DateTime()) { customer.SendTime = DateTime.Now; } if (customer.CheckTime == new DateTime()) { customer.CheckTime = DateTime.Now; } return(View(new RxDrugSaveViewModel { RxUserList = customers, NewRxUser = customer })); }
/// <summary> /// 编辑处方记录 /// </summary> /// <param name="rxSaveId"></param> /// <returns></returns> public IActionResult EditRxSave(long rxSaveId) { var u = GetUserSelf(); RxUserViewModel model = new RxUserViewModel { SendDrugMan = u.LoginExtName, SendTime = DateTime.Now, CheckTime = DateTime.Now }; if (rxSaveId == 0) { return(PartialView("_pvRxDrugSaveBase", model)); } return(PartialView("_pvRxDrugSaveBase", model)); }
public async Task <IActionResult> RxDrugSave(RxUserViewModel model) { var info = Ass.Data.Utils.GetIdCardInfo(model.CustomerIdCode); bool isNewUser = false; #region 输入检验 if (string.IsNullOrEmpty(model.CheckDrugMan)) { ModelState.AddModelError("CheckDrugMan", "审核人不能为空"); } if (model.CheckTime.Date < model.SendTime.Date) { ModelState.AddModelError("CheckTime", "审核日期不能早于发药日期"); } var u = GetUserSelf(); if (model.RxSaveId == 0) { isNewUser = true; //判断是否为已注册用户 if (model.CustomerId == 0) { var userCreated = _cusSvr.GetCustomersBy(model.CustomerIdCode).SingleOrDefault(); var newUser = await _cusSvr.CreateCustomerAsync( model.CustomerName, model.CustomerMobile, model.CustomerIdCode, sysSources.处方药记录快录, u.CustomerId, u.LoginExtName); model.CustomerId = newUser.CustomerID; } var newRx = new CHIS_DrugStore_RxSave( u.StationId, u.DoctorId, model.CustomerId, model.CustomerName, model.CustomerIdCode, model.CustomerMobile, Ass.Data.Utils.GetIdCardInfo(model.CustomerIdCode).GenderString, model.RxPicUrl1, model.RxPicUrl2, model.RxPicUrl3); newRx.SendDrugMan = u.LoginExtName; newRx.CheckDrugMan = model.CheckDrugMan; newRx.SendTime = model.SendTime; newRx.CheckTime = model.CheckTime; newRx.IsCompleted = true; model.RxSaveId = _rxSvr.SaveCustomer(newRx); _rxSvr.UpdateDrugsInfo(model.RxSaveId, model.RxSaveDrugsId); } var rxUser = _rxSvr.GetRxUser(model.RxSaveId, u.DoctorId); if (rxUser.DrugList == null || !rxUser.DrugList.Any()) { ModelState.AddModelError("DrugList", "处方药记录不能为空"); } if (!ModelState.IsValid) { var customers = _rxSvr.GetNeedAddCustomers(u.StationId, u.DoctorId); var customer = _rxSvr.GetRxUser(model.RxSaveId, u.DoctorId); if (customer != null) { return(View(new RxDrugSaveViewModel { RxUserList = customers, NewRxUser = customer })); } return(View(new RxDrugSaveViewModel { RxUserList = customers, NewRxUser = model })); } #endregion //非新用户直接update,使用ifelse有ef上下文问题 if (!isNewUser) { var rxModel = new CHIS_DrugStore_RxSave( u.StationId, u.DoctorId, model.CustomerId, model.CustomerName, model.CustomerIdCode, model.CustomerMobile, u.GenderText, model.RxPicUrl1, model.RxPicUrl2, model.RxPicUrl3); rxModel.SendDrugMan = u.LoginExtName; rxModel.CheckTime = model.CheckTime; rxModel.SendTime = model.SendTime; rxModel.CheckDrugMan = model.CheckDrugMan; rxModel.RxSaveId = model.RxSaveId; var res = _rxSvr.UpdateCustomerInfos(rxModel); if (res) { return(Redirect("~/Nurse/RxDrugSave")); } return(View("Error", new Exception("权限不足"))); } return(Redirect("~/Nurse/RxDrugSave")); }