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); }
private async Task <bool> UploadEmployment(Person person, SSG_SearchRequest request, SSG_Person ssg_person, int?providerDynamicsID, CancellationToken concellationToken) { if (person.Employments == null) { return(true); } try { foreach (var employment in person.Employments) { EmploymentEntity e = _mapper.Map <EmploymentEntity>(employment); e.SearchRequest = request; e.InformationSource = providerDynamicsID; e.Person = ssg_person; SSG_Employment ssg_employment = await _searchRequestService.CreateEmployment(e, concellationToken); if (employment.Employer != null) { foreach (var phone in employment.Employer.Phones) { SSG_EmploymentContact p = _mapper.Map <SSG_EmploymentContact>(phone); p.Employment = ssg_employment; await _searchRequestService.CreateEmploymentContact(p, concellationToken); } } } return(true); } catch (Exception ex) { _logger.LogError(ex.Message); return(false); } }
public void SSG_Employment_couldnotlocate_should_map_to_Employment_correctly() { SSG_Employment employment = new SSG_Employment { CouldNotLocate = true }; Employment e = _mapper.Map <Employment>(employment); Assert.AreEqual("Could Not Locate", e.Employer.Name); }
private async Task <bool> UploadEmployment(bool inUpdateProcess = false) { if (_personSought.Employments == null) { return(true); } _logger.LogDebug($"Attempting to create employment records for PersonSought."); foreach (var employment in _personSought.Employments) { EmploymentEntity e = _mapper.Map <EmploymentEntity>(employment); e.SearchRequest = _uploadedSearchRequest; e.InformationSource = InformationSourceType.Request.Value; e.Person = _uploadedPerson; e.IsCreatedByAgency = true; if (inUpdateProcess) { e.UpdateDetails = "New Employment"; } SSG_Employment ssg_employment = await _searchRequestService.CreateEmployment(e, _cancellationToken); if (employment.Employer != null) { foreach (var phone in employment.Employer.Phones) { EmploymentContactEntity p = _mapper.Map <EmploymentContactEntity>(phone); p.Employment = ssg_employment; if (inUpdateProcess) { e.UpdateDetails = "New EmploymentContact"; } await _searchRequestService.CreateEmploymentContact(p, _cancellationToken); } } } _logger.LogInformation("Create employment records for SearchRequest successfully"); return(true); }
public async Task employment_does_not_contain_same_employmentcontact_Exists_should_return_empty_guid() { DuplicateDetectionService._configs = null; Guid existedEmploymentContactID = Guid.NewGuid(); SSG_Employment employment = new SSG_Employment() { SSG_EmploymentContacts = new List <SSG_EmploymentContact>() { new SSG_EmploymentContact() { PhoneNumber = "123456", EmploymentContactId = existedEmploymentContactID } }.ToArray() }; EmploymentContactEntity entity = new EmploymentContactEntity() { PhoneNumber = "12345678" }; Guid guid = await _sut.Exists(employment, entity); Assert.AreEqual(Guid.Empty, guid); }
private async Task <bool> UploadEmployment( ) { if (_foundPerson.Employments == null) { return(true); } try { _logger.LogDebug($"Attempting to create found employment records for SearchRequest[{_searchRequest.SearchRequestId}]"); foreach (var employment in _foundPerson.Employments) { EmploymentEntity e = _mapper.Map <EmploymentEntity>(employment); e.SearchRequest = _searchRequest; e.InformationSource = _providerDynamicsID; e.Person = _returnedPerson; SSG_Employment ssg_employment = await _searchRequestService.CreateEmployment(e, _cancellationToken); //FAMS3-3742-OpenShift to stop creating Employment Contact records //if (employment.Employer != null) //{ // foreach (var phone in employment.Employer.Phones) // { // EmploymentContactEntity p = _mapper.Map<EmploymentContactEntity>(phone); // p.Employment = ssg_employment; // await _searchRequestService.CreateEmploymentContact(p, _cancellationToken); // } //} await CreateResultTransaction(ssg_employment); } return(true); } catch (Exception ex) { LogException(ex); return(false); } }
//this function is never been used. private async Task <bool> UpdateEmployment() { if (_personSought.Employments == null) { return(true); } _logger.LogDebug($"Attempting to update employment records for PersonSought."); SSG_Employment originalEmployment = _uploadedPerson.SSG_Employments?.FirstOrDefault( m => m.InformationSource == InformationSourceType.Request.Value && m.IsCreatedByAgency); if (_personSought.Employments.Count() > 0) { EmploymentEntity employ = _mapper.Map <EmploymentEntity>(_personSought.Employments.ElementAt(0)); if (originalEmployment == null) { await UploadEmployment(); } else { IDictionary <string, object> updatedFields = originalEmployment.Clone().GetUpdateEntries(employ); if (updatedFields.ContainsKey("ssg_countrytext")) //country changed { SSG_Country country = await _searchRequestService.GetEmploymentCountry(employ.CountryText, _cancellationToken); updatedFields.Add("ssg_LocationCountry", country); } if (updatedFields.ContainsKey("ssg_countrysubdivision_text")) //subdivision changed { SSG_CountrySubdivision subdivision = await _searchRequestService.GetEmploymentSubdivision(employ.CountrySubdivisionText, _cancellationToken); updatedFields.Add("ssg_CountrySubDivision", subdivision); } if (updatedFields.Count > 0) { await _searchRequestService.UpdateEmployment(originalEmployment.EmploymentId, updatedFields, _cancellationToken); _logger.LogInformation("Update Employment records for SearchRequest successfully"); } Employer employer = _personSought.Employments.ElementAt(0).Employer; if (employer != null && employer.Phones != null && employer.Phones.Count() > 0) { SSG_Employment existedEmployment = await _searchRequestService.GetEmployment(originalEmployment.EmploymentId, _cancellationToken); existedEmployment.IsDuplicated = true; foreach (var phone in employer.Phones) { EmploymentContactEntity p = _mapper.Map <EmploymentContactEntity>(phone); p.Employment = existedEmployment; await _searchRequestService.CreateEmploymentContact(p, _cancellationToken); } } } } return(true); }
public void SSG_Employment_should_map_to_Employment_correctly() { SSG_Employment employment = new SSG_Employment { EmploymentType = EmploymentRecordType.IncomeAssistance.Value, BusinessName = "legalBizName", DBAName = "dbaName", PrimaryPhoneNumber = "primaryPhone", PrimaryPhoneExtension = "primaryExt", PrimaryContactEmail = "*****@*****.**", PrimaryFax = "primaryFax", Email = "*****@*****.**", Website = "www.website.com", AddressLine1 = "employmentAddress1", AddressLine2 = "employmentAddress2", City = "employmentCity", PostalCode = "postalCode", CountryText = "country", CountrySubdivisionText = "province", EmploymentStatus = EmploymentStatusType.NotEmployed.Value, SelfEmployComRegistrationNo = "selfComNo", SelfEmployComType = SelfEmploymentCompanyType.ExtraprovincialNonShareCorp.Value, Occupation = "occupation", SelfEmployComRole = SelfEmploymentCompanyRoleType.Officer.Value, SelfEmployPercentOfShare = 50, IncomeAssistanceStatusOption = IncomeAssistanceStatusType.Closed.Value, IncomeAssistanceDesc = "income assistance description", IncomeAssistanceCls = IncomeAssistanceClassType.LongTermCare.Value, ContactPerson = "contact person", PrimaryContactPhone = "primaryContactPhoneNumber", PrimaryContactPhoneExt = "primaryContactExt", SSG_EmploymentContacts = new List <SSG_EmploymentContact> { new SSG_EmploymentContact { ContactName = "contactName", Description = "description", PhoneNumber = "phone", PhoneExtension = "ext", FaxNumber = "faxNumber", PhoneType = TelephoneNumberType.Cell.Value, Email = "contactemail" } }.ToArray(), Date1 = new DateTime(2002, 1, 1), Date1Label = "Effective Date", Date2 = new DateTime(2003, 1, 1), Date2Label = "End Date" }; Employment e = _mapper.Map <Employment>(employment); Assert.AreEqual(true, e.IncomeAssistance); Assert.AreEqual("legalBizName", e.Employer.Name); Assert.AreEqual("dbaName", e.Employer.DbaName); Assert.AreEqual("employmentAddress1", e.Employer.Address.AddressLine1); Assert.AreEqual("province", e.Employer.Address.StateProvince); Assert.AreEqual("Not Employed", e.EmploymentStatus); Assert.AreEqual("Extraprovincial Non-Share Corporation", e.SelfEmployComType); Assert.AreEqual("05 - Long Term Care", e.IncomeAssistanceClass); Assert.AreEqual(5, e.Employer.Phones.Count); Assert.AreEqual(2, e.Employer.EmployerContacts.Count); Assert.AreEqual("*****@*****.**", e.Email); Assert.AreEqual(new DateTimeOffset(new DateTime(2002, 1, 1)), e.ReferenceDates.ElementAt(0).Value); Assert.AreEqual("Effective Date", e.ReferenceDates.ElementAt(0).Key); Assert.AreEqual(new DateTimeOffset(new DateTime(2003, 1, 1)), e.ReferenceDates.ElementAt(1).Value); Assert.AreEqual("End Date", e.ReferenceDates.ElementAt(1).Key); }
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; } }