FRED
Infection.h
00001 /*
00002   Copyright 2009 by the University of Pittsburgh
00003   Licensed under the Academic Free License version 3.0
00004   See the file "LICENSE" for more information
00005 */
00006 
00007 //
00008 // File: Infection.h
00009 //
00010 
00011 #ifndef _FRED_INFECTION_H
00012 #define _FRED_INFECTION_H
00013 
00014 #include "Global.h"
00015 #include <map>
00016 #include "Trajectory.h"
00017 #include "IntraHost.h"
00018 #include <limits.h>
00019 
00020 class Health;
00021 class Person;
00022 class Place;
00023 class Disease;
00024 class Antiviral;
00025 class Health;
00026 class IntraHost;
00027 class Transmission;
00028 
00029 #define BIFURCATING 0
00030 #define SEQUENTIAL 1
00031 
00032 extern int Infection_model;
00033 
00034 class Infection {
00035 public:
00036   // if primary infection, infector and place are null.
00037   // if mutation, place is null.
00038   Infection(Disease *s, Person *infector, Person *infectee, Place* place, int day);
00039   ~Infection() { }
00040 
00046   void update(int today);
00047 
00048   // general
00052   Disease * get_disease() const { return disease; }
00053 
00057   Person * get_infector() const { return infector; }
00058 
00062   Place * get_infected_place() const { return place; }
00063 
00067   int get_infectee_count() const { return infectee_count; }
00068 
00073   int add_infectee() { return ++infectee_count; }
00074 
00075 
00079   void print() const;
00080 
00084   void report_infection(int day) const;
00085 
00086   // chrono
00090   int get_exposure_date() const { return exposure_date; }
00091 
00095   int get_infectious_date() const { return infectious_date - offset; }
00096 
00100   int get_symptomatic_date() const { return symptomatic_date - offset; }
00101 
00105   int get_asymptomatic_date() const { return asymptomatic_date - offset; }
00106 
00110   int get_recovery_date() const { return recovery_date - offset; }
00111 
00115   int get_susceptible_date() const {
00116     if (recovery_period > -1) {
00117       return get_recovery_date() + recovery_period;
00118     } else {
00119       return INT_MAX;
00120     }
00121   }
00122 
00126   int set_susceptibility_period(int period) {
00127     return susceptibility_period = period;
00128   }
00129 
00133   int get_unsusceptible_date() const {
00134     return exposure_date + susceptibility_period;
00135   }
00136 
00141   void modify_asymptomatic_period(double multp, int cur_day);
00142 
00147   void modify_symptomatic_period(double multp, int cur_day);
00148 
00153   void modify_infectious_period(double multp, int cur_day);
00154 
00155   // parameters
00159   bool is_infectious() { return infectivity > trajectory_infectivity_threshold; }
00160 
00164   bool is_symptomatic() { return symptoms > trajectory_symptomaticity_threshold; }
00165 
00169   double get_susceptibility() const { return susceptibility; }
00170 
00174   double get_symptoms() const { return symptoms; }
00175 
00180   void modify_develops_symptoms(bool symptoms, int cur_day);
00181 
00185   void modify_susceptibility(double multp) { susceptibility *= multp; }
00186 
00190   void modify_infectivity(double multp) { infectivity_multp *= multp; }
00191 
00196   double get_infectivity(int day) const {
00197     day = day - exposure_date + offset;
00198     Trajectory::point point = trajectory->get_data_point(day);
00199     return point.infectivity * infectivity_multp;
00200   }
00201 
00206   void transmit(Person *infectee, Transmission *transmission);
00207 
00211   void addTransmission(Transmission *transmission);
00212 
00216   void setTrajectory(Trajectory *trajectory);
00217 
00218   //
00225   static Infection * get_dummy_infection(Disease *s, Person *host, int day);
00226 
00230   Trajectory * get_trajectory() { return trajectory; }
00231 
00232 private:
00233   // associated disease
00234   Disease *disease;
00235   int id;
00236   bool isSusceptible;
00237 
00238   // chrono data
00239   int exposure_date;
00240 
00241   int latent_period;
00242   int asymptomatic_period;
00243   int symptomatic_period;
00244   int recovery_period;
00245   int susceptibility_period;
00246 
00247   // people involved
00248   Person *infector;
00249   Person *host;
00250 
00251   // where infection was caught
00252   Place *place;
00253 
00254   // number of people infected by this infection
00255   int infectee_count;
00256 
00257   // parameters
00258   bool will_be_symptomatic;
00259   double susceptibility;
00260   double infectivity;
00261   double infectivity_multp;
00262   double symptoms;
00263   int infection_model;
00264 
00265   // trajectory contains vectors that describe the (tentative) infection course
00266   Trajectory * trajectory;
00267   // thresholds used by determine_transition_dates()
00268   double trajectory_infectivity_threshold;
00269   double trajectory_symptomaticity_threshold;
00270 
00271   int incubation_period;
00272   // the transition dates are set in the constructor by determine_transition_dates()
00273   int infectious_date;
00274   int symptomatic_date;
00275   int asymptomatic_date;
00276   int recovery_date;
00277   int susceptible_date;
00278 
00279   void determine_transition_dates();
00280 
00281   // offset is used for dummy infections to advance to the first infectious day
00282   // this offset is applied in the get_*_date() methods defined in the header
00283   // as well as in the update() method when evaluating the trajectory
00284   bool dummy;
00285   int offset;
00286 
00287   std::vector <Transmission *> transmissions;
00288 
00289 protected:
00290   // for mocks
00291   Infection() { }
00292 };
00293 
00294 #endif // _FRED_INFECTION_H
00295 
 All Classes Functions