Exemplo n.º 1
0
        private void btnRadiationDoctorReport_Click(object sender, EventArgs e)
        {
            DateTime startTime = dtpRadiationDoctorStartTime.Value.Date;
            DateTime endTime   = dtpRadiationDoctorEndTime.Value.Date.AddDays(1);

            Dictionary <string, List <DoctorStatistics> > dictionary = _importFileService.GetStoreDoctorDetialDic(startTime, endTime);

            List <DoctorStatistics> doctorStatisticsList = new List <DoctorStatistics>();

            dgvRadiationStoreDoctorPrice.Rows.Clear();
            dgvRadiationDoctorPrice.Rows.Clear();

            foreach (var item in dictionary)
            {
                string storeName = item.Key;

                List <DoctorStatistics> storeDoctorStatisticsList = dictionary[item.Key];
                foreach (var doctorStatistics in storeDoctorStatisticsList)
                {
                    StoreStatistics storeStatistics = new StoreStatistics();

                    storeStatistics.StoreName  = storeName;
                    storeStatistics.DoctorName = doctorStatistics.DoctorName;

                    storeStatistics.CTAuditCount     = doctorStatistics.CTAuditCount;
                    storeStatistics.CTDiagnosisCount = doctorStatistics.CTDiagnosisCount;
                    storeStatistics.CTCount          = doctorStatistics.CTCount;

                    storeStatistics.DRAuditCount     = doctorStatistics.DRAuditCount;
                    storeStatistics.DRDiagnosisCount = doctorStatistics.DRDiagnosisCount;
                    storeStatistics.DRCount          = doctorStatistics.DRCount;

                    storeStatistics.MRAuditCount     = doctorStatistics.MRAuditCount;
                    storeStatistics.MRDiagnosisCount = doctorStatistics.MRDiagnosisCount;
                    storeStatistics.MRCount          = doctorStatistics.MRCount;

                    string priceStr = "没有找到此医生对应的放射价格.";

                    DoctorPriceDetial doctorPriceDetial = _importFileService.GetDoctorPriceDetial(storeStatistics.DoctorName);
                    if (doctorPriceDetial != null)
                    {
                        string CTDiagnosisPriceStr = doctorPriceDetial.CTDiagnosisPrice;
                        if (string.IsNullOrEmpty(CTDiagnosisPriceStr))
                        {
                            CTDiagnosisPriceStr = "0";
                        }

                        string CTAuditPriceStr = doctorPriceDetial.CTAuditPrice;
                        if (string.IsNullOrEmpty(CTAuditPriceStr))
                        {
                            CTAuditPriceStr = "0";
                        }

                        string MRDiagnosisPriceStr = doctorPriceDetial.MRDiagnosisPrice;
                        if (string.IsNullOrEmpty(MRDiagnosisPriceStr))
                        {
                            MRDiagnosisPriceStr = "0";
                        }

                        string MRAuditPriceStr = doctorPriceDetial.MRAuditPrice;
                        if (string.IsNullOrEmpty(MRAuditPriceStr))
                        {
                            MRAuditPriceStr = "0";
                        }

                        string DRDiagnosisPriceStr = doctorPriceDetial.DRDiagnosisPrice;
                        if (string.IsNullOrEmpty(DRDiagnosisPriceStr))
                        {
                            DRDiagnosisPriceStr = "0";
                        }


                        decimal CTDiagnosisPrice = storeStatistics.CTDiagnosisCount * Convert.ToDecimal(CTDiagnosisPriceStr);
                        decimal CTAuditPrice     = storeStatistics.CTAuditCount * Convert.ToDecimal(CTAuditPriceStr);

                        decimal MRDiagnosisPrice = storeStatistics.MRDiagnosisCount * Convert.ToDecimal(MRDiagnosisPriceStr);
                        decimal MRAuditPrice     = storeStatistics.MRAuditCount * Convert.ToDecimal(MRAuditPriceStr);

                        decimal DRDiagnosisPrice = storeStatistics.DRDiagnosisCount * Convert.ToDecimal(DRDiagnosisPriceStr);
                        //decimal DRAuditPrice = storeStatistics.DRAuditCount * Convert.ToDecimal(doctorPriceDetial.DR); //TODO::这个暂时没有

                        doctorStatistics.Price = CTDiagnosisPrice + CTAuditPrice + MRDiagnosisPrice + MRAuditPrice + DRDiagnosisPrice;
                        storeStatistics.Price  = doctorStatistics.Price;

                        doctorStatistics.IsContainPrice = true;
                        storeStatistics.IsContainPrice  = true;

                        priceStr = storeStatistics.Price.ToString();
                    }

                    var findDoctorStatistics = doctorStatisticsList.Find(d => d.DoctorName.Equals(doctorStatistics.DoctorName));
                    if (findDoctorStatistics != null) //找到了此医生
                    {
                        findDoctorStatistics.CTDiagnosisCount += doctorStatistics.CTDiagnosisCount;
                        findDoctorStatistics.CTAuditCount     += doctorStatistics.CTAuditCount;
                        findDoctorStatistics.DRDiagnosisCount += doctorStatistics.DRDiagnosisCount;
                        findDoctorStatistics.DRAuditCount     += doctorStatistics.DRAuditCount;
                        findDoctorStatistics.MRDiagnosisCount += doctorStatistics.MRDiagnosisCount;
                        findDoctorStatistics.MRAuditCount     += doctorStatistics.MRAuditCount;

                        findDoctorStatistics.IsContainPrice = doctorStatistics.IsContainPrice;
                        findDoctorStatistics.Price         += doctorStatistics.Price;
                    }
                    else //没有找到此医生
                    {
                        DoctorStatistics currentDoctorStatistics = new DoctorStatistics();

                        currentDoctorStatistics.DoctorName       = doctorStatistics.DoctorName;
                        currentDoctorStatistics.CTDiagnosisCount = doctorStatistics.CTDiagnosisCount;
                        currentDoctorStatistics.CTAuditCount     = doctorStatistics.CTAuditCount;
                        currentDoctorStatistics.DRDiagnosisCount = doctorStatistics.DRDiagnosisCount;
                        currentDoctorStatistics.DRAuditCount     = doctorStatistics.DRAuditCount;
                        currentDoctorStatistics.MRDiagnosisCount = doctorStatistics.MRDiagnosisCount;
                        currentDoctorStatistics.MRAuditCount     = doctorStatistics.MRAuditCount;

                        currentDoctorStatistics.IsContainPrice = doctorStatistics.IsContainPrice;
                        currentDoctorStatistics.Price          = doctorStatistics.Price;

                        doctorStatisticsList.Add(currentDoctorStatistics);
                    }

                    dgvRadiationStoreDoctorPrice.Rows.Add(storeStatistics.StoreName, storeStatistics.DoctorName,
                                                          storeStatistics.CTDiagnosisCount, storeStatistics.CTAuditCount,
                                                          storeStatistics.MRDiagnosisCount, storeStatistics.MRAuditCount,
                                                          storeStatistics.DRDiagnosisCount, priceStr, string.Empty);
                }
            }

            foreach (var item in doctorStatisticsList)
            {
                dgvRadiationDoctorPrice.Rows.Add(item.DoctorName, item.CTDiagnosisCount, item.MRDiagnosisCount, item.CTAuditCount, item.MRAuditCount, item.IsContainPrice ? item.Price.ToString() : "没有找到此医生对应的放射价格.");
            }

            MessageBox.Show("生成报表成功!");
        }
Exemplo n.º 2
0
        public Dictionary <string, List <DoctorStatistics> > GetStoreDoctorDetialDic(DateTime startTime, DateTime endTime)
        {
            Dictionary <string, List <DoctorStatistics> > dictionary = new Dictionary <string, List <DoctorStatistics> >();

            List <StoreDoctorStatistics> storeDoctorStatisticsList = _storeDoctorDetialRepository.GetStoreDoctorStatistics(startTime, endTime);

            for (int i = 0; i < storeDoctorStatisticsList.Count; i++)
            {
                StoreDoctorStatistics storeDoctorStatistics = storeDoctorStatisticsList[i];
                if (storeDoctorStatistics.StoreName == null)
                {
                    storeDoctorStatistics.StoreName = "";
                }
                if (storeDoctorStatistics.AuditDoctor == null)
                {
                    storeDoctorStatistics.AuditDoctor = "";
                }

                if (storeDoctorStatistics.DiagnosisDoctor == null)
                {
                    storeDoctorStatistics.DiagnosisDoctor = "";
                }


                if (!dictionary.ContainsKey(storeDoctorStatistics.StoreName))
                {
                    List <DoctorStatistics> statisticsList = new List <DoctorStatistics>();

                    DoctorStatistics diagnosisStatistics = new DoctorStatistics();
                    DoctorStatistics statistics          = new DoctorStatistics();

                    diagnosisStatistics.DoctorName = storeDoctorStatistics.DiagnosisDoctor;

                    //各种类型的诊断数量
                    if (storeDoctorStatistics.CheckType == CheckType.CT)
                    {
                        diagnosisStatistics.CTDiagnosisCount = storeDoctorStatistics.Count;
                    }
                    if (storeDoctorStatistics.CheckType == CheckType.MR)
                    {
                        diagnosisStatistics.MRDiagnosisCount = storeDoctorStatistics.Count;
                    }
                    if (storeDoctorStatistics.CheckType == CheckType.DR)
                    {
                        diagnosisStatistics.DRDiagnosisCount = storeDoctorStatistics.Count;
                    }

                    //如果此医生是审核医生,则赋值各种类型的审核数量
                    if (diagnosisStatistics.DoctorName.Equals(storeDoctorStatistics.AuditDoctor))
                    {
                        statistics.DoctorName = storeDoctorStatistics.AuditDoctor;
                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            diagnosisStatistics.CTAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            diagnosisStatistics.MRAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            diagnosisStatistics.DRAuditCount = storeDoctorStatistics.Count;
                        }
                    }
                    else
                    {
                        statistics.DoctorName = storeDoctorStatistics.AuditDoctor;
                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            statistics.CTAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            statistics.MRAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            statistics.DRAuditCount = storeDoctorStatistics.Count;
                        }
                    }

                    diagnosisStatistics.CTCount = diagnosisStatistics.CTDiagnosisCount + diagnosisStatistics.CTAuditCount;
                    statistics.CTCount          = statistics.CTDiagnosisCount + statistics.CTAuditCount;

                    diagnosisStatistics.MRCount = diagnosisStatistics.MRDiagnosisCount + diagnosisStatistics.MRAuditCount;
                    statistics.MRCount          = statistics.MRDiagnosisCount + statistics.MRAuditCount;

                    diagnosisStatistics.DRCount = diagnosisStatistics.DRDiagnosisCount + diagnosisStatistics.DRAuditCount;
                    statistics.DRCount          = statistics.DRDiagnosisCount + statistics.DRAuditCount;

                    statisticsList.Add(diagnosisStatistics);
                    statisticsList.Add(statistics);

                    dictionary.Add(storeDoctorStatistics.StoreName, statisticsList);
                }
                else
                {
                    List <DoctorStatistics> currentStore = dictionary[storeDoctorStatistics.StoreName];

                    var findDiagnosisStatisticsList = currentStore.FindAll(c => c.DoctorName != null && c.DoctorName.Equals(storeDoctorStatistics.DiagnosisDoctor)); //诊断医生

                    if (findDiagnosisStatisticsList.Count > 0)                                                                                                       //诊断医生
                    {
                        var firstFindStatistics = findDiagnosisStatisticsList[0];

                        //各种类型的诊断数量
                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            firstFindStatistics.CTDiagnosisCount += storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            firstFindStatistics.MRDiagnosisCount += storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            firstFindStatistics.DRDiagnosisCount += storeDoctorStatistics.Count;
                        }

                        firstFindStatistics.CTCount = firstFindStatistics.CTDiagnosisCount + firstFindStatistics.CTAuditCount;
                        firstFindStatistics.MRCount = firstFindStatistics.MRDiagnosisCount + firstFindStatistics.MRAuditCount;
                        firstFindStatistics.DRCount = firstFindStatistics.DRDiagnosisCount + firstFindStatistics.DRAuditCount;
                    }
                    else
                    {
                        DoctorStatistics diagonsisStatistics = new DoctorStatistics(); //诊断医生

                        diagonsisStatistics.DoctorName = storeDoctorStatistics.DiagnosisDoctor;

                        //各种类型的诊断数量
                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            diagonsisStatistics.CTDiagnosisCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            diagonsisStatistics.MRDiagnosisCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            diagonsisStatistics.DRDiagnosisCount = storeDoctorStatistics.Count;
                        }


                        diagonsisStatistics.CTCount = diagonsisStatistics.CTDiagnosisCount + diagonsisStatistics.CTAuditCount;
                        diagonsisStatistics.MRCount = diagonsisStatistics.MRDiagnosisCount + diagonsisStatistics.MRAuditCount;
                        diagonsisStatistics.DRCount = diagonsisStatistics.DRDiagnosisCount + diagonsisStatistics.DRAuditCount;

                        currentStore.Add(diagonsisStatistics);
                    }

                    var findAuditStatisticsList = currentStore.FindAll(c => c.DoctorName != null && c.DoctorName.Equals(storeDoctorStatistics.AuditDoctor)); //终审医生

                    if (findAuditStatisticsList.Count > 0)                                                                                                   //终审医生
                    {
                        var firstFindStatistics = findAuditStatisticsList[0];

                        //如果此医生是审核医生,则赋值各种类型的审核数量
                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            firstFindStatistics.CTAuditCount += storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            firstFindStatistics.MRAuditCount += storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            firstFindStatistics.DRAuditCount += storeDoctorStatistics.Count;
                        }

                        firstFindStatistics.CTCount = firstFindStatistics.CTDiagnosisCount + firstFindStatistics.CTAuditCount;
                        firstFindStatistics.MRCount = firstFindStatistics.MRDiagnosisCount + firstFindStatistics.MRAuditCount;
                        firstFindStatistics.DRCount = firstFindStatistics.DRDiagnosisCount + firstFindStatistics.DRAuditCount;
                    }
                    else
                    {
                        DoctorStatistics auditStatistics = new DoctorStatistics(); //终审医生

                        auditStatistics.DoctorName = storeDoctorStatistics.AuditDoctor;

                        if (storeDoctorStatistics.CheckType == CheckType.CT)
                        {
                            auditStatistics.CTAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.MR)
                        {
                            auditStatistics.MRAuditCount = storeDoctorStatistics.Count;
                        }
                        if (storeDoctorStatistics.CheckType == CheckType.DR)
                        {
                            auditStatistics.DRAuditCount = storeDoctorStatistics.Count;
                        }

                        auditStatistics.CTCount = auditStatistics.CTDiagnosisCount + auditStatistics.CTAuditCount;
                        auditStatistics.MRCount = auditStatistics.MRDiagnosisCount + auditStatistics.MRAuditCount;
                        auditStatistics.DRCount = auditStatistics.DRDiagnosisCount + auditStatistics.DRAuditCount;

                        currentStore.Add(auditStatistics);
                    }
                }
            }

            return(dictionary);
        }