Example #1
0
 public async Task <IActionResult> CustomerRegistDoctor(string regtype, string account)
 {
     return(await TryCatchFuncAsync(async() =>
     {
         if (account.IsEmpty())
         {
             throw new Exception("传入账号错误");
         }
         Models.CHIS_Code_Customer cus = null;
         if (regtype == "mobile")
         {
             var cusid = _db.CHIS_Sys_Login.FirstOrDefault(m => m.Mobile == account).CustomerId;
             cus = _db.CHIS_Code_Customer.Find(cusid);
         }
         else if (regtype == "email")
         {
             var cusid = _db.CHIS_Sys_Login.FirstOrDefault(m => m.Email == account).CustomerId;
             cus = _db.CHIS_Code_Customer.Find(cusid);
         }
         else
         {
             throw new Exception("不支持的注册方式");
         }
         if (cus == null)
         {
             throw new Exception("没有发现客户信息");
         }
         bool rlt = await new DoctorCBL(this).CustomerRegistDoctor(cus);
         return View("Regist_Success");
     }, bExceptionView : true, backLink : "/home/regist", backLinkName : "返回注册"));
 }
Example #2
0
        public Models.CHIS_Code_Customer GetOneCustomer(string idcard, string name, string mobile)
        {
            Models.CHIS_Code_Customer rtn = null;

            if (idcard.IsNotEmpty())
            {
                var finds    = _db.CHIS_Code_Customer.Where(m => m.IDcard == idcard).AsNoTracking();
                int findsNum = finds.Count();
                if (findsNum == 1)
                {
                    return(finds.FirstOrDefault());
                }
                if (findsNum > 1)
                {
                    throw new Exception($"该身份证[{idcard}]对应了多个用户,系统不允许");
                }
            }
            if (mobile.IsNotEmpty())
            {
                var finds    = _db.CHIS_Code_Customer.Where(m => m.Telephone == mobile).AsNoTracking();
                int findsNum = finds.Count();
                if (findsNum == 1)
                {
                    return(finds.FirstOrDefault());
                }
                if (findsNum > 1 && string.IsNullOrEmpty(name))
                {
                    throw new Exception($"手机号码[{mobile}]有多用户对应,但没有输入用户名");
                }

                if (findsNum > 1)
                {
                    var finds1    = _db.CHIS_Code_Customer.Where(m => m.Telephone == mobile && m.CustomerName == name).AsNoTracking();
                    int findsNum1 = finds1.Count();
                    if (findsNum1 == 1)
                    {
                        return(finds1.FirstOrDefault());
                    }
                    if (findsNum1 > 1)
                    {
                        throw new Exception($"用户{name}[{mobile}]注册了多个了,请联系后台管理员,调整您的用户信息");
                    }
                }
            }
            return(rtn);
        }
Example #3
0
        /// <summary>
        /// 根据挂号,获取一个就诊全信息
        /// </summary> `
        public Models.ViewModels.DoctorTreatViewModel GetNewTreatInfo(long?registerid, long?treatid)
        {
            var registerInfo = _db.CHIS_Register.FirstOrDefault(m => m.RegisterID == registerid);
            var treatmodel   = _db.CHIS_DoctorTreat.FirstOrDefault(m => m.TreatId == treatid);

            if (treatmodel == null)
            {
                treatmodel = _db.CHIS_DoctorTreat.FirstOrDefault(m => m.RegisterID == registerid);                    //保障接诊和挂号唯一
            }
            //如果必须要挂号,则在这里做判断
            // if (registerInfo == null) throw new Exception("没有发现挂号信息");

            //获取就诊人员信息
            Models.CHIS_Code_Customer cus = null;
            if (treatmodel != null)
            {
                cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.CustomerID == treatmodel.CustomerId);                    //如果已经接诊,则返回的是接诊的人员信息
            }
            else if (registerInfo != null)
            {
                cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.CustomerID == registerInfo.CustomerID);
            }
            else
            {
                throw new Exception("没有找到就诊人员信息");
            }
            //获取人员健康信息
            var cus_h = _db.CHIS_Code_Customer_HealthInfo.FirstOrDefault(m => m.CustomerId == cus.CustomerID);

            if (treatmodel != null && treatmodel.TreatStatus == 1) // 是在诊则重新设置时间
            {
                treatmodel.TreatTime = DateTime.Now;
                _db.SaveChanges();
            }

            //如果接诊信息为空,则初始化接诊信息 包括插入初始化接诊信息到数据库
            if (treatmodel == null)
            {
                treatmodel = _db.Add(new CHIS_DoctorTreat()
                {
                    Height         = cus_h?.Height,
                    Weight         = cus_h?.Weight,
                    TreatStatus    = 0,
                    CustomerId     = cus.CustomerID,
                    DoctorId       = CurrentOper.DoctorId,
                    RegisterID     = registerid,
                    StationId      = CurrentOper.StationId,
                    TreatTime      = DateTime.Now,
                    FirstTreatTime = DateTime.Now,
                    Department     = CurrentOper.SelectedDepartmentId
                }).Entity;
            }

            //设置人员健康的默认值
            if (!treatmodel.Height.HasValue)
            {
                treatmodel.Height = cus_h?.Height;
            }
            if (!treatmodel.Weight.HasValue)
            {
                treatmodel.Weight = cus_h?.Weight;
            }

            //一体机信息
            Models.CHIS_DataInput_OneMachine oneMachineData = null;
            if (treatid > 0)
            {
                oneMachineData = _db.CHIS_DataInput_OneMachine.Where(m => m.TreatId == treatid).AsNoTracking().FirstOrDefault();
            }

            //返回展示模型数据 包括 1挂号信息 2病人信息 3接诊信息
            return(new Models.ViewModels.DoctorTreatViewModel()
            {
                CustomerRegist = registerInfo,
                Customer = cus,
                CHIS_DoctorTreat = treatmodel,
                Doctor = _db.CHIS_Code_Doctor.FirstOrDefault(m => m.DoctorId == treatmodel.DoctorId),
                OneMachineData = oneMachineData,
                CustomerHealthInfo = _db.CHIS_Code_Customer_HealthInfo.AsNoTracking().FirstOrDefault(m => m.CustomerId == cus.CustomerID)
            });
        }
Example #4
0
        /// <summary>
        /// 注册医生基本信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool RegistDoctorBasic(CHIS.Models.ViewModel.CustomerRegistViewModel model)
        {
            if (model.RegistType == "mobile")
            {
                var find = _db.CHIS_DataTemp_SMS.AsNoTracking().Where(m => m.PhoneCode == model.Mobile && m.VCodeProp == null && m.CreatTime > DateTime.Today).OrderByDescending(m => m.CreatTime).FirstOrDefault();
                if (find == null)
                {
                    throw new Exception("没有找到短信验证码");
                }
                if (!string.Equals(find.VCode, model.VCode, StringComparison.CurrentCultureIgnoreCase))
                {
                    throw new Exception("验证码输入错误");
                }
            }
            if (model.RegistType == "email")
            {
                var find = _db.CHIS_DataTemp_SendMailVCode.AsNoTracking().Where(m => m.EmailAddress == model.Email && m.VCodeProp == null && m.CreatTime > DateTime.Today).OrderByDescending(m => m.CreatTime).FirstOrDefault();
                if (find == null)
                {
                    throw new Exception("没有找到邮件的验证码");
                }
                if (!string.Equals(find.VCode, model.VCode, StringComparison.CurrentCultureIgnoreCase))
                {
                    throw new Exception("验证码输入错误");
                }
            }

            if (model.RegPaswd != model.RegPaswdConfirm)
            {
                throw new Exception("注册密码与确认密码不一致");
            }
            if (model.RegistRole != "doctor")
            {
                throw new Exception("注册非医生");
            }

            _db.BeginTransaction();

            try
            {
                //----获取或者添加会员信息-------
                Models.CHIS_Code_Customer cus = null;
                if (model.RegistType == "mobile")
                {
                    cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.CustomerMobile == model.Mobile);
                }
                if (model.RegistType == "email")
                {
                    cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.Email == model.Email);
                }

                if (cus == null)
                {
                    var newcus = new Models.CHIS_Code_Customer
                    {
                        Email               = model.Email,
                        CustomerMobile      = model.Mobile,
                        CustomerCreateDate  = DateTime.Now, //创建时间
                        sysLatestActiveTime = DateTime.Now,
                        sysSource           = sysSources.医生注册.ToString()
                    };
                    newcus.NickName = newcus.CustomerName = "用户" + DateTime.Now.ToString("yyMMddHHmmssfff");
                    cus             = _db.Add(newcus).Entity;
                    _db.SaveChanges();
                }

                //----获取医生信息 -----------
                Models.CHIS_Code_Doctor doc = null;
                doc = _db.CHIS_Code_Doctor.FirstOrDefault(m => m.CustomerId == cus.CustomerID);
                if (doc == null)
                {
                    var docEntry = _db.Add(new Models.CHIS_Code_Doctor
                    {
                        CustomerId       = cus.CustomerID,
                        DoctorCreateTime = DateTime.Now,
                        IsEnable         = true
                    });
                    _db.SaveChanges();
                    doc = docEntry.Entity;
                }
                //--------------增加医生与工作站默认基本联系 网上平台测试站-------------
                new CHIS.Api.syshis(controller._db).UpsertDoctorStationRoles(doc.DoctorId, 6, new List <int> {
                    12
                });



                var login = new Models.CHIS_Sys_Login
                {
                    CustomerId    = cus.CustomerID,
                    DoctorId      = doc.DoctorId,
                    Email         = model.Email,
                    Mobile        = model.Mobile,
                    LoginPassword = model.RegPaswd,
                    IsLock        = false
                };
                if (model.RegistType == "email")
                {
                    login.EmailIsAuthenticated = true; login.EmailAuthenticatedTime = DateTime.Now;
                }
                if (model.RegistType == "mobile")
                {
                    login.MobileIsAuthenticated = true; login.MobileAuthenticatedTime = DateTime.Now;
                }
                var addEntry = _db.CHIS_Sys_Login.Add(login);
                _db.SaveChanges();
                //   tx.Rollback();
                _db.CommitTran();
                return(true);
            }
            catch (Exception ex) { _db.RollbackTran(); throw ex; }

            // return false;
        }