public Examination Get(int id)
 {
     try
     {
         var exam = _context.Examinations.Find(id);
         if (exam is null)
         {
             throw new NotFoundException("Examination with id " + id + " not found.");
         }
         return(new Examination(new ExaminationMemento()
         {
             Appointment = exam.DateAndTime,
             Doctor = _doctorRepository.Get(exam.DoctorJmbg),
             Patient = _patientRepository.Get(exam.PatientCard.PatientJmbg),
             Room = _roomRepository.Get(exam.Room.Id),
             Id = exam.Id,
             ExaminationStatus = exam.ExaminationStatus.ToExaminationStatus(),
             ExaminationType = exam.Type.ToExaminationType()
         }));
     }
     catch (ScheduleServiceException)
     {
         throw;
     }
     catch (Exception e)
     {
         throw new DataStorageException(e.Message);
     }
 }
        public Doctor Delete(int id)
        {
            var doctor = _repository.Get(id);

            if (doctor == null)
            {
                AddNotification("Doctor", "Não foi encontrado o Doutor solicitado");
            }
            else
            {
                _repository.Delete(doctor);
            }
            return(doctor);
        }
Beispiel #3
0
        public BusinessDay GetEager(long id)
        {
            BusinessDay businessDay = Get(id);

            businessDay.doctor = _doctorRepository.Get(businessDay.doctor.GetId());
            businessDay.room   = _roomRepository.GetEager(businessDay.room.GetId());
            return(businessDay);
        }
        public Schedule Create(CreateScheduleDto schedule)
        {
            if (!_repository.CheckAvailability(schedule.Initial))
            {
                AddNotification("Schedule", "A data escolhida não está disponivel");
                return(null);
            }
            var doctor      = _repositoryDoctor.Get(schedule.DoctorId);
            var patient     = _repositoryPatient.Get(schedule.PatientId);
            var typeConsult = _repositoryTypeConsult.Get(schedule.TypeConsultId);
            var scheduleTmp = new Schedule(0, doctor, patient, schedule.Initial, schedule.Finish, DateTime.Now, typeConsult, (EStatus)schedule.Status);

            if (scheduleTmp.Valid)
            {
                _repository.Save(scheduleTmp);
            }
            return(scheduleTmp);
        }
Beispiel #5
0
        public void Schedule(ScheduleExaminationDTO examinationDTO)
        {
            DateTime    startTime   = examinationDTO.StartTime.AddHours(-1);
            DateTime    endTime     = examinationDTO.StartTime.AddHours(1);
            Patient     patient     = _patientRepository.Get(examinationDTO.PatientJmbg, startTime, endTime);
            Doctor      doctor      = _doctorRepository.Get(examinationDTO.DoctorJmbg, startTime, endTime);
            Room        room        = _roomRepository.Get(examinationDTO.RoomId, startTime, endTime);
            Examination examination = new Examination(examinationDTO.StartTime, patient, doctor, room);

            if (!examination.IsAvailable())
            {
                throw new ValidationException("Examination is not available.");
            }
            if (examination.IsBefore(_clock.GetTimeLimit()))
            {
                throw new ValidationException("The time limit for scheduling the examinaton has passed.");
            }

            _examinationRepository.Add(examination);
        }
        private ExaminationGeneratorDTO GetExaminationGeneratorDTO(BasicSearchDTO basicSearchDTO)
        {
            Patient patient = _patientRepository.Get(basicSearchDTO.PatientJmbg,
                                                     basicSearchDTO.EarliestDateTime,
                                                     basicSearchDTO.LatestDateTime);
            Doctor doctor = _doctorRepository.Get(basicSearchDTO.DoctorJmbg,
                                                  basicSearchDTO.EarliestDateTime,
                                                  basicSearchDTO.LatestDateTime);
            IEnumerable <Room> rooms = _roomRepository.GetByEquipmentTypes(RoomType.Examination,
                                                                           basicSearchDTO.RequiredEquipmentTypes,
                                                                           basicSearchDTO.EarliestDateTime,
                                                                           basicSearchDTO.LatestDateTime);
            ExaminationGeneratorDTO examinationGeneratorDTO = new ExaminationGeneratorDTO(
                patient,
                doctor,
                rooms,
                FixTime(basicSearchDTO.EarliestDateTime),
                FixTime(basicSearchDTO.LatestDateTime));

            return(examinationGeneratorDTO);
        }
Beispiel #7
0
        // GET: DoctorController/Edit/5
        public ActionResult Edit(string id)
        {
            var allClinics = _clinicRepository.GetAll()
                             .Select(a => new SelectListItem
            {
                Text = a.Name, Value = a.Id.ToString()
            }
                                     ).ToList();

            var doctor = _doctorRepository.Get(id);

            var model = new EditViewModel
            {
                Clinics        = allClinics,
                Id             = doctor.Id,
                Email          = doctor.Email,
                EmailConfirmed = doctor.EmailConfirmed,
                ClinicId       = doctor.ClinicId,
                //Password = doctor.PasswordHash,
            };

            return(View(model));
        }
Beispiel #8
0
 public async Task <IEnumerable <Doctor> > Get() => await _repository.Get();
        public Doctor GetDoctor(int doctorId)
        {
            var result = _doctorRepository.Get(doctorId);

            return(result);
        }
Beispiel #10
0
        public async Task <string> Get()
        {
            var doctors = await _doctorRepository.Get();

            return(JsonConvert.SerializeObject(doctors));
        }