/// <summary> ////////////////////////////////////////////////////////////////////////// /// Person constructor - copies an existing Person. /// Person - Person to be copied. /// </summary> ///////////////////////////////////////////////////////////////////////// public Person(Person personToBeCopied) { initializeOK = personToBeCopied.initializeOK; birthYear = personToBeCopied.birthYear; yearNow = personToBeCopied.yearNow; startAge = personToBeCopied.startAge; ageNow = personToBeCopied.ageNow; haveDiarrhea = personToBeCopied.haveDiarrhea; haveAnemia = personToBeCopied.haveAnemia; haveStunting = personToBeCopied.haveStunting; gender = personToBeCopied.gender; country = personToBeCopied.country; disease = personToBeCopied.disease; alive = personToBeCopied.alive; LY = personToBeCopied.LY; LYDisc = personToBeCopied.LYDisc; QALYs = personToBeCopied.QALYs; everStunting = personToBeCopied.everStunting; everAnemia = personToBeCopied.everAnemia; everDiarrhea = personToBeCopied.everDiarrhea; Stunting_0 = personToBeCopied.Stunting_0; Anemia_0 = personToBeCopied.Anemia_0; Diarrhea_0 = personToBeCopied.Diarrhea_0; Stunting_5 = personToBeCopied.Stunting_5; Anemia_5 = personToBeCopied.Anemia_5; Diarrhea_5 = personToBeCopied.Diarrhea_5; isAlive_0 = personToBeCopied.isAlive_0; isAlive_5 = personToBeCopied.isAlive_5; //costs = personToBeCopied.costs; }
/// <summary> ////////////////////////////////////////////////////////////////////////// /// Person constructor - Uses input from DISEASE PREVALENCE file to create a person object /// that stores Disease prevalence as a function of startage, year & country. /// </summary> ///////////////////////////////////////////////////////////////////////// public Person(DiseasePrevPersonInitializer x) { // Set InitializeOK flag to true; initializeOK = true; // Set disease prevalence lookup field values; ageNow = x.ageNow; yearNow = x.yearNow; country = x.country; disease = x.disease; }
public static int getPrevOffset(diseaseType myDisease) { int returnVal; switch (myDisease) { case diseaseType.STUNTING: returnVal = DiseasePrevVALUEInitializer.PrevValue_offsetStart + (int)diseaseType.STUNTING; break; case diseaseType.DIARRHEA: returnVal = DiseasePrevVALUEInitializer.PrevValue_offsetStart + (int)diseaseType.DIARRHEA; break; case diseaseType.ANEMIA: returnVal = DiseasePrevVALUEInitializer.PrevValue_offsetStart + (int)diseaseType.ANEMIA; break; default: returnVal = -1; break; } return(returnVal); }
///////////////////////////////////////////////////////////////////////// //Ages person by duration in the current stage //Steps through lifetime of person //If alive, probabilitly of disease & increase age ///////////////////////////////////////////////////////////////////////// public void simMyLife(Policy myPolicy) { // Transition probabilities double probStunting; double probAnemia; double probDiarrhea; double mortConversionFactor; double baselineMortProb; // Outcome/Acumulator values LY = 0; LYDisc = 0; QALYs = 0; ageAtDeath = 0; everDiarrhea = 0; everAnemia = 0; everStunting = 0; Stunting_0 = 0; Anemia_0 = 0; Diarrhea_0 = 0; Stunting_5 = 0; Anemia_5 = 0; Diarrhea_5 = 0; isAlive_0 = 0; isAlive_5 = 0; // Initialize variables that have to be initialized at the beginning of life yearsSinceStart = (int)0; yearNow = SimModel.StartYear; firstSimCycle = true; alive = true; intAgeNow = ageNow + 0.5; // Check if person has been born yet (age less than zero). // How to get at simulation variables double discountRate = SimModel.discountRatePerYr; double deltaTime = SimModel.deltaTime; double NumSubjects = SimModel.Sim_NumSubjects; double StartYear = SimModel.StartYear; double maxAge = SimModel.maxAge; // How to get at policy variables double RR_mortality = myPolicy.RR_mortality; double RR_diarrhea = myPolicy.RR_diarrhea; double RR_stunting = myPolicy.RR_stunting; double RR_anemia = myPolicy.RR_anemia; this.country = myPolicy.country; while (this.alive) { alive = (ageNow < 100); // Stuff to do only after person is born... if (ageNow >= 0) { // Determine if person has STUNTING this.disease = diseaseType.STUNTING; probStunting = DiseasePrev.DiseasePrevTable[this]; this.haveStunting = MyRandom.RandomProvider.NextBernoulli(Math.Min(probStunting * myPolicy.RR_stunting, 1.0)); // Determine if person has ANEMIA this.disease = diseaseType.ANEMIA; probAnemia = DiseasePrev.DiseasePrevTable[this]; this.haveAnemia = MyRandom.RandomProvider.NextBernoulli(Math.Min(probAnemia * myPolicy.RR_anemia, 1.0)); // Determine if person has DIARRHEA this.disease = diseaseType.DIARRHEA; probDiarrhea = DiseasePrev.DiseasePrevTable[this]; this.haveDiarrhea = MyRandom.RandomProvider.NextBernoulli(Math.Min(probDiarrhea * myPolicy.RR_diarrhea, 1.0)); // Determine if person dies now according to disease probabilities + policy if (yearsSinceStart >= SimModel.maxSimDuration) { this.alive = false; } else { mortConversionFactor = DiseaseRR.diseaseRRTable[this]; baselineMortProb = MortRisk.mortRiskTable[this]; this.alive = !MyRandom.RandomProvider.NextBernoulli(baselineMortProb * mortConversionFactor * RR_mortality); } // DEBUG XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /* if (ageNow == 0) * { * int have_diarrhea_int = 0; * int have_anemia_int = 0; * int have_stunting_int = 0; * if (this.haveDiarrhea) have_diarrhea_int = 1; * if (this.haveAnemia) have_anemia_int = 2; * if (this.haveStunting) have_stunting_int = 4; * * int disComboNum = have_stunting_int + have_anemia_int + have_diarrhea_int; * SimModel.diseaseArray[disComboNum]++; * }*/ LY += SimModel.deltaTime; LYDisc += SimModel.deltaTime * (1 / Math.Pow(1 + SimModel.discountRatePerYr, yearsSinceStart)); } // If person ever acquires disease then set to 1 //To determine prev of disease at age 0 and age 5 if (haveStunting) { everStunting = 1; if (intAgeNow == 0) { Stunting_0 = 1; } if (intAgeNow == 5) { Stunting_5 = 1; } } if (haveAnemia) { everAnemia = 1; if (intAgeNow == 0) { Anemia_0 = 1; } if (intAgeNow == 5) { Anemia_5 = 1; } } if (haveDiarrhea) { everDiarrhea = 1; if (intAgeNow == 0) { Diarrhea_0 = 1; } if (intAgeNow == 5) { Diarrhea_5 = 1; } } if ((alive) && (intAgeNow >= 0 || intAgeNow < 1)) { isAlive_0 = 1; } if ((alive) && (intAgeNow >= 5 || intAgeNow < 6)) { isAlive_5 = 1; } // Increment years taking into account myDeltaTime and discountFactor // deltaTime = time duration between events // Don't have QALYs yet yearsSinceStart += SimModel.deltaTime; yearNow = SimModel.StartYear + yearsSinceStart; ageNow += SimModel.deltaTime; // Flag that the subject is on the first cycle through the model firstSimCycle = false; } }