Exemplo n.º 1
0
 public static TestPerson BuildPersonFromDataBaseData(string idPerson, string MIS)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string findPatient = "SELECT * FROM public.person WHERE id_person = '" + idPerson + "'";
         NpgsqlCommand person = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             Person p = new Person();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["birthday"]!= DBNull.Value)
                     p.BirthDate = Convert.ToDateTime(personFromDataBase["birthday"]);
                 if (MIS == "")
                     p.IdPatientMis = null;
                 if ((personFromDataBase["family_name"] != DBNull.Value) || (personFromDataBase["given_name"] != DBNull.Value) || (personFromDataBase["middle_name"] != DBNull.Value))
                 {
                     p.HumanName = new HumanName();
                     if (personFromDataBase["family_name"] != DBNull.Value)
                         p.HumanName.FamilyName = Convert.ToString(personFromDataBase["family_name"]);
                     if (personFromDataBase["given_name"] != DBNull.Value)
                         p.HumanName.GivenName = Convert.ToString(personFromDataBase["given_name"]);
                     if (personFromDataBase["middle_name"] != DBNull.Value)
                         p.HumanName.MiddleName = Convert.ToString(personFromDataBase["middle_name"]);
                 }
                 TestPerson pers = new TestPerson(p);
                 if (personFromDataBase["id_sex"] != DBNull.Value)
                     pers.sex = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_sex"]));
                 return pers;
             }
         }
     }
     return null;
 }
Exemplo n.º 2
0
 public TestPatient(Patient p)
 {
     if ((p.Documents != null) && (p.Documents.Length != 0))
     {
         documents = new List<TestDocument>();
         foreach (DocumentDto i in p.Documents)
             documents.Add(new TestDocument(i));
     }
     if ((p.Addresses != null) && (p.Addresses.Length != 0))
     {
         addreses = new List<TestAddress>();
         foreach (AddressDto i in p.Addresses)
             addreses.Add(new TestAddress(i));
     }
     if ((p.ContactDtos != null) && (p.ContactDtos.Length != 0))
     {
         contacts = new List<TestContact>();
         foreach (ContactDto i in p.ContactDtos)
             contacts.Add(new TestContact(i));
     }
     if ((p.Jobs != null) && (p.Jobs.Length != 0))
     {
         jobs = new List<TestJob>();
         foreach (Job i in p.Jobs)
             jobs.Add(new TestJob(i));
     }
     if ((p.Privileges != null) && (p.Privileges.Length != 0))
     {
         privileges = new List<TestPrivilege>();
         foreach (Privilege i in p.Privileges)
             privileges.Add(new TestPrivilege(i));
     }
     if (p.Person != null)
         person = new TestPerson(p.Person);
 }
Exemplo n.º 3
0
 public TestDoctor(Doctor r)
 {
     doctor = r;
     if (doctor.ContactDtos != null)
         foreach (ContactDto i in doctor.ContactDtos)
             cnts.Add(new TestContact(i));
     lpu = new TestCoding(doctor.Lpu);
     person = new TestPerson(doctor.Person);
     position = new TestCoding(doctor.Position);
     role = new TestCoding(doctor.Role);
     speciality = new TestCoding(doctor.Speciality);
 }
Exemplo n.º 4
0
 public TestDoctor(Doctor r)
 {
     doctor = r;
     if (doctor.ContactDtos != null)
     {
         foreach (ContactDto i in doctor.ContactDtos)
         {
             cnts.Add(new TestContact(i));
         }
     }
     lpu        = new TestCoding(doctor.Lpu);
     person     = new TestPerson(doctor.Person);
     position   = new TestCoding(doctor.Position);
     role       = new TestCoding(doctor.Role);
     speciality = new TestCoding(doctor.Speciality);
 }
Exemplo n.º 5
0
 public TestPatient(Patient p)
 {
     if ((p.Documents != null) && (p.Documents.Length != 0))
     {
         documents = new List <TestDocument>();
         foreach (DocumentDto i in p.Documents)
         {
             documents.Add(new TestDocument(i));
         }
     }
     if ((p.Addresses != null) && (p.Addresses.Length != 0))
     {
         addreses = new List <TestAddress>();
         foreach (AddressDto i in p.Addresses)
         {
             addreses.Add(new TestAddress(i));
         }
     }
     if ((p.ContactDtos != null) && (p.ContactDtos.Length != 0))
     {
         contacts = new List <TestContact>();
         foreach (ContactDto i in p.ContactDtos)
         {
             contacts.Add(new TestContact(i));
         }
     }
     if ((p.Jobs != null) && (p.Jobs.Length != 0))
     {
         jobs = new List <TestJob>();
         foreach (Job i in p.Jobs)
         {
             jobs.Add(new TestJob(i));
         }
     }
     if ((p.Privileges != null) && (p.Privileges.Length != 0))
     {
         privileges = new List <TestPrivilege>();
         foreach (Privilege i in p.Privileges)
         {
             privileges.Add(new TestPrivilege(i));
         }
     }
     if (p.Person != null)
     {
         person = new TestPerson(p.Person);
     }
 }
Exemplo n.º 6
0
 static public TestPerson BuildPersonFromDataBaseData(string idPerson, string MIS)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT * FROM public.person WHERE id_person = '" + idPerson + "'";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             Person p = new Person();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["birthday"] != DBNull.Value)
                 {
                     p.BirthDate = Convert.ToDateTime(personFromDataBase["birthday"]);
                 }
                 if (MIS == "")
                 {
                     p.IdPatientMis = null;
                 }
                 if ((personFromDataBase["family_name"] != DBNull.Value) || (personFromDataBase["given_name"] != DBNull.Value) || (personFromDataBase["middle_name"] != DBNull.Value))
                 {
                     p.HumanName = new HumanName();
                     if (personFromDataBase["family_name"] != DBNull.Value)
                     {
                         p.HumanName.FamilyName = Convert.ToString(personFromDataBase["family_name"]);
                     }
                     if (personFromDataBase["given_name"] != DBNull.Value)
                     {
                         p.HumanName.GivenName = Convert.ToString(personFromDataBase["given_name"]);
                     }
                     if (personFromDataBase["middle_name"] != DBNull.Value)
                     {
                         p.HumanName.MiddleName = Convert.ToString(personFromDataBase["middle_name"]);
                     }
                 }
                 TestPerson pers = new TestPerson(p);
                 if (personFromDataBase["id_sex"] != DBNull.Value)
                 {
                     pers.sex = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_sex"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Exemplo n.º 7
0
 public TestDoctor(Doctor r)
 {
     doctor = r;
     if ((doctor.ContactDtos != null) && (doctor.ContactDtos.Length != 0))
     {
         cnts = new List<TestContact>();
         foreach (ContactDto i in doctor.ContactDtos)
             cnts.Add(new TestContact(i));
     }
     if (doctor.Lpu != null)
         lpu = new TestCoding(doctor.Lpu);
     if (doctor.Person != null)
         person = new TestPerson(doctor.Person);
     if (doctor.Position != null)
         position = new TestCoding(doctor.Position);
     if (doctor.Role != null)
         role = new TestCoding(doctor.Role);
     if (doctor.Speciality != null)
         speciality = new TestCoding(doctor.Speciality);
 }
Exemplo n.º 8
0
        public override bool Equals(Object obj)
        {
            TestPerson p = obj as TestPerson;

            if ((object)p == null)
            {
                return(false);
            }
            if ((this.person.BirthDate == p.person.BirthDate) &&
                (this.person.IdPersonMis == p.person.IdPersonMis) &&
                (Global.IsEqual(this.sex, p.sex)) &&
                (this.person.HumanName.FamilyName == p.person.HumanName.FamilyName) &&
                (this.person.HumanName.GivenName == p.person.HumanName.GivenName) &&
                (this.person.HumanName.MiddleName == p.person.HumanName.MiddleName))
            {
                return(true);
            }
            else
            {
                this.FindMismatch(p);
                Global.errors3.Add("несовпадение TestPerson");
                return(false);
            }
        }
Exemplo n.º 9
0
 private void FindMismatch(TestPerson b)
 {
     if (this.person.BirthDate != b.person.BirthDate)
         Global.errors3.Add("Несовпадение BirthDate TestPerson");
     if (this.person.Sex.Code != b.person.Sex.Code)
         Global.errors3.Add("Несовпадение Sex TestPerson");
     if (this.person.IdPersonMis != b.person.IdPersonMis)
         Global.errors3.Add("Несовпадение IdPersonMis TestPerson");
     if (this.person.HumanName.FamilyName != b.person.HumanName.FamilyName)
         Global.errors3.Add("Несовпадение длины FamilyName TestPerson");
     if (this.person.HumanName.GivenName != b.person.HumanName.GivenName)
         Global.errors3.Add("Несовпадение длины GivenName TestPerson");
     if (this.person.HumanName.MiddleName != b.person.HumanName.MiddleName)
         Global.errors3.Add("Несовпадение длины MiddleName TestPerson");
 }
Exemplo n.º 10
0
        static public List <TestDoctor> BuildDoctorFromDataBaseData(string idReferral, string idLpu)
        {
            List <TestDoctor> docs = new List <TestDoctor>();

            if (idLpu != "")
            {
                using (NpgsqlConnection c = Global.GetSqlConnection())
                {
                    string findDoctorsIds = "SELECT * FROM public.referral_doctor WHERE id_referral = '" + idReferral +
                                            "'";
                    NpgsqlCommand fd = new NpgsqlCommand(findDoctorsIds, c);
                    using (NpgsqlDataReader idr = fd.ExecuteReader())
                    {
                        while (idr.Read())
                        {
                            if (idr["id_referral_doctor"] != DBNull.Value)
                            {
                                string idDoctor = idr["id_referral_doctor"].ToString();
                                using (NpgsqlConnection connection = Global.GetSqlConnection())
                                {
                                    string findDoctor = "SELECT * FROM public.doctor WHERE id_doctor = '" + idDoctor +
                                                        "' AND id_lpu = '" + idLpu +
                                                        "' ORDER BY id_doctor DESC LIMIT 1";
                                    NpgsqlCommand doc = new NpgsqlCommand(findDoctor, connection);
                                    using (NpgsqlDataReader doctorFromDataBase = doc.ExecuteReader())
                                    {
                                        while (doctorFromDataBase.Read())
                                        {
                                            TestDoctor doctor = new TestDoctor();
                                            if (doctorFromDataBase["id_doctor_role"] != DBNull.Value)
                                            {
                                                doctor.role =
                                                    TestCoding.BuildCodingFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_doctor_role"]));
                                            }
                                            if (doctorFromDataBase["id_doctor_speciality"] != DBNull.Value)
                                            {
                                                doctor.speciality =
                                                    TestCoding.BuildCodingFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_doctor_speciality"]));
                                            }
                                            if (doctorFromDataBase["id_lpu"] != DBNull.Value)
                                            {
                                                doctor.lpu =
                                                    TestCoding.BuildCodingFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_lpu"]));
                                            }
                                            if (doctorFromDataBase["id_doctor_position"] != DBNull.Value)
                                            {
                                                doctor.position =
                                                    TestCoding.BuildCodingFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_doctor_position"]));
                                            }
                                            if (doctorFromDataBase["id_person"] != DBNull.Value)
                                            {
                                                doctor.person =
                                                    TestPerson.BuildPersonFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_person"]),
                                                        Convert.ToString(doctorFromDataBase["id_doctor_mis"]));
                                            }
                                            if (doctorFromDataBase["id_person"] != DBNull.Value)
                                            {
                                                doctor.cnts =
                                                    TestContact.BuildContactsFromDataBaseData(
                                                        Convert.ToString(doctorFromDataBase["id_person"]));
                                            }
                                            docs.Add(doctor);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return((docs.Count != 0) ? docs : null);
        }