public IHttpActionResult Get([FromUri] Request <HR_CNR_USER> request) { Response <IEnumerable <object> > response = new Response <IEnumerable <object> >(); try { var model = _repository.FindAll(); if (model == null) { return(NotFound()); } if (!string.IsNullOrEmpty(request.Keyword)) { model = model.Where(o => o.IDCARD.Equals(request.Keyword)); } if (!string.IsNullOrEmpty(request.UserName)) { model = model.Where(o => o.NAME.Contains(request.UserName)); } UserInfo user = new UserInfoService().GetCurrentUser(); if (user == null) { return(BadRequest("获取不到当前用户信息!")); } ArrayList args = new ArrayList(); string filterString = new RoleFunctionBLL().GetFilterString(user.UserId, "HR_CNR_USER", PermissionType.View, ref args); model = model.where (filterString, args.ToArray()); List <HR_CNR_USER> list = model.ToList(); for (int i = 0; i < list.Count; i++) { HR_CNR_USER entity = list[i]; PersonInfo person = null; if (!string.IsNullOrEmpty(entity.PERSONID)) { int personID = 0; int.TryParse(entity.PERSONID, out personID); if (personID > 0) { person = personRepostitory.Get(personID); } } else if (!string.IsNullOrEmpty(entity.IDCARD)) { person = personRepostitory.Get(entity.IDCARD); } if (person != null) { if (person.BirthDate.Length <= 4) { continue; } int birthDateYear = Convert.ToInt32(person.BirthDate.Substring(0, 4)); entity.AGE = DateTime.Now.Year - birthDateYear + 1; switch (person.Gender) { case "1": entity.SEX = "男"; break; case "2": entity.SEX = "女"; break; case "0": entity.SEX = "未知"; break; default: entity.SEX = "其他"; break; } } } response.Data = list; return(Ok(response)); } catch (Exception ex) { LogHelper.WriteError(ex.ToString()); return(BadRequest(ex.Message)); } }
/// <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); }