in pathology/viewer/src/components/cohorts-page/cohorts-page.component.ts [169:232]
private setupCohortData(): void {
this.cohortService.loadAllCohorts();
this.cohortService.cohorts$.subscribe((cohorts) => {
this.dataSource.data = [];
this.dataSource.data = cohorts;
});
combineLatest([
this.cohortService.selectedPathologyCohort$, this.cohortService.cohorts$
]).subscribe(([selectedPathologyCohort, cohorts]) => {
this.isCohortSaved = cohorts.some(
(cohort) => cohort.name === selectedPathologyCohort?.name);
});
this.cohortService.selectedPathologyCohort$.subscribe(
(selectedPathologyCohort) => {
this.selectedPathologyCohort = selectedPathologyCohort;
});
this.cohortService.selectedCohortInfo$.subscribe((selectedCohortInfo) => {
this.selectedCohortInfo = selectedCohortInfo;
});
this.cohortService.selectedPathologyCohortCases$
.pipe(
takeUntil(this.destroyed$),
tap((selectedPathologyCohortCases) => {
this.resetSelectedCases();
this.selectedPathologyCohortCases =
selectedPathologyCohortCases.sort((a, b) => {
const aDate =
this.isDate(a.date) ? new Date(a.date).getTime() : 0;
const bDate =
this.isDate(b.date) ? new Date(b.date).getTime() : 0;
// Sort by date and then accessionNumber
return (aDate - bDate) ||
a.accessionNumber.localeCompare(b.accessionNumber);
});
}),
)
.subscribe();
combineLatest([
this.cohortService.selectedPathologyCohort$.pipe(
takeUntil(this.destroyed$),
filter((selectedCohort) => selectedCohort !== undefined)),
this.userService.getCurrentUser$(),
])
.pipe(
takeUntil(this.destroyed$),
tap(([selectedPathologyCohort, currentUser]) => {
if (selectedPathologyCohort && currentUser) {
this.setAccess(
selectedPathologyCohort,
currentUser,
);
} else {
this.resetAccess();
}
}))
.subscribe();
}