Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
person.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <map>
7
8namespace hgps {
9
11enum struct DiseaseStatus : uint8_t {
13 free,
14
16 active
17};
18
20struct Disease {
23
26
29
32 Disease clone() const noexcept {
33 return Disease{
34 .status = status, .start_time = start_time, .time_since_onset = time_since_onset};
35 }
36};
37
39struct Person {
42
46 Person(const core::Gender gender) noexcept;
47
49 static constexpr std::size_t unassigned_id = 0;
50
53 Person(std::size_t id) noexcept;
54
58 Person(const core::Gender gender, std::size_t id) noexcept;
59
62 void set_id(std::size_t id) noexcept;
63
65 [[nodiscard]] bool has_assigned_id() const noexcept { return id_ != unassigned_id; }
66
72 std::size_t id() const noexcept;
73
76
78 unsigned int age{};
79
82
84 std::string region{"unknown"};
85
87 std::string ethnicity{"unknown"};
88
91
93 double income_continuous{0.0};
94
98
101
103 double physical_activity{0.0};
104
106 double ses{};
107
109 std::map<core::Identifier, double> risk_factors;
110
112 std::map<core::Identifier, Disease> diseases;
113
116 bool is_alive() const noexcept;
117
120 bool has_emigrated() const noexcept;
121
124 unsigned int time_of_death() const noexcept;
125
128 unsigned int time_of_migration() const noexcept;
129
133 bool is_active() const noexcept;
134
139 double get_risk_factor_value(const core::Identifier &key) const;
140
144 float gender_to_value() const;
145
150 static float gender_to_value(core::Gender gender);
151
155 std::string gender_to_string() const;
156
159 bool over_18() const noexcept;
160
164 float sector_to_value() const;
165
169 float income_to_value() const;
170
174 float region_to_value() const;
175
179 float ethnicity_to_value() const;
180
184 void emigrate(const unsigned int time);
185
189 void die(const unsigned int time);
190
191 private:
192 std::size_t id_{};
193 bool is_alive_{true};
194 bool has_emigrated_{false};
195 unsigned int time_of_death_{};
196 unsigned int time_of_migration_{};
197
198 static std::map<core::Identifier, std::function<double(const Person &)>> current_dispatcher;
199};
200} // namespace hgps
Sector
Enumerates sector types.
Definition forward_type.h:39
@ unknown
Unknown sector.
Gender
Enumerates gender types.
Definition forward_type.h:18
@ unknown
Unknown gender.
Income
Enumerates income categories.
Definition forward_type.h:51
@ unknown
Unknown income.
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
DiseaseStatus
Disease status enumeration.
Definition person.h:11
@ free
Declared free from condition.
@ active
Current with the condition.
Global namespace.
Definition column_iterator.h:123
Defines the disease history data type.
Definition person.h:20
DiseaseStatus status
The disease current status.
Definition person.h:22
int start_time
Disease start time.
Definition person.h:25
Disease clone() const noexcept
Clone a disease history entry.
Definition person.h:32
int time_since_onset
Disease time since onset (cancer disease only)
Definition person.h:28
Defines a virtual population person data type.
Definition person.h:39
bool has_emigrated() const noexcept
Determine if a Person has emigrated from the population.
Definition person.cpp:49
std::map< core::Identifier, Disease > diseases
Diseases history and current status.
Definition person.h:112
float sector_to_value() const
Gets the sector enumeration as a number.
Definition person.cpp:97
unsigned int time_of_death() const noexcept
Gets the time of death, for dead, non-alive individuals only.
Definition person.cpp:51
float region_to_value() const
Gets the region as a numeric value for analysis.
Definition person.cpp:125
void set_id(std::size_t id) noexcept
Set the person identifier (Population use when placing or recycling slots).
Definition person.cpp:43
float income_to_value() const
Gets the income enumeration as a number.
Definition person.cpp:108
core::Gender gender
The assigned gender.
Definition person.h:75
double ses
Social-economic status (SES) assigned value.
Definition person.h:106
std::size_t id() const noexcept
Gets this instance unique identifier.
Definition person.cpp:45
std::string gender_to_string() const
Gets the gender enumeration name string.
Definition person.cpp:88
std::string region
Region category (dynamically assigned from CSV)
Definition person.h:84
bool is_alive() const noexcept
Determine if a Person is current alive.
Definition person.cpp:47
double get_risk_factor_value(const core::Identifier &key) const
Gets a risk factor current value.
Definition person.cpp:57
double physical_activity
Physical activity level.
Definition person.h:103
std::size_t income_adjustment_stratum
Income adjustment stratum index (0..N-1) for optional stratum-specific factors mean.
Definition person.h:97
void emigrate(const unsigned int time)
Emigrate this instance from the virtual population.
Definition person.cpp:163
bool has_income_adjustment_stratum
Whether income_adjustment_stratum has been assigned for this simulation step.
Definition person.h:100
double income_continuous
Continuous income value (for FINCH approach)
Definition person.h:93
float ethnicity_to_value() const
Gets the ethnicity as a numeric value for analysis.
Definition person.cpp:144
bool has_assigned_id() const noexcept
Whether Population has assigned a lifetime ID to this instance.
Definition person.h:65
unsigned int time_of_migration() const noexcept
Gets the time of migration, for emigrated individuals only.
Definition person.cpp:53
core::Sector sector
Sector (region) assigned value.
Definition person.h:81
std::map< core::Identifier, double > risk_factors
Current risk factors values.
Definition person.h:109
bool is_active() const noexcept
Gets a value indicating whether a Person is current active in the population.
Definition person.cpp:55
std::string ethnicity
Ethnicity category (dynamically assigned from CSV)
Definition person.h:87
float gender_to_value() const
Gets the gender enumeration as a number for analysis.
Definition person.cpp:79
unsigned int age
Current age in years.
Definition person.h:78
Person()
Initialise a new instance without an assigned ID (unassigned_id).
core::Income income
Income category.
Definition person.h:90
void die(const unsigned int time)
Mark this instance as dead.
Definition person.cpp:172
bool over_18() const noexcept
Check if person is an adult (18 or over)
Definition person.cpp:95
static constexpr std::size_t unassigned_id
Sentinel returned by default constructors until Population assigns an ID.
Definition person.h:49