/// <summary>
        /// Returns the folio by concatenation the list name of insured name involvement with folio.
        /// </summary>
        /// <param name="folio">Concatenated Folio</param>
        /// <param name="claimNameInvolvement">Claim Name Involvement</param>
        /// <returns>Returns list name</returns>
        private string GenerateFolio(string folio, ClaimNameInvolvement claimNameInvolvement)
        {
            string listName = string.Empty;
            if (claimNameInvolvement != null && claimNameInvolvement.NameID.HasValue)
            {
                listName = ClaimsBusinessLogicHelper.GetListName(claimNameInvolvement.NameID.Value);
            }

            return this.GenerateFolio(folio, listName);
        }
        internal static void TestInitialize(ref ClaimEvent component, ref ProductEvent pce)
        {
            component = new ClaimEvent();
            component.ProductEventID = 34;

            if (pce == null)
            {
                pce = new ProductEvent();
            }

            component.InternalClaimHeader = new ClaimHeader();
            component.ClaimHeader.InternalClaimDetails.Add(new ClaimDetail() { ClaimDetailReference = "D0001" });
            ClaimInvolvement claimInvolvement = new ClaimInvolvement() { InternalClaimHeader = component.InternalClaimHeader, ClaimInvolvementType = (short)Xiap.Metadata.Data.Enums.StaticValues.LinkableComponentType.NameInvolvement, InternalClaimNameInvolvements = new System.Data.Objects.DataClasses.EntityCollection<ClaimNameInvolvement>() };
            ClaimNameInvolvement nameInvolvement = new ClaimNameInvolvement() { NameInvolvementType = (short)StaticValues.NameInvolvementType_ClaimNameInvolvement.MainClaimHandler, NameInvolvementMaintenanceStatus = (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest, NameID = 1 };
            claimInvolvement.InternalClaimNameInvolvements.Add(nameInvolvement);
            component.InternalClaimHeader.InternalClaimInvolvements.Add(claimInvolvement);

            pce.ProductVersion = new ProductVersion();
            pce.ProductVersion.Product = new Product();
            pce.ProductVersion.Product.Code = "TST";

            pce.EventType = new EventType();
            pce.EventType.IsStatusChangeEvent = false;
            pce.EventType.IsSystemCreationAllowed = false;
            pce.EventType.IsManualCreationAllowed = true;
            pce.EventType.IsManualDeletionAllowed = true;
            pce.EventType.Code = "ABCD";
            pce.EventTypeReference.SetEntityKey(new System.Data.EntityKey("MetadataEntities.EventType", "Code", "ABCD"));

            IComponentMetadata metadata = MockRepository.GenerateStub<IComponentMetadata>();
            metadata.Stub(m => m.GetDefinitionComponent<EventType>()).Return(pce.EventType);

            UnityContainer container = new UnityContainer();
            container.RegisterType<IMessageService, MessageService>();
            container.RegisterInstance<IComponentMetadata>(metadata);

            var metadataMock = MockRepository.GenerateStub<IMetadataQuery>();
            var list = new List<ProductEvent>() { pce };
            long productEventID = 34;

            metadataMock.Stub(m => m.GetProductEvent(productEventID));

            var listEventType = new List<EventType>() { pce.EventType };
            metadataMock.Stub(m => m.GetEventType("ABCD")).Return(listEventType.AsQueryable());

            EventTypeVersion etv = new EventTypeVersion();
            etv.EventTypeVersionID = 34;
            var listTypeVersion = new List<EventTypeVersion>() { etv };
            metadataMock.Stub(m => m.GetEventTypeVersion("ABCD")).Return(listTypeVersion.AsQueryable());

         

            container.RegisterInstance<IMetadataQuery>(metadataMock);
            container.RegisterType<ObjectContext, MetadataEntities>("MetadataEntities", new InjectionConstructor[] { new InjectionConstructor(new object[] { }) });
            container.RegisterType<MetadataEntities>("MetadataEntities", new InjectionConstructor[] { new InjectionConstructor(new object[] { }) });
            IConfigurationManager configurationManager = MockRepository.GenerateStub<IConfigurationManager>();
            configurationManager.Stub(m => m.AppSettings).Return(new System.Collections.Specialized.NameValueCollection());
            container.RegisterInstance<IConfigurationManager>(configurationManager);
            ObjectFactory.Instance = new ObjectFactory(container);

            component.Context = new ClaimsTransactionContext(string.Empty, string.Empty, string.Empty);
        }
        /// <summary>
        /// Check Driver Date of birth. Return it via the output parameter if found
        /// </summary>
        /// <param name="driverNameInvolvement">Claim Name Involvement</param>
        /// <param name="driverDOB">output Date Of Birth</param>
        /// <returns>True /False </returns>
        private bool IsDriverDateOfBirthEmpty(ClaimNameInvolvement driverNameInvolvement, out DateTime? driverDOB)
        {
            if (driverNameInvolvement.NameID.GetValueOrDefault(0) == 0)
            {
                driverDOB = null;
                return true;
            }

            IInsuranceDirectoryService ids = ObjectFactory.Resolve<IInsuranceDirectoryService>();

            IPerson person = ids.GetPersonForName(driverNameInvolvement.NameID.Value, DateTime.Now);

            if (person != null && person.DateOfBirth != null)
            {
                driverDOB = person.DateOfBirth.Value;
                return false;
            }

            driverDOB = null;
            return true;
        }
 /// <summary>
 /// Adding a change Handler event.
 /// </summary>
 /// <param name="claimNameInvolvement">Claim Name Involvement</param>
 private void AddChangeHandlerEvent(ClaimNameInvolvement claimNameInvolvement)
 {
     ClaimHeader claimHeader = claimNameInvolvement.Parent.Parent as ClaimHeader;
     var productEvents = ProductService.GetProductEventQuery().GetProductEvents(claimHeader.ProductVersionID.GetValueOrDefault());
     if (productEvents.Any(x => x.EventTypeCode == ClaimConstants.SYSUPD_Event_Type))
     {
         var productEvent = productEvents.Where(x => x.EventTypeCode == ClaimConstants.SYSUPD_Event_Type).First();
         ClaimEvent claimEvent = claimHeader.AddNewClaimEvent(productEvent.ProductEventID, true);
         claimEvent.EventDescription = "Claim Handler changed";
     }
 }