public async System.Threading.Tasks.Task Load(EvacuationFile file, CancellationToken ct) { if (file.NeedsAssessment.CompletedBy?.Id != null) { var member = (await teamRepository.GetMembers(userId: file.NeedsAssessment.CompletedBy.Id)).SingleOrDefault(); if (member != null) { file.NeedsAssessment.CompletedBy.DisplayName = $"{member.FirstName} {member.LastName.Substring(0, 1)}."; file.NeedsAssessment.CompletedBy.TeamId = member.TeamId; file.NeedsAssessment.CompletedBy.TeamName = member.TeamName; } } if (file.RelatedTask?.Id != null) { var task = (EssTask)(await taskRepository.QueryTask(new TaskQuery { ById = file.RelatedTask.Id })).Items.SingleOrDefault(); if (task != null) { file.RelatedTask = mapper.Map <IncidentTask>(task); } } foreach (var note in file.Notes.AsParallel().WithCancellation(ct)) { if (string.IsNullOrEmpty(note.CreatedBy?.Id)) { continue; } var teamMembers = await teamRepository.GetMembers(null, null, note.CreatedBy.Id); var member = teamMembers.SingleOrDefault(); if (member != null) { note.CreatedBy.DisplayName = $"{member.FirstName}, {member.LastName.Substring(0, 1)}"; note.CreatedBy.TeamId = member.TeamId; note.CreatedBy.TeamName = member.TeamName; } } var supports = ((SearchSupportQueryResult)await supportRepository.Query(new Resources.Supports.SearchSupportsQuery { ByEvacuationFileId = file.Id })).Items; file.Supports = mapper.Map <IEnumerable <Shared.Contracts.Events.Support> >(supports); await Parallel.ForEachAsync(file.Supports, ct, async (s, ct) => await Load(s, ct)); }
private IEnumerable <EvacuationFileTaskFeature> GetEvacuationFileFeatures(EvacuationFile file) { // temporary toggle feature for e-transfer var etransferEnabled = configuration.GetValue("features:eTransferEnabled", true); return(new[] { new EvacuationFileTaskFeature { Name = "digital-support-referrals", Enabled = file.Task.To >= DateTime.UtcNow }, new EvacuationFileTaskFeature { Name = "digital-support-etransfer", Enabled = etransferEnabled && file.Task.To >= DateTime.UtcNow }, new EvacuationFileTaskFeature { Name = "paper-support-referrals", Enabled = file.ManualFileId != null }, }); }
private EvacuationFile CreateTestFile(string primaryRegistrantId) { var uniqueSignature = Guid.NewGuid().ToString().Substring(0, 5); var file = new EvacuationFile() { PrimaryRegistrantId = primaryRegistrantId, EvacuatedFromAddress = new Address() { AddressLine1 = $"{uniqueSignature}_3738 Main St", AddressLine2 = "Suite 3", Community = "9e6adfaf-9f97-ea11-b813-005056830319", StateProvince = "BC", Country = "CAN", PostalCode = "V8V 2W3" }, NeedsAssessments = new[] { new NeedsAssessment { Type = NeedsAssessmentType.Preliminary, HaveMedication = false, Insurance = InsuranceOption.Yes, HaveSpecialDiet = true, SpecialDietDetails = "Shellfish allergy", HasPetsFood = true, CanEvacueeProvideClothing = true, CanEvacueeProvideFood = true, CanEvacueeProvideIncidentals = true, CanEvacueeProvideLodging = true, CanEvacueeProvideTransportation = true, HouseholdMembers = new[] { new HouseholdMember { FirstName = $"{uniqueSignature}_hm1", LastName = "hm1", PreferredName = "hm1p", Initials = $"{uniqueSignature}_1", Gender = "X", DateOfBirth = "03/11/2000", IsUnder19 = false, IsPrimaryRegistrant = false }, new HouseholdMember { FirstName = $"{uniqueSignature}_hm2", LastName = "hm2", PreferredName = "hm2p", Initials = $"{uniqueSignature}_2", Gender = "M", DateOfBirth = "03/12/2010", IsUnder19 = true, IsPrimaryRegistrant = false } }, Pets = new[] { new Pet { Type = $"{uniqueSignature}_Cat", Quantity = "1" } } } } }; return(file); }
public async System.Threading.Tasks.Task Load(EvacuationFile file) { if (file.NeedsAssessment.CompletedBy?.Id != null) { var member = (await teamRepository.GetMembers(userId: file.NeedsAssessment.CompletedBy.Id)).SingleOrDefault(); if (member != null) { file.NeedsAssessment.CompletedBy.DisplayName = $"{member.FirstName} {member.LastName.Substring(0, 1)}."; file.NeedsAssessment.CompletedBy.TeamId = member.TeamId; file.NeedsAssessment.CompletedBy.TeamName = member.TeamName; } } if (file.RelatedTask?.Id != null) { var task = (EssTask)(await taskRepository.QueryTask(new TaskQuery { ById = file.RelatedTask.Id })).Items.SingleOrDefault(); if (task != null) { file.RelatedTask = mapper.Map <IncidentTask>(task); } } foreach (var note in file.Notes) { if (string.IsNullOrEmpty(note.CreatedBy?.Id)) { continue; } var teamMembers = await teamRepository.GetMembers(null, null, note.CreatedBy.Id); var member = teamMembers.SingleOrDefault(); if (member != null) { note.CreatedBy.DisplayName = $"{member.FirstName}, {member.LastName.Substring(0, 1)}"; note.CreatedBy.TeamId = member.TeamId; note.CreatedBy.TeamName = member.TeamName; } } foreach (var support in file.Supports) { if (!string.IsNullOrEmpty(support.CreatedBy?.Id)) { var teamMember = (await teamRepository.GetMembers(userId: support.CreatedBy.Id)).SingleOrDefault(); if (teamMember != null) { support.CreatedBy.DisplayName = $"{teamMember.FirstName}, {teamMember.LastName.Substring(0, 1)}"; support.CreatedBy.TeamId = teamMember.TeamId; support.CreatedBy.TeamName = teamMember.TeamName; if (support.IssuedBy == null) { support.IssuedBy = support.CreatedBy; } } } if (support is Referral referral && !string.IsNullOrEmpty(referral.SupplierDetails?.Id)) { var supplier = (await supplierRepository.QuerySupplier(new SupplierSearchQuery { SupplierId = referral.SupplierDetails.Id, ActiveOnly = false })).Items.SingleOrDefault(); if (supplier != null) { referral.SupplierDetails.Name = supplier.LegalName; referral.SupplierDetails.Address = mapper.Map <Shared.Contracts.Events.Address>(supplier.Address); referral.SupplierDetails.TeamId = supplier.Team?.Id; referral.SupplierDetails.TeamName = supplier.Team?.Name; } } } }
public static EvacuationFile CreateNewTestEvacuationFile(RegistrantProfile registrant) { var uniqueSignature = Guid.NewGuid().ToString().Substring(0, 4); var file = new EvacuationFile() { PrimaryRegistrantId = registrant.Id, SecurityPhrase = "SecretPhrase", SecurityPhraseChanged = true, RelatedTask = new IncidentTask { Id = "0001" }, EvacuatedFromAddress = new Address() { AddressLine1 = $"{uniqueSignature}-3738 Main St", AddressLine2 = "Suite 3", Community = "9e6adfaf-9f97-ea11-b813-005056830319", StateProvince = "BC", Country = "CAN", PostalCode = "V8V 2W3" }, NeedsAssessment = new NeedsAssessment { Type = NeedsAssessmentType.Preliminary, TakeMedication = false, HaveMedicalSupplies = false, Insurance = InsuranceOption.Yes, HaveSpecialDiet = true, SpecialDietDetails = "Shellfish allergy", HavePetsFood = true, CanProvideClothing = true, CanProvideFood = true, CanProvideIncidentals = true, CanProvideLodging = true, CanProvideTransportation = true, HouseholdMembers = new[] { new HouseholdMember { FirstName = registrant.FirstName, LastName = registrant.LastName, Initials = registrant.Initials, Gender = registrant.Gender, DateOfBirth = registrant.DateOfBirth, IsPrimaryRegistrant = true, LinkedRegistrantId = registrant.Id }, new HouseholdMember { FirstName = $"{uniqueSignature}-hm1first", LastName = $"{uniqueSignature}-hm1last", Initials = $"{uniqueSignature}-1", Gender = "X", DateOfBirth = "03/15/2000", IsUnder19 = false, IsPrimaryRegistrant = false }, new HouseholdMember { FirstName = $"{uniqueSignature}-hm2first", LastName = $"{uniqueSignature}-hm2last", Initials = $"{uniqueSignature}-2", Gender = "M", DateOfBirth = "03/16/2010", IsUnder19 = true, IsPrimaryRegistrant = false } }, Pets = new[] { new Pet { Type = $"{uniqueSignature}_Cat", Quantity = "1" }, new Pet { Type = $"{uniqueSignature}_Dog", Quantity = "4" } }, Notes = new[] { new Note { Type = NoteType.EvacuationImpact, Content = "evac" }, new Note { Type = NoteType.EvacuationExternalReferrals, Content = "refer" }, new Note { Type = NoteType.PetCarePlans, Content = "pat plans" }, new Note { Type = NoteType.RecoveryPlan, Content = "recovery" }, } } }; return(file); }
private EvacuationFile CreateTestFile(Contact primaryContact) { var now = DateTime.UtcNow; var uniqueSignature = Guid.NewGuid().ToString().Substring(0, 5); var file = new EvacuationFile() { PrimaryRegistrantId = primaryContact.Id, EvacuationDate = now, TaskId = "0001", SecurityPhrase = "secret123", SecurityPhraseChanged = true, RegistrationLocation = $"{uniqueSignature}_testlocation", NeedsAssessment = new NeedsAssessment { CompletedOn = now, EvacuatedFrom = new EvacuationAddress() { AddressLine1 = $"{uniqueSignature}_3738 Main St", AddressLine2 = "Suite 3", CommunityCode = "9e6adfaf-9f97-ea11-b813-005056830319", PostalCode = "V8V 2W3" }, Type = NeedsAssessmentType.Preliminary, TakeMedication = false, HaveMedicalSupplies = false, Insurance = InsuranceOption.Yes, HaveSpecialDiet = true, SpecialDietDetails = "Shellfish allergy", HavePetsFood = true, CanProvideClothing = true, CanProvideFood = true, CanProvideIncidentals = true, CanProvideLodging = true, CanProvideTransportation = true, HouseholdMembers = new[] { new HouseholdMember { FirstName = primaryContact.FirstName, LastName = primaryContact.LastName, Initials = primaryContact.Initials, Gender = primaryContact.Gender, DateOfBirth = primaryContact.DateOfBirth, IsUnder19 = false, IsPrimaryRegistrant = true, LinkedRegistrantId = primaryContact.Id, HasAccessRestriction = false, IsVerifiedRegistrant = true }, new HouseholdMember { FirstName = $"{uniqueSignature}_hm1", LastName = "hm1", Initials = $"{uniqueSignature}_1", Gender = "Female", DateOfBirth = "03/11/2000", IsUnder19 = false, IsPrimaryRegistrant = false }, new HouseholdMember { FirstName = $"{uniqueSignature}_hm2", LastName = "hm2", Initials = $"{uniqueSignature}_2", Gender = "Male", DateOfBirth = "03/12/2010", IsUnder19 = true, IsPrimaryRegistrant = false } }, Pets = new[] { new Pet { Type = $"{uniqueSignature}_Cat", Quantity = "1" } } } }; return(file); }
public static async Task <IEnumerable <Support> > CreateSupports(EventsManager manager, EvacuationFile file, string RequestingUserId, string prefix) { var newSupports = CreateSupports(prefix, file); await manager.Handle(new ProcessSupportsCommand { FileId = file.Id, Supports = newSupports, IncludeSummaryInReferralsPrintout = false, RequestingUserId = RequestingUserId }); await manager.Handle(new ProcessPendingSupportsCommand()); var supports = (await manager.Handle(new SearchSupportsQuery { FileId = file.Id })).Items; return(supports.Where(s => (s.SupportDelivery is Interac i && i.NotificationEmail.StartsWith(prefix)) || (s.SupportDelivery is Referral r && r.IssuedToPersonName.StartsWith(prefix))) .ToArray()); }
public static async Task <string> SaveEvacuationFile(EventsManager manager, EvacuationFile file) => await manager.Handle(new SubmitEvacuationFileCommand { File = file });
public static IEnumerable <Support> CreateSupports(string prefix, EvacuationFile file) { var householdMemberIds = file.HouseholdMembers.Select(m => m.Id).ToArray(); var from = DateTime.UtcNow.AddDays(-1); var to = DateTime.UtcNow.AddDays(2); var supports = new Support[] { new ClothingSupport { TotalAmount = RandomAmount() }, new IncidentalsSupport { TotalAmount = RandomAmount() }, new FoodGroceriesSupport { TotalAmount = RandomAmount() }, new FoodRestaurantSupport { TotalAmount = RandomAmount() }, new LodgingBilletingSupport() { NumberOfNights = RandomInt() }, new LodgingGroupSupport { NumberOfNights = RandomInt(), FacilityCommunityCode = file.EvacuatedFromAddress.Community }, new LodgingHotelSupport { NumberOfNights = RandomInt(), NumberOfRooms = RandomInt() }, new TransportationOtherSupport { TotalAmount = RandomAmount() }, new TransportationTaxiSupport { FromAddress = "test", ToAddress = "test" }, }; Func <Support, SupportDelivery> createSupportDelivery = sup => sup switch { IncidentalsSupport s => new Interac { NotificationEmail = $"{prefix}[email protected]", ReceivingRegistrantId = file.PrimaryRegistrantId }, ClothingSupport s => new Interac { NotificationEmail = $"{prefix}[email protected]", ReceivingRegistrantId = file.PrimaryRegistrantId }, _ => new Referral { IssuedToPersonName = $"{prefix}-unitest" }, }; foreach (var support in supports) { support.FileId = file.Id; support.IncludedHouseholdMembers = householdMemberIds.TakeRandom(); support.From = from; support.To = to; support.SupportDelivery = createSupportDelivery(support); } return(supports); }