Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
neophyte57 committed Nov 29, 2024
2 parents d42dc56 + eb9069b commit adf8baf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
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 != null && 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; }
}
}

0 comments on commit adf8baf

Please sign in to comment.