Esempio n. 1
0
        public async Task <SSG_Asset_WorkSafeBcClaim> CreateCompensationClaim(CompensationClaimEntity claim, CancellationToken cancellationToken)
        {
            SSG_Asset_WorkSafeBcClaim returnedClaim   = null;
            SSG_Asset_WorkSafeBcClaim duplicatedClaim = await GetDuplicatedCompensation(claim, cancellationToken);

            SSG_Employment ssg_employment = null;

            if (duplicatedClaim != null && duplicatedClaim.IsDuplicated)
            {
                ssg_employment = duplicatedClaim.Employment;
                returnedClaim  = duplicatedClaim;
            }
            else
            {
                SSG_Asset_BankingInformation ssg_bank = claim.BankInformationEntity == null ? null : await CreateBankInfo(claim.BankInformationEntity, cancellationToken);

                ssg_employment = claim.EmploymentEntity == null ? null : await CreateEmployment(claim.EmploymentEntity, cancellationToken);

                claim.BankingInformation = ssg_bank;
                claim.Employment         = ssg_employment;
                SSG_Asset_WorkSafeBcClaim ssg_Claim = await this._oDataClient.For <SSG_Asset_WorkSafeBcClaim>().Set(claim).InsertEntryAsync(cancellationToken);

                returnedClaim = ssg_Claim;
            }

            if (claim.EmploymentEntity != null && claim.EmploymentEntity.EmploymentContactEntities != null)
            {
                foreach (EmploymentContactEntity contact in claim.EmploymentEntity.EmploymentContactEntities)
                {
                    contact.Employment = ssg_employment;
                    await CreateEmploymentContact(contact, cancellationToken);
                }
            }
            return(returnedClaim);
        }
Esempio n. 2
0
        private async Task <bool> UploadCompensationClaims()
        {
            if (_foundPerson.CompensationClaims == null)
            {
                return(true);
            }
            try
            {
                _logger.LogDebug($"Attempting to create compnsation claims records for SearchRequest[{_searchRequest.SearchRequestId}]");

                foreach (CompensationClaim claim in _foundPerson.CompensationClaims)
                {
                    BankingInformationEntity bankEntity = null;
                    if (claim.BankInfo != null)
                    {
                        bankEntity = _mapper.Map <BankingInformationEntity>(claim.BankInfo);
                        bankEntity.InformationSource = _providerDynamicsID;
                    }

                    EmploymentEntity employmentEntity = null;
                    if (claim.Employer != null)
                    {
                        employmentEntity = _mapper.Map <EmploymentEntity>(claim.Employer);
                        employmentEntity.InformationSource = _providerDynamicsID;
                        employmentEntity.Date1             = claim.ReferenceDates?.SingleOrDefault(m => m.Index == 0)?.Value.DateTime;
                        employmentEntity.Date1Label        = claim.ReferenceDates?.SingleOrDefault(m => m.Index == 0)?.Key;
                        //FAMS3-3742: OpenShift to stop creating Employment Contact records
                        //List<EmploymentContactEntity> contacts = new List<EmploymentContactEntity>();
                        //if (claim.Employer.Phones != null)
                        //{
                        //    foreach (var phone in claim.Employer.Phones)
                        //    {
                        //        EmploymentContactEntity p = _mapper.Map<EmploymentContactEntity>(phone);
                        //        contacts.Add(p);
                        //    }
                        //}
                        //employmentEntity.EmploymentContactEntities = contacts.ToArray();
                    }

                    CompensationClaimEntity ssg_claim = _mapper.Map <CompensationClaimEntity>(claim);
                    ssg_claim.SearchRequest         = _searchRequest;
                    ssg_claim.InformationSource     = _providerDynamicsID;
                    ssg_claim.Person                = _returnedPerson;
                    ssg_claim.BankInformationEntity = bankEntity;
                    ssg_claim.EmploymentEntity      = employmentEntity;

                    SSG_Asset_WorkSafeBcClaim ssg_Claim = await _searchRequestService.CreateCompensationClaim(ssg_claim, _cancellationToken);
                    await CreateResultTransaction(ssg_Claim);
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex);
                return(false);
            }
        }
        public void SSG_WorkSafeBCClaim_should_map_to_CompensationClaim_correctly()
        {
            SSG_Asset_WorkSafeBcClaim claim = new SSG_Asset_WorkSafeBcClaim
            {
                ClaimNumber      = "claimNumber",
                ClaimAmount      = "ClaimAmount",
                ResponseComments = "response"
            };

            CompensationClaim comClaim = _mapper.Map <CompensationClaim>(claim);

            Assert.AreEqual("claimNumber", comClaim.ClaimNumber);
            Assert.AreEqual("ClaimAmount", comClaim.ClaimAmount);
            Assert.AreEqual("response", comClaim.ResponseComments);
        }
Esempio n. 4
0
        public async Task <SSG_SearchRequestResponse> GetSearchResponse(Guid responseId, CancellationToken cancellationToken)
        {
            try
            {
                SSG_SearchRequestResponse ssgSearchResponse = await _oDataClient
                                                              .For <SSG_SearchRequestResponse>()
                                                              .Key(responseId)
                                                              .Expand(x => x.SSG_BankInfos)
                                                              .Expand(x => x.SSG_Asset_Others)
                                                              .Expand(x => x.SSG_Addresses)
                                                              .Expand(x => x.SSG_Aliases)
                                                              .Expand(x => x.SSG_Asset_ICBCClaims)
                                                              .Expand(x => x.SSG_Asset_Vehicles)
                                                              .Expand(x => x.SSG_Asset_WorkSafeBcClaims)
                                                              .Expand(x => x.SSG_Employments)
                                                              .Expand(x => x.SSG_Identifiers)
                                                              .Expand(x => x.SSG_Identities)
                                                              .Expand(x => x.SSG_Noteses)
                                                              .Expand(x => x.SSG_Persons)
                                                              .Expand(x => x.SSG_PhoneNumbers)
                                                              .Expand(x => x.SSG_SearchRequests)
                                                              .Expand(x => x.SSG_Asset_Investments)
                                                              .Expand(x => x.SSG_SafetyConcernDetails)
                                                              .Expand(x => x.SSG_Asset_PensionDisablilitys)
                                                              .Expand(x => x.SSG_Asset_RealEstatePropertys)
                                                              .Expand(x => x.SSG_Emails)
                                                              .Expand(x => x.SSG_Electronicas)
                                                              .FindEntryAsync(cancellationToken);

                if (ssgSearchResponse.SSG_SearchRequests != null)
                {
                    Guid id = ssgSearchResponse.SSG_SearchRequests[0].SearchRequestId;
                    ssgSearchResponse.SSG_SearchRequests[0] = await _oDataClient.For <SSG_SearchRequest>()
                                                              .Key(id)
                                                              .Expand(x => x.SearchReason)
                                                              .FindEntryAsync(cancellationToken);
                }

                if (ssgSearchResponse.SSG_Asset_WorkSafeBcClaims != null)
                {
                    foreach (SSG_Asset_WorkSafeBcClaim claim in ssgSearchResponse.SSG_Asset_WorkSafeBcClaims)
                    {
                        SSG_Asset_WorkSafeBcClaim c = await _oDataClient.For <SSG_Asset_WorkSafeBcClaim>()
                                                      .Key(claim.CompensationClaimId)
                                                      .Expand(x => x.BankingInformation)
                                                      .Expand(x => x.Employment)
                                                      .FindEntryAsync(cancellationToken);

                        claim.BankingInformation = c.BankingInformation;
                        claim.Employment         = c.Employment;
                    }
                }

                if (ssgSearchResponse.SSG_Addresses != null)
                {
                    foreach (SSG_Address address in ssgSearchResponse.SSG_Addresses)
                    {
                        SSG_Address addr = await _oDataClient.For <SSG_Address>()
                                           .Key(address.AddressId)
                                           .Expand(x => x.CountrySubdivision)
                                           .FindEntryAsync(cancellationToken);

                        if (addr.CountrySubdivision != null)
                        {
                            address.CountrySubdivisionText = addr.CountrySubdivision.ProvinceCode;
                        }
                    }
                }

                if (ssgSearchResponse.SSG_Asset_ICBCClaims != null)
                {
                    foreach (SSG_Asset_ICBCClaim claim in ssgSearchResponse.SSG_Asset_ICBCClaims)
                    {
                        if (claim.CountrySubdivision != null)
                        {
                            SSG_Asset_ICBCClaim expandedClaim = await _oDataClient.For <SSG_Asset_ICBCClaim>()
                                                                .Key(claim.ICBCClaimId)
                                                                .Expand(x => x.CountrySubdivision)
                                                                .FindEntryAsync(cancellationToken);


                            if (expandedClaim.CountrySubdivision != null)
                            {
                                claim.SupplierCountrySubdivisionCode = expandedClaim.CountrySubdivision.ProvinceCode;
                            }
                        }
                    }
                }

                if (ssgSearchResponse.SSG_Employments != null)
                {
                    foreach (SSG_Employment e in ssgSearchResponse.SSG_Employments)
                    {
                        SSG_Employment expandedEmployment = await _oDataClient.For <SSG_Employment>()
                                                            .Key(e.EmploymentId)
                                                            .Expand(x => x.CountrySubdivision)
                                                            .FindEntryAsync(cancellationToken);

                        if (expandedEmployment.CountrySubdivision != null)
                        {
                            e.CountrySubdivisionText = expandedEmployment.CountrySubdivision.ProvinceCode;
                        }

                        SSG_Employment temp = await _oDataClient.For <SSG_Employment>()
                                              .Key(e.EmploymentId)
                                              .Expand(x => x.SSG_EmploymentContacts)
                                              .FindEntryAsync(cancellationToken);

                        if (temp.SSG_EmploymentContacts != null)
                        {
                            e.SSG_EmploymentContacts = temp.SSG_EmploymentContacts;
                        }
                    }
                }


                return(ssgSearchResponse);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }