generated from EyeSeeTea/dhis2-app-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge development and solve conflicts
- Loading branch information
Showing
43 changed files
with
2,434 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { DataStoreClient } from "../DataStoreClient"; | ||
import { FutureData } from "../api-futures"; | ||
import { ChartConfigRepository } from "../../domain/repositories/ChartConfigRepository"; | ||
import { Id } from "../../domain/entities/Ref"; | ||
|
||
type ChartConfig = { | ||
key: string; | ||
casesId: Id; | ||
deathsId: Id; | ||
riskAssessmentHistoryId: Id; | ||
}; | ||
|
||
const chartConfigDatastoreKey = "charts-config"; | ||
|
||
export class ChartConfigD2Repository implements ChartConfigRepository { | ||
constructor(private dataStoreClient: DataStoreClient) {} | ||
|
||
public getCases(chartKey: string): FutureData<string> { | ||
return this.dataStoreClient | ||
.getObject<ChartConfig[]>(chartConfigDatastoreKey) | ||
.map(chartConfigs => { | ||
const currentChart = chartConfigs?.find( | ||
chartConfig => chartConfig.key === chartKey | ||
); | ||
if (currentChart) return currentChart.casesId; | ||
else throw new Error(`Chart id not found for ${chartKey}`); | ||
}); | ||
} | ||
|
||
public getDeaths(chartKey: string): FutureData<string> { | ||
return this.dataStoreClient | ||
.getObject<ChartConfig[]>(chartConfigDatastoreKey) | ||
.map(chartConfigs => { | ||
const currentChart = chartConfigs?.find( | ||
chartConfig => chartConfig.key === chartKey | ||
); | ||
if (currentChart) return currentChart.deathsId; | ||
else throw new Error(`Chart id not found for ${chartKey}`); | ||
}); | ||
} | ||
|
||
public getRiskAssessmentHistory(chartKey: string): FutureData<string> { | ||
return this.dataStoreClient | ||
.getObject<ChartConfig[]>(chartConfigDatastoreKey) | ||
.map(chartConfigs => { | ||
const currentChart = chartConfigs?.find( | ||
chartConfig => chartConfig.key === chartKey | ||
); | ||
if (currentChart) return currentChart.riskAssessmentHistoryId; | ||
else throw new Error(`Chart id not found for ${chartKey}`); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.