Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ set (Model_CPP
Host/WithinHost/Diagnostic.cpp
Host/WithinHost/Treatments.cpp

mon/mon.cpp
mon/misc.cpp
mon/Monitoring.cpp
mon/init.cpp
mon/Continuous.cpp

util/errors.cpp
Expand Down
12 changes: 6 additions & 6 deletions model/Clinical/CM5DayCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ using namespace ::OM::util;

// These parameters are set by setHealthSystem() and do not need checkpointing.
mon::Measure CM5DayCommon::measures[NumCaseTypes] = {
mon::MHT_TREATMENTS_1, // first line official
mon::MHT_TREATMENTS_2 // second line official
mon::measure("nTreatments1"), // first line official
mon::measure("nTreatments2") // second line official
};
double CM5DayCommon::accessUCAny[NumCaseTypes];
double CM5DayCommon::accessUCSelfTreat[NumCaseTypes];
Expand Down Expand Up @@ -135,21 +135,21 @@ void CM5DayCommon::severeMalaria (
// expanded, separating in-hospital and without (q[0]):
const double exHospitalDeath = p2 * (p3 * p4 + (1 - p3) * p5b);
const double exDeath = exHospitalDeath + (1 - p2) * p5a;
mon::reportStatMHF( mon::MHF_EXPECTED_HOSPITAL_DEATHS, human, exHospitalDeath );
mon::reportStatMHF( mon::MHF_EXPECTED_DIRECT_DEATHS, human, exDeath );
mon::recordStat(mon::measure("expectedHospitalDeaths"), human, exHospitalDeath);
mon::recordStat(mon::measure("expectedDirectDeaths"), human, exDeath);

// Expectation of sequelae is:
// double exSeq = (q[7] - q[6]) + (q[4] - q[3]) + (q[1] - q[0]);
// expanded and simplified, noting that p7 == p6 :
const double exSeq = (p2 * (p3 * (1 - p4) + (1 - p3) * (1 - p5b)) + (1 - p2) * (1 - p5a)) * p6;
mon::reportStatMHF( mon::MHF_EXPECTED_SEQUELAE, human, exSeq );
mon::recordStat(mon::measure("expectedSequelae"), human, exSeq);

double prandom = human.rng.uniform_01();

//NOTE: we do not model diagnostics in this case
if( prandom >= q[2] ){ // treated in hospital
m_tLastTreatment = sim::ts0();
mon::reportEventMHI( mon::MHT_TREATMENTS_3, human, 1 );
mon::recordEvent(mon::measure("nTreatments3"), human, 1);
Episode::State stateTreated = Episode::State (pgState | Episode::EVENT_IN_HOSPITAL);

if( prandom >= q[5] ){ // treatment successful at clearing parasites
Expand Down
2 changes: 1 addition & 1 deletion model/Clinical/CM5DayCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "Clinical/ClinicalModel.h"
#include "Host/Human.h"
#include "Host/WithinHost/WHInterface.h"
#include "mon/reporting.h"
#include "mon/Monitoring.h"

namespace OM {
namespace Clinical {
Expand Down
2 changes: 1 addition & 1 deletion model/Clinical/CMDecisionTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class CMDTReport : public CMDecisionTree {

virtual CMDTOut exec( CMHostData hostData ) const{
for( const size_t outId : outIds ){
mon::reportEventMHI_CMDT( mon::MCD_CMDT_REPORT, hostData.human, 1, outId);
mon::recordStat(mon::measure("nCMDTReport"), hostData.human, 1, 0, 0, 0, outId);
}
return CMDTOut(false);
}
Expand Down
6 changes: 3 additions & 3 deletions model/Clinical/ClinicalModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "Clinical/ImmediateOutcomes.h"
#include "Clinical/DecisionTree5Day.h"
#include "Host/NeonatalMortality.h"
#include "mon/reporting.h"
#include "mon/Monitoring.h"
#include "util/ModelOptions.h"
#include "util/CommandLine.h"
#include "util/errors.h"
Expand Down Expand Up @@ -143,14 +143,14 @@ void ClinicalModel::update (Human& human, double ageYears, bool newBorn) {

//indirect death: if this human's about to die, don't worry about further episodes:
if (doomed <= DOOMED_EXPIRED) { //clinical bout 6 intervals before
mon::reportEventMHI( mon::MHO_INDIRECT_DEATHS, human, 1 );
mon::recordEvent(mon::measure("nIndDeaths"), human, 1);
doomed = DOOMED_INDIRECT;
return;
}
if(newBorn /* i.e. first update since birth */) {
// Chance of neonatal mortality:
if (Host::NeonatalMortality::eventNeonatalMortality(human.rng)) {
mon::reportEventMHI( mon::MHO_INDIRECT_DEATHS, human, 1 );
mon::recordEvent(mon::measure("nIndDeaths"), human, 1);
doomed = DOOMED_NEONATAL;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions model/Clinical/DecisionTree5Day.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ void DecisionTree5Day::uncomplicatedEvent ( Human& human, Episode::State pgState

if( output.treated ){ // if any treatment or intervention deployed
m_tLastTreatment = sim::ts0();
mon::reportEventMHI( measures[regimen], human, 1 );
mon::recordEvent(measures[regimen], human, 1);
}
if( output.screened ){
mon::reportEventMHI( mon::MHT_TREAT_DIAGNOSTICS, human, 1 );
mon::recordEvent(mon::measure("nTreatDiagnostics"), human, 1);
}

human.withinHostModel->optionalPqTreatment(human);
Expand Down
36 changes: 18 additions & 18 deletions model/Clinical/Episode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,55 +71,55 @@ void Episode::report () {
if (state & Episode::MALARIA) {
// Malarial fevers: report bout
if (state & Episode::COMPLICATED) {
mon::reportMSACI( mon::MHE_SEVERE_EPISODES, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nSevere"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
if (state & Episode::SEVERE) {
mon::reportMSACI( mon::MHE_SEVERE_EPISODES_WITHOUT_COMORBIDITIES, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nSevereWithoutComorbidities"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
} else { // UC or UC2
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nUncomp"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
if(infectionType == WithinHost::InfectionOrigin::Indigenous)
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_INDIGENOUS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nUncomp_Indigenous"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
else if(infectionType == WithinHost::InfectionOrigin::Introduced)
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_INTRODUCED, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nUncomp_Introduced"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
else
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_IMPORTED, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nUncomp_Imported"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}

// Report outcomes of malarial fevers
if (state & Episode::EVENT_IN_HOSPITAL) {
if (state & Episode::DIRECT_DEATH) {
mon::reportMSACI( mon::MHO_DIRECT_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::reportMSACI( mon::MHO_HOSPITAL_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nDirDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
mon::record(mon::measure("nHospitalDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
if (state & Episode::EVENT_FIRST_DAY){
mon::reportMSACI( mon::MHO_FIRST_DAY_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::reportMSACI( mon::MHO_HOSPITAL_FIRST_DAY_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("Clinical_FirstDayDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
mon::record(mon::measure("Clinical_HospitalFirstDayDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
}
else if (state & Episode::SEQUELAE) {
mon::reportMSACI( mon::MHO_SEQUELAE, surveyPeriod, ageGroup, cohortSet, 1 );
mon::reportMSACI( mon::MHO_HOSPITAL_SEQUELAE, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nSeq"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
mon::record(mon::measure("nHospitalSeqs"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
else if (state & Episode::RECOVERY){
mon::reportMSACI( mon::MHO_HOSPITAL_RECOVERIES, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nHospitalRecovs"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
} else {
if (state & Episode::DIRECT_DEATH) {
mon::reportMSACI( mon::MHO_DIRECT_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nDirDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
if (state & Episode::EVENT_FIRST_DAY){
mon::reportMSACI( mon::MHO_FIRST_DAY_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("Clinical_FirstDayDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
}
else if (state & Episode::SEQUELAE){
mon::reportMSACI( mon::MHO_SEQUELAE, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nSeq"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
// Don't care about out-of-hospital recoveries
}
} else if (state & Episode::SICK) {
// Report non-malarial fever and outcomes
mon::reportMSACI( mon::MHE_NON_MALARIA_FEVERS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nNMFever"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);

if (state & Episode::DIRECT_DEATH) {
mon::reportMSACI( mon::MHO_NMF_DEATHS, surveyPeriod, ageGroup, cohortSet, 1 );
mon::record(mon::measure("nNmfDeaths"), surveyPeriod, ageGroup, cohortSet, 0, 0, 0, 1);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions model/Clinical/Episode.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include "Global.h"
#include "Host/WithinHost/Pathogenesis/State.h"
#include "Host/WithinHost/Infection/Infection.h"
#include "mon/AgeGroup.h"
#include "mon/info.h"
#include "mon/Monitoring.h"
#include "util/ModelOptions.h"
#include <ostream>

Expand Down Expand Up @@ -84,7 +83,7 @@ class Episode{
Episode() :
time(sim::never()),
surveyPeriod(mon::NOT_USED),
ageGroup(),
ageGroup(0),
cohortSet(0),
state(NONE)
{
Expand Down Expand Up @@ -112,7 +111,7 @@ class Episode{
/// Survey during which the event occured
size_t surveyPeriod;
/// Age group of the individual when the episode's first bout occurred
mon::AgeGroup ageGroup;
size_t ageGroup;
/// Cohort membership
uint32_t cohortSet;
/// Descriptor of state, containing reporting info. Not all information will
Expand Down
20 changes: 10 additions & 10 deletions model/Clinical/EventScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Clinical/EventScheduler.h"
#include "util/random.h"
#include "Host/WithinHost/WHInterface.h"
#include "mon/reporting.h"
#include "mon/Monitoring.h"
#include "util/ModelOptions.h"
#include "util/errors.h"
#include "util/StreamValidator.h"
Expand Down Expand Up @@ -174,7 +174,7 @@ void ClinicalEventScheduler::doClinicalUpdate (Human& human, double ageYears, Wi
} else {
if ( pgState & Episode::COMPLICATED ) {
const double pSequelae = pSequelaeInpatient.eval( ageYears );
mon::reportStatMHF( mon::MHF_EXPECTED_SEQUELAE, human, pSequelae );
mon::recordStat(mon::measure("expectedSequelae"), human, pSequelae);
if( human.rng.uniform_01() < pSequelae ){
pgState = Episode::State (pgState | Episode::SEQUELAE);
}else{
Expand Down Expand Up @@ -253,17 +253,17 @@ void ClinicalEventScheduler::doClinicalUpdate (Human& human, double ageYears, Wi
if( auxOut.treated ){ // I.E. some treatment was given
timeLastTreatment = sim::ts0();
if( pgState & Episode::COMPLICATED ){
mon::reportEventMHI( mon::MHT_TREATMENTS_3, human, 1 );
mon::recordEvent(mon::measure("nTreatments3"), human, 1);
}else{
if( pgState & Episode::SECOND_CASE ){
mon::reportEventMHI( mon::MHT_TREATMENTS_2, human, 1 );
mon::recordEvent(mon::measure("nTreatments2"), human, 1);
}else{
mon::reportEventMHI( mon::MHT_TREATMENTS_1, human, 1 );
mon::recordEvent(mon::measure("nTreatments1"), human, 1);
}
}
}
if( auxOut.screened ){
mon::reportEventMHI( mon::MHT_TREAT_DIAGNOSTICS, human, 1 );
mon::recordEvent(mon::measure("nTreatDiagnostics"), human, 1);
}

if ( true /*FIXME auxOut.hospitalisation != CMAuxOutput::NONE*/ ) { // in hospital
Expand All @@ -283,9 +283,9 @@ void ClinicalEventScheduler::doClinicalUpdate (Human& human, double ageYears, Wi
// community fatality rate when not in hospital or delayed hospital entry
if( !inHospital )
pDeath = getCommunityCFR( pDeath );
mon::reportStatMHF( mon::MHF_EXPECTED_DIRECT_DEATHS, human, pDeath );
mon::recordStat(mon::measure("expectedDirectDeaths"), human, pDeath);
if( inHospital )
mon::reportStatMHF( mon::MHF_EXPECTED_HOSPITAL_DEATHS, human, pDeath );
mon::recordStat(mon::measure("expectedHospitalDeaths"), human, pDeath);
if (human.rng.uniform_01() < pDeath) {
pgState = Episode::State (pgState | Episode::DIRECT_DEATH | Episode::EVENT_FIRST_DAY);
// Human is killed at end of time at risk
Expand Down Expand Up @@ -370,9 +370,9 @@ void ClinicalEventScheduler::doClinicalUpdate (Human& human, double ageYears, Wi
// community fatality rate when not in hospital
if( !(pgState & Episode::EVENT_IN_HOSPITAL) )
pDeath = getCommunityCFR( pDeath );
mon::reportStatMHF( mon::MHF_EXPECTED_DIRECT_DEATHS, human, pDeath );
mon::recordStat(mon::measure("expectedDirectDeaths"), human, pDeath);
if( pgState & Episode::EVENT_IN_HOSPITAL )
mon::reportStatMHF( mon::MHF_EXPECTED_HOSPITAL_DEATHS, human, pDeath );
mon::recordStat(mon::measure("expectedHospitalDeaths"), human, pDeath);
if (human.rng.uniform_01() < pDeath) {
pgState = Episode::State (pgState | Episode::DIRECT_DEATH);
// Human is killed at end of time at risk
Expand Down
4 changes: 2 additions & 2 deletions model/Clinical/ImmediateOutcomes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ void ImmediateOutcomes::uncomplicatedEvent (
// UC2: official care only

if( useDiagnosticUC ){
mon::reportEventMHI( mon::MHT_TREAT_DIAGNOSTICS, human, 1 );
mon::recordEvent(mon::measure("nTreatDiagnostics"), human, 1);
auto diag = WithinHost::diagnostics::monitoringDiagnostic();
if( !human.withinHostModel->diagnosticResult(human.rng, diag) )
return; // negative outcome: no treatment
}

m_tLastTreatment = sim::ts0();
mon::reportEventMHI( measures[regimen], human, 1 );
mon::recordEvent(measures[regimen], human, 1);

double p = ( x < accessUCSelfTreat[regimen] * m_treatmentSeekingFactor ) ?
cureRateUCSelfTreat[regimen] : cureRateUCOfficial[regimen];
Expand Down
12 changes: 6 additions & 6 deletions model/Host/Human.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "util/StreamValidator.h"
#include "Population.h"
#include "interventions/InterventionManager.h"
#include "mon/reporting.h"
#include "mon/Monitoring.h"
#include "schema/scenario.h"

namespace OM { namespace Host {
Expand Down Expand Up @@ -147,7 +147,7 @@ void Human::removeFirstEvent(interventions::SubPopRemove::RemoveAtCode code )
clinicalModel->flushReports(); // reset HS memory

// report removal due to first infection/bout/treatment
mon::reportEventMHI( mon::MHR_SUB_POP_REM_FIRST_EVENT, *this, 1 );
mon::recordEvent(mon::measure("nSubPopRemovalFirstEvent"), *this, 1);
}
cohortSet = mon::updateCohortSet( cohortSet, expIt->first, false );
// remove (affects reporting, restrictToSubPop and cumulative deployment):
Expand All @@ -163,7 +163,7 @@ void Human::updateCohortSet()
if( !(expIt->second >= sim::ts0()) ){ // membership expired
// don't flush reports
// report removal due to expiry
mon::reportEventMHI( mon::MHR_SUB_POP_REM_TOO_OLD, *this, 1 );
mon::recordEvent(mon::measure("nSubPopRemovalTooOld"), *this, 1);
cohortSet = mon::updateCohortSet( cohortSet, expIt->first, false );
// erase element, but continue iteration
expIt = subPopExp.erase( expIt );
Expand Down Expand Up @@ -211,8 +211,8 @@ void summarize(Human &human, bool surveyOnlyNewEp) {
return;
}

mon::reportStatMHI( mon::MHR_HOSTS, human, 1 );
mon::reportStatMHF( mon::MHF_AGE, human, sim::inYears(human.age(sim::now())) );
mon::recordStat(mon::measure("nHost"), human, 1);
mon::recordStat(mon::measure("sumAge"), human, sim::inYears(human.age(sim::now())) );
bool patent = human.withinHostModel->summarize (human);
human.infIncidence->summarize (human);

Expand All @@ -234,7 +234,7 @@ void update(Human &human, Transmission::TransmissionModel& transmission)
util::streamValidate( age0 );

// monitoringAgeGroup is the group for the start of the time step.
human.monitoringAgeGroup.update( age0 );
mon::updateAgeGroup(human.monitoringAgeGroup, age0);

human.updateCohortSet();

Expand Down
3 changes: 1 addition & 2 deletions model/Host/Human.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "Global.h"
#include "Transmission/PerHost.h"
#include "InfectionIncidenceModel.h"
#include "mon/AgeGroup.h"
#include "interventions/HumanComponents.h"
#include "util/checkpoint_containers.h"
#include <map>
Expand Down Expand Up @@ -118,7 +117,7 @@ class Human {
interventions::PerHumanVaccine vaccine;

/** Made persistant to save a lookup each time step (significant performance improvement) */
mon::AgeGroup monitoringAgeGroup;
size_t monitoringAgeGroup = 0;

/** The next continuous distribution in the series */
uint32_t nextCtsDist = 0;
Expand Down
4 changes: 2 additions & 2 deletions model/Host/ImportedInfections.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ namespace Host {
for(Human& human : population){
if(human.rng.bernoulli( rateNow )){
human.withinHostModel->importInfection(human.rng);
mon::reportEventMHI( mon::MHR_NEW_INFECTIONS, human, 1);
mon::reportEventMHI( mon::MHR_NEW_INFECTIONS_IMPORTED, human, 1);
mon::recordEvent(mon::measure("nNewInfections"), human, 1);
mon::recordEvent(mon::measure("nNewInfections_Imported"), human, 1);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions model/Host/InfectionIncidenceModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ double LogNormalMAII::getAvailabilityFactor(LocalRng& rng, double baseAvailabili
}

void InfectionIncidenceModel::summarize (const Host::Human& human) {
mon::reportStatMHF( mon::MHF_EXPECTED_INFECTED, human, m_pInfected );
mon::recordStat(mon::measure("nExpectd"), human, m_pInfected);
}


Expand Down Expand Up @@ -265,9 +265,9 @@ int InfectionIncidenceModel::numNewInfections (Human& human, double expectedNumI

void InfectionIncidenceModel::reportNumNewInfections(Human& human, int newNumInfections_i, int newNumInfections_l)
{
mon::reportEventMHI( mon::MHR_NEW_INFECTIONS, human, newNumInfections_i+newNumInfections_l);
mon::reportEventMHI( mon::MHR_NEW_INFECTIONS_INTRODUCED, human, newNumInfections_i);
mon::reportEventMHI( mon::MHR_NEW_INFECTIONS_INDIGENOUS, human, newNumInfections_l);
mon::recordEvent(mon::measure("nNewInfections"), human, newNumInfections_i+newNumInfections_l);
mon::recordEvent(mon::measure("nNewInfections_Introduced"), human, newNumInfections_i);
mon::recordEvent(mon::measure("nNewInfections_Indigenous"), human, newNumInfections_l);
ctsNewInfections += newNumInfections_i+newNumInfections_l;
}

Expand Down
Loading
Loading