Exemple #1
0
        public static List <AppointmentDataGrid> getAllAppointments()
        {
            var adb             = new AppointmentDatabaseAccess();
            var ddb             = new DoctorDatabaseAccess();
            var pdb             = new PatientDatabaseAccess();
            var appointmentList = adb.GetAllAppointments();
            var appointments    = new List <AppointmentDataGrid>();

            foreach (var appointment in appointmentList)
            {
                //var appointmentid = int.Parse(appointment[0]);
                //var dateTime = DateTime.Parse(appointment[2]);
                //var doctorData = ddb.GetDoctorDataFromId(int.Parse(appointment[3]));
                //var doctorName = doctorData[0] + " " + doctorData[1];
                //var description = appointment[4];

                //var patientData = pdb.GetPatientDataFromId(int.Parse(appointment[1]));
                //var patientName = patientData[0] + " " + patientData[1];
                //appointments.Add(new AppointmentDataGrid(appointmentid, dateTime, doctorName, description, int.Parse(appointment[1]), patientName));


                var appointmentid = int.Parse(appointment[0]);
                var patientid     = int.Parse(appointment[1]);
                var dateTime      = DateTime.Parse(appointment[2]);
                var doctorData    = ddb.GetDoctorDataFromId(int.Parse(appointment[3]));
                var doctorName    = doctorData[0] + " " + doctorData[1];
                var description   = appointment[4];
                var patientData   = pdb.GetPatientDataFromId(patientid);
                var patientName   = patientData[0] + " " + patientData[1];
                var dob           = new Date(DateTime.Parse(patientData[2])).ToString();
                appointments.Add(new AppointmentDataGrid(appointmentid, dateTime, doctorName, description, patientid, patientName, dob, int.Parse(appointment[3])));
            }

            return(appointments);
        }
Exemple #2
0
        /// <summary>
        /// Registers the patient.
        /// </summary>
        /// <param name="lname">The lname.</param>
        /// <param name="fname">The fname.</param>
        /// <param name="dob">The dob.</param>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="phone">The phone.</param>
        /// <param name="gender">The gender.</param>
        public static bool RegisterPatient(string lname, string fname, Date dob, string street, string city, string state, string zip,
                                           string phone, Gender gender)
        {
            var dba = new PatientDatabaseAccess();
            var a   = new Address(street, city, state, zip);
            //$"{dob:yyyy MM dd}";
            var p = new Patient(null, fname, lname, dob, a, phone, gender);

            return(dba.CreatePatient(p));
        }
Exemple #3
0
        /// <summary>
        /// Searches for patients.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="option">The option.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException">option - null</exception>
        public static List <Patient> SearchForPatients(List <string> search, SearchOption option)
        {
            var        patientList = new List <Patient>();
            List <int> patientids;

            switch (option)
            {
            case SearchOption.Name:
                patientids = new PatientDatabaseAccess().SearchPatientsWithName(search[0]);
                break;

            case SearchOption.Date:
                patientids = new PatientDatabaseAccess().SearchPatientsWithDate(search[0]);
                break;

            case SearchOption.Both:
                var byName = new PatientDatabaseAccess().SearchPatientsWithName(search[0]);
                var byDate = new PatientDatabaseAccess().SearchPatientsWithDate(search[1]);
                patientids = byName.Intersect(byDate).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(option), option, null);
            }

            foreach (var patient in patientids)
            {
                var patientData = new PatientDatabaseAccess().GetPatientDataFromId(patient);
                var fullDate    = patientData[2].Split(' ')[0].Split('/');
                Debug.WriteLine(fullDate);
                var date    = new Date(fullDate[2], fullDate[0], fullDate[1]);
                var address = new Address(patientData[3], patientData[4], patientData[5], patientData[6]);
                var gender  = patientData[8] == "Male" ? Gender.Male : Gender.Female;
                var pt      = new Patient(patientData[9], patientData[0], patientData[1], date, address, patientData[7],
                                          gender)
                {
                    Patientid = patientData[10]
                };
                patientList.Add(pt);
            }

            return(patientList);
        }
Exemple #4
0
        public static bool UpdatePatient(Patient p)
        {
            var dba = new PatientDatabaseAccess();

            return(dba.UpdatePatient(p));
        }