/// <summary> /// 该挂号信息包含的药物种类需计数为-1的药品种类集合. /// </summary> /// <param name="startTime">The start time.</param> /// <param name="endTime">The end time.</param> /// <returns>List<System.String>.</returns> internal List <int> DrugCategoryNumberNegativeList(DateTime startTime, DateTime endTime, EnumDrugCategory drugCategory) { List <int> result = new List <int>(); //并且获取在endTime之前的基本药物种类总金额 >0的集合 try { //outDate小于startTime,才需要判断是否有负数 if (this.OutDate.HasValue && this.OutDate < startTime) { var preStartTimeList = this.InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.InDate, startTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) > 0).Select(s => s.Key).ToList(); var preEndTimeList = InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.InDate, endTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) == 0).Select(s => s.Key).ToList(); //preStartTimeList preEndTimeList 的交集,即为该挂号信息中有效的药品种类 if (preStartTimeList.Count > 0 && preEndTimeList.Count > 0) { result = preEndTimeList.Intersect(preEndTimeList).ToList(); } } } catch (Exception e) { throw new InvalidOperationException(String.Format("数据操作出错! {0}", e.Message)); } return(result); }
/// <summary> /// 该住院病例信息包含的药物种类需计数为+1的药品种类集合. /// </summary> /// <param name="startTime">The start time.</param> /// <param name="endTime">The end time.</param> /// <returns>List<System.String>.</returns> /// <remarks> /// outDate在startTime之前的情况,获取preStartTimeList中的时间为InDate到startTime /// outDate在取定时间段内的情况,preStartTimeList = 0 /// </remarks> internal List <int> DrugCategoryNumberPositiveList(DateTime startTime, DateTime endTime, EnumDrugCategory drugCategory) { var result = new List <int>(); var preStartTimeList = new List <int>(); var preEndTimeList = new List <int>(); var preStartTimeGreaterZeroList = new List <int>(); //获取在startTime之前的基本药物种类总金额==0的集合, //并且获取在endTime之前的基本药物种类总金额 >0的集合 try { if (this.OutDate.HasValue && this.OutDate.Value >= startTime) { preEndTimeList = InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.InDate, endTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) > 0).Select(s => s.Key).ToList(); } else if (this.OutDate.HasValue && this.OutDate.Value < startTime) { preStartTimeList = this.InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.InDate, startTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) == 0).Select(s => s.Key).ToList(); preStartTimeGreaterZeroList = InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.OutDate.Value, startTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) > 0).Select(s => s.Key).ToList(); preEndTimeList = InPatientDrugRecords.Select(opp => opp.GetDrugCategoryMessage(this.OutDate.Value, endTime, drugCategory)).ToList() .GroupBy(g => g.ProductID).Where(w => w.Sum(su => su.Cost) > 0).Select(s => s.Key).ToList(); } //preStartTimeList preEndTimeList 的交集,即为该挂号信息中有效的药品种类 if (preStartTimeGreaterZeroList.Count > 0 && preEndTimeList.Count > 0) { //preStartTimeGreaterZeroList为在startTime之前总费用大于0,但在preEndTimeList中总费用也大于0,计数为0。 //返回空,计数0 } else if (preStartTimeList.Count > 0 && preEndTimeList.Count > 0) { //如果preStartTimeList result = preEndTimeList.Intersect(preEndTimeList).ToList(); } else if (preStartTimeList.Count == 0 && preEndTimeList.Count > 0) { result = preEndTimeList; } } catch (Exception e) { throw new InvalidOperationException(String.Format("数据操作出错! {0}", e.Message)); } return(result); }