public CustomerContactViewModel UpdateCallQueueCustomer([FromBody] CallQueueCustomerEditModel customerEditModel)
 {
     _callQueueCustomerContactService.UpdateCustomerData(customerEditModel, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
     if (customerEditModel.IsHealthPlanQueue)
     {
         _primaryCarePhysicianHelper.UpdatePrimaryCarePhysician(customerEditModel.PrimaryCarePhysician, customerEditModel.CustomerId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
     }
     return(_callQueueCustomerContactService.Get(customerEditModel.CallQueueCustomerId, customerEditModel.CallId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId));
 }
        public ActionResult SavePatientInfo(CallQueueCustomerEditModel model)
        {
            if (ModelState.IsValid)
            {
                _callQueueCustomerContactService.UpdateCustomerData(model, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
                if (model.IsHealthPlanQueue)
                {
                    _primaryCarePhysicianHelper.UpdatePrimaryCarePhysician(model.PrimaryCarePhysician, model.CustomerId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
                }
            }
            var viewModel = _callQueueCustomerContactService.GetByCustomerId(model.CustomerId, model.CallId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);

            if (!ModelState.IsValid)
            {
                viewModel.HasError             = true;
                viewModel.PatientInfoEditModel = model;
            }
            return(PartialView("GetPatientInfo", viewModel));
        }
        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);
            }
        }