/// <summary> /// 获取咨询我的记录 /// <param name="doctorUid"></param> /// <param name="MemberName"></param> /// <param name="PageSize"></param> /// <param name="CurrentPage"></param> /// <param name="Status"></param> /// <param name="BeginDate"></param> /// <param name="EndDate"></param> /// <param name="OPDType">预约类型(0-挂号、1-图文、2-语音、3-视频,-1-不区分类型)</param> /// <returns></returns> public PagedList <ResponseTaskDTO> GetTaskList(RequestQueryTaskDTO request) { return(userOPDRegisterRepository.GetTaskList(request)); }
public ApiResult GetTaskList(RequestQueryTaskDTO request) { return(doctorTaskService.GetTaskList(request).ToApiResultForList()); }
/// <summary> /// 获取咨询我的记录 /// </summary> /// <param name="request"></param> /// <param name="db"></param> /// <returns></returns> public PagedList <ResponseTaskDTO> GetTaskList(RequestQueryTaskDTO request, DBEntities db = null) { PagedList <ResponseTaskDTO> response = new PagedList <ResponseTaskDTO>(); bool dbPrivateFlag = false; if (db == null) { db = CreateDb(); dbPrivateFlag = true; } //查询预约患者,不显示已就诊的患者 //TODO:待优化成存储过程 IQueryable <ResponseTaskDTO> query = null; query = from opd in db.UserOPDRegisters.Where(a => !a.IsDeleted).Where(a => a.DoctorID == request.DoctorID) join room in db.ConversationRooms.Where(a => !a.IsDeleted) on opd.OPDRegisterID equals room.ServiceID join uid in db.ConversationIMUids on opd.UserID equals uid.UserID into leftJoinUid from uidIfEmpty in leftJoinUid.DefaultIfEmpty() join message in db.ConversationMessages.GroupBy(a => a.ConversationRoomID) on room.ConversationRoomID equals message.Key into leftJoinMessage from messageIfEmpty in leftJoinMessage.DefaultIfEmpty() //orderby //房间状态 -1 其它,0 未就诊,1 候诊中,2 就诊中,3 已就诊,4 呼叫中,5 离开中,6 断开连接 //房间状态排序:呼叫中、就诊中、候诊中、未就诊、(其他状态) //((int)room.RoomState >= 0 && (int)room.RoomState <= 2 ? (int)room.RoomState : -1) descending, //room.Priority ascending, //room.TriageID ascending select new ResponseTaskDTO { RegDate = opd.RegDate, OPDDate = opd.OPDDate, ConsultContent = opd.ConsultContent, Address = opd.Address, Age = opd.Age, Birthday = opd.Birthday, DoctorID = opd.DoctorID, DoctorName = opd.DoctorName, Gender = opd.Gender, IDNumber = opd.IDNumber, IDType = opd.IDType, Marriage = opd.Marriage, MemberID = opd.MemberID, MemberName = opd.MemberName, Mobile = opd.Mobile, OPDRegisterID = opd.OPDRegisterID, RoomState = room.RoomState, OPDType = opd.OPDType, UserID = opd.UserID, MedicalCardNumber = opd.MedicalCardNumber, PayTime = opd.PayTime, Priority = room.Priority, ChannelID = room.ConversationRoomID, TriageID = room.TriageID }; if (request.OrderType.HasValue) { switch (request.OrderType.Value) { case EnumRecordOrderType.OPDDate: query = query.OrderByDescending(x => x.OPDDate); break; case EnumRecordOrderType.OrderTime: query = query.OrderByDescending(x => x.PayTime); break; } } else { query = query.OrderByDescending(x => (int)x.RoomState >= 0 && (int)x.RoomState <= 2 ? (int)x.RoomState : -1). ThenBy(x => x.Priority).ThenBy(x => x.TriageID); } //开始日期 if (!string.IsNullOrEmpty(request.BeginDate)) { DateTime beginTime = Convert.ToDateTime(request.BeginDate + " 00:00:00"); query = query.Where(opd => opd.OPDDate >= beginTime); } if (!string.IsNullOrEmpty(request.EndDate)) { DateTime endTime = Convert.ToDateTime(request.EndDate + " 23:59:59"); query = query.Where(opd => opd.OPDDate <= endTime); } //房间状态 if (request.RoomState != null && request.RoomState.Count > 0) { query = query.Where(opd => request.RoomState.Contains(opd.RoomState)); } //服务类型 if (request.OPDType != null && request.OPDType.Count > 0) { query = query.Where(opd => request.OPDType.Contains(opd.OPDType)); } //会员编号 if (!string.IsNullOrEmpty(request.MemberID)) { query = query.Where(opd => opd.MemberID == request.MemberID); } //关键字 if (!string.IsNullOrEmpty(request.Keyword)) { if (request.ResponseFilters.Count <= 0) { query = query.Where(opd => opd.MemberName.Contains(request.Keyword) || opd.MedicalCardNumber.Contains(request.Keyword)); } else { query = query.Where(opd => opd.MemberName.Contains(request.Keyword)); } } response = query.ToPagedList(request.CurrentPage, request.PageSize); // 合并是否已开处方的状态 //if (request.IncludeDiagnoseStatus.HasValue && request.IncludeDiagnoseStatus.Value) //{ // List<string> medicalRecords = db.UserMedicalRecords.Where(x => opdRegisterIDs.Contains(x.OPDRegisterID)).Select(x => x.OPDRegisterID).ToList(); // response.Data.Where(x => medicalRecords.Contains(x.Room.ServiceID)).ToList().ForEach(x => // { // x.IsDiagnosed = true; // }); //} // 合并已签名处方数 //if (request.IncludeRecipeSignedCount.HasValue && request.IncludeRecipeSignedCount.Value) //{ // var recipeFiles = db.DoctorRecipeFiles.Where(x => // opdRegisterIDs.Contains(x.OPDRegisterID) && x.RecipeFileStatus == EnumRecipeFileStatus.Signed).GroupBy(x => x.OPDRegisterID).Select(x => new // { // OPDRegisterID = x.Key, // RecipeSignedCount = x.Count() // }).ToList(); // var ids = recipeFiles.Select(x => x.OPDRegisterID).ToList(); // response.Data = (from data in response.Data // join recipe in recipeFiles on data.Room.ServiceID equals recipe.OPDRegisterID into recipeLeftJoin // from recipeIfEmpty in recipeLeftJoin.DefaultIfEmpty() // select new // { // Data = data, // RecipeSignedCount = recipeIfEmpty == null ? 0 : recipeIfEmpty.RecipeSignedCount // }).Select(x => // { // x.Data.RecipeSignedCount = x.RecipeSignedCount; // return x.Data; // }).ToList(); //} if (dbPrivateFlag) { db.Dispose(); } return(response); }