From 262cf3bbad876f4c49f54ae60b8743c7c2ed9ea6 Mon Sep 17 00:00:00 2001 From: Jack Wong <108699279+bergomi02@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:22:03 -0800 Subject: [PATCH] PRIME-2670 Fix HA Site status filtering (#2455) * initial commit * fix PR issues * fix PR issues --------- Co-authored-by: Alan Leung --- .../src/app/lib/enums/site-status.enum.ts | 4 +++- .../search-ha-form.component.ts | 7 +++--- .../Models/Statuses/SiteStatusType.cs | 6 ++++- .../Services/HealthAuthoritySiteService.cs | 24 +++++++++++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/prime-angular-frontend/src/app/lib/enums/site-status.enum.ts b/prime-angular-frontend/src/app/lib/enums/site-status.enum.ts index f81295b71b..265a406d24 100644 --- a/prime-angular-frontend/src/app/lib/enums/site-status.enum.ts +++ b/prime-angular-frontend/src/app/lib/enums/site-status.enum.ts @@ -1,5 +1,7 @@ export enum SiteStatusType { EDITABLE = 1, IN_REVIEW = 2, - LOCKED = 3 + LOCKED = 3, + EDITABLE_NOT_APPROVED = 4, + FLAGGED = 5 } diff --git a/prime-angular-frontend/src/app/modules/adjudication/shared/components/search-ha-form/search-ha-form.component.ts b/prime-angular-frontend/src/app/modules/adjudication/shared/components/search-ha-form/search-ha-form.component.ts index ad8b152691..5315a67c2a 100644 --- a/prime-angular-frontend/src/app/modules/adjudication/shared/components/search-ha-form/search-ha-form.component.ts +++ b/prime-angular-frontend/src/app/modules/adjudication/shared/components/search-ha-form/search-ha-form.component.ts @@ -45,10 +45,11 @@ export class SearchHAFormComponent implements OnInit { this.siteStatuses = new Array>(); const inReviewStatus = new Config(SiteStatusType.IN_REVIEW, 'In Review'); - const editableStatus = new Config(SiteStatusType.EDITABLE, 'Editable'); - const lockedStatus = new Config(SiteStatusType.LOCKED, 'Locked'); + const editableStatus = new Config(SiteStatusType.EDITABLE, 'Editable - approved'); + const editableNotApprovedStatus = new Config(SiteStatusType.EDITABLE_NOT_APPROVED, 'Editable - not approved'); + const flaggedStatus = new Config(SiteStatusType.FLAGGED, 'Flagged'); - this.siteStatuses.push(inReviewStatus, editableStatus, lockedStatus); + this.siteStatuses.push(editableNotApprovedStatus, inReviewStatus, editableStatus, flaggedStatus); this.careTypes = this.configService.careTypes; this.vendors = this.configService.vendors diff --git a/prime-dotnet-webapi/Models/Statuses/SiteStatusType.cs b/prime-dotnet-webapi/Models/Statuses/SiteStatusType.cs index efd7dd00c3..3fc4151603 100644 --- a/prime-dotnet-webapi/Models/Statuses/SiteStatusType.cs +++ b/prime-dotnet-webapi/Models/Statuses/SiteStatusType.cs @@ -4,6 +4,10 @@ public enum SiteStatusType { Editable = 1, InReview = 2, - Locked = 3 + Locked = 3, + + //the status types below is used for filtering + EditableNotApproved = 4, + Flagged = 5 } } diff --git a/prime-dotnet-webapi/Services/HealthAuthoritySiteService.cs b/prime-dotnet-webapi/Services/HealthAuthoritySiteService.cs index 21df728631..fb9f54c013 100644 --- a/prime-dotnet-webapi/Services/HealthAuthoritySiteService.cs +++ b/prime-dotnet-webapi/Services/HealthAuthoritySiteService.cs @@ -91,6 +91,21 @@ public async Task> GetSitesAs { searchOptions ??= new HealthAuthoritySiteSearchOptions(); + int? statusId = null; + bool flagged = false; + if (searchOptions.StatusId.HasValue) + { + if (searchOptions.StatusId == (int)SiteStatusType.Flagged) + { + flagged = true; + } + else + { + statusId = searchOptions.StatusId == (int)SiteStatusType.EditableNotApproved ? + (int)SiteStatusType.Editable : searchOptions.StatusId; + } + } + var query = _context.HealthAuthoritySites .AsNoTracking() .If(!string.IsNullOrWhiteSpace(searchOptions.TextSearch), @@ -104,9 +119,14 @@ public async Task> GetSitesAs s => s.HealthAuthorityCareType.CareType) .Containing(searchOptions.TextSearch) ) - .If(searchOptions.StatusId.HasValue, + .If(statusId.HasValue, q => q.Where(s => (int)s.SiteStatuses.OrderByDescending(ss => ss.StatusDate) - .FirstOrDefault().StatusType == searchOptions.StatusId)) + .FirstOrDefault().StatusType == statusId && + ((searchOptions.StatusId == (int)SiteStatusType.Editable && s.ApprovedDate.HasValue) || + (searchOptions.StatusId == (int)SiteStatusType.EditableNotApproved && !s.ApprovedDate.HasValue) || + searchOptions.StatusId == (int)SiteStatusType.InReview || + searchOptions.StatusId == (int)SiteStatusType.Locked))) + .If(flagged, q => q.Where(s => s.Flagged)) .If(!string.IsNullOrWhiteSpace(searchOptions.AdminUserName), q => q.Where(s => s.Adjudicator.Username == searchOptions.AdminUserName)) .If(searchOptions.VendorId.HasValue,