public void Add(Examination examination)
 {
     try
     {
         var memento            = examination.GetMemento();
         var patientCard        = _context.PatientCards.Where(c => c.PatientJmbg == memento.Patient.Jmbg.Value).FirstOrDefault();
         var backendExamination = new Backend.Model.PerformingExamination.Examination()
         {
             DoctorJmbg        = memento.Doctor.Jmbg.Value,
             DateAndTime       = memento.Appointment,
             IdRoom            = memento.Room.Id,
             IdPatientCard     = patientCard.Id,
             IsSurveyCompleted = false,
             ExaminationStatus = memento.ExaminationStatus.ToBackendExaminationStatus(),
             Type = memento.ExaminationType.ToBackendExaminationType()
         };
         _context.Add(backendExamination);
         _context.SaveChanges();
     }
     catch (ScheduleServiceException)
     {
         throw;
     }
     catch (DbUpdateException e)
     {
         throw new ValidationException(e.Message);
     }
     catch (Exception e)
     {
         throw new DataStorageException(e.Message);
     }
 }
 public void Update(Examination examination)
 {
     try
     {
         var memento = examination.GetMemento();
         var exam    = _context.Examinations.Find(memento.Id);
         if (exam is null)
         {
             throw new NotFoundException("Examination with id " + memento.Id + " not found.");
         }
         exam.ExaminationStatus = memento.ExaminationStatus.ToBackendExaminationStatus();
         _context.Update(exam);
         _context.SaveChanges();
     }
     catch (ScheduleServiceException)
     {
         throw;
     }
     catch (DbUpdateException e)
     {
         throw new ValidationException(e.Message);
     }
     catch (Exception e)
     {
         throw new DataStorageException(e.Message);
     }
 }
        public static ExaminationDTO ToExaminationDTO(this Examination examination)
        {
            ExaminationMemento memento = examination.GetMemento();

            return(new ExaminationDTO()
            {
                DateAndTime = memento.DateAndTime,
                Anamnesis = memento.Anamnesis,
                DoctorJmbg = memento.DoctorJmbg,
                DoctorName = memento.DoctorName,
                DoctorSurname = memento.DoctorSurname,
                Id = memento.Id
            });
        }
Exemple #4
0
        public static UnscheduledExaminationDTO ToUnscheduledExaminationDTO(this Examination examination)
        {
            var memento = examination.GetMemento();

            return(new UnscheduledExaminationDTO()
            {
                StartTime = memento.Appointment,
                DoctorJmbg = memento.Doctor.Jmbg.Value,
                DoctorName = memento.Doctor.Name,
                DoctorSurname = memento.Doctor.Surname,
                PatientJmbg = memento.Patient.Jmbg.Value,
                PatientName = memento.Patient.Name,
                PatientSurname = memento.Patient.Surname,
                ExaminationType = memento.ExaminationType.ToString(),
                RoomId = memento.Room.Id
            });
        }