Example #1
0
        public void Load()
        {
            string pathMed = @"C:\Users\AVassilyev\Source\Repos\MedOrganization\MedOrganization\bin\Debug\MedOrganithations.xml";

            if (!File.Exists(pathMed))
            {
                OrgGenerator();
            }
            else
            {
                var document = new XmlDocument();
                document.Load(pathMed);

                foreach (XmlElement node in document.DocumentElement)
                {
                    var org = new MedOrganization();
                    org.Id        = int.Parse(node[nameof(MedOrganization.Id)].InnerText);
                    org.NameOrgan = node[nameof(MedOrganization.NameOrgan)].InnerText;
                    org.Adress    = node[nameof(MedOrganization.Adress)].InnerText;
                    var nodeList = node[nameof(MedOrganization.PacientList)];
                    foreach (XmlElement nodePacient in nodeList)
                    {
                        var id = int.Parse(nodePacient.InnerText);
                        org.PacientList.Add(PacientServise.Instance[id]);
                    }
                    MedOrgList.Add(org);
                }
            }
        }
        public bool Zakreplenie(ref MedOrgService ms,
                                ref PacientServise ps,
                                out string mesage)
        {
            #region Select Pation
            foreach (Pacient p in ps.PacientList.Take(10))
            {
                p.PacientInfo();
            }

            Console.WriteLine("--------------------------------------");
            Pacient selectPation = new Pacient();
            Console.WriteLine("Выберите пациента");
            int selectIin = Int32.Parse(Console.ReadLine());
            selectPation = ps[selectIin];
            Console.WriteLine("--------------------------------------");
            if (selectPation == null)
            {
                mesage = "Данный пациент не существует!";
                return(false);
            }
            #endregion

            #region Select MedOrg
            foreach (MedOrganization o in ms.MedOrgList.Take(10))
            {
                o.MedOrganizationInfo();
            }

            Console.WriteLine("--------------------------------------");
            MedOrganization selectOrg = new MedOrganization();
            Console.WriteLine("Выберите мед организацию");
            int selectOrgId = Int32.Parse(Console.ReadLine());
            selectOrg = ms[selectOrgId];
            Console.WriteLine("--------------------------------------");

            #endregion

            Console.Clear();

            var so = ms.MedOrgList.FirstOrDefault(f => f.Id == selectOrgId);

            foreach (var p in so.PacientList)
            {
                if (p.IIN == selectIin)
                {
                    mesage = "Данный пациент уже прикреплен!";
                    return(false);
                }
            }

            so.PacientList.Add(selectPation);
            ps.PacientList.FirstOrDefault(f => f.IIN == selectIin)
            .MedOrganization = selectOrg;

            mesage = "Данный пациент прикреплен успешно!";
            return(true);
        }
Example #3
0
 public void OrgGenerator(int size)
 {
     for (int i = 0; i < size; i++)
     {
         string          NameOrgan = ((OrgName)r.Next(1, 4)).ToString();
         string          Adres     = ((Streets)r.Next(1, 7)).ToString();
         string          TelNumber = "+7" + (r.Next(701, 708).ToString()) + (r.Next(1000000, 9999999).ToString());
         MedOrganization newPac    = new MedOrganization(NameOrgan, Adres, TelNumber);
         lmed.Add(newPac);
     }
 }
        public bool Zakreplenie(/*ref MedOrgService ms, ref PacientServise ps,*/ out string mesage)
        {
            #region Select Pation
            //foreach (Pacient p in PacientServiseStat.PacientList.Take(10))
            foreach (Pacient p in PacientServise.Instance.PacientList.Take(10))
            {
                p.PacientInfo();
            }

            Console.WriteLine("           --------------------------------------");
            Pacient selectPation = new Pacient();
            Console.WriteLine("                 Select patient, enter IIN");

            int selectIin = Int32.Parse(Console.ReadLine());
            //selectPation = PacientServiseStat[selectIin];
            selectPation = PacientServise.Instance[selectIin];
            Console.WriteLine("          --------------------------------------");
            if (selectPation == null)
            {
                mesage = "                   This patient does not exist!";
                return(false);
            }

            #endregion
            #region Select MedOrg
            //foreach (MedOrganization o in MedOrgServiceStat.MedOrgList.Take(10))
            foreach (MedOrganization o in MedOrgService.Instance.MedOrgList.Take(10))
            {
                o.MedOrganizationInfo();
            }

            Console.WriteLine("           --------------------------------------");
            MedOrganization selectOrg = new MedOrganization();
            Console.WriteLine("               Select med organization, enter id");
            int selectOrgId = Int32.Parse(Console.ReadLine());
            //selectOrg = MedOrgServiceStat[selectOrgId];
            selectOrg = MedOrgService.Instance[selectOrgId];
            Console.WriteLine("           --------------------------------------");

            #endregion

            Console.Clear();


            //var so = MedOrgServiceStat.MedOrgList.FirstOrDefault(f => f.Id == selectOrgId);
            var so = MedOrgService.Instance.MedOrgList.FirstOrDefault(f => f.Id == selectOrgId);
            foreach (var p in so.PacientList)
            {
                if (p.IIN == selectIin)
                {
                    mesage = "This patient is already attached!";
                    Console.WriteLine("This patient is already attached!");
                    return(false);
                }
            }

            so.PacientList.Add(selectPation);
            //PacientServiseStat.PacientList.FirstOrDefault(f => f.IIN == selectIin)
            PacientServise.Instance.PacientList.FirstOrDefault(f => f.IIN == selectIin)
            .MedOrganization = selectOrg;

            mesage = "This patient is successfully attached!";
            Console.WriteLine("This patient is successfully attached!");
            //MedOrgService.Instance.PokazVsehOrg();
            return(true);
        }