Exemple #1
0
 public Appointment(AppointmentId appointmentId, DoctorId doctorId, PatientId patientId, DateTime appointmentAt, AppointmentDuration appointmentDuration)
 {
     AppointmentId       = appointmentId;
     DoctorId            = doctorId;
     PatientId           = patientId;
     AppointmentAt       = appointmentAt;
     AppointmentDuration = appointmentDuration;
 }
Exemple #2
0
 public ConsultationSchedulingIsCompletedEvent(PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime patientRegistrationDate, DateTime consultationDate)
 {
     PatientId               = patientId;
     DoctorId                = doctorId;
     TreatmentRoomId         = treatmentRoomId;
     PatientRegistrationDate = patientRegistrationDate;
     ConsultationDate        = consultationDate;
 }
Exemple #3
0
 //TODO:Validate arguments
 public CreateConsultationCommand(ConsultationId aggregateId, PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime registrationDate, DateTime consultationDate) : base(aggregateId)
 {
     PatientId        = patientId;
     DoctorId         = doctorId;
     TreatmentRoomId  = treatmentRoomId;
     RegistrationDate = registrationDate;
     ConsultationDate = consultationDate;
 }
Exemple #4
0
 public void AssignSpecialization(Specialization specializationData)
 {
     if (Specializations.Contains(specializationData))
     {
         throw new TheDoctorAlreadyHasSpecializationException("Doctor: " + DoctorId.ToString() + "Spec: " + specializationData);
     }
     Specializations.Add(specializationData);
 }
Exemple #5
0
    public DayTests()
    {
        RegisterHandlers <Handlers>();

        _doctorId = new DoctorId(Guid.NewGuid());
        _date     = new DateTime(2020, 5, 2, 10, 0, 0);
        _dayId    = new DayId(_doctorId, _date);
    }
Exemple #6
0
 public Visit(DoctorId doctorId, DateTime date, PatientId patientId = null)
 {
     _state = new VisitState {
         Doctor = doctorId ?? throw new ArgumentNullException(nameof(doctorId)),
                        Date    = date,
                        Patient = patientId
     };
 }
Exemple #7
0
        public IActionResult Delete(DoctorId request)
        {
            var db = new CodeFirstContext();

            db.Remove(db.Doctor.Find(request.IdDoctor));
            db.SaveChanges();

            return(StatusCode(201, "Doktor został usunięty"));
        }
        //Metodo para interactuar
        public Boolean FillformDate(string sDate, string patientID, string doctorID, string observations)
        {
            AppointmentDate.SendKeys(sDate);
            PatientID.SendKeys(patientID);
            DoctorId.SendKeys(doctorID);
            Observaciones.SendKeys(observations);
            GuardarBTN.Click();

            return(true);
        }
Exemple #9
0
 public ConsultationIsCreatedEvent(ConsultationId consultationId, PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime registrationDate, DateTime consultationDate)
 {
     ConsultationId   = consultationId;
     PatientId        = patientId;
     DoctorId         = doctorId;
     TreatmentRoomId  = treatmentRoomId;
     RegistrationDate = registrationDate;
     ConsultationDate = consultationDate;
     Timestamp        = DateTime.UtcNow;
 }
        public async Task <IReadOnlyList <DoctorAvailability> > GetAllForDoctorAsync(DoctorId doctorId,
                                                                                     CancellationToken cancellationToken = default)
        {
            var context = await _dbContextProvider.GetAsync();

            return(await context.DoctorAvailabilityTables
                   .Where(x => x.DoctorId == doctorId.Value)
                   .Select(x => new DoctorAvailability(new DoctorAvailabilityId(x.DoctorAvailabilityId), new DoctorId(x.DoctorId), x.DayOfWeek,
                                                       new TimeOfDay(x.StartsAt), new TimeOfDay(x.EndsAt)))
                   .ToListAsync(cancellationToken));
        }
        public async Task <Doctor> GetByIdAsync(DoctorId doctorId, CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var doctorTable = await context.DoctorTables.SingleOrDefaultAsync(x => x.DoctorId == doctorId.Value, cancellation);

            if (doctorTable == null)
            {
                return(null);
            }

            return(new Doctor(new DoctorId(doctorTable.DoctorId), doctorTable.Name));
        }
        static void Main(string[] args)
        {
            var visitId = VisitId.New();
            var agg     = new Visit(DoctorId.New(), DateTime.Now);

            var rep    = new VisitRepository();
            var exists = rep.Get(new VisitId(Guid.Parse("b1e81cb1-0683-473a-94b6-666d9c1babe8")));

            rep.Save(agg, visitId);

            var vis = rep.Get(visitId);

            vis.ReserveVisit(PatientId.New());
            rep.Save(vis, visitId);
            Console.WriteLine("Hello World!");
        }
        public async Task HandleAsync(ScheduleAppointmentCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var unitOfWork = await _unitOfWorkFactory.CreateAsync())
            {
                // Convert from external representations to domain representations
                var appointmentId       = new AppointmentId(command.AppointmentId);
                var doctorId            = new DoctorId(command.DoctorId);
                var patientId           = new PatientId(command.PatientId);
                var appointmentDuration = new AppointmentDuration(command.AppointmentDurationInMinutes);

                // Invoke domain logic
                await _scheduleAppointmentService.ScheduleAsync(appointmentId, doctorId, patientId, command.AppointmentAt,
                                                                appointmentDuration, cancellationToken);

                await unitOfWork.CommitAsync();
            }
        }
Exemple #14
0
    public void Schedule(DoctorId doctorId, DateTime date, List <ScheduledSlot> slots, Func <Guid> idGenerator)
    {
        IsCancelledOrArchived();

        if (_isScheduled)
        {
            throw new DayAlreadyScheduledException();
        }

        var dayId = new DayId(doctorId, date);

        Raise(new DayScheduled(dayId.Value, doctorId.Value, date));

        foreach (var slot in slots)
        {
            Raise(new SlotScheduled(idGenerator(), dayId.Value, slot.StartTime, slot.Duration));
        }
    }
Exemple #15
0
        public async Task <IReadOnlyList <Appointment> > GetAllUpcomingForDoctorAsync(DoctorId doctorId,
                                                                                      CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var now = _systemClockService.UtcNow;

            return(await context.AppointmentTables
                   .Where(x => x.AppointmentAt >= now)
                   .Where(x => x.DoctorId == doctorId.Value)
                   .Select(x => new Appointment(new AppointmentId(x.AppointmentId), new DoctorId(x.DoctorId), new PatientId(x.PatientId),
                                                x.AppointmentAt, new AppointmentDuration(x.Duration)))
                   .ToListAsync(cancellation));
        }
Exemple #16
0
 public SchedulerHasReservedDoctorEvent(DoctorId doctorId, DateTime reservationDay)
 {
     DoctorId       = doctorId;
     ReservationDay = reservationDay;
 }
Exemple #17
0
 public Doctor(DoctorId doctorId, string name)
 {
     DoctorId = doctorId;
     Name     = name;
 }
        //TODO:Instead of a tuple, return a value object


        private void InitiateReservation(DateTime firstAvailableDay, TreatmentRoomId treatmentRoomId, DoctorId doctorId)
        {
            this.PublishReserveTreatmentroomCommand(treatmentRoomId, firstAvailableDay);
            this.PublishBookDoctorCommand(doctorId, firstAvailableDay);
        }
        public async Task ScheduleAsync(AppointmentId appointmentId, DoctorId doctorId, PatientId patientId, DateTime requestedAppointmentAt, AppointmentDuration requestedAppointmentDuration,
                                        CancellationToken cancellationToken = default)
        {
            if (requestedAppointmentAt < _systemClockService.UtcNow.DateTime)
            {
                throw new DomainValidationException("The appointment could not be scheduled because it occurs in the past.");
            }

            var doctor = await _doctorRepository.GetByIdAsync(doctorId, cancellationToken);

            if (doctor == null)
            {
                throw new EntityNotFoundException("The requested doctor was not found.");
            }

            var patient = await _patientRepository.GetByIdAsync(patientId, cancellationToken);

            if (patient == null)
            {
                throw new EntityNotFoundException("The requested patient was not found.");
            }

            // Does the requested appointment occur during the doctor's availability?

            var doctorAvailabilities = await _doctorAvailabilityRepository.GetAllForDoctorAsync(doctorId, cancellationToken);

            var doctorIsAvailable = doctorAvailabilities.Any(a =>
                                                             a.DayOfWeek == requestedAppointmentAt.DayOfWeek &&                            // Occurs on an available day of the week
                                                             a.StartsAt <= requestedAppointmentAt.TimeOfDay && // After that day of the week's start time
                                                             a.EndsAt >= requestedAppointmentAt.TimeOfDay + requestedAppointmentDuration); // And ends before that day of the week's end time

            if (!doctorIsAvailable)
            {
                throw new DomainValidationException("The appointment could not be scheduled because it is outside of the doctor's availability.");
            }

            // Determine if there are any scheduling conflicts.
            // Algorithm description: Two time periods overlap if each one starts before the other one ends.

            var doctorAppointments = await _appointmentRepository.GetAllUpcomingForDoctorAsync(doctorId, cancellationToken);

            var doctorHasConflictingAppointment = doctorAppointments.Any(existingAppointment =>
                                                                         requestedAppointmentAt < existingAppointment.AppointmentAt.Add(existingAppointment.AppointmentDuration) &&
                                                                         existingAppointment.AppointmentAt < requestedAppointmentAt.Add(requestedAppointmentDuration));

            if (doctorHasConflictingAppointment)
            {
                throw new DomainValidationException("The appointment could not be scheduled because the doctor has a conflicting appointment.");
            }

            var patientAppointments = await _appointmentRepository.GetAllUpcomingForPatientAsync(patientId, cancellationToken);

            var patientHasConflictingAppointment = patientAppointments.Any(existingAppointment =>
                                                                           requestedAppointmentAt < existingAppointment.AppointmentAt.Add(existingAppointment.AppointmentDuration) &&
                                                                           existingAppointment.AppointmentAt < requestedAppointmentAt.Add(requestedAppointmentDuration));

            if (patientHasConflictingAppointment)
            {
                throw new DomainValidationException("The appointment could not be scheduled because the patient has a conflicting appointment.");
            }

            var appointment = new Appointment(appointmentId, doctorId, patientId, requestedAppointmentAt, requestedAppointmentDuration);

            await _appointmentRepository.CreateAsync(appointment, cancellationToken);
        }
 public void CreateConsultation(PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime registrationDate, DateTime consultationDate)
 {
     Specs.AggregateIsNew.ThrowDomainErrorIfNotSatisfied(this);
     Emit(new ConsultationIsCreatedEvent(Id, patientId, doctorId, treatmentRoomId, registrationDate, consultationDate));
 }
        private void PublishBookDoctorCommand(DoctorId doctorId, DateTime reservationDay)
        {
            var command = new ReserveDoctorCommand(doctorId, reservationDay, Id.Value);

            this.Publish(command);
        }
 public void add_visit(string visitId, string doctorId, string date, string parentId = null)
 {
     _visitId  = new VisitId(new Guid(visitId));
     _doctorId = new DoctorId(new Guid(doctorId));
     _visit    = new Visit(_doctorId, DateTime.Parse(date));
 }