public AppointmentBDO(int id, DateTime time, string serviceType, PatientBDO patient, DoctorBDO doctor, VisitBDO visit) { this.id = id; this.time = time; this.serviceType = serviceType; this.patient = patient; this.doctor = doctor; this.visit = visit; }
public List<AppointmentBDO> GetAllAppointments() { List<AppointmentBDO> appointments = null; AppointmentBDO appointmentBDO = null; PatientBDO patientBDO = null; DoctorBDO doctorBDO = null; using (var PHEntities = new PublicHospitalEntities()) { var listInDb = (from Appointment in PHEntities.Appointment from Doctor in PHEntities.Doctor from Patient in PHEntities.Patient where Appointment.idDoctor == Doctor.id && Appointment.idPatient == Patient.id select new { Appointment.id, Appointment.time, Appointment.serviceType, Doctor.firstName, Doctor.lastName, DoctorId = Doctor.id, Column1 = Patient.firstName, Column2 = Patient.lastName, Column3 = Patient.id }); if (listInDb != null) { appointments = new List<AppointmentBDO>(); foreach (var mergedList in listInDb) { if (mergedList != null) { doctorBDO = new DoctorBDO(); patientBDO = new PatientBDO(); doctorBDO.firstName = mergedList.firstName; doctorBDO.lastName = mergedList.lastName; doctorBDO.id = mergedList.DoctorId; patientBDO.firstName = mergedList.Column1; patientBDO.lastName = mergedList.Column2; patientBDO.id = mergedList.Column3; appointmentBDO = new AppointmentBDO() { id = mergedList.id, time = mergedList.time, serviceType = mergedList.serviceType, doctor = doctorBDO, patient = patientBDO }; appointments.Add(appointmentBDO); } } } } return appointments; }
public bool UpdateDoctor( ref DoctorBDO doctorBDO, ref string message) { var doctorInDb = GetDoctor(doctorBDO.id); if (doctorInDb == null) { message = "cannot fetch doctor with this ID"; return false; } else { return doctorDAO.UpdateDoctor(ref doctorBDO, ref message); } }
public bool DeleteDoctor(ref Doctor doctor, ref string message) { var result = false; try { var doctorBDO = new DoctorBDO(); TranslateDoctorDTOToDoctorBDO(doctor, doctorBDO); result = doctorLogic.DeleteDoctor( ref doctorBDO, ref message); } catch (Exception e) { var msg = e.Message; throw new FaultException<DoctorFault> (new DoctorFault(msg), msg); } return result; }
public bool InsertDoctor(ref DoctorBDO doctorBDO, ref string massage) { return doctorDAO.InsertDoctor(ref doctorBDO, ref massage); }
public bool GetAppointmentsHistoryDoctor(ref DoctorBDO doctor, ref string message) { return appointmentDAO.GetAppointmentsHistoryDoctor(ref doctor, ref message); }
public bool DeleteDoctor(ref DoctorBDO doctorBDO, ref string message) { doctorBDO.isDeleted = true; return doctorDAO.DeleteDoctor(ref doctorBDO, ref message); }
private void TranslateAppointmentDTOToAppointmentBDO( Appointment Appointment, AppointmentBDO AppointmentBDO) { DoctorBDO doctorBDO = new DoctorBDO(); new DoctorService().TranslateDoctorDTOToDoctorBDO(Appointment.doctor, doctorBDO); PatientBDO patientBDO = new PatientBDO(); new PatientService().TranslatePatientDTOToPatientBDO(Appointment.patient, patientBDO); AppointmentBDO.id = Appointment.id; AppointmentBDO.patient = patientBDO; AppointmentBDO.serviceType = Appointment.serviceType; AppointmentBDO.time = Appointment.time; AppointmentBDO.doctor = doctorBDO; AppointmentBDO.rowVersion = Appointment.RowVersion; }
public bool UpdateDoctor(ref Doctor doctor, ref string message) { var result = true; if (!DoctorCheck(ref doctor, ref message)) { result = false; } else { try { var doctorBDO = new DoctorBDO(); TranslateDoctorDTOToDoctorBDO(doctor, doctorBDO); result = doctorLogic.UpdateDoctor( ref doctorBDO, ref message); doctor.RowVersion = doctorBDO.RowVersion; } catch (Exception e) { var msg = e.Message; throw new FaultException<DoctorFault> (new DoctorFault(msg), msg); } } return result; }
public void TranslateDoctorDTOToDoctorBDO( Doctor doctor, DoctorBDO doctorBDO) { doctorBDO.id = doctor.id; doctorBDO.firstName = doctor.firstName; doctorBDO.lastName = doctor.lastName; doctorBDO.city = doctor.city; doctorBDO.zip = doctor.zip; doctorBDO.street = doctor.street; doctorBDO.streetNr = doctor.streetNr; doctorBDO.phoneNr = doctor.phoneNr; doctorBDO.specialty = doctor.specialty; doctorBDO.description = doctor.description; doctorBDO.login = doctor.login; doctorBDO.pass = doctor.pass; doctorBDO.RowVersion = doctor.RowVersion; }
public Doctor GetAppointmentsHistoryDoctor(int id, ref string message) { Doctor doctor = GetDoctor(id); DoctorBDO doctorBDO = new DoctorBDO(); try { TranslateDoctorDTOToDoctorBDO(doctor, doctorBDO); bool succesfull = new AppointmentLogic().GetAppointmentsHistoryDoctor(ref doctorBDO, ref message); if (succesfull == true) { TranslateDoctorBDOToDoctorDTO(doctorBDO, doctor); doctor.appointmentsHistory = new List<Appointment>(); foreach (var appointment in doctorBDO.appointmentsHistory) { Patient patientDTO = new Patient(); new PatientService().TranslatePatientBDOToPatientDTO(appointment.patient, patientDTO); doctor.appointmentsHistory.Add(new Appointment { id = appointment.id, serviceType = appointment.serviceType, patient = patientDTO, time = appointment.time }); if (appointment.visit != null) { doctor.appointmentsHistory.Last().visit = new Visit { id = appointment.visit.id, advice = appointment.visit.advice, patientProblem = appointment.visit.patientProblem, symptom = appointment.visit.symptom }; } } return doctor; } else return null; } catch (Exception e) { var msg = e.Message; throw new FaultException<PatientFault>(new PatientFault(msg), msg); } }
public bool GetAppointmentsHistoryDoctor(ref DoctorBDO doctor, ref string message) { bool succesful = false; using (var PHEntities = new PublicHospitalEntities()) { int doctorID = doctor.id; var appointments = PHEntities.Appointment.Where(a => a.idDoctor == doctorID); if (appointments.FirstOrDefault() != null) { VisitDAO visitDAO = new VisitDAO(); List<AppointmentBDO> appointmentList = new List<AppointmentBDO>(); foreach (var appointment in appointments) { appointmentList.Add(new AppointmentBDO() { id = appointment.id, time = Convert.ToDateTime(appointment.time), serviceType = appointment.serviceType, patient = new PatientDAO().GetPatient(appointment.idPatient.Value), visit = visitDAO.GetVisit(appointment.id) }); } if (appointmentList != null) { doctor.appointmentsHistory = appointmentList; succesful = true; } else message = "Appointment list is empty"; } else message = "Can not get id from the database appointment"; } return succesful; }