public List <Appointment> GetFutureAppointments(Member member) { using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { List <Appointment> appointments = new List <Appointment>(); appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Future, paths: new string[] { "Doctor", "Member", "Hospital" }).ToList(); return(appointments); } }
public List <Appointment> GetHistoryAppointments(Member member) { using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { List <Appointment> appointments = new List <Appointment>(); appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State != AppointmentEnumState.Future, paths: new string[] { "Doctor", "Member", "Hospital", "Medicines" }).ToList(); foreach (var item in appointments) { item.Doctor.Age = (DateTime.Now.Year - item.Doctor.Birthday.Year); } return(appointments); } }
public List <string> GetSelectableAppointmentTime(DateTime date, Doctor doctor) { List <Appointment> appointments = new List <Appointment>(); List <string> times = new List <string>(); using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Future, paths: new string[] { "Doctor" }).ToList(); } foreach (var item in appointments) { if (item.Time.ToString("dd.MM.yyyy") == date.ToString("dd.MM.yyyy")) { times.Add(item.Time.ToString("HH:mm")); } } return(times.Distinct().ToList()); }
public List <DoctorEnumExpertise> GetSelectedHospitalExpertises(Hospital hospital, Member member) { using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { List <Appointment> appointments = new List <Appointment>(); appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Future, paths: new string[] { "Doctor" }).ToList(); List <DoctorEnumExpertise> existingExpertise = new List <DoctorEnumExpertise>(); foreach (var item in appointments) { existingExpertise.Add(item.Doctor.Expertise); } List <DoctorEnumExpertise> expertises = new List <DoctorEnumExpertise>(); foreach (var item in hospital.Doctors) { expertises.Add(item.Expertise); } List <DoctorEnumExpertise> expertisesFinal = new List <DoctorEnumExpertise>(); foreach (var item in expertises) { expertisesFinal.Add(item); } foreach (var item in existingExpertise) { foreach (var exp in expertises) { if (expertises.Contains(item)) { expertisesFinal.Remove(item); } } } return(expertisesFinal.Distinct().ToList()); } }
public List <string> GetStatistic(Doctor doctor) { List <string> statistics = new List <string>(); using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { DateTime thirtyDayAgo = DateTime.Now.AddDays(-30); { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Attended && I.Time.CompareTo(thirtyDayAgo) > 0).Count().ToString()); } { int medicineCount = 0; List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Attended && I.Time.CompareTo(thirtyDayAgo) > 0, paths: new string[] { "Medicines" }).ToList(); foreach (var item in appointments) { medicineCount += item.Medicines.Count; } statistics.Add(medicineCount.ToString()); } { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Cancel && I.Time.CompareTo(thirtyDayAgo) > 0).Count().ToString()); } { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.NotAttended && I.Time.CompareTo(thirtyDayAgo) > 0).Count().ToString()); } { int ageSum = 0; List <Member> members = new List <Member>(); List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Attended && I.Time.CompareTo(thirtyDayAgo) > 0, paths: new string[] { "Member" }).ToList(); foreach (var item in appointments) { item.Member.Age = item.Time.Year - item.Member.Birthday.Year; members.Add(item.Member); } foreach (var item in members.Distinct()) { ageSum += item.Age; } if (members.Distinct().Count() == 0) { statistics.Add("0"); } else { statistics.Add(((double)ageSum / (double)members.Distinct().Count()).ToString()); } } { double man = 0, woman = 0; List <Appointment> appointments = new List <Appointment>(); appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.DoctorId == doctor.Id && I.State == AppointmentEnumState.Attended && I.Time.CompareTo(thirtyDayAgo) > 0, paths: new string[] { "Member" }).ToList(); foreach (var item in appointments) { if (item.Member.Gender == MemberEnumGender.Erkek) { man++; } else { woman++; } } if (man == 0 && woman == 0) { statistics.Add("0"); statistics.Add("0"); } else { statistics.Add(Math.Round(man / (man + woman) * 100, 2).ToString()); statistics.Add(Math.Round(woman / (man + woman) * 100, 2).ToString()); } } return(statistics); } }
public List <string> GetStatistic(Member member) { List <string> statistics = new List <string>(); using (RepositoryAppointment repositoryAppointment = new RepositoryAppointment()) { { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Attended).Count().ToString()); } { int medicineCount = 0; List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Attended, paths: new string[] { "Medicines" }).ToList(); foreach (var item in appointments) { medicineCount += item.Medicines.Count; } statistics.Add(medicineCount.ToString()); } { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Cancel).Count().ToString()); } { statistics.Add(repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.NotAttended).Count().ToString()); } { int ageSum = 0; List <Doctor> doctors = new List <Doctor>(); List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Attended, paths: new string[] { "Doctor" }).ToList(); foreach (var item in appointments) { item.Doctor.Age = item.Time.Year - item.Doctor.Birthday.Year; doctors.Add(item.Doctor); } foreach (var item in doctors.Distinct()) { ageSum += item.Age; } if (doctors.Distinct().Count() == 0) { statistics.Add("0"); } else { statistics.Add(((double)ageSum / (double)doctors.Distinct().Count()).ToString()); } } { int maxAge = 0; List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Attended, paths: new string[] { "Doctor" }).ToList(); foreach (var item in appointments) { item.Doctor.Age = item.Time.Year - item.Doctor.Birthday.Year; if (item.Doctor.Age >= maxAge) { maxAge = item.Doctor.Age; } } statistics.Add(maxAge.ToString()); } { int minAge = 200; List <Appointment> appointments = repositoryAppointment.WhereWithExplicitLoad(I => I.MemberId == member.Id && I.State == AppointmentEnumState.Attended, paths: new string[] { "Doctor" }).ToList(); foreach (var item in appointments) { item.Doctor.Age = item.Time.Year - item.Doctor.Birthday.Year; if (item.Doctor.Age <= minAge) { minAge = item.Doctor.Age; } } statistics.Add(minAge.ToString()); } return(statistics); } }