Ejemplo n.º 1
0
        public List <DrugTopRank> GetDrugTopRankList(DateTime startTime, DateTime endTime)
        {
            List <DrugTopRank> result = new List <DrugTopRank>();

            var Iprescrition = this.uow.DomainFactories.CreatePrescrtionInDuration();

            var prescritionList = Iprescrition.GetPrescriptionInDuration(startTime, endTime);
            var query           = prescritionList.SelectMany(opp => opp.GetDrugCost()).GroupBy(opp => new { opp.ProductNumber, opp.ProductName, opp.IsAntibiotic })
                                  .Select(c => new DrugTopRank
            {
                ProductNumber = c.Key.ProductNumber,
                ProductName   = c.Key.ProductName,
                Cost          = c.Sum(su => su.Cost),
                IsAntibiotic  = c.Key.IsAntibiotic
            }).OrderByDescending(o => o.Cost).Take(30);

            //根据每个productNumber 按doctorName为组,找到其前三名医生及对应金额
            foreach (var item in query)
            {
                DrugTopRank temp = new DrugTopRank
                {
                    ProductNumber = item.ProductNumber,
                    ProductName   = item.ProductName,
                    IsAntibiotic  = item.IsAntibiotic,
                    Cost          = item.Cost
                };
                temp.DrugDoctorDepartmentCostList = prescritionList.SelectMany(opp => opp.GetDrugDoctorDepartmentCost(item.ProductNumber)).GroupBy(g => new { g.Doctor, g.Department })
                                                    .Select(c => new DrugDoctorDepartmentCost
                {
                    Doctor     = c.Key.Doctor,
                    Department = c.Key.Department,
                    Cost       = c.Sum(su => su.Cost)
                }).OrderByDescending(o => o.Cost).Take(3).ToList();
                result.Add(temp);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public List <DrugTopRank> GetDrugTopRankList(DateTime startTime, DateTime endTime)
        {
            List <DrugTopRank> result = new List <DrugTopRank>();
            //取定时间范围内的处方单

            var iPrescrtiptions = this.innerFactory.CreatePrescrtionInDuration();
            var prescritionList = iPrescrtiptions.GetPrescriptionInDuration(startTime, endTime);
            var query           = prescritionList.SelectMany(opp => opp.GetAntibioticCost()).GroupBy(opp => new { opp.ProductCJID, opp.ProductName, opp.IsAntibiotic })
                                  .Select(c => new DrugTopRank
            {
                ProductCJID  = c.Key.ProductCJID,
                ProductName  = c.Key.ProductName,
                Cost         = c.Sum(su => su.Cost),
                IsAntibiotic = c.Key.IsAntibiotic
            }).OrderByDescending(o => o.Cost).Take(10);

            //根据每个productNumber 按Department为组,统找到其前三名科室及对应金额
            foreach (var item in query)
            {
                DrugTopRank temp = new DrugTopRank
                {
                    ProductCJID  = item.ProductCJID,
                    ProductName  = item.ProductName,
                    IsAntibiotic = item.IsAntibiotic,
                    Cost         = item.Cost
                };
                temp.DrugDoctorDepartmentCostList = prescritionList.SelectMany(opp => opp.GetDrugDoctorDepartmentCost(item.ProductNumber)).GroupBy(g => g.DepartmentID)
                                                    .Select(c => new DrugDoctorDepartmentCost
                {
                    DepartmentID = c.Key,
                    Cost         = c.Sum(su => su.Cost)
                }).OrderByDescending(o => o.Cost).Take(3).ToList();
                result.Add(temp);
            }
            return(result);
        }