/// <summary> /// 查询服药历史信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public IActionResult GetDrugOrdersHistory([FromBody] GetDrugOrdersHistoryInput input) { if (string.IsNullOrEmpty(input.patientId)) { return(BadRequest("患者主键未传值")); } var startDate = input.startDate.ToDate().Date; var endDate = input.endDate.ToDate().AddDays(1).Date; var sourse = _ordersExecLogApp.GetList(input.patientId, input.keyword, input.startDate.ToDate(), input.endDate.ToDate()) .Where(t => t.F_OrderType.Equals("药疗")) .OrderByDescending(t => t.F_NurseOperatorTime) .Select(t => new { t.F_Id, t.F_NurseOperatorTime, t.F_OrderText, t.F_OrderAmount, t.F_OrderUnitSpec, t.F_OrderFrequency, t.F_OrderAdministration, t.F_IsTemporary, t.F_Memo, t.F_Doctor, t.F_DoctorAuditTime, t.F_Nurse, t.F_NurseId, t.F_Oid }) .ToList(); var list = sourse.Select(t => new { id = t.F_Id, exexDate = t.F_NurseOperatorTime.ToDate().Date, execTime = t.F_NurseOperatorTime, orderText = t.F_OrderText, amount = t.F_OrderAmount, unit = t.F_OrderUnitSpec, frequency = t.F_OrderFrequency, administration = t.F_OrderAdministration, isTemporary = t.F_IsTemporary, memo = t.F_Memo, doctorName = t.F_Doctor, doctorAuditTime = t.F_DoctorAuditTime, nurseName = t.F_Nurse, nurseId = t.F_NurseId, orderId = t.F_Oid }); var data = list.GroupBy(t => t.exexDate).Select(t => new { key = t.Key, items = t.OrderByDescending(m => m.execTime) }).OrderByDescending(t => t.key) ; return(Ok(data)); }
/// <summary> /// 患者-透析历史记录 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> GetBrieflyList(GetBrieflyListInput input) { var query = _patVisitApp.GetList() .Where(t => t.F_Pid == input.keyValue && t.F_DialysisEndTime != null && t.F_VisitDate >= input.startDate.Date && t.F_VisitDate <= input.endDate.Date); if (input.dialysisType != null) { query = query.Where(t => t.F_DialysisType.Equals(input.dialysisType)); } var list = query .OrderByDescending(t => t.F_VisitDate) .Take(50) .Select(t => new { t.F_Id, t.F_VisitDate, t.F_VisitNo, t.F_GroupName, t.F_DialysisBedNo, t.F_DialysisType, t.F_DialysisStartTime, t.F_DialysisEndTime, t.F_VascularAccess, t.F_AccessName, t.F_DialyzerType1, t.F_HeparinType, t.F_HeparinAmount, t.F_HeparinUnit, t.F_HeparinAddAmount, t.F_HeparinAddSpeedUnit, t.F_WeightTQ, t.F_WeightTH, t.F_WeightYT, t.F_WeightST }) .ToList() .Select(t => new { id = t.F_Id, monthDesc = t.F_VisitDate.ToDateString().Substring(0, 7), visitDate = t.F_VisitDate.ToDate(), visitNo = t.F_VisitNo.ToInt(), groupName = t.F_GroupName, bedNo = t.F_DialysisBedNo, dialysisType = t.F_DialysisType, dialysisStartTime = t.F_DialysisStartTime.ToDate(), dialysisEndTime = t.F_DialysisEndTime.ToDate(), startTimeStr = t.F_DialysisStartTime == null ? "" : t.F_DialysisStartTime.ToTimeString(true), endTimeStr = t.F_DialysisEndTime == null ? "" : t.F_DialysisEndTime.ToTimeString(true), vascularAccess = t.F_VascularAccess, accessName = t.F_AccessName, dialyzerType = t.F_DialysisType, heparinType = t.F_HeparinType, heparinAmount = t.F_HeparinAmount, heparinUnit = t.F_HeparinUnit, heparinAddAmount = t.F_HeparinAddAmount, heparinAddSpeedUnit = t.F_HeparinAddSpeedUnit, weightYT = t.F_WeightYT.ToFloat(2), weightTQ = t.F_WeightTQ.ToFloat(2), weightTH = t.F_WeightTH.ToFloat(2), weightST = t.F_WeightST.ToFloat(2) }) .ToList(); //查询药物医嘱执行记录 var orderList = await _ordersExecLogApp.GetList(input.keyValue, input.startDate.Date, input.endDate.Date.AddDays(1)); //存储肝素、透析器字典 Hashtable table = new Hashtable(); var months = list.Select(t => t.monthDesc).Distinct().OrderByDescending(t => t); var data = new List <GetBrieflyListOutput>(); foreach (var month in months) { var find = list.Where(t => t.monthDesc.Equals(month)).ToArray(); var output = new GetBrieflyListOutput { monthDesc = month, count = find.Count() }; foreach (var item in find) { if (item.heparinType != null && !table.ContainsKey(item.heparinType)) { var drug = await _drugsApp.GetForm(item.heparinType); table.Add(item.heparinType, drug?.F_DrugName); } if (item.dialyzerType != null && !table.ContainsKey(item.dialyzerType)) { var m = await _materialApp.GetForm(item.dialyzerType); table.Add(item.dialyzerType, m?.F_MaterialName); } var brieflyItem = new BrieflyItem { id = item.id, visitDate = item.visitDate, visitNo = item.visitNo, groupName = item.groupName, bedNo = item.groupName, dialysisType = item.dialysisType, dialysisStartTime = item.dialysisStartTime, dialysisEndTime = item.dialysisEndTime, startTimeStr = item.startTimeStr, endTimeStr = item.endTimeStr, vascularAccess = item.vascularAccess, accessName = item.accessName, dialyzerType = item.dialyzerType == null ? "" : table[item.dialyzerType] + "", heparinType = item.heparinType == null ? "" : table[item.heparinType] + "", heparinAmount = item.heparinAmount ?? 0, heparinUnit = item.heparinUnit, heparinAddAmount = item.heparinAddAmount ?? 0, heparinAddSpeedUnit = item.heparinAddSpeedUnit, weightYT = item.weightYT, weightTQ = item.weightTQ, weightTH = item.weightTH, weightST = item.weightST }; var filterOrders = orderList.Where(t => t.F_NurseOperatorTime >= item.visitDate && t.F_NurseOperatorTime <= item.visitDate.AddDays(1)); foreach (var child in filterOrders) { brieflyItem.orders.Add(new DrugOrderItem { drugName = child.F_OrderText, drugAmount = child.F_OrderAmount.ToFloat(2), drugUnit = child.F_OrderUnitSpec }); } output.items.Add(brieflyItem); } data.Add(output); } return(Ok(data)); }