Ejemplo n.º 1
0
 public ServiceTaskController()
 {
     _user       = new UserInfoService();
     _event      = new UserEventBLL();
     _apply      = new DoctorControlBll();
     _service    = new ServiceTraceInfoService();
     _repository = new CancerUserInfoRepository();
     _member     = new MemberBLL();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取公共个人信息
        /// </summary>
        /// <param name="personid"></param>
        /// <returns></returns>
        public IHttpActionResult Get(string Uid)
        {
            IPersonInfoRepository    _personRepository = new EFPersonInfoRepository();
            CancerUserInfoRepository _repository       = new CancerUserInfoRepository();

            //申明返回
            HR_CNR_USER model = new HR_CNR_USER();

            try
            {
                model = _repository.FindOne(p => p.USERID == Uid);
                if (model != null)
                {
                    int personID = 0;
                    int.TryParse(model.PERSONID, out personID);
                    if (personID > 0)
                    {
                        var person = _personRepository.Get(personID);
                        if (person != null && person.BirthDate.Length > 4)
                        {
                            int birthDateYear = Convert.ToInt32(person.BirthDate.Substring(0, 4));
                            model.AGE = DateTime.Now.Year - birthDateYear + 1;
                            switch (person.Gender)
                            {
                            case "1":
                                model.SEX = "男";
                                break;

                            case "2":
                                model.SEX = "女";
                                break;

                            case "0":
                                model.SEX = "未知";
                                break;

                            default:
                                model.SEX = "其他";
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.ToString());
                return(BadRequest(ex.Message));
            }

            //返回
            return(Ok(model));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 发送用户待办通知
        /// </summary>
        private void SendEvent(string uid, string loginname)
        {
            string _appleID = Guid.NewGuid().ToString();


            DoctorControlBll dcbll     = new DoctorControlBll();
            UserApply        userApply = new UserApply();

            userApply.ID             = Guid.NewGuid().ToString();
            userApply.APPLYID        = _appleID;
            userApply.USERID         = uid;
            userApply.GUIDELINEID    = "1";
            userApply.STATUS         = "1";
            userApply.CREATEDATETIME = DateTime.Now;
            userApply.ISDELETED      = false;

            dcbll.Add(userApply);

            UserEvent userEvent = new UserEvent();

            userEvent.FromUser     = "";
            userEvent.UserApplyId  = userApply.ID;
            userEvent.ActionType   = ((int)ActionType.待办事项).ToString();
            userEvent.ActionInfo   = "您已注册成功,请上传您的病历资料";
            userEvent.ReceiptTime  = DateTime.Now;
            userEvent.ActionStatus = ((int)ActionStatus.Progress).ToString();
            userEvent.ToUser       = uid;
            userEvent.CreateTime   = DateTime.Now;
            userEvent.LinkUrl      = "ViewUpload";

            UserEventBLL userEventBLL = new UserEventBLL();

            userEventBLL.Add(userEvent);

            CancerUserInfoRepository cancerUserRepository = new CancerUserInfoRepository();
            HR_CNR_USER cnr_User = new HR_CNR_USER();

            cnr_User.CREATTIME = DateTime.Now;
            cnr_User.USERID    = uid;
            cnr_User.NAME      = loginname;
            cancerUserRepository.Insert(cnr_User);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取该医生下的患者列表
        /// </summary>
        public List <UserApply> GetPersonList(PageInfo page, string keyWord)
        {
            List <UserApply> list = new List <UserApply>();

            using (var context = new CRDatabase())
            {
                CancerUserInfoRepository repository = new CancerUserInfoRepository();
                var userlist = repository.FindAll().ToList();

                (from user in userlist
                 join userapply in context.CTMS_USERAPPLY on user.USERID equals userapply.USERID
                 where (string.IsNullOrEmpty(keyWord) || user.USERNAME.Contains(keyWord))
                 select
                 new
                {
                    ID = userapply.APPLYID,
                    USERID = user.USERID,
                    NAME = user.USERNAME,
                    CURRENTNODE = userapply.CURRENTNODE,
                    ENTRYDATE = userapply.ENTRYDATE,
                    EXITDATE = userapply.EXITDATE
                }
                ).Skip((page.PageIndex - 1) * page.PageSize).Take(page.PageSize)
                .ToList().ForEach(p =>
                {
                    var firstOrDefault = context.CTMS_GUIDELINE.FirstOrDefault(k => k.ID == p.CURRENTNODE);
                    list.Add(new UserApply()
                    {
                        //ID = p.ID,
                        USERID      = p.USERID,
                        Name        = p.NAME,
                        CurrentName = firstOrDefault == null ? "" : firstOrDefault.NAME,
                        CURRENTNODE = p.CURRENTNODE,
                        ENTRYDATE   = p.ENTRYDATE,
                        EXITDATE    = p.EXITDATE
                    });
                });

                //(from user in userlist
                //    join userapply in context.CTMS_USERAPPLY on user.USERID equals userapply.USERID into temp
                //    from tt in temp.DefaultIfEmpty()
                //    where ( string.IsNullOrEmpty(keyWord) || user.NAME.Contains(keyWord))
                //    select
                //        new
                //        {
                //            ID=tt==null?"":tt.ID,
                //            USERID = user.USERID,
                //            NAME = user.NAME,
                //            CURRENTNODE = tt == null ? "" : tt.CURRENTNODE,
                //            ENTRYDATE = tt == null ? null : tt.ENTRYDATE,
                //            EXITDATE = tt == null ? null : tt.EXITDATE
                //        }
                //    ).Skip((page.PageIndex - 1)*page.PageSize).Take(page.PageSize)
                //    .ToList().ForEach(p =>
                //    {
                //        var firstOrDefault = context.CTMS_GUIDELINE.FirstOrDefault(k => k.ID == p.CURRENTNODE);

                //            list.Add(new UserApply()
                //            {
                //                ID = p.ID,
                //                USERID = p.USERID,
                //                Name = p.NAME,
                //                CurrentName = firstOrDefault==null?"":firstOrDefault.NAME,
                //            CURRENTNODE = p.CURRENTNODE,
                //                ENTRYDATE = p.ENTRYDATE,
                //                EXITDATE = p.EXITDATE
                //            });
                //    });
            }
            return(list);
        }
Ejemplo n.º 5
0
        public bool SaveUserApply(UserApply model)
        {
            using (var context = new CRDatabase())
            {
                //根据model的NextCurrentNode字段来判断是否有选择
                //if (model.NextCurrentNode == "") //当为空的时候,默认就更新几个字段
                //{
                //    var entity = context.CTMS_USERAPPLY.FirstOrDefault(p => p.APPLYID == oldApplyId);
                //    entity.DOCTORSUGGEST = model.DOCTORSUGGEST;
                //    return context.SaveChanges() > 0;
                //}
                //else
                //{
                UserInfo currentUser = new UserInfoService().GetCurrentUser();

                UserEventBLL ueBll   = new UserEventBLL();
                UserEvent    ueModel = new UserEvent();

                UserEvent oldEvent = ueBll.Get(p => p.EVENTID == model.EventId);

                //更新原先的待办信息
                ueBll.CloseEvent(model.EventId);

                var entity = context.CTMS_USERAPPLY.FirstOrDefault(p => p.APPLYID == model.APPLYID);
                entity.STATUS = ((int)ActionStatus.Complete).ToString();

                var addModel = new CTMS_USERAPPLY();
                addModel.ID            = Guid.NewGuid().ToString();
                addModel.APPLYID       = model.APPLYID;
                addModel.USERID        = entity.USERID;
                addModel.GUIDELINEID   = entity.GUIDELINEID;
                addModel.CURRENTNODE   = model.NextCurrentNode;
                addModel.STATUS        = ((int)ActionStatus.Progress).ToString();
                addModel.DOCTORSUGGEST = model.DOCTORSUGGEST;
                addModel.ENTRYDATE     = model.ENTRYDATE;
                addModel.EXITDATE      = model.EXITDATE;
                addModel.ISDELETED     = false;

                context.CTMS_USERAPPLY.Add(addModel);

                //发送待办任务
                CancerUserInfoRepository _repository = new CancerUserInfoRepository();
                HR_CNR_USER user = _repository.FindOne(p => p.USERID == entity.USERID);
                ueModel.EventID = Guid.NewGuid().ToString();
                string userEventId = ueModel.EventID;
                ueModel.UserApplyId  = addModel.ID;
                ueModel.ActionType   = "1";
                ueModel.ActionInfo   = "您收到了Doc医生的建议,请查看";// + model.NextCurrentNodeName;
                ueModel.ReceiptTime  = System.DateTime.Now;
                ueModel.ActionStatus = ((int)ActionStatus.Progress).ToString();
                ueModel.FromUser     = currentUser.UserId;
                ueModel.ToUser       = entity.USERID;
                ueModel.CreateTime   = System.DateTime.Now;
                ueModel.LinkUrl      = "DoTreatmentView"; //用户待办界面
                ueModel.ModelId      = oldEvent.ModelId;

                ueBll.AddUserEvent(ueModel);

                #region 推荐产品与待办关联
                string _guidID = model.NextCurrentNode == "" ? model.CURRENTNODE : model.NextCurrentNode;
                GuidelineProductBLL            gpBLL    = new GuidelineProductBLL();
                IEnumerable <GuidelineProduct> products = gpBLL.GetList(p => p.GUIDELINEID.Equals(_guidID));
                EventProductBLL epdBLL = new EventProductBLL();
                foreach (GuidelineProduct item in products)
                {
                    EventProduct eventProduct = new EventProduct();
                    eventProduct.EventId      = ueModel.EventID;
                    eventProduct.ProductID    = item.ProductId;
                    eventProduct.ProductName  = item.ProductName;
                    eventProduct.ProductPrice = item.ProductPrice;
                    eventProduct.ProductDes   = item.Productdes;
                    eventProduct.IsAlreadyBuy = "0";

                    epdBLL.Add(eventProduct);
                }
                #endregion

                #region 发送客服待办
                ueModel              = new UserEvent();
                ueModel.EventID      = Guid.NewGuid().ToString();
                ueModel.UserApplyId  = addModel.ID;
                ueModel.ActionType   = "1";
                ueModel.ActionInfo   = string.Format("{0}收到了{1}对于病例的处理建议,请跟踪", user.USERNAME, currentUser.LoginName);
                ueModel.ReceiptTime  = System.DateTime.Now;
                ueModel.ActionStatus = ((int)ActionStatus.Progress).ToString();
                ueModel.FromUser     = currentUser.UserId;
                var toUserId = context.CTMS_SYS_USERINFO.FirstOrDefault(p => p.USERTYPE == (decimal)UserType.客服);
                ueModel.ToUser     = toUserId.USERID;
                ueModel.CreateTime = System.DateTime.Now;
                ueModel.LinkUrl    = "ServiceTask"; //客服待办
                ueModel.Remarks    = userEventId;
                ueModel.ModelId    = oldEvent.ModelId;
                ueBll.AddUserEvent(ueModel);
                #endregion

                return(context.SaveChanges() > 0);
                //}
            }
        }
Ejemplo n.º 6
0
        public IHttpActionResult Post([FromBody] Request <PersonInfo> request)
        {
            Response <PersonInfo> response = new Response <PersonInfo>();

            try
            {
                using (EFPersonInfoRepository repository = new EFPersonInfoRepository())
                {
                    PersonInfo model = request.Data as PersonInfo;
                    if (model == null)
                    {
                        return(NotFound());
                    }
                    if (string.IsNullOrEmpty(model.PersonNo))
                    {
                        model.PersonNo = model.IDNumber;
                    }
                    if (model.PersonId <= 0)
                    {
                        int ID = repository.Add(model);
                        model.PersonId = ID;
                        if (!string.IsNullOrEmpty(request.Keyword))
                        {
                            CancerUserInfoRepository cancerUserRepository = new CancerUserInfoRepository();
                            HR_CNR_USER cancerUser = cancerUserRepository.Find(request.Keyword);
                            if (cancerUser != null)
                            {
                                cancerUser.PERSONID = ID.ToString();
                                cancerUserRepository.Update(cancerUser);
                            }
                        }
                    }
                    else
                    {
                        bool isEditSuccess = repository.Edit(model);
                    }
                    response.Data = model;
                    return(Ok(response));
                }
            }
            catch (DbEntityValidationException ex)
            {
                StringBuilder errors = new StringBuilder();
                IEnumerable <DbEntityValidationResult> validationResult = ex.EntityValidationErrors;
                foreach (DbEntityValidationResult result in validationResult)
                {
                    ICollection <DbValidationError> validationError = result.ValidationErrors;
                    foreach (DbValidationError err in validationError)
                    {
                        errors.Append(err.PropertyName + ":" + err.ErrorMessage + "\r\n");
                    }
                }
                string errMsg = errors.ToString();
                LogService.WriteErrorLog("GeneDicGeneController[Post]", errMsg);
                return(BadRequest(errMsg));
                //简写
                //var validerr = ex.EntityValidationErrors.First().ValidationErrors.First();
                //Console.WriteLine(validerr.PropertyName + ":" + validerr.ErrorMessage);
            }
            catch (Exception ex)
            {
                LogService.WriteErrorLog("GeneDicGeneController[Post]", ex.ToString());
                return(BadRequest(ex.Message));
            }
        }