diff --git a/i18n/en.pot b/i18n/en.pot index 5346f5a0..59f8784d 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-09-16T15:12:17.095Z\n" -"PO-Revision-Date: 2024-09-16T15:12:17.095Z\n" +"POT-Creation-Date: 2024-09-30T07:39:32.843Z\n" +"PO-Revision-Date: 2024-09-30T07:39:32.843Z\n" msgid "Low" msgstr "" @@ -81,6 +81,9 @@ msgstr "" msgid "Edit Details" msgstr "" +msgid "Notes" +msgstr "" + msgid "Create Event" msgstr "" diff --git a/src/CompositionRoot.ts b/src/CompositionRoot.ts index 2edd710e..ff0d5bdc 100644 --- a/src/CompositionRoot.ts +++ b/src/CompositionRoot.ts @@ -24,7 +24,7 @@ import { PerformanceOverviewRepository } from "./domain/repositories/Performance import { GetAllPerformanceOverviewMetricsUseCase } from "./domain/usecases/GetAllPerformanceOverviewMetricsUseCase"; import { PerformanceOverviewD2Repository } from "./data/repositories/PerformanceOverviewD2Repository"; import { PerformanceOverviewTestRepository } from "./data/repositories/test/PerformanceOverviewTestRepository"; -import { GetDiseasesTotalUseCase } from "./domain/usecases/GetDiseasesTotalUseCase"; +import { GetTotalCardCountsUseCase } from "./domain/usecases/GetDiseasesTotalUseCase"; import { MapDiseaseOutbreakToAlertsUseCase } from "./domain/usecases/MapDiseaseOutbreakToAlertsUseCase"; import { AlertRepository } from "./domain/repositories/AlertRepository"; import { AlertTestRepository } from "./data/repositories/test/AlertTestRepository"; @@ -66,7 +66,7 @@ function getCompositionRoot(repositories: Repositories) { getPerformanceOverviewMetrics: new GetAllPerformanceOverviewMetricsUseCase( repositories ), - getEventTrackerCounts: new GetDiseasesTotalUseCase( + getTotalCardCounts: new GetTotalCardCountsUseCase( repositories.performanceOverviewRepository ), }, diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index ff695856..ba285f19 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -23,7 +23,7 @@ import { OrgUnit } from "../../domain/entities/OrgUnit"; export class PerformanceOverviewD2Repository implements PerformanceOverviewRepository { constructor(private api: D2Api, private datastore: DataStoreClient) {} - getDiseasesTotal(filters?: Record): FutureData { + getTotalCardCounts(filters?: Record): FutureData { return apiToFuture( this.api.analytics.get({ dimension: [ @@ -107,32 +107,29 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos getPerformanceOverviewMetrics( diseaseOutbreakEvents: DiseaseOutbreakEventBaseAttrs[] ): FutureData { - const fetchEnrollmentsQuery = (): FutureData => - apiToFuture( - this.api.get( - `/analytics/enrollments/query/${RTSL_ZEBRA_PROGRAM_ID}`, - { - enrollmentDate: "LAST_12_MONTHS,THIS_MONTH", - dimension: [ - IndicatorsId.suspectedDisease, - IndicatorsId.hazardType, - IndicatorsId.event, - IndicatorsId.era1, - IndicatorsId.era2, - IndicatorsId.era3, - IndicatorsId.era4, - IndicatorsId.era5, - IndicatorsId.era6, - IndicatorsId.era7, - IndicatorsId.detect7d, - IndicatorsId.notify1d, - IndicatorsId.respond7d, - ], - } - ) - ); - - return fetchEnrollmentsQuery().flatMap(indicatorsProgramFuture => { + return apiToFuture( + this.api.get( + `/analytics/enrollments/query/${RTSL_ZEBRA_PROGRAM_ID}`, + { + enrollmentDate: "LAST_12_MONTHS,THIS_MONTH", + dimension: [ + IndicatorsId.suspectedDisease, + IndicatorsId.hazardType, + IndicatorsId.event, + IndicatorsId.era1, + IndicatorsId.era2, + IndicatorsId.era3, + IndicatorsId.era4, + IndicatorsId.era5, + IndicatorsId.era6, + IndicatorsId.era7, + IndicatorsId.detect7d, + IndicatorsId.notify1d, + IndicatorsId.respond7d, + ], + } + ) + ).flatMap(indicatorsProgramFuture => { const mappedIndicators = indicatorsProgramFuture?.rows.map((row: string[]) => this.mapRowToBaseIndicator( @@ -143,20 +140,20 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos ) ) || []; - const something = diseaseOutbreakEvents.map(event => { + const performanceOverviewMetrics = diseaseOutbreakEvents.map(event => { const baseIndicator = mappedIndicators.find(indicator => indicator.id === event.id); - const key = baseIndicator?.suspectedDisease || baseIndicator?.hazardType; return this.getCasesAndDeathsFromDatastore(key).map(casesAndDeaths => { + const duration = `${moment() + .diff(moment(event.emerged.date), "days") + .toString()}d`; if (!baseIndicator) { return { id: event.id, event: event.name, manager: event.incidentManagerName, - duration: `${moment() - .diff(moment(event.emerged.date), "days") - .toString()}d`, + duration: duration, nationalIncidentStatus: event.incidentStatus, cases: casesAndDeaths.cases.toString(), deaths: casesAndDeaths.deaths.toString(), @@ -166,16 +163,14 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos ...baseIndicator, nationalIncidentStatus: event.incidentStatus, manager: event.incidentManagerName, - duration: `${moment() - .diff(moment(event.emerged.date), "days") - .toString()}d`, + duration: duration, cases: casesAndDeaths.cases.toString(), deaths: casesAndDeaths.deaths.toString(), } as PerformanceOverviewMetrics; }); }); - return Future.sequential(something); + return Future.sequential(performanceOverviewMetrics); }); } diff --git a/src/data/repositories/test/PerformanceOverviewTestRepository.ts b/src/data/repositories/test/PerformanceOverviewTestRepository.ts index cd282184..4bbc4a4f 100644 --- a/src/data/repositories/test/PerformanceOverviewTestRepository.ts +++ b/src/data/repositories/test/PerformanceOverviewTestRepository.ts @@ -3,7 +3,7 @@ import { PerformanceOverviewRepository } from "../../../domain/repositories/Perf import { FutureData } from "../../api-futures"; export class PerformanceOverviewTestRepository implements PerformanceOverviewRepository { - getDiseasesTotal(): FutureData { + getTotalCardCounts(): FutureData { return Future.success(0); } getPerformanceOverviewMetrics(): FutureData { diff --git a/src/domain/repositories/PerformanceOverviewRepository.ts b/src/domain/repositories/PerformanceOverviewRepository.ts index ff4fc107..88c3d101 100644 --- a/src/domain/repositories/PerformanceOverviewRepository.ts +++ b/src/domain/repositories/PerformanceOverviewRepository.ts @@ -9,5 +9,5 @@ export interface PerformanceOverviewRepository { getPerformanceOverviewMetrics( diseaseOutbreakEvents: DiseaseOutbreakEventBaseAttrs[] ): FutureData; - getDiseasesTotal(filters?: Record): FutureData; + getTotalCardCounts(filters?: Record): FutureData; } diff --git a/src/domain/usecases/GetDiseasesTotalUseCase.ts b/src/domain/usecases/GetDiseasesTotalUseCase.ts index 8359cac7..b241d3e1 100644 --- a/src/domain/usecases/GetDiseasesTotalUseCase.ts +++ b/src/domain/usecases/GetDiseasesTotalUseCase.ts @@ -2,10 +2,10 @@ import { FutureData } from "../../data/api-futures"; import { TotalCardCounts } from "../entities/disease-outbreak-event/PerformanceOverviewMetrics"; import { PerformanceOverviewRepository } from "../repositories/PerformanceOverviewRepository"; -export class GetDiseasesTotalUseCase { +export class GetTotalCardCountsUseCase { constructor(private performanceOverviewRepository: PerformanceOverviewRepository) {} public execute(filters?: Record): FutureData { - return this.performanceOverviewRepository.getDiseasesTotal(filters); + return this.performanceOverviewRepository.getTotalCardCounts(filters); } } diff --git a/src/webapp/pages/dashboard/useCardCounts.ts b/src/webapp/pages/dashboard/useCardCounts.ts index 6aa6bd17..fa990bed 100644 --- a/src/webapp/pages/dashboard/useCardCounts.ts +++ b/src/webapp/pages/dashboard/useCardCounts.ts @@ -12,7 +12,7 @@ export function useCardCounts(filters: Record) { useEffect(() => { setIsLoading(true); - compositionRoot.performanceOverview.getEventTrackerCounts.execute(filters).run( + compositionRoot.performanceOverview.getTotalCardCounts.execute(filters).run( diseasesTotal => { setCardCounts(diseasesTotal); setIsLoading(false);