示例#1
0
        static public List <TestDoctor> BuildDoctorFromDataBaseData(string idReferral)
        {
            List <TestDoctor> docs = new List <TestDoctor>();

            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())
                {
                    if (idr["id_doctor"] != DBNull.Value)
                    {
                        string idDoctor = idr["id_doctor"].ToString();
                        using (NpgsqlConnection connection = Global.GetSqlConnection())
                        {
                            string        findDoctor = "SELECT * FROM public.doctor WHERE id_doctor = '" + idDoctor + "' ORDER BY id_doctor DESC LIMIT 1";
                            NpgsqlCommand doc        = new NpgsqlCommand(findDoctor, connection);
                            using (NpgsqlDataReader doctorFromDataBase = doc.ExecuteReader())
                            {
                                Doctor p = new Doctor();
                                while (doctorFromDataBase.Read())
                                {
                                    TestDoctor doctor = new TestDoctor(p);
                                    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_position"] != DBNull.Value)
                                    {
                                        doctor.position = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(doctorFromDataBase["id_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);
        }
示例#2
0
        static public TestPatient BuildPatientFromDataBaseData(string idPerson, string MIS)
        {
            TestPatient patient = new TestPatient();

            patient.addreses   = TestAddress.BuildAdressesFromDataBaseData(idPerson);
            patient.contacts   = TestContact.BuildContactsFromDataBaseData(idPerson);
            patient.documents  = TestDocument.BuildDocumentsFromDataBaseData(idPerson);
            patient.jobs       = TestJob.BuildJobFromDataBaseData(idPerson);
            patient.privileges = TestPrivilege.BuildPrivilegeFromDataBaseData(idPerson);
            patient.person     = TestPerson.BuildPersonFromDataBaseData(idPerson, MIS);
            return(patient);
        }