public FinancialTransactionContext(ClaimHeader claimHeader, ClaimDetail claimDetail, ClaimTransactionHeader claimTransactionHeader, ClaimTransactionGroup claimTransactionGroup, User user) { this.ClaimHeader = claimHeader; this.ClaimDetail = claimDetail; this.ClaimTransactionHeader = claimTransactionHeader; this.ClaimTransactionGroup = claimTransactionGroup; this.CurrentUser = user; this.TransactionSource = (StaticValues.ClaimTransactionSource)this.ClaimTransactionHeader.ClaimTransactionSource; this.Product = claimHeader.GetProduct(); this.ProductClaimDefinition = this.Product.ProductClaimDefinition; this.ProductClaimDetails = this.Product.ClaimDetails; }
public bool Execute(ClaimHeader claimHeader, Claim claim) { if (claimHeader == null) throw new ArgumentNullException("claimHeader"); if (claim == null) throw new ArgumentNullException("claim"); IUWHeader uwHeader = null; if (!FindPolicy(claimHeader, claim, out uwHeader)) return false; claim.PolicyHeaderStatusCode = uwHeader.HeaderStatusCode; var geniusGateway = GlobalClaimWakeUp.Container.Resolve<IGeniusGateway>(); var queryProductSectionDetails = ObjectFactory.Resolve<ISystemValueSetQuery<ISectionDetailTypeData>>(); try { //SetDateOfLossTypeCode(claimHeader, uwHeader); claimHeader.PolicyHeaderID = uwHeader.HeaderID; claimHeader.ProposedPolicyReference = uwHeader.HeaderReference; foreach (var claimDetail in claim.ClaimDetails) { //var components = new SortedList<string, ComponentRequest>(); var geniusXClaimDetail = claimHeader.ClaimDetails.SingleOrDefault(cd => cd.ClaimDetailID == claimDetail.GeniusXDetailID); if (geniusXClaimDetail == null) { Logger.ErrorFormat( "Could not find ClaimDetail\r\n{0}\r\n", JObject.FromObject( new{ claim.ClaimReference, uwHeader.HeaderReference, claimDetail.GeniusXDetailID, claimDetail.ClaimDetailType})); return false; } geniusXClaimDetail.PolicyLinkLevel = (short)StaticValues.PolicyLinkLevel.Coverage; var section = uwHeader.ISections.SingleOrDefault(s => s.SectionTypeCode == claimDetail.PolicySectionCode); if (section == null) { Logger.ErrorFormat("Could not find Section\r\n{0}\r\n", JObject.FromObject(new{claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode})); return false; } IUWSectionDetail sectionDetail = section.ISectionDetails .FirstOrDefault( sd => string.Equals(sd.SectionDetailTitle, claimDetail.SectionDetailIdentifier, StringComparison.OrdinalIgnoreCase) && sd.ICoverages.Any( c => c.CoverageTypeCode == claimDetail.CoverageCode && geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossFrom.GetValueOrDefault(DateTime.MinValue)) || geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossTo.GetValueOrDefault(DateTime.MinValue)))); if (sectionDetail == null) { Logger.WarnFormat("Could not find a matching SectionDetail, trying 'WW'\r\n{0}", JObject.FromObject( new { claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode, claimDetail.SectionDetailIdentifier } )); sectionDetail = section.ISectionDetails .FirstOrDefault(sd => string.Equals(sd.SectionDetailTitle, "WW", StringComparison.OrdinalIgnoreCase) && sd.ICoverages.Any( c => c.CoverageTypeCode == claimDetail.CoverageCode && geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossFrom.GetValueOrDefault(DateTime.MinValue)) || geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossTo.GetValueOrDefault(DateTime.MinValue)))); } if (sectionDetail == null) { Logger.WarnFormat("Could not find a matching SectionDetail, trying 'EL UK'\r\n{0}", JObject.FromObject( new { claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode, claimDetail.SectionDetailIdentifier } )); sectionDetail = section.ISectionDetails .FirstOrDefault(sd => string.Equals(sd.SectionDetailTitle, "EL UK", StringComparison.OrdinalIgnoreCase) && sd.ICoverages.Any( c => c.CoverageTypeCode == claimDetail.CoverageCode && geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossFrom.GetValueOrDefault(DateTime.MinValue)) || geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossTo.GetValueOrDefault(DateTime.MinValue)))); } if (sectionDetail == null) { Logger.WarnFormat("Could not find a matching SectionDetail, trying 'Europe'\r\n{0}", JObject.FromObject( new { claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode, claimDetail.SectionDetailIdentifier } )); sectionDetail = section.ISectionDetails .FirstOrDefault(sd => string.Equals(sd.SectionDetailTitle, "Europe", StringComparison.OrdinalIgnoreCase) && sd.ICoverages.Any( c => c.CoverageTypeCode == claimDetail.CoverageCode && geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossFrom.GetValueOrDefault(DateTime.MinValue)) || geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossTo.GetValueOrDefault(DateTime.MinValue)))); } if (sectionDetail == null) { Logger.WarnFormat("Could not find a matching SectionDetail using *any* method, picking first SectionDetail\r\n{0}", JObject.FromObject( new { claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode, } )); sectionDetail = section.ISectionDetails .FirstOrDefault(sd => queryProductSectionDetails.GetValue(sd.SectionDetailTypeCode).IsSummarySectionDetailType == false); } if (sectionDetail == null) { Logger.ErrorFormat("Could not find SectionDetail\r\n{0}\r\n", JObject.FromObject( new { /*\tVehicleType={3}\r\n\tAreaCode={4}\r\n]", */ claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode //,claimDetail.VehicleType //,claimDetail.AreaCode })); return false; } if (!string.Equals(sectionDetail.SectionDetailTitle, claimDetail.SectionDetailIdentifier, StringComparison.OrdinalIgnoreCase)) { Logger.WarnFormat( "Fuzzy matched SectionDetail\r\n{0}\r\n", JObject.FromObject( new{ /*\tVehicleType={3}\r\n\tAreaCode={4}\r\n]", */ claim.ClaimReference, uwHeader.HeaderReference, claimDetail.CmsPolicySectionCode, claimDetail.PolicySectionCode, claimDetail.SectionDetailIdentifier, sectionDetail.SectionDetailTitle //,claimDetail.VehicleType //,claimDetail.AreaCode })); } var coverage = sectionDetail.ICoverages.FirstOrDefault( c => c.CoverageTypeCode == claimDetail.CoverageCode && geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossFrom.GetValueOrDefault(DateTime.MinValue)) || geniusGateway.CheckDates(c.ExternalReference, claimHeader.DateOfLossTo.GetValueOrDefault(DateTime.MinValue))) ?? sectionDetail.ICoverages.FirstOrDefault(); if (coverage == null) { Logger.ErrorFormat( "Could not find Coverage\r\n{0}\r\n", JObject.FromObject( new{ claim.ClaimReference, uwHeader.HeaderReference, claimDetail.PolicySectionCode, claimDetail.CoverageCode })); return false; } if (!string.Equals(sectionDetail.SectionDetailTitle, claimDetail.SectionDetailIdentifier, StringComparison.OrdinalIgnoreCase) || !string.Equals(coverage.CoverageTypeCode, claimDetail.CoverageCode, StringComparison.OrdinalIgnoreCase)) { Logger.WarnFormat( "Fuzzy matched CoverageType\r\n{0}\r\n", JObject.FromObject( new { /*\tVehicleType={3}\r\n\tAreaCode={4}\r\n]", */ claim.ClaimReference, uwHeader.HeaderReference, claimDetail.CmsPolicySectionCode, claimDetail.PolicySectionCode, claimDetail.SectionDetailIdentifier, sectionDetail.SectionDetailTitle, claimDetail.CoverageCode, coverage.CoverageTypeCode //,claimDetail.VehicleType //,claimDetail.AreaCode })); } geniusXClaimDetail.PolicyCoverageID = coverage.CoverageID; geniusXClaimDetail.PolicySectionDetailID = sectionDetail.SectionDetailID; geniusXClaimDetail.PolicySectionID = section.SectionID; } foreach (var sectionDetail in uwHeader.ISections.SelectMany(s => s.ISectionDetails.Where(sd => queryProductSectionDetails.GetValue(sd.SectionDetailTypeCode).IsSummarySectionDetailType == false))) { var dateOfLossTypeCode = "O"; var sectionDetailCustomCode03 = GlobalClaimWakeUp.Container.Resolve<IGeniusGateway>().GetSectionDetailDateOfLossTypeCode(sectionDetail.ExternalReference); if (!string.IsNullOrEmpty(sectionDetailCustomCode03) && (sectionDetailCustomCode03 == "M" || sectionDetailCustomCode03 == "O")) { dateOfLossTypeCode = sectionDetailCustomCode03; } if (dateOfLossTypeCode != claimHeader.DateOfLossTypeCode) { claimHeader.DateOfLossTypeCode = dateOfLossTypeCode; Logger.InfoFormat("Setting Claim DATEOFLOSSTYPECODE \r\n{0}", JObject.FromObject(new { ClaimReference = claimHeader.ClaimReference, DateOfLossTypeCode = dateOfLossTypeCode })); break; } } } catch (Exception ex) { claim.ClaimIsAttachedToPolicy = false; claim.CustomCode18 = "F02"; claim.ClaimProcessingFailed = true; claim.FailureReason = "Could not attach Claim to Policy"; Logger.WarnFormat("Claim to Policy attachment failed:\r\n{0}\r\n", JObject.FromObject(new{claim.ClaimReference, claim.PolicyNumber, @Exception=ex})); return false; } // Create the lossBroker name involvement try { var transaction = UWBusinessTransactionFactory.DisplayPolicy(uwHeader.HeaderReference, false, VersionSelectionParameters.SelectLatestVersion); var lossBroker = transaction.Header.NameInvolvements.FirstOrDefault(ni => ni.NameInvolvementType == (short)StaticValues.NameInvolvementType_UWNameInvolvement.MajorBroker); if (lossBroker != null && !claimHeader.NameInvolvementExists((short)StaticValues.NameInvolvementType_ClaimNameInvolvement.LossBroker, lossBroker.NameID)) { if (lossBroker.NameID != null) { var claimInvolvement = claimHeader.AddNewClaimInvolvement(StaticValues.LinkableComponentType.NameInvolvement); var claimProduct = claimHeader.GetProduct(); // TGB: New changes to XIAP mean you now must supply the NameUsageTypeCode here. For Loss Broke it is 'Broker', which is UBK claimInvolvement.AddClaimNameInvolvement(claimProduct.ProductVersionID, (short)StaticValues.NameInvolvementType_ClaimNameInvolvement.LossBroker, lossBroker.NameID, "UBK"); Logger.InfoFormat("LOSSBROKER setup on Claim\r\n{0}\r\n", JObject.FromObject(new { claim.ClaimReference, lossBroker.NameID })); } else { Logger.WarnFormat("Could not setup LOSSBROKER on Claim\r\n{{ClaimReference: {0}\r\n}}", claim.ClaimReference); } } transaction.Cancel(); } catch (Exception ex) { Logger.WarnFormat("Error creating LOSSBROKER for '{0}'\r\n[\r\n\tException={1}\r\n]", claim.ClaimReference, ex); return false; } Logger.InfoFormat("Claim to Policy attachment success:\r\n{0}\r\n", JObject.FromObject( new {claim.ClaimReference, claim.PolicyNumber} )); return true; }
/// <summary> /// Load policy deductibles /// </summary> /// <param name="claimHeader">Claim Header</param> /// <returns>AXA policy excess and deductible data</returns> private AXAPolicyEDData LoadPolicyDeductibles(ClaimHeader claimHeader) { // Initialise to false AXAPolicyEDData policyEDData = new AXAPolicyEDData(false, false); // If policy is attached or changed, set context level flag to identify whether policy deductibles exist ProductClaimDefinition productClaimDef = claimHeader.GetProduct().ProductClaimDefinition; if (productClaimDef.ClaimHeaderAutomaticDeductibleProcessingMethod == (short)StaticValues.ClaimHeaderAutomaticDeductibleProcessingMethod.StandardClaimHeaderDeductible) { IAXAClaimsQuery query = new AXAClaimsQueries(); bool deductibleExist = false; bool EDExcessExist = false; query.PolicyDeductiblesExist(claimHeader.PolicyHeaderID.Value, "AND2", "AND3", out deductibleExist, out EDExcessExist); policyEDData.DeductiblesExist = deductibleExist; policyEDData.EDExcessExist = EDExcessExist; } return policyEDData; }