private void UpdateCustomerCurrentMedication(CorporateCustomerEditModel model, OrganizationRoleUser createdByOrgRoleUser, Customer customer, IEnumerable <EventCustomer> eventCustomers)
        {
            //Moved CurrentMedication logic to Function
            var ndcMedicationSourcePairs = _customerRegistrationHelper.PrepareNdcPairs(model);

            if (!ndcMedicationSourcePairs.IsNullOrEmpty())
            {
                _currentMedicationRepository.SaveCurrentMedication(customer.CustomerId, ndcMedicationSourcePairs, createdByOrgRoleUser.Id);

                if (!eventCustomers.IsNullOrEmpty())
                {
                    //save EventCustomerCurrentMedication domain for each event customer
                    foreach (var eventCustomer in eventCustomers)
                    {
                        var eventCustomerCurrentMedicationList = ndcMedicationSourcePairs.Select(ndcMedicationSourcePair => new EventCustomerCurrentMedication
                        {
                            EventCustomerId = eventCustomer.Id,
                            IsOtc           = ndcMedicationSourcePair.SecondValue == "o",
                            IsPrescribed    = ndcMedicationSourcePair.SecondValue == "p",
                            NdcId           = ndcMedicationSourcePair.FirstValue
                        }).ToList();
                        _eventCustomerCurrentMedicationRepository.Save(eventCustomer.Id, eventCustomerCurrentMedicationList);
                    }
                }
            }
        }
示例#2
0
        public void ExistingCustomerEventRegistrationTasks(long eventId, long customerId)
        {
            //Saving Icd codes and CurrentMedication at EVENT LEVEL
            var currentMedication = _currentMedicationRepository.GetByCustomerId(customerId);
            var eventCustomer     = _eventCustomerRepository.Get(eventId, customerId);
            var icdCodes          = _customerIcdCodesRepository.GetIcdByCustomerId(customerId);

            if (!currentMedication.IsNullOrEmpty())
            {
                var list = currentMedication.Select(medication => new EventCustomerCurrentMedication
                {
                    EventCustomerId = eventCustomer.Id,
                    IsOtc           = medication.IsOtc,
                    IsPrescribed    = medication.IsPrescribed,
                    NdcId           = medication.NdcId
                }).ToList();

                _eventCustomerCurrentMedicationRepository.Save(eventCustomer.Id, list);
            }

            if (icdCodes.Any())
            {
                _eventCustomerIcdCodesRepository.SaveAll(eventCustomer.Id, icdCodes.Select(x => x.IcdCodeId));
            }
        }