Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
datamanager.h
Go to the documentation of this file.
1#pragma once
2
4#include "pif_data.h"
5
6#include <filesystem>
7#include <nlohmann/json.hpp>
8
9namespace hgps::input {
10
11using namespace hgps::core;
12
25class DataManager : public Datastore {
26 public:
27 DataManager() = delete;
28
34 explicit DataManager(std::filesystem::path data_path,
35 VerboseMode verbosity = VerboseMode::none);
36
37 std::vector<Country> get_countries() const override;
38
39 Country get_country(const std::string &alpha) const override;
40
41 std::vector<PopulationItem> get_population(const Country &country) const;
42
43 std::vector<PopulationItem>
44 get_population(const Country &country,
45 std::function<bool(unsigned int)> time_filter) const override;
46
47 std::vector<MortalityItem> get_mortality(const Country &country) const;
48
49 std::vector<MortalityItem>
50 get_mortality(const Country &country,
51 std::function<bool(unsigned int)> time_filter) const override;
52
53 std::vector<DiseaseInfo> get_diseases() const override;
54
55 DiseaseInfo get_disease_info(const core::Identifier &code) const override;
56
57 DiseaseEntity get_disease(const DiseaseInfo &info, const Country &country) const override;
58
59 std::optional<RelativeRiskEntity>
61 const DiseaseInfo &target) const override;
62
63 std::optional<RelativeRiskEntity>
65 const core::Identifier &risk_factor_key) const override;
66
70 const Country &country) const override;
71
72 DiseaseAnalysisEntity get_disease_analysis(const Country &country) const override;
73
74 std::vector<BirthItem> get_birth_indicators(const Country &country) const;
75
76 std::vector<BirthItem>
77 get_birth_indicators(const Country &country,
78 std::function<bool(unsigned int)> time_filter) const override;
79
80 std::vector<LmsDataRow> get_lms_parameters() const override;
81
87 std::optional<PIFData> get_pif_data(const DiseaseInfo &disease_info, const Country &country,
88 const nlohmann::json &pif_config) const;
89
92 const std::filesystem::path &get_root_path() const noexcept { return root_; }
93
94 private:
95 std::filesystem::path root_;
96 VerboseMode verbosity_;
97 nlohmann::json index_;
98
99 std::map<int, std::map<Gender, double>>
100 load_cost_of_diseases(const Country &country, const nlohmann::json &node,
101 const std::filesystem::path &parent_path) const;
102
103 std::vector<LifeExpectancyItem> load_life_expectancy(const Country &country) const;
104
105 static std::string replace_string_tokens(const std::string &source,
106 const std::vector<std::string> &tokens);
107
108 static std::map<std::string, std::size_t>
109 create_fields_index_mapping(const std::vector<std::string> &column_names,
110 const std::vector<std::string> &fields);
111
112 void notify_warning(std::string_view message) const;
113
117 PIFTable load_pif_from_csv(const std::filesystem::path &filepath) const;
118
123 std::filesystem::path construct_pif_path(const std::string &disease_code,
124 const nlohmann::json &pif_config) const;
125
129 std::string expand_environment_variables(const std::string &path) const;
130};
131
132} // namespace hgps::input
Defines the Health-GPS back-end data store interface for all implementations.
Definition datastore.h:14
Implements Health-GPS back-end data store interface using a file-based storage.
Definition datamanager.h:25
std::vector< DiseaseInfo > get_diseases() const override
Gets the collection of diseases information in the store.
Definition datamanager.cpp:171
std::optional< RelativeRiskEntity > get_relative_risk_to_risk_factor(const DiseaseInfo &source, Gender gender, const core::Identifier &risk_factor_key) const override
Gets the relative risk effects for risk factor to disease interactions.
Definition datamanager.cpp:341
std::vector< MortalityItem > get_mortality(const Country &country) const
Definition datamanager.cpp:127
std::vector< Country > get_countries() const override
Gets the full collection of countries in the store.
Definition datamanager.cpp:39
std::vector< BirthItem > get_birth_indicators(const Country &country) const
Definition datamanager.cpp:447
CancerParameterEntity get_disease_parameter(const DiseaseInfo &info, const Country &country) const override
Gets the parameters required by cancer type diseases for a country.
Definition datamanager.cpp:387
Country get_country(const std::string &alpha) const override
Gets a single country by the alpha code.
Definition datamanager.cpp:65
DiseaseAnalysisEntity get_disease_analysis(const Country &country) const override
Gets the Burden of Diseases (BoD) analysis dataset for a country.
Definition datamanager.cpp:515
DiseaseInfo get_disease_info(const core::Identifier &code) const override
Gets a single disease information by identifier.
Definition datamanager.cpp:196
DiseaseEntity get_disease(const DiseaseInfo &info, const Country &country) const override
Gets a disease full definition by identifier for a country.
Definition datamanager.cpp:220
std::vector< PopulationItem > get_population(const Country &country) const
Definition datamanager.cpp:80
std::optional< PIFData > get_pif_data(const DiseaseInfo &disease_info, const Country &country, const nlohmann::json &pif_config) const
Gets PIF data for a specific disease.
Definition datamanager.cpp:650
const std::filesystem::path & get_root_path() const noexcept
Get the root data directory path.
Definition datamanager.h:92
std::optional< RelativeRiskEntity > get_relative_risk_to_disease(const DiseaseInfo &source, const DiseaseInfo &target) const override
Gets the relative risk effects for disease to disease interactions.
Definition datamanager.cpp:279
std::vector< LmsDataRow > get_lms_parameters() const override
Gets the LMS (lambda-mu-sigma) parameters for childhood growth charts.
Definition datamanager.cpp:485
PIF data table for a specific disease-risk factor-scenario combination.
Definition pif_data.h:29
Top-level namespace for Health-GPS Core C++ API.
Definition analysis.h:7
VerboseMode
Verbosity mode enumeration.
Definition forward_type.h:9
Gender
Enumerates gender types.
Definition forward_type.h:18
Data structures containing model parameters and configuration options.
Definition configuration.cpp:75
@ info
General notification and progress message.
Cancer disease parameters per country data structure.
Definition disease.h:86
Country ISO-3166 definition data structure.
Definition country.h:7
Burden of Diseases (BoD) analysis for a country data structure.
Definition analysis.h:25
Disease full definition data structure.
Definition disease.h:54
Disease information structure.
Definition disease.h:14
Entity unique identifier data type.
Definition identifier.h:20