Example #1
0
        public void Get_patient_by_id()
        {
            // Arrange
            var patientId     = Guid.NewGuid();
            var appointmentId = Guid.NewGuid();

            DateTime date        = DateTime.Now;
            var      appointment = new AppointmentEntity(appointmentId)
            {
                Date = date
            };

            string firstName     = "David";
            string lastName      = "Bowie";
            string pesel         = "47010813770";
            var    patientEntity = new PatientEntity(patientId)
            {
                FirstName    = firstName,
                LastName     = lastName,
                Pesel        = pesel,
                Appointments = new List <AppointmentEntity>
                {
                    appointment
                }
            };

            _patientDalMock.Stub(x => x.GetPatientById(patientId)).Return(patientEntity).Repeat.Once();

            // Act
            Patient patient = _patientService.GetPatientById(patientId);

            // Assert
            _patientDalMock.VerifyAllExpectations();
            Assert.AreEqual(patientId, patient.Id);
            StringAssert.Contains(firstName, patient.FirstName);
            StringAssert.Contains(lastName, patient.LastName);
            Assert.AreEqual(date.Date, patient.Appointments.First().Date.Date);
            Assert.AreEqual(appointmentId, patient.Appointments.First().Id);
            Assert.That(patient.Pesel, Is.EqualTo(pesel));
        }
Example #2
0
        public void SaveAppointment(AppointmentModel appointment)
        {
            AppointmentEntity appointmentEntity;

            if (appointment.Id > 0)
            {
                appointmentEntity = _sampleContext.Appointments.FirstOrDefault(e => e.Id == appointment.Id);
            }
            else
            {
                appointmentEntity = new AppointmentEntity();
                _sampleContext.Appointments.Add(appointmentEntity);
            }
            if (appointmentEntity != null)
            {
                appointmentEntity.StudentId     = appointment.StudentId;
                appointmentEntity.StudentName   = appointment.StudentName;
                appointmentEntity.StudentCourse = appointment.StudentCourse;
                appointmentEntity.Appointment   = appointment.Appointment;
            }
            _sampleContext.SaveChanges();
        }
    public string CreateFollowUp()
    {
        SaleEntity sale = AgentFactory.GetSaleAgent().GetSaleEntity(SuperStateManager.GetCurrentId("sale"));

        if (sale != null)
        {
            AppointmentAgent  agent = new AppointmentAgent();
            AppointmentEntity app   = agent.CreateDefaultAppointmentEntityByType(SuperOffice.Data.TaskType.Appointment);
            app.Contact     = sale.Contact;
            app.Person      = sale.Person;
            app.Associate   = sale.Associate;
            app.Description = "Sample Follow-up from Sale " + sale.SaleId;
            app.StartDate   = DateTime.Today.AddDays(7);
            app.EndDate     = app.StartDate;
            app             = agent.SaveAppointmentEntity(app);
            return(app.AppointmentId.ToString());
        }
        else
        {
            return(String.Empty);
        }
    }
Example #4
0
        public void Get_all_appointments_from_database()
        {
            // Arrange
            string   firstName       = "Kenny";
            string   lastName        = "Hickey";
            DateTime appointmentDate = DateTime.Now;

            DatabaseTools.AddPatientToDatabase(firstName, lastName, appointmentDate);

            // Act
            IList <AppointmentEntity> appointments = _patientDal.GetAllAppointments();

            // Assert
            Assert.IsNotNull(appointments);
            Assert.IsNotEmpty(appointments);
            Assert.IsTrue(appointments.Count() == 1);
            AppointmentEntity appointment = appointments.First();

            Assert.AreEqual(appointment.Date.Date, appointmentDate.Date);

            Assert.AreEqual(appointment.Patient.FirstName, firstName);
            Assert.AreEqual(appointment.Patient.LastName, lastName);
        }
Example #5
0
        public static List <AppointmentEntity> GetFakeBookingsAsList()
        {
            var fakeAppt1 = new AppointmentEntity()
            {
                PatientID = 1, AppointmentDateTime = DateTime.Now
            };
            var fakeAppt2 = new AppointmentEntity()
            {
                PatientID = 2, AppointmentDateTime = DateTime.Now.AddDays(1)
            };
            var fakeAppt3 = new AppointmentEntity()
            {
                PatientID = 3, AppointmentDateTime = DateTime.Now.AddDays(3)
            };

            var list = new List <AppointmentEntity>();

            list.Add(fakeAppt1);
            list.Add(fakeAppt2);
            list.Add(fakeAppt3);

            return(list);
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("Id,Time,DoctorId,PatientId,Comment")] AppointmentViewModel appointmentViewModel)
        {
            var appointmentEntity = new AppointmentEntity()
            {
                DoctorId = appointmentViewModel.DoctorId,
                //        Doctor = new DoctorEntity(),
                PatientId = appointmentViewModel.PatientId,
                Time      = appointmentViewModel.Time,
                Comment   = appointmentViewModel.Comment,
                //        Patient = new PatientEntity(),
                ReviewStatuse = AppointmentStatuse.Waiting
            };

            if (ModelState.IsValid)
            {
                _context.Add(appointmentEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"]  = new SelectList(_context.Doctors, "Id", "Id", appointmentEntity.DoctorId);
            ViewData["PatientId"] = new SelectList(_context.Patients, "Id", "Id", appointmentEntity.PatientId);
            return(View(appointmentEntity));
        }
        public void WhenCreate_ThenReturnsAppointment()
        {
            var start = DateTime.UtcNow.AddDays(1);
            var end   = start.AddDays(1);

            this.clinicsService.Setup(cs => cs.GetDoctor(It.IsAny <string>()))
            .Returns(new Doctor {
                Id = "adoctorid"
            });
            var entity = new AppointmentEntity(this.logger.Object, this.idFactory.Object);

            this.storage.Setup(s =>
                               s.Save(It.IsAny <AppointmentEntity>()))
            .Returns(entity);

            var result = this.appointmentsApplication.Create(this.caller.Object, start, end, null);

            result.Id.Should().Be("anid");
            this.storage.Verify(s =>
                                s.Save(It.Is <AppointmentEntity>(e =>
                                                                 e.StartUtc == start &&
                                                                 e.EndUtc == end &&
                                                                 e.DoctorId == null)));
        }
Example #8
0
        protected override void ExecuteBusinessLogic(PluginContext pluginContext)
        {
            var appointment = pluginContext.TargetImageEntity;

            if (appointment == null)
            {
                return;
            }

            AppointmentEntity newAppointment = new AppointmentEntity()
            {
                Body      = string.Empty,
                End       = null,
                Location  = string.Empty,
                OutlookId = string.Empty,
                Start     = null,
                Subject   = string.Empty,
                RequiredAttendeesEmails = new List <string>()
            };

            newAppointment.CrmId = appointment.Id;
            if (appointment.Contains("subject"))
            {
                newAppointment.Subject = appointment["subject"].ToString();
            }
            if (appointment.Contains("location"))
            {
                newAppointment.Location = appointment["location"].ToString();
            }
            if (appointment.Contains("description"))
            {
                newAppointment.Body = appointment["description"].ToString();
            }
            if (appointment.Contains("scheduledstart"))
            {
                newAppointment.Start = DateTime.Parse(appointment["scheduledstart"].ToString());
            }
            if (appointment.Contains("scheduledend"))
            {
                newAppointment.End = DateTime.Parse(appointment["scheduledend"].ToString());
            }
            if (appointment.Contains("ylv_outlookid"))
            {
                newAppointment.OutlookId = appointment["ylv_outlookid"].ToString();
            }

            if (appointment.Contains("ylv_emailness"))
            {
                foreach (var attendees in appointment["ylv_emailness"].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                {
                    newAppointment.RequiredAttendeesEmails.Add(attendees.Trim());
                }
            }
            if (string.IsNullOrEmpty(newAppointment.OutlookId))
            {
                var attendeesCollection = appointment.GetAttributeValue <EntityCollection>("requiredattendees");
                foreach (var att in attendeesCollection.Entities)
                {
                    var responserRef = (EntityReference)att["partyid"];
                    if (responserRef.LogicalName == "contact")
                    {
                        var response = new Entity("ylv_response");
                        response["ylv_name"]         = appointment["subject"].ToString();
                        response["ylv_contact"]      = responserRef;
                        response["ylv_responsetype"] = new OptionSetValue((int)ResponseType.Unknown);
                        response["ylv_responses"]    = appointment.ToEntityReference();
                        response.Id = pluginContext.OrganizationService.Create(response);
                    }
                    else if (responserRef.LogicalName == "systemuser")
                    {
                        var response = new Entity("ylv_response");
                        response["ylv_name"]         = appointment["subject"].ToString();
                        response["ylv_sysuser"]      = responserRef;
                        response["ylv_responsetype"] = new OptionSetValue((int)ResponseType.Unknown);
                        response["ylv_responses"]    = appointment.ToEntityReference();
                        response.Id = pluginContext.OrganizationService.Create(response);
                    }
                }
            }

            var data = CreateAppointmentInOutlook(newAppointment, serviceUrl);

            Entity crmAppointment = new Entity("appointment");

            crmAppointment.Id = appointment.Id;
            crmAppointment["ylv_outlookid"] = data.Trim('"');
            pluginContext.OrganizationService.Update(crmAppointment);
        }
Example #9
0
 public void InsertIntoAppointment(AppointmentEntity appointment)
 {
     data.InsertIntoAppointment(appointment);
 }
 public async Task <bool> CreateAppointment(AppointmentEntity appointmentToCreate)
 {
     return(await _appointmentRepository.CreateAppointment(appointmentToCreate));
 }
 public void BookTimeSlot(int slotIndex, AppointmentEntity appointment)
 {
     TimeSlots[slotIndex].Appointment = appointment;
 }
Example #12
0
 public AppointmentEntity Save(AppointmentEntity clinic)
 {
     this.clinicEventStreamStorage.Save(clinic);
     return(clinic);
 }