From 0d6ae5f3a18cb0f7ee0aafd10a857d084f2a35c0 Mon Sep 17 00:00:00 2001 From: Jack Wong <108699279+bergomi02@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:00:09 -0800 Subject: [PATCH 1/2] initial commit --- .../site-registration-tabs.component.ts | 8 -------- .../Controllers/SitesController.cs | 2 +- .../Services/CommunitySiteService.cs | 15 +++++++++++++++ .../CommunitySiteAdminListViewModel.cs | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/prime-angular-frontend/src/app/modules/adjudication/shared/components/site-registration-tabs/site-registration-tabs.component.ts b/prime-angular-frontend/src/app/modules/adjudication/shared/components/site-registration-tabs/site-registration-tabs.component.ts index aa91ed1909..fd098fb6ea 100644 --- a/prime-angular-frontend/src/app/modules/adjudication/shared/components/site-registration-tabs/site-registration-tabs.component.ts +++ b/prime-angular-frontend/src/app/modules/adjudication/shared/components/site-registration-tabs/site-registration-tabs.component.ts @@ -172,19 +172,11 @@ export class SiteRegistrationTabsComponent extends AbstractSiteAdminPage impleme const { textSearch, careType, statusId, vendorId, assignToMe } = queryParams; this.healthAuthResource.getHealthAuthoritySitesByQuery({ textSearch, careType, statusId, vendorId, assignToMe }) .subscribe((sites: HealthAuthoritySiteAdminList[]) => { - sites.forEach((s: HealthAuthoritySiteAdminList) => { - s.duplicatePecSiteCount = sites.filter((innerSite: HealthAuthoritySiteAdminList) => innerSite.id !== s.id - && innerSite.pec && innerSite.pec === s.pec).length; - }); this.healthAuthoritySites = sites; }) } else { this.busy = this.getPaginatedSites({ careSettingCode, ...queryParams }) .subscribe((paginatedList: PaginatedList) => { - paginatedList.results.forEach((s: SiteRegistrationListViewModel) => { - s.duplicatePecSiteCount = paginatedList.results.filter((innerSite: SiteRegistrationListViewModel) => innerSite.id !== s.id - && innerSite.pec && innerSite.pec === s.pec).length; - }); this.dataSource.data = paginatedList.results; this.pagination = paginatedList; }); diff --git a/prime-dotnet-webapi/Controllers/SitesController.cs b/prime-dotnet-webapi/Controllers/SitesController.cs index 00c0bc6b3b..8be3fe2c74 100755 --- a/prime-dotnet-webapi/Controllers/SitesController.cs +++ b/prime-dotnet-webapi/Controllers/SitesController.cs @@ -98,7 +98,7 @@ public async Task GetSites(int organizationId, [FromQuery] bool ve [Authorize(Roles = Roles.ViewSite)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] - [ProducesResponseType(typeof(ApiResultResponse>), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ApiResultResponse>), StatusCodes.Status200OK)] public async Task GetAllSites([FromQuery] OrganizationSearchOptions search) { var paginatedList = await _communitySiteService.GetSitesAsync(search); diff --git a/prime-dotnet-webapi/Services/CommunitySiteService.cs b/prime-dotnet-webapi/Services/CommunitySiteService.cs index b0dd284e98..6bea843dc1 100644 --- a/prime-dotnet-webapi/Services/CommunitySiteService.cs +++ b/prime-dotnet-webapi/Services/CommunitySiteService.cs @@ -76,6 +76,14 @@ public async Task> GetSitesAsync( .DecompileAsync(); var paginatedList = await PaginatedList.CreateAsync(query, searchOptions.Page ?? 1); + + + //check for duplicate site id + foreach (var site in paginatedList) + { + site.DuplicatePecSiteCount = await GetDuplicatePecCount(site.CareSettingCode, site.PEC, site.Id); + } + GroupSitesToOrgVisually(paginatedList); return paginatedList; } @@ -108,6 +116,13 @@ private static void GroupSitesToOrgVisually(PaginatedList GetDuplicatePecCount(int? careSettingCode, string pec, int orgSiteId) + { + return await _context.Sites + .Where(s => s.PEC == pec && s.CareSettingCode == careSettingCode && orgSiteId != s.Id) + .CountAsync(); + } + public async Task GetSiteAsync(int siteId) { return await GetBaseSiteQuery() diff --git a/prime-dotnet-webapi/ViewModels/SiteRegistration/CommunitySiteAdminListViewModel.cs b/prime-dotnet-webapi/ViewModels/SiteRegistration/CommunitySiteAdminListViewModel.cs index f44a11b061..61a51ac96a 100644 --- a/prime-dotnet-webapi/ViewModels/SiteRegistration/CommunitySiteAdminListViewModel.cs +++ b/prime-dotnet-webapi/ViewModels/SiteRegistration/CommunitySiteAdminListViewModel.cs @@ -22,5 +22,6 @@ public class CommunitySiteAdminListViewModel public int RemoteUserCount { get; set; } public bool Flagged { get; set; } public bool IsNew { get; set; } + public int DuplicatePecSiteCount { get; set; } } } From 340fe9359d67a0c4ffa5d7d3d464ee5be8324f0a Mon Sep 17 00:00:00 2001 From: Jack Wong <108699279+bergomi02@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:41:44 -0800 Subject: [PATCH 2/2] update parameter name --- prime-dotnet-webapi/Services/CommunitySiteService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prime-dotnet-webapi/Services/CommunitySiteService.cs b/prime-dotnet-webapi/Services/CommunitySiteService.cs index 6bea843dc1..c5779d38fd 100644 --- a/prime-dotnet-webapi/Services/CommunitySiteService.cs +++ b/prime-dotnet-webapi/Services/CommunitySiteService.cs @@ -116,10 +116,10 @@ private static void GroupSitesToOrgVisually(PaginatedList GetDuplicatePecCount(int? careSettingCode, string pec, int orgSiteId) + private async Task GetDuplicatePecCount(int? careSettingCode, string pec, int originalSiteId) { return await _context.Sites - .Where(s => s.PEC == pec && s.CareSettingCode == careSettingCode && orgSiteId != s.Id) + .Where(s => s.PEC == pec && s.CareSettingCode == careSettingCode && originalSiteId != s.Id) .CountAsync(); }