Пример #1
0
        private IList <RefSiteImportData> GetDataRow(DataSet ds)
        {
            string       regionName;
            string       siteName;
            string       rName  = "";
            ForlabRegion region = null;
            ForlabSite   site   = null;

            string CD4RefSite;
            string ChemRefSite;
            string HemRefSite;
            string ViralRefSite;
            string OtherRefSite;

            int  rowno = 0;
            bool haserror;

            ForlabSite refSite        = null;
            int        CD4RefSiteId   = 0;
            int        ChemRefSiteId  = 0;
            int        HemRefSiteId   = 0;
            int        ViralRefSiteId = 0;
            int        OtherRefSiteId = 0;

            IList <ForlabSite> _referingSites = new List <ForlabSite>();
            IList <ForlabSite> sites;
            IList <ForlabSite> _validsites = new List <ForlabSite>();

            IList <RefSiteImportData> rdlist = new List <RefSiteImportData>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string errorDiscription = "";
                rowno++;
                haserror   = false;
                regionName = Convert.ToString(dr[0]).Trim(); //region namegory name
                siteName   = Convert.ToString(dr[1]).Trim(); //short name
                try
                {
                    CD4RefSite = Convert.ToString(dr[2]);
                }
                catch
                {
                    CD4RefSite = "";
                }
                try
                {
                    ChemRefSite = Convert.ToString(dr[3]);
                }
                catch
                {
                    ChemRefSite = "";
                }
                try
                {
                    HemRefSite = Convert.ToString(dr[4]);
                }
                catch
                {
                    HemRefSite = "";
                }
                try
                {
                    ViralRefSite = Convert.ToString(dr[5]);
                }
                catch
                {
                    ViralRefSite = "";
                }
                try
                {
                    OtherRefSite = Convert.ToString(dr[6]);
                }
                catch
                {
                    OtherRefSite = "";
                }

                RefSiteImportData rd = new RefSiteImportData(rowno, regionName, siteName, CD4RefSite, ChemRefSite, HemRefSite, ViralRefSite, OtherRefSite);

                if (rName != regionName)
                {
                    if (!string.IsNullOrEmpty(regionName))
                    {
                        region = DataRepository.GetRegionByName(regionName);
                    }
                    else
                    {
                        region = null;
                    }
                    rName = regionName;
                }

                if (region != null)
                {
                    rd.Region = region;
                    if (!String.IsNullOrEmpty(siteName))
                    {
                        site = DataRepository.GetSiteByName(siteName, region.Id);
                        if (site != null)
                        {
                            //if((site.CD4RefSite.ToString().Trim()==(dr[2]).ToString().Trim().ToLower())||(site.ChemistryRefSite.ToString().Trim().ToLower()==(dr[3]).ToString().Trim().ToLower())||
                            //    (site.HematologyRefSite.ToString().Trim().ToLower()==(dr[4]).ToString().Trim().ToLower())||(site.ViralLoadRefSite.ToString().Trim().ToLower()==(dr[5]).ToString().Trim().ToLower())||
                            //    (site.OtherRefSite.ToString().Trim().ToLower()==(dr[6]).ToString().Trim().ToLower()))
                            //    rd.IsExist=true;
                        }
                        else
                        {
                            errorDiscription = errorDiscription + " Site doesn't exist";
                            haserror         = true;
                        }
                    }
                    else
                    {
                        errorDiscription = errorDiscription + " Site name required";
                        haserror         = true;
                    }
                    if (!haserror)
                    {
                        if (!String.IsNullOrEmpty(CD4RefSite))
                        {
                            if ((ISValidReferralSite(CD4RefSite, siteName, "CD4", out refSite)) || (ISValidReferralSite(CD4RefSite, siteName, "Flow Cytometry", out refSite)))
                            {
                                CD4RefSiteId = refSite.Id;
                            }
                            else
                            {
                                haserror         = true;
                                CD4RefSiteId     = -1;
                                errorDiscription = errorDiscription + " Is Not Valid CD4 Referral Site";//14 may 14
                            }
                        }

                        if (!String.IsNullOrEmpty(ChemRefSite))
                        {
                            if (ISValidReferralSite(ChemRefSite, siteName, "Chemistry", out refSite))
                            {
                                ChemRefSiteId = refSite.Id;
                            }
                            else
                            {
                                haserror         = true;
                                ChemRefSiteId    = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Chemistry Referral Site";
                            }
                        }

                        if (!String.IsNullOrEmpty(HemRefSite))
                        {
                            if (ISValidReferralSite(HemRefSite, siteName, "Hematology", out refSite))
                            {
                                HemRefSiteId = refSite.Id;
                            }
                            else
                            {
                                haserror         = true;
                                HemRefSiteId     = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Hematology Referral Site";
                            }
                        }

                        if (!String.IsNullOrEmpty(ViralRefSite))
                        {
                            if (ISValidReferralSite(ViralRefSite, siteName, "ViralLoad", out refSite))
                            {
                                ViralRefSiteId = refSite.Id;
                            }
                            else
                            {
                                haserror         = true;
                                ViralRefSiteId   = -1;
                                errorDiscription = errorDiscription + " Is Not Valid ViralLoad Referral Site";
                            }
                        }

                        if (!String.IsNullOrEmpty(OtherRefSite))
                        {
                            if (ISValidReferralSite(OtherRefSite, siteName, "Other", out refSite))
                            {
                                OtherRefSiteId = refSite.Id;
                            }
                            else
                            {
                                haserror         = true;
                                OtherRefSiteId   = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Referral Site";
                            }
                        }
                    }
                    else
                    {
                        haserror = true;
                    }
                }
                else
                {
                    errorDiscription = errorDiscription + " Region doesn't exist";
                    haserror         = true;
                }


                rd.CD4RefSiteId        = CD4RefSiteId;
                rd.ChemistryRefSiteId  = ChemRefSiteId;
                rd.HematologyRefSiteId = HemRefSiteId;
                rd.ViralLoadRefSiteId  = ViralRefSiteId;
                rd.OtheRefSiteId       = OtherRefSiteId;
                rd.HasError            = haserror;
                if (rd.CD4RefSiteId == 0 && rd.ChemistryRefSiteId == 0 && rd.HematologyRefSiteId == 0 && rd.ViralLoadRefSiteId == 0 && rd.OtheRefSiteId == 0)
                {
                    rd.HasError      = true;
                    errorDiscription = errorDiscription + " At least one referral site required";
                }

                rd.ErrorDescription = errorDiscription;//14 may 14
                rdlist.Add(rd);
                CD4RefSiteId   = 0;
                ChemRefSiteId  = 0;
                HemRefSiteId   = 0;
                ViralRefSiteId = 0;
                OtherRefSiteId = 0;
            }

            return(rdlist);
        }
Пример #2
0
        private IList<RefSiteImportData> GetDataRow(DataSet ds)
        {
            string regionName;
            string siteName;
            string rName = "";
            ForlabRegion region = null;
            ForlabSite site = null;

            string CD4RefSite;
            string ChemRefSite;
            string HemRefSite;
            string ViralRefSite;
            string OtherRefSite;

            int rowno = 0;
            bool haserror;

            ForlabSite refSite = null;
            int CD4RefSiteId = 0;
            int ChemRefSiteId = 0;
            int HemRefSiteId = 0;
            int ViralRefSiteId = 0;
            int OtherRefSiteId = 0;

            IList<ForlabSite> _referingSites = new List<ForlabSite>();
            IList<ForlabSite> sites;
            IList<ForlabSite> _validsites = new List<ForlabSite>();

            IList<RefSiteImportData> rdlist = new List<RefSiteImportData>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string errorDiscription = "";
                rowno++;
                haserror = false;
                regionName = Convert.ToString(dr[0]).Trim();   //region namegory name
                siteName = Convert.ToString(dr[1]).Trim();   //short name
                try
                {
                    CD4RefSite = Convert.ToString(dr[2]);

                }
                catch
                {
                    CD4RefSite = "";
                }
                try
                {
                    ChemRefSite = Convert.ToString(dr[3]);

                }
                catch
                {
                    ChemRefSite = "";
                }
                try
                {
                    HemRefSite = Convert.ToString(dr[4]);

                }
                catch
                {
                    HemRefSite = "";
                }
                try
                {
                    ViralRefSite = Convert.ToString(dr[5]);

                }
                catch
                {
                    ViralRefSite = "";
                }
                try
                {
                    OtherRefSite = Convert.ToString(dr[6]);

                }
                catch
                {
                    OtherRefSite = "";
                }

                RefSiteImportData rd = new RefSiteImportData(rowno, regionName, siteName, CD4RefSite, ChemRefSite, HemRefSite, ViralRefSite, OtherRefSite);

                if (rName != regionName)
                {
                    if (!string.IsNullOrEmpty(regionName))
                        region = DataRepository.GetRegionByName(regionName);
                    else
                        region = null;
                    rName = regionName;
                }

                if (region != null)
                {
                    rd.Region = region;
                    if (!String.IsNullOrEmpty(siteName))
                    {
                        site = DataRepository.GetSiteByName(siteName, region.Id);
                        if (site != null)
                        {
                            //if((site.CD4RefSite.ToString().Trim()==(dr[2]).ToString().Trim().ToLower())||(site.ChemistryRefSite.ToString().Trim().ToLower()==(dr[3]).ToString().Trim().ToLower())||
                            //    (site.HematologyRefSite.ToString().Trim().ToLower()==(dr[4]).ToString().Trim().ToLower())||(site.ViralLoadRefSite.ToString().Trim().ToLower()==(dr[5]).ToString().Trim().ToLower())||
                            //    (site.OtherRefSite.ToString().Trim().ToLower()==(dr[6]).ToString().Trim().ToLower()))
                            //    rd.IsExist=true;
                        }
                        else
                        {
                            errorDiscription = errorDiscription + " Site doesn't exist";
                            haserror = true;
                        }

                    }
                    else
                    {
                        errorDiscription = errorDiscription + " Site name required";
                        haserror = true;
                    }
                    if (!haserror)
                    {
                        if (!String.IsNullOrEmpty(CD4RefSite))
                            if ((ISValidReferralSite(CD4RefSite, siteName, "CD4", out refSite)) || (ISValidReferralSite(CD4RefSite, siteName, "Flow Cytometry", out refSite)))
                                CD4RefSiteId = refSite.Id;
                            else
                            {
                                haserror = true;
                                CD4RefSiteId = -1;
                                errorDiscription = errorDiscription + " Is Not Valid CD4 Referral Site";//14 may 14
                            }

                        if (!String.IsNullOrEmpty(ChemRefSite))
                            if (ISValidReferralSite(ChemRefSite, siteName, "Chemistry", out refSite))
                                ChemRefSiteId = refSite.Id;
                            else
                            {
                                haserror = true;
                                ChemRefSiteId = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Chemistry Referral Site";
                            }

                        if (!String.IsNullOrEmpty(HemRefSite))
                            if (ISValidReferralSite(HemRefSite, siteName, "Hematology", out refSite))
                                HemRefSiteId = refSite.Id;
                            else
                            {
                                haserror = true;
                                HemRefSiteId = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Hematology Referral Site";
                            }

                        if (!String.IsNullOrEmpty(ViralRefSite))
                            if (ISValidReferralSite(ViralRefSite, siteName, "ViralLoad", out refSite))
                                ViralRefSiteId = refSite.Id;
                            else
                            {
                                haserror = true;
                                ViralRefSiteId = -1;
                                errorDiscription = errorDiscription + " Is Not Valid ViralLoad Referral Site";
                            }

                        if (!String.IsNullOrEmpty(OtherRefSite))
                            if (ISValidReferralSite(OtherRefSite, siteName, "Other", out refSite))
                                OtherRefSiteId = refSite.Id;
                            else
                            {
                                haserror = true;
                                OtherRefSiteId = -1;
                                errorDiscription = errorDiscription + " Is Not Valid Referral Site";
                            }
                    }
                    else
                        haserror = true;
                }
                else
                {
                    errorDiscription = errorDiscription + " Region doesn't exist";
                    haserror = true;
                }

                rd.CD4RefSiteId = CD4RefSiteId;
                rd.ChemistryRefSiteId = ChemRefSiteId;
                rd.HematologyRefSiteId = HemRefSiteId;
                rd.ViralLoadRefSiteId = ViralRefSiteId;
                rd.OtheRefSiteId = OtherRefSiteId;
                rd.HasError = haserror;
                if (rd.CD4RefSiteId == 0 && rd.ChemistryRefSiteId == 0 && rd.HematologyRefSiteId == 0 && rd.ViralLoadRefSiteId == 0 && rd.OtheRefSiteId == 0)
                {
                    rd.HasError = true;
                    errorDiscription = errorDiscription + " At least one referral site required";
                }

                rd.ErrorDescription = errorDiscription;//14 may 14
                rdlist.Add(rd);
                CD4RefSiteId = 0;
                ChemRefSiteId = 0;
                HemRefSiteId = 0;
                ViralRefSiteId = 0;
                OtherRefSiteId = 0;
            }

            return rdlist;
        }