public bool AppointmentBooking(string patientName, string doctorName, DateTime appointmentTime, string clinicName)
        {
            string[] patientNames = patientName.Split(' ');
            string[] doctorNames = doctorName.Split(' ');

            if (patientNames.Length != 2 || doctorNames.Length != 2)
            {
                return false;
            }

            Patient patient = GetPatientInfo(patientNames[0], patientNames[1]);
            Doctor doctor = GetDoctorInfo(doctorNames[0], doctorNames[1]);

            Appointment a = new Appointment()
            {
                HealthInsuranceNo = patient.HealthInsuranceNo,
                MedicalRegistrationNo = doctor.MedicalRegistrationNo,
                AppointmentTime = appointmentTime,
                ClinicName = clinicName
            };

            string sql = String.Format("INSERT INTO Appointments VALUES('{0}', '{1}', '{2}', '{3}')",
                a.HealthInsuranceNo, a.MedicalRegistrationNo, a.AppointmentTime, a.ClinicName);

            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();

            int num;
            try
            {
                num = command.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                conn.Close();
                throw new FaultException(e.Message);
            }

            if (num > 0)
                return true;
            else
                return false;
        }
        public bool AppointmentReschedule(string patientName, string doctorName, DateTime newTime)
        {
            string[] patientNames = patientName.Split(' ');
            string[] doctorNames = doctorName.Split(' ');

            if (patientNames.Length != 2 || doctorNames.Length != 2)
            {
                return false;
            }

            Patient patient = GetPatientInfo(patientNames[0], patientNames[1]);
            Doctor doctor = GetDoctorInfo(doctorNames[0], doctorNames[1]);

            Appointment a = new Appointment()
            {
                HealthInsuranceNo = patient.HealthInsuranceNo,
                MedicalRegistrationNo = doctor.MedicalRegistrationNo,
                AppointmentTime = newTime,
            };

            string sql = String.Format("UPDATE Appointments SET AppointmentTime='{0}' WHERE HealthInsuranceNo='{1}' AND MedicalRegistrationNo='{2}'",
                a.AppointmentTime, a.HealthInsuranceNo, a.MedicalRegistrationNo);

            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();

            int num;
            try
            {
                num = command.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                conn.Close();
                throw new FaultException(e.Message);
            }

            if (num > 0)
                return true;
            else
                return false;
        }
        public Models.Appointment GetAppointment(string patientName, string doctorName)
        {
            string[] patientNames = patientName.Split(' ');
            string[] doctorNames = doctorName.Split(' ');

            if (patientNames.Length != 2 || doctorNames.Length != 2)
            {
                return null;
            }

            Patient patient = GetPatientInfo(patientNames[0], patientNames[1]);
            Doctor doctor = GetDoctorInfo(doctorNames[0], doctorNames[1]);

            string sql = String.Format("SELECT * FROM Appointments WHERE HealthInsuranceNo = '{0}' AND MedicalRegistrationNo = '{1}'",
                patient.HealthInsuranceNo, doctor.MedicalRegistrationNo);

            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();

            SqlDataReader reader;
            try
            {
                reader = command.ExecuteReader();
            }
            catch (Exception e)
            {
                conn.Close();
                throw new FaultException(e.Message);
            }

            if (reader.HasRows)
            {
                reader.Read();

                Appointment result = new Appointment()
                {
                    HealthInsuranceNo = reader.GetString(0),
                    MedicalRegistrationNo = reader.GetString(1),
                    AppointmentTime = reader.GetDateTime(2),
                    ClinicName = reader.GetString(3)
                };

                reader.Close();
                conn.Close();
                return result;
            }
            else
                conn.Close();
                reader.Close();
                return null;
        }
        public Models.Appointment GetAppointment(string patientName, string doctorName)
        {
            string[] patientNames = patientName.Split(' ');
            string[] doctorNames = doctorName.Split(' ');

            if (patientNames.Length != 2 || doctorNames.Length != 2)
            {
                return null;
            }

            Patient patient = GetPatientInfo(patientNames[0], patientNames[1]);
            Doctor doctor = GetDoctorInfo(doctorNames[0], doctorNames[1]);

            AppointmentData aData = (from a in db.AppointmentDatas
                                     where a.HealthInsuranceNo == patient.HealthInsuranceNo
                                     && a.MedicalRegistrationNo == doctor.MedicalRegistrationNo
                                     select a).FirstOrDefault();

            if (aData == null)
            {
                return null;
            }

            Appointment aModel = new Appointment()
            {
                HealthInsuranceNo = aData.HealthInsuranceNo,
                MedicalRegistrationNo = aData.MedicalRegistrationNo,
                AppointmentTime = aData.AppointmentTime,
                ClinicName = aData.ClinicName
            };

            return aModel;
        }