Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
person.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <atomic>
4 #include <map>
5 
7 #include "interfaces.h"
8 
9 namespace hgps {
10 
12 enum struct DiseaseStatus : uint8_t {
14  free,
15 
17  active
18 };
19 
21 struct Disease {
24 
26  int start_time{};
27 
30 
33  Disease clone() const noexcept {
34  return Disease{
35  .status = status, .start_time = start_time, .time_since_onset = time_since_onset};
36  }
37 };
38 
40 struct Person {
42  Person();
43 
46  Person(const core::Gender gender) noexcept;
47 
51  std::size_t id() const noexcept;
52 
55 
57  unsigned int age{};
58 
60  double ses{};
61 
63  std::map<core::Identifier, double> risk_factors;
64 
66  std::map<core::Identifier, Disease> diseases;
67 
70  bool is_alive() const noexcept;
71 
74  bool has_emigrated() const noexcept;
75 
78  unsigned int time_of_death() const noexcept;
79 
82  unsigned int time_of_migration() const noexcept;
83 
87  bool is_active() const noexcept;
88 
92  double get_risk_factor_value(const core::Identifier &key) const noexcept;
93 
96  float gender_to_value() const noexcept;
97 
100  std::string gender_to_string() const noexcept;
101 
105  void emigrate(const unsigned int time);
106 
110  void die(const unsigned int time);
111 
113  static void reset_id();
114 
115  private:
116  std::size_t id_{};
117  bool is_alive_{true};
118  bool has_emigrated_{false};
119  unsigned int time_of_death_{};
120  unsigned int time_of_migration_{};
121 
122  static std::atomic<std::size_t> newUID;
123  static std::map<core::Identifier, std::function<double(const Person &)>> current_dispatcher;
124 };
125 } // namespace hgps
Gender
Enumerates gender types.
Definition: forward_type.h:18
@ unknown
Unknown gender.
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
DiseaseStatus
Disease status enumeration.
Definition: person.h:12
@ free
Declared free from condition.
@ active
Current with the condition.
Global namespace.
Definition: jsonparser.h:88
Defines the disease history data type.
Definition: person.h:21
DiseaseStatus status
The disease current status.
Definition: person.h:23
int start_time
Disease start time.
Definition: person.h:26
Disease clone() const noexcept
Clone a disease history entry.
Definition: person.h:33
int time_since_onset
Disease time since onset (cancer disease only)
Definition: person.h:29
Defines a virtual population person data type.
Definition: person.h:40
static void reset_id()
Resets the unique identifier sequence to zero.
Definition: person.cpp:81
bool has_emigrated() const noexcept
Determine if a Person has emigrated from the population.
Definition: person.cpp:25
std::map< core::Identifier, Disease > diseases
Diseases history and current status.
Definition: person.h:66
unsigned int time_of_death() const noexcept
Gets the time of death, for dead, non-alive individuals only.
Definition: person.cpp:27
core::Gender gender
The assigned gender.
Definition: person.h:54
double ses
Social-economic status (SES) assigned value.
Definition: person.h:60
std::size_t id() const noexcept
Gets this instance unique identifier.
Definition: person.cpp:21
bool is_alive() const noexcept
Determine if a Person is current alive.
Definition: person.cpp:23
void emigrate(const unsigned int time)
Emigrate this instance from the virtual population.
Definition: person.cpp:63
std::string gender_to_string() const noexcept
Gets the gender enumeration name string.
Definition: person.cpp:55
double get_risk_factor_value(const core::Identifier &key) const noexcept
Gets a risk factor current value.
Definition: person.cpp:33
unsigned int time_of_migration() const noexcept
Gets the time of migration, for emigrated individuals only.
Definition: person.cpp:29
std::map< core::Identifier, double > risk_factors
Current risk factors values.
Definition: person.h:63
bool is_active() const noexcept
Gets a value indicating whether a Person is current active in the population.
Definition: person.cpp:31
unsigned int age
Current age in years.
Definition: person.h:57
Person()
Initialise a new instance of the Person structure.
Definition: person.cpp:16
float gender_to_value() const noexcept
Gets the gender enumeration as a number for analysis.
Definition: person.cpp:47
void die(const unsigned int time)
Mark this instance as dead.
Definition: person.cpp:72