Пример #1
0
        public string GetDoctorDeviationReportDetails(string startDate, string endDate, string statusName, string userCode, string userName,
                                                      string dcrStatus, string reportFormat)
        {
            StringBuilder strTblContent = new StringBuilder();
            string        blobUrl       = string.Empty;

            try
            {
                DataControl.CurrentInfo             objCurInfo               = new CurrentInfo();
                DataControl.BLUser                  objUser                  = new BLUser();
                DataControl.BAL_DoctorVisitAnalysis objDoctorVisit           = new BAL_DoctorVisitAnalysis();
                IEnumerable <MVCModels.HiDoctor_Master.UserModel> lstUser    = null;
                IEnumerable <MVCModels.DCRHeaderModel>            lstHeader  = null;
                IEnumerable <MVCModels.DCRDoctorVisitModel>       lstDoctors = null;
                strTblContent.Append(objUser.GetReportHeaderTableString(objCurInfo.GetCompanyCode(), userCode, startDate, endDate, statusName, ""));
                lstHeader = objDoctorVisit.GetDCRHeaderByStatusAndDate(objCurInfo.GetCompanyCode(), dcrStatus, userCode, startDate, endDate);
                StringBuilder strAcc = new StringBuilder();
                ArrayList     al     = new ArrayList();
                if (lstHeader != null)
                {
                    #region get dcr header info
                    foreach (var dr in lstHeader)
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(dr.Acc1_Name)))
                        {
                            if (!al.Contains(Convert.ToString(dr.Acc1_Name)))
                            {
                                strAcc.Append(Convert.ToString(dr.Acc1_Name).Trim() + "^");
                                al.Add(Convert.ToString(dr.Acc1_Name).Trim());
                            }
                        }
                        if (!string.IsNullOrEmpty(Convert.ToString(dr.Acc2_Name)))
                        {
                            if (!al.Contains(Convert.ToString(dr.Acc2_Name)))
                            {
                                strAcc.Append(Convert.ToString(dr.Acc2_Name) + "^");
                                al.Add(Convert.ToString(dr.Acc2_Name).Trim());
                            }
                        }
                        if (!string.IsNullOrEmpty(Convert.ToString(dr.Acc3_Name)))
                        {
                            if (!al.Contains(Convert.ToString(dr.Acc3_Name)))
                            {
                                strAcc.Append(Convert.ToString(dr.Acc3_Name) + "^");
                                al.Add(Convert.ToString(dr.Acc3_Name).Trim());
                            }
                        }
                        if (!string.IsNullOrEmpty(Convert.ToString(dr.Acc4_Name)))
                        {
                            if (!al.Contains(Convert.ToString(dr.Acc4_Name)))
                            {
                                strAcc.Append(Convert.ToString(dr.Acc4_Name) + "^");
                                al.Add(Convert.ToString(dr.Acc4_Name).Trim());
                            }
                        }
                    }
                    strAcc.Append(userName.Split(',')[0] + "^");
                    #endregion dcr header info
                    lstDoctors = objDoctorVisit.GetDCRDoctorsByUserName(objCurInfo.GetCompanyCode(), dcrStatus, strAcc.ToString(), startDate, endDate);
                    strTblContent.Append("<table class='table table-striped'>");
                    strTblContent.Append("<thead><tr><th>Date</th><th>" + userName + "</th>");
                    foreach (string accName in al)
                    {
                        strTblContent.Append("<th>Doctors met by " + accName + "</th>");
                    }
                    strTblContent.Append("<th>Doctor Missed</th>");
                    strTblContent.Append("<th>Doctor Deviation</th></thead><tbody>");

                    if (lstDoctors != null)
                    {
                        foreach (var dr in lstHeader)
                        {
                            StringBuilder strDoctorContent = new StringBuilder();
                            strTblContent.Append("<tr><td>" + dr.DCR_Date + "</td>");
                            var disDcr = lstDoctors.AsEnumerable().Where(a => a.DCR_Actual_Date == dr.DCR_Date &&
                                                                         a.User_Name.ToUpper() == userName.Split(',')[0].ToString().ToUpper()).ToList();
                            ArrayList alManagerDocs = new ArrayList();
                            ArrayList alChildDocs   = new ArrayList();
                            if (disDcr.Count > 0)
                            {
                                strDoctorContent.Append("<table>");
                                foreach (var doc in disDcr)
                                {
                                    strDoctorContent.Append("<tr><td>" + doc.Doctor_Name + "</td></tr>");
                                    alManagerDocs.Add(doc.Doctor_Name);
                                }
                                strDoctorContent.Append("</table>");
                                strTblContent.Append("<td>" + strDoctorContent.ToString() + "</td>");
                                foreach (string accName in al)
                                {
                                    StringBuilder strAccDocs = new StringBuilder();
                                    if (accName == Convert.ToString(dr.Acc1_Name).Trim() || accName == Convert.ToString(dr.Acc2_Name).Trim() ||
                                        accName == Convert.ToString(dr.Acc3_Name).Trim() || accName == Convert.ToString(dr.Acc4_Name).Trim())
                                    {
                                        var lstAcc = lstDoctors.AsEnumerable().Where(b => b.DCR_Actual_Date == dr.DCR_Date && b.User_Name == accName).ToList();
                                        if (lstAcc.Count > 0)
                                        {
                                            strAccDocs.Append("<table>");
                                            foreach (var accDoc in lstAcc)
                                            {
                                                strAccDocs.Append("<tr><td>" + accDoc.Doctor_Name + "</td></tr>");
                                                alChildDocs.Add(accDoc.Doctor_Name);
                                            }
                                            strAccDocs.Append("</table>");
                                        }
                                    }
                                    strTblContent.Append("<td>" + strAccDocs.ToString() + "</td>");
                                }
                                strDoctorContent.Clear();
                                #region doctor missed count
                                if (alChildDocs.Count > 0)
                                {
                                    strDoctorContent.Append("<table>");
                                    foreach (string childDoctor in alChildDocs)
                                    {
                                        if (!alManagerDocs.Contains(childDoctor))
                                        {
                                            strDoctorContent.Append("<tr><td>" + childDoctor.Trim() + "</td></tr>");
                                        }
                                    }
                                    strDoctorContent.Append("</table>");
                                }
                                strTblContent.Append("<td>" + strDoctorContent.ToString() + "</td>");
                                #endregion doctor missed count
                                #region doctor deviation
                                strDoctorContent.Clear();
                                int count = 0;
                                if (alManagerDocs.Count > 0)
                                {
                                    strDoctorContent.Append("<table>");
                                    foreach (string managerDoctor in alManagerDocs)
                                    {
                                        if (!alChildDocs.Contains(managerDoctor))
                                        {
                                            count++;
                                            strDoctorContent.Append("<tr><td>" + managerDoctor.Trim() + "</td></tr>");
                                        }
                                    }
                                    strDoctorContent.Append("</table>");
                                    if (count < 0)
                                    {
                                        strDoctorContent.Clear();
                                    }
                                }
                                strTblContent.Append("<td>" + strDoctorContent + "</td>");
                                #endregion doctor deviation
                            }
                            strTblContent.Append("</tr>");
                        }
                    }
                }
                if (reportFormat == "2")
                {
                    DataControl.Repository.FileDownload     objFileDownload = new DataControl.Repository.FileDownload();
                    DataControl.CurrentInfo                 _objCurr        = new CurrentInfo();
                    DataControl.Abstraction.IConfigProvider iConfigPro      = new DataControl.Impl.ConfigProvider();
                    DataControl.Repository.AzureBlobUpload  objAzureBlob    = new DataControl.Repository.AzureBlobUpload();
                    string accKey   = iConfigPro.GetConfigValue("SWAASBLOBACCKEY");
                    string compCode = _objCurr.GetCompanyCode();
                    string fileName = "DoctorDeviationReport_" + "_" + compCode + "_" + _objCurr.GetUserName() + ".xls";

                    string error = string.Empty;
                    //string strExcelContent = GetDoctorDeviationReportDetails(startDate,endDate,statusName,userCode,userName,dcrStatus);
                    blobUrl = objAzureBlob.AzureBlobUploadText(strTblContent.ToString(), accKey, fileName, "bulkdatasvc");
                }
            }
            catch (Exception ex)
            {
            }
            if (reportFormat == "1")
            {
                return(strTblContent.ToString());
            }
            else
            {
                return(blobUrl);
            }
        }