Esempio n. 1
0
 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 List<Patient> GetAllpatients()
 {
     List<Patient> aaa = new List<Patient>();
     try
     {
         List<PatientBDO> patientTable = patientLogic.GetAllpatients();
         foreach (PatientBDO pBDO in patientTable)
         {
             var patient = new Patient();
             TranslatePatientBDOToPatientDTO(pBDO, patient);
             aaa.Add(patient);
         }
     }
     catch (Exception e)
     {
         var msg = e.Message;
         var reason = "GetAllpatients exception";
         throw new FaultException<DoctorFault>
             (new DoctorFault(msg), reason);
     }
     if (aaa == null)
     {
         var msg = "GetAllpatients is empty";
         var reason = "patientTable empty";
         throw new FaultException<DoctorFault>
             (new DoctorFault(msg), reason);
     }
     return aaa;
 }
Esempio n. 3
0
 public Patient GetPatient(int id)
 {
     PatientBDO patientBDO = null;
     try
     {
         patientBDO = patientLogic.GetPatient(id);
     }
     catch (Exception e)
     {
         var msg = e.Message;
         var reason = "GetPatient exception";
         throw new FaultException<PatientFault>
             (new PatientFault(msg), reason);
     }
     if (patientBDO == null)
     {
         var msg =
             string.Format("No patient found for id {0}",
             id);
         var reason = "GetPatient empty";
         throw new FaultException<PatientFault>
             (new PatientFault(msg), reason);
     }
     var patient = new Patient();
     TranslatePatientBDOToPatientDTO(patientBDO,
         patient);
     return patient;
 }
Esempio n. 4
0
 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;
 }
        private bool PatientCheck(ref Patient patient,
            ref string message)
        {
            var result = true;
            if (string.IsNullOrEmpty(patient.firstName))
            {
                message = "Patient's first name cannot be empty";
                result = false;
            }
            else if (string.IsNullOrEmpty(patient.lastName))
            {
                message = "Patient's last name cannot be empty";
                result = false;
            }
            else if (string.IsNullOrEmpty(patient.city))
            {
                message = "Patient's city cannot be empty";
                result = false;
            }
            else if (patient.zip <= 0)
            {
                message = "Patient's zip cannot be empty or smaller or equal to 0";
                result = false;
            }
            else if (string.IsNullOrEmpty(patient.street))
            {
                message = "Patient's street cannot be empty";
                result = false;
            }
            else if (patient.streetNr <= 0)
            {
                message = "Patient's street number cannot be empty or smaller or equal to 0";
                result = false;
            }
            else if (string.IsNullOrEmpty(patient.phoneNr))
            {
                message = "Patient's phone number cannot be empty";
                result = false;
            }
            else if (patient.dateOfBirth == null)
            {
                //checking to do

                message = "Patient's date of birth cannot be empty";
                result = false;
            }

            else if (string.IsNullOrEmpty(patient.login))
            {
                message = "Patient's username cannot be empty";
                result = false;
            }
            else if (string.IsNullOrEmpty(patient.pass))
            {
                message = "Patient's password cannot be empty";
                result = false;
            }
            return result;
        }
 private void TranslateAppointmentBDOToAppointmentDTO(
 AppointmentBDO AppointmentBDO,
 Appointment Appointment)
 {
     Doctor doctorDTO = new Doctor();
     new DoctorService().TranslateDoctorBDOToDoctorDTO(AppointmentBDO.doctor, doctorDTO);
     Patient patientDTO = new Patient();
     new PatientService().TranslatePatientBDOToPatientDTO(AppointmentBDO.patient, patientDTO);
     Appointment.id = AppointmentBDO.id;
     Appointment.patient = patientDTO;
     Appointment.serviceType = AppointmentBDO.serviceType;
     Appointment.time = AppointmentBDO.time;
     Appointment.doctor = doctorDTO;
     Appointment.RowVersion = AppointmentBDO.rowVersion;
 }
Esempio n. 7
0
 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);
     }
 }