Skip to content

Commit

Permalink
Merge pull request #216 from SwissTPH/logdens
Browse files Browse the repository at this point in the history
Guard against usage of log(dens) when specificity of diagnostic < 1
  • Loading branch information
dhardy authored Dec 11, 2018
2 parents 7739452 + d3faab7 commit bb5f5cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions model/WithinHost/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ bool Diagnostic::isPositive( double dens ) const {
}
}

bool Diagnostic::allowsFalsePositives() const{
if( (boost::math::isnan)(specificity) ) return dens_lim <= 0.0;
return specificity < 1.0;
}


// ——— diagnostics (static) ———

Expand Down
5 changes: 4 additions & 1 deletion model/WithinHost/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class Diagnostic {
return specificity != that.specificity ||
dens_lim != that.dens_lim;
}


/// True if false positives are possible
bool allowsFalsePositives() const;

private:
/** Construct from XML parameters. */
Diagnostic( const Parameters& parameters, const scnXml::Diagnostic& elt );
Expand Down
9 changes: 9 additions & 0 deletions model/mon/mon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "mon/management.h"
#define H_OM_mon_cpp
#include "mon/OutputMeasures.h"
#include "WithinHost/Diagnostic.h"
#include "WithinHost/Genotypes.h"
#include "Clinical/CaseManagementCommon.h"
#include "Host/Human.h"
Expand Down Expand Up @@ -451,6 +452,14 @@ void internal::initReporting( const scnXml::Scenario& scenario ){
} else TRACED_EXCEPTION_DEFAULT("invalid measure code");
}

if( om.m == MHF_LOG_DENSITY || om.m == MHF_LOG_DENSITY_GENOTYPE){
if( WithinHost::diagnostics::monitoringDiagnostic().allowsFalsePositives() ){
throw util::xml_scenario_error( (boost::format("measure %1% "
"may not be used when monitoring diagnostic sensitivity "
"< 1") %optElt.getName()).str() );
}
}

// Categorisation can be disabled but not enabled. We check each now.
if( optElt.getByAge().present() ){
if( om.byAge ){
Expand Down

0 comments on commit bb5f5cf

Please sign in to comment.