コード例 #1
0
        public EventCustomerPcpAppointmentEditModel GetEventCustomerEventModel(long eventcustomerId)
        {
            var eventCustomer = _eventCustomerRepository.GetById(eventcustomerId);

            var account = _corporateAccountRepository.GetbyEventId(eventCustomer.EventId);
            var customer = _customerRepository.GetCustomer(eventCustomer.CustomerId);
            var theEvent = _eventRepository.GetById(eventCustomer.EventId);
            var host = _hostRepository.GetHostForEvent(eventCustomer.EventId);

            var order = _orderRepository.GetOrder(eventCustomer.CustomerId, eventCustomer.EventId);
            var eventPackage = _eventPackageRepository.GetPackageForOrder(order.Id);
            var eventTest = _eventTestRepository.GetTestsForOrder(order.Id);

            var pcpDispositions = _pcpDispositionRepository.GetByCustomerIdEventId(eventCustomer.CustomerId, eventCustomer.EventId);
            var pcpAppointment = GetPcpAppointment(eventCustomer, pcpDispositions);

            PcpDisposition pcpDisposition = null;
            if (!pcpDispositions.IsNullOrEmpty())
            {
                pcpDisposition = pcpDispositions.OrderByDescending(pd => pd.DataRecorderMetaData.DateCreated).First();
            }


            var customerTest = new List<string>();

            if (eventPackage != null)
            {
                customerTest.AddRange(eventPackage.Tests.Select(x => x.Test.Name));
            }

            if (eventTest != null && eventTest.Any())
            {
                customerTest.AddRange(eventTest.Select(x => x.Test.Name));
            }

            var model = new EventCustomerPcpAppointmentEditModel
            {
                EventCustomerId = eventCustomer.Id,
                EventId = eventCustomer.EventId,
                CustomerId = customer.CustomerId,
                CustomerName = customer.Name,
                PhoneNumber = customer.HomePhoneNumber,
                CustomerEmail = customer.Email,
                ScreeningDate = theEvent.EventDate,
                HostName = host.OrganizationName,
                Location = host.Address,
                ScreenedForTest = customerTest,
                BookAfterNumberOfDays = account != null ? account.NumberOfDays : 0,
                NotAbleToSchedule = (pcpAppointment == null && pcpDisposition != null),
                DispositionId = (pcpAppointment == null && pcpDisposition != null) ? (long)pcpDisposition.Disposition : 0,
                Notes = (pcpAppointment == null && pcpDisposition != null) ? pcpDisposition.Notes : string.Empty,
                AppointmentDate = pcpAppointment != null ? pcpAppointment.AppointmentOn.Date : (DateTime?)null,
                AppointmentTime = pcpAppointment != null ? pcpAppointment.AppointmentOn.ToString("hh:mm: tt") : null,
                PreferredContactMethod = pcpAppointment != null ? pcpAppointment.PreferredContactMethod : -1,
                EventDate = theEvent.EventDate
            };

            return model;
        }
コード例 #2
0
        public void UpdatePcpAppointmentTime(EventCustomerPcpAppointmentEditModel model, long orgRoleUserId)
        {
            _primaryCarePhysicianHelper.UpdatePrimaryCarePhysician(model.Pcp, model.CustomerId, orgRoleUserId);

            if (!model.NotAbleToSchedule && model.AppointmentDateTime.HasValue)
            {
                var pcpAppointment = _pcpAppointmentRepository.GetByEventCustomerId(model.EventCustomerId);

                if (pcpAppointment != null)
                {
                    pcpAppointment.ModifiedOn = DateTime.Now;
                    pcpAppointment.ModifiedBy = orgRoleUserId;
                }
                else
                {
                    pcpAppointment = new PcpAppointment
                    {
                        CreatedOn = DateTime.Now,
                        CreatedBy = orgRoleUserId,
                        ModifiedOn = DateTime.Now,
                        ModifiedBy = orgRoleUserId,
                        EventCustomerId = model.EventCustomerId,
                    };
                }

                pcpAppointment.AppointmentOn = model.AppointmentDateTime.Value;
                pcpAppointment.PreferredContactMethod = model.PreferredContactMethod.HasValue && model.PreferredContactMethod > 0 ? model.PreferredContactMethod : null;

                _pcpAppointmentRepository.Save(pcpAppointment);
            }
            else if (model.NotAbleToSchedule)
            {
                var pcpDiposition = new PcpDisposition
                  {
                      Disposition = (PcpAppointmentDisposition)model.DispositionId,
                      EventCustomerId = model.EventCustomerId,
                      Notes = model.Notes,
                      DataRecorderMetaData = new DataRecorderMetaData(orgRoleUserId, DateTime.Now, DateTime.Now)
                  };

                pcpDiposition.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(orgRoleUserId);

                _pcpDispositionRepository.Save(pcpDiposition);
            }
        }