public ProviderClinicalInterest(Provider provider, ClinicalInterest clinicalInterest)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     if (clinicalInterest == null)
     {
         throw new ArgumentNullException("clinicalInterest");
     }
     Provider = provider;
     ClinicalInterest = clinicalInterest;
 }
Beispiel #2
0
        /// <summary>
        /// Removes the clinicalInterest.
        /// </summary>
        /// <param name="clinicalInterest">The clinicalInterest.</param>
        /// <returns>The removed clinicalInterest.</returns>
        public ProviderClinicalInterest RemoveClinicalInterest(ClinicalInterest clinicalInterest)
        {
            if (clinicalInterest == null)
            {
                throw new ArgumentNullException("clinicalInterest");
            }
            var providerClinicalInterest = ProviderClinicalInterests.Single(pl => pl.ClinicalInterest.Id == clinicalInterest.Id);
            ProviderClinicalInterests.Remove(providerClinicalInterest);

            return providerClinicalInterest;
        }
Beispiel #3
0
        /// <summary>
        /// Adds a clinicalInterest.
        /// </summary>
        /// <param name="clinicalInterest">The clinicalInterest.</param>
        /// <returns>The added clinicalInterest.</returns>
        public ProviderClinicalInterest AddClinicalInterest(ClinicalInterest clinicalInterest)
        {
            if (clinicalInterest == null)
            {
                throw new ArgumentNullException("clinicalInterest");
            }
            if (ProviderClinicalInterests.Count(pl => pl.ClinicalInterest.Id.Equals(clinicalInterest.Id)) > 0)
            {
                throw new BusinessException("The Clinical Interest is already associated with this provider");
            }

            var providerClinicalInterest = new ProviderClinicalInterest(this, clinicalInterest);
            ProviderClinicalInterests.Add(providerClinicalInterest);

            return providerClinicalInterest;
        }
        public static void SetProviderClinicalInterests(ObjectContext context, ProviderV2 source, Provider provider)
        {
            if (source.ClinicalInterests == null)
                return;

            try
            {
                var existingClinicalInterests = provider.ProviderClinicalInterests.ToArray();
                foreach (var item in existingClinicalInterests)
                    context.DeleteObject(item);

                var clinicalInterests = context.CreateObjectSet<ClinicalInterest>();
                var providerClinicalInterests = new List<ProviderClinicalInterest>();

                foreach (var item in source.ClinicalInterests)
                {
                    //Ensure Clinical Interest Exists
                    var clinicalInterest = clinicalInterests.FirstOrDefault(s => s.Name == item.Name);
                    if (clinicalInterest == null)
                    {
                        clinicalInterest = new ClinicalInterest(item.Name, true);
                        clinicalInterests.AddObject(clinicalInterest);
                    }

                    providerClinicalInterests.Add(new ProviderClinicalInterest(provider, clinicalInterest));
                }

                provider.ProviderClinicalInterests = providerClinicalInterests;
            }
            catch (Exception ex)
            {
                throw new BusinessException("Error processing clinical interests for provider '" + provider.Name + "' - " + ex.Message, ex);
            }
        }