Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRIME-2824 Site ID Duplicates icon did not show up correctly #2639

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<SiteRegistrationListViewModel>) => {
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;
});
Expand Down
2 changes: 1 addition & 1 deletion prime-dotnet-webapi/Controllers/SitesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task<ActionResult> GetSites(int organizationId, [FromQuery] bool ve
[Authorize(Roles = Roles.ViewSite)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ApiResultResponse<PaginatedResponse<CommunitySiteListViewModel>>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResultResponse<PaginatedResponse<CommunitySiteAdminListViewModel>>), StatusCodes.Status200OK)]
public async Task<ActionResult> GetAllSites([FromQuery] OrganizationSearchOptions search)
{
var paginatedList = await _communitySiteService.GetSitesAsync(search);
Expand Down
15 changes: 15 additions & 0 deletions prime-dotnet-webapi/Services/CommunitySiteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public async Task<PaginatedList<CommunitySiteAdminListViewModel>> GetSitesAsync(
.DecompileAsync();

var paginatedList = await PaginatedList<CommunitySiteAdminListViewModel>.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;
}
Expand Down Expand Up @@ -108,6 +116,13 @@ private static void GroupSitesToOrgVisually(PaginatedList<CommunitySiteAdminList
}
}

private async Task<int> GetDuplicatePecCount(int? careSettingCode, string pec, int originalSiteId)
{
return await _context.Sites
.Where(s => s.PEC == pec && s.CareSettingCode == careSettingCode && originalSiteId != s.Id)
.CountAsync();
}

public async Task<CommunitySite> GetSiteAsync(int siteId)
{
return await GetBaseSiteQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}