public bool UpdatePatient(ref Patient patient, ref string message) { var result = true; if (!PatientCheck(ref patient, ref message)) { result = false; } else { try { var patientBDO = new PatientBDO(); TranslatePatientDTOToPatientBDO(patient, patientBDO); result = patientLogic.UpdatePatient( ref patientBDO, ref message); } catch (Exception e) { var msg = e.Message; throw new FaultException<PatientFault> (new PatientFault(msg), msg); } } return result; }
public PatientBDO GetPatient(int id) { PatientBDO patientBDO = null; using (var PHEntities = new PublicHospitalEntities()) { var patientObj = (from a in PHEntities.Patient where a.id == id select a).FirstOrDefault(); if (patientObj != null) patientBDO = new PatientBDO() { id = patientObj.id, firstName = patientObj.firstName, lastName = patientObj.lastName, city = patientObj.city, street = patientObj.street, streetNr = patientObj.streetNr, phoneNr = patientObj.phoneNr, zip = patientObj.zip, login = patientObj.login, pass = patientObj.pass, dateOfBirth = patientObj.dateOfBirth, RowVersion = patientObj.rowVersion }; } return patientBDO; }
public bool InsertPatient(ref PatientBDO patientBDO, ref string massage) { massage = "Patient inserted successfully"; var ret = true; Password passObj = new Password(); string[] passAndSalt = passObj.getFullyHash(patientBDO.pass); using (var PHEntities = new PublicHospitalEntities()) { PHEntities.Patient.Add(new Patient { id = GetNextID(), firstName = patientBDO.firstName, lastName = patientBDO.lastName, city = patientBDO.city, street = patientBDO.street, streetNr = patientBDO.streetNr, phoneNr = patientBDO.phoneNr, zip = patientBDO.zip, login = patientBDO.login, dateOfBirth = patientBDO.dateOfBirth, rowVersion = patientBDO.RowVersion, pass = passAndSalt[0], salt = passAndSalt[1] }); var num = PHEntities.SaveChanges(); if (num != 1) { ret = false; massage = "Patient was not inserted"; } } return ret; }
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 void TranslatePatientBDOToPatientDTO( PatientBDO patientBDO, Patient patient) { patient.id = patientBDO.id; patient.firstName = patientBDO.firstName; patient.lastName = patientBDO.lastName; patient.city = patientBDO.city; patient.zip = patientBDO.zip; patient.street = patientBDO.street; patient.streetNr = patientBDO.streetNr; patient.phoneNr = patientBDO.phoneNr; patient.dateOfBirth = patientBDO.dateOfBirth; patient.login = patientBDO.login; patient.pass = patientBDO.pass; }
public bool UpdatePatient( ref PatientBDO patientBDO, ref string message) { var patientInDb = GetPatient(patientBDO.id); if (patientInDb == null) { message = "cannot fetch patient with this ID"; return false; } else { return patientDAO.UpdatePatient(ref patientBDO, ref message); } }
public Patient GetAppointmentsHistoryPatient(int id, ref string message) { Patient patient = GetPatient(id); PatientBDO patientBDO = new PatientBDO(); try { TranslatePatientDTOToPatientBDO(patient, patientBDO); bool succesfull = new AppointmentLogic().GetAppointmentsHistoryPatient(ref patientBDO, ref message); if (succesfull == true) { TranslatePatientBDOToPatientDTO(patientBDO, patient); patient.appointmentsHistory = new List<Appointment>(); foreach (var appointment in patientBDO.appointmentsHistory) { Doctor doctorDTO = new Doctor(); new DoctorService().TranslateDoctorBDOToDoctorDTO(appointment.doctor, doctorDTO); patient.appointmentsHistory.Add(new Appointment { id = appointment.id, serviceType = appointment.serviceType, doctor = doctorDTO, time = appointment.time }); if (appointment.visit != null) { patient.appointmentsHistory.Last().visit = new Visit { id = appointment.visit.id, advice = appointment.visit.advice, patientProblem = appointment.visit.patientProblem, symptom = appointment.visit.symptom }; } } return patient; } else return null; } catch (Exception e) { var msg = e.Message; throw new FaultException<PatientFault>(new PatientFault(msg), msg); } }
public bool UpdatePatient(ref PatientBDO patientBDO, ref string massage) { massage = "Patient updated successfully"; var ret = true; using (var PHEntites = new PublicHospitalEntities()) { var patientId = patientBDO.id; var patientInDb = (from a in PHEntites.Patient where a.id == patientId select a).FirstOrDefault(); if (patientInDb == null) { throw new Exception("No patient with id " + patientBDO.id); } patientInDb.firstName = patientBDO.firstName; patientInDb.lastName = patientBDO.lastName; patientInDb.city = patientBDO.city; patientInDb.zip = patientBDO.zip; patientInDb.street = patientBDO.street; patientInDb.streetNr = patientBDO.streetNr; patientInDb.phoneNr = patientBDO.phoneNr; patientInDb.dateOfBirth = patientBDO.dateOfBirth; //without username and pass PHEntites.Patient.Attach(patientInDb); PHEntites.Entry(patientInDb).State = System.Data.Entity.EntityState.Modified; var num = PHEntites.SaveChanges(); if (num != 1) { ret = false; massage = "Patient was not updated"; } } return ret; }
public bool GetAppointmentsHistoryPatient(ref PatientBDO patient, ref string message) { return appointmentDAO.GetAppointmentsHistoryPatient(ref patient, ref message); }
public bool InsertPatient(ref PatientBDO patientBDO, ref string massage) { return patientDAO.InsertPatient(ref patientBDO, ref massage); }
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 GetAppointmentsHistoryPatient(ref PatientBDO patient, ref string message) { bool succesful = false; using (var PHEntities = new PublicHospitalEntities()) { int patientID = patient.id; var appointments = PHEntities.Appointment.Where(a => a.idPatient == patientID); 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, doctor = new DoctorDAO().GetDoctor(appointment.idDoctor.Value), visit = visitDAO.GetVisit(appointment.id) }); } if (appointmentList != null) { patient.appointmentsHistory = appointmentList; succesful = true; } else message = "Appointment list is empty"; } else message = "Can not get id from the database appointment"; } return succesful; }