void IndividualHumanMalaria::setupMaternalAntibodies(IIndividualHumanContext* mother, INodeContext* node) { if ( mother ) { IMalariaHumanContext* malaria_mother; if( s_OK != mother->QueryInterface(GET_IID(IMalariaHumanContext), (void**)&malaria_mother) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "mother", "IMalariaHumanContext", "IIndividualHumanContext" ); } // If we are using individual pregnancies, initialize maternal antibodies dependent on mother's antibody history malaria_susceptibility->init_maternal_antibodies(malaria_mother->GetMalariaSusceptibilityContext()->get_fraction_of_variants_with_antibodies(MalariaAntibodyType::PfEMP1_major)); } else { INodeMalaria* malaria_node; if( s_OK != node->QueryInterface(GET_IID(INodeMalaria), (void**)&malaria_node) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "node", "INodeMalaria", "INodeContext" ); } // If we are doing births at population level, use the average antibody history of all possible mothers malaria_susceptibility->init_maternal_antibodies(malaria_node->GetMaternalAntibodyFraction()); } }
bool MasterInterventionsContainer::GiveIntervention( IDistributableIntervention * pIV ) { IHIVDrugEffects* phivde; if ( pIV->QueryInterface(GET_IID(IHIVIntervention), (void**)&phivde ) == s_OK) { for (auto container : InterventionsContainerList) { ISupports* tempInterface; if (container->QueryInterface(GET_IID(IHIVInterventionsContainer), (void**)&tempInterface ) == s_OK) { return container->GiveIntervention(pIV); } } } else //default is to go to TBInterventionConsumer { for (auto container : InterventionsContainerList) { ISupports* tempInterface; if (container->QueryInterface(GET_IID(ITBInterventionsContainer), (void**)&tempInterface ) == s_OK) { return container->GiveIntervention(pIV); } } } return false; }
void NodeLevelHealthTriggeredIVScaleUpSwitch::onDisqualifiedByCoverage( IIndividualHumanEventContext *pIndiv ) { //if qualify by everything except demographic coverage, give the not_covered_individualintervention_config // this intervention is the one phased out as the actual_individualintervention_config is phased in // if the not_covered_individualintervention_config is NULL, then there is no intervention to phase out LOG_DEBUG("The person qualified by everything except demographic coverage, give the not_covered_individualintervention_config \n"); // Query for campaign cost observer interface from INodeEventContext *parent ICampaignCostObserver *iCCO; if (s_OK != parent->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&iCCO)) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent", "ICampaignCostObserver", "INodeEventContext" ); } // Important: Use the instance method to obtain the intervention factory obj instead of static method to cross the DLL boundary //const IInterventionFactory* ifobj = dynamic_cast<NodeEventContextHost *>(parent)->GetInterventionFactoryObj(); IGlobalContext *pGC = nullptr; const IInterventionFactory* ifobj = nullptr; if (s_OK == parent->QueryInterface(GET_IID(IGlobalContext), (void**)&pGC)) { ifobj = pGC->GetInterventionFactory(); } if (!ifobj) { throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, "The pointer to IInterventionFactory object is not valid (could be DLL specific)" ); } const json::Array & interventions_array = json::QuickInterpreter(not_covered_intervention_configs._json).As<json::Array>(); LOG_DEBUG_F("not_covered_intervention_configs array size = %d\n", interventions_array.Size()); if (interventions_array.Size() == 0 ) { LOG_DEBUG("nothing to phase out \n"); } else { for( int idx=0; idx<interventions_array.Size(); idx++ ) { const json::Object& notcoveredIntervention = json_cast<const json::Object&>(interventions_array[idx]); Configuration * tmpConfig = Configuration::CopyFromElement( notcoveredIntervention, "campaign" ); assert( tmpConfig ); LOG_DEBUG_F("NodeHTIScaleUpSwitch will distribute notcoveredintervention #%d\n", idx); IDistributableIntervention *di = const_cast<IInterventionFactory*>(ifobj)->CreateIntervention(tmpConfig); delete tmpConfig; tmpConfig = nullptr; if( di ) { di->Distribute( pIndiv->GetInterventionsContext(), iCCO ); LOG_DEBUG("A Node level health-triggered intervention was successfully distributed, gave the not_covered_intervention_configs\n"); // It's not at all clear to me that we would incur cost at this point, but we could. //iCCO->notifyCampaignExpenseIncurred( interventionCost, pIndiv ); } } } }
bool BaseIntervention::Distribute( IIndividualHumanInterventionsContext *context, // interventions container usually ICampaignCostObserver * const pICCO ) { if( dont_allow_duplicates && context->ContainsExisting( typeid(*this).name() ) ) { return false ; } bool wasDistributed=false; IInterventionConsumer * ic; if (s_OK == (context->QueryInterface(GET_IID(IInterventionConsumer), (void**)&ic) ) ) { assert(ic); if( ic->GiveIntervention(this) ) { // Need to get Individual pointer from interventions container pointer. Try parent. IIndividualHumanEventContext * pIndiv = (context->GetParent())->GetEventContext(); if( pICCO ) { pICCO->notifyCampaignExpenseIncurred( cost_per_unit, pIndiv ); } wasDistributed = true; } } else { std::ostringstream oss; oss << "Unable to distribute intervention because IIndividualHumanInterventionsContext doesn't support IInterventionConsumer." << std::endl; throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, oss.str().c_str() ); } return wasDistributed; }
IIndividualHuman* NodeSTI::processImmigratingIndividual( IIndividualHuman* movedind ) { // ------------------------------------------------------------------------------- // --- SetContextTo() is called in Node::processImmigratingIndividual() but // --- we need need to set context before onImmigrating(). onImmigrating() needs // --- the RelationshipManager which is part of the node. // ------------------------------------------------------------------------------- movedind->SetContextTo(getContextPointer()); IIndividualHumanSTI* sti_individual = nullptr; if (movedind->QueryInterface(GET_IID(IIndividualHumanSTI), (void**)&sti_individual) != s_OK) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "retVal", "IIndividualSTI", "IndividualHuman" ); } sti_individual->onImmigrating(); auto retVal = Node::processImmigratingIndividual( movedind ); event_context_host->TriggerNodeEventObservers( retVal->GetEventContext(), IndividualEventTriggerType::STIPostImmigrating ); return retVal; }
// todo: lift to HIVIntervention or helper function (repeated in HIVDelayedIntervention) bool HIVSimpleDiagnostic::UpdateCascade() { if( AbortDueToCurrentCascadeState() ) { return false ; } // is this the first time through? if so, update the cascade state. if (firstUpdate) { IHIVCascadeOfCare *ihcc = nullptr; if ( s_OK != parent->GetInterventionsContext()->QueryInterface(GET_IID(IHIVCascadeOfCare), (void **)&ihcc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetInterventionsContext()", "IHIVCascadeOfCare", "IIndividualHumanInterventionsContext" ); } LOG_DEBUG_F( "Setting Cascade State to %s for individual %d.\n", cascadeState.c_str(), parent->GetSuid().data ); ihcc->setCascadeState(cascadeState); original_days_to_diagnosis = days_to_diagnosis; } return true ; }
bool HIVSimpleDiagnostic::AbortDueToCurrentCascadeState() { IHIVCascadeOfCare *ihcc = nullptr; if ( s_OK != parent->GetInterventionsContext()->QueryInterface(GET_IID(IHIVCascadeOfCare), (void **)&ihcc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetInterventionsContext()", "IHIVCascadeOfCare", "IIndividualHumanInterventionsContext" ); } std::string currentState = ihcc->getCascadeState(); if ( abortStates.find(currentState) != abortStates.end() ) { // Duplicated from SimpleDiagnostic::positiveTestDistribute INodeTriggeredInterventionConsumer* broadcaster = nullptr; if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster)) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext" ); } broadcaster->TriggerNodeEventObservers( parent->GetEventContext(), IndividualEventTriggerType::CascadeStateAborted ); LOG_DEBUG_F("The current cascade state \"%s\" is one of the Abort_States. Expiring the diagnostic for individual %d.\n", currentState.c_str(), parent->GetSuid().data ); expired = true; return true; } return false; }
bool CommunityHealthWorkerEventCoordinator::Distribute( IIndividualHumanEventContext* pIHEC ) { release_assert( m_pInterventionIndividual ); IDistributableIntervention *di = m_pInterventionIndividual->Clone(); release_assert(di); ICampaignCostObserver* p_icco = nullptr; if (s_OK != pIHEC->GetNodeEventContext()->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&p_icco)) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pIHEC->GetNodeEventContext()", "ICampaignCostObserver", "INodeEventContext" ); } di->AddRef(); bool distributed = di->Distribute( pIHEC->GetInterventionsContext(), p_icco ); if( distributed ) { LOG_DEBUG_F("Distributed '%s' intervention to individual %d\n", m_InterventionName.c_str(), pIHEC->GetSuid().data ); } di->Release(); return distributed; }
void MultiEffectBoosterVaccine::ApplyPrimingAndBoostingEffects(IIndividualHumanInterventionsContext *context) { IDrugVaccineInterventionEffects* idvie = nullptr; if (s_OK != context->QueryInterface(GET_IID(IDrugVaccineInterventionEffects), (void**)&idvie) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "IDrugVaccineInterventionEffects", "IIndividualHumanInterventionsContext" ); } ISusceptibilityContext* isc = context->GetParent()->GetSusceptibilityContext(); float acquisition_immunity = idvie->GetInterventionReducedAcquire()* isc->getModAcquire(); float transmission_immunity = idvie->GetInterventionReducedTransmit()* isc->getModTransmit(); float mortality_immunity = idvie->GetInterventionReducedMortality()*isc->getModMortality(); acquire_effect->SetInitial(prime_acquire); transmit_effect->SetInitial(prime_transmit); mortality_effect->SetInitial(prime_mortality); if (acquisition_immunity < (1.0f - boost_threshold_acquire) ) { acquire_effect->SetInitial(boost_acquire); } if (transmission_immunity < (1.0f - boost_threshold_transmit) ) { transmit_effect->SetInitial(boost_transmit); } if (mortality_immunity < (1.0f - boost_threshold_mortality) ) { mortality_effect->SetInitial(boost_mortality); } }
bool NodeLevelHealthTriggeredIV::Distribute( INodeEventContext *pNodeEventContext, IEventCoordinator2 *pEC ) { bool was_distributed = BaseNodeIntervention::Distribute(pNodeEventContext, pEC); if (was_distributed) { LOG_DEBUG_F("Distributed Nodelevel health-triggered intervention to NODE: %d\n", pNodeEventContext->GetId().data); // QI to register ourself as a NodeLevelHealthTriggeredIV observer INodeTriggeredInterventionConsumer * pNTIC = nullptr; if (s_OK != pNodeEventContext->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&pNTIC)) { throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "pNodeEventContext", "INodeTriggeredInterventionConsumer", "INodeEventContext"); } release_assert(pNTIC); for (auto &trigger : m_trigger_conditions) { pNTIC->RegisterNodeEventObserver((IIndividualEventObserver*)this, trigger); } } return was_distributed; }
void DiagnosticTreatNeg::onPatientDefault() { LOG_DEBUG_F( "Individual %d got the test but defaulted, receiving Defaulters intervention without waiting for days_to_diagnosis (actually means days_to_intervention) \n", parent->GetSuid().data ); // Important: Use the instance method to obtain the intervention factory obj instead of static method to cross the DLL boundary IGlobalContext *pGC = nullptr; const IInterventionFactory* ifobj = nullptr; if (s_OK == parent->QueryInterface(GET_IID(IGlobalContext), (void**)&pGC)) { ifobj = pGC->GetInterventionFactory(); } if (!ifobj) { throw NullPointerException( __FILE__, __LINE__, __FUNCTION__, "parent->GetInterventionFactoryObj()" ); } if( !defaulters_event.IsUninitialized() ) { if( defaulters_event != NO_TRIGGER_STR ) { INodeTriggeredInterventionConsumer* broadcaster = nullptr; if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster)) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext" ); } broadcaster->TriggerNodeEventObserversByString( parent->GetEventContext(), defaulters_event ); } } else if( defaulters_config._json.Type() != ElementType::NULL_ELEMENT ) { auto tmp_config = Configuration::CopyFromElement(defaulters_config._json); // Distribute the defaulters intervention, right away (do not use the days_to_diagnosis IDistributableIntervention *di = const_cast<IInterventionFactory*>(ifobj)->CreateIntervention( tmp_config ); delete tmp_config; tmp_config = nullptr; ICampaignCostObserver* pICCO; // Now make sure cost of the test-positive intervention is reported back to node if (s_OK == parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&pICCO) ) { di->Distribute( parent->GetInterventionsContext(), pICCO ); pICCO->notifyCampaignEventOccurred( (IBaseIntervention*)di, (IBaseIntervention*)this, parent ); } else { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "ICampaignCostObserver", "INodeEventContext" ); } } else { throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, "neither event or config defined" ); } }
bool DiagnosticTreatNeg::positiveTestResult() { LOG_DEBUG_F("Individual %d is taking the test \n", parent->GetSuid().data); //This test is the same as smear, but if you are smear neg you can get a different intervention // Apply diagnostic test with given specificity/sensitivity IIndividualHumanTB2* tb_ind = nullptr; if(parent->QueryInterface( GET_IID( IIndividualHumanTB2 ), (void**)&tb_ind ) != s_OK) { LOG_WARN("DiagnosticTreatNeg works with TB sims ONLY"); throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent", "IIndividualHumanTB2", "IIndividualHuman" ); } bool activeinf = tb_ind->HasActiveInfection() && !tb_ind->HasActivePresymptomaticInfection(); if (activeinf) { // True positive (sensitivity), or False positive (1-specificity) bool smearpos = tb_ind->IsSmearPositive(); bool positiveTest = applySensitivityAndSpecificity( smearpos ); LOG_DEBUG_F("Individual %d is active %d, smearpos %d, Test sensitivity is %f, result is %d \n", parent->GetSuid().data, activeinf, smearpos, (float) base_sensitivity, positiveTest); return positiveTest; } else { LOG_DEBUG("Got a negative result \n"); return false; } }
IIndividualHumanHIV* HIVRelationshipStartReporter::GetIndividualHumanHIV( IIndividualHumanSTI* pPartner ) { IIndividualHumanHIV* p_hiv_individual = nullptr; if( pPartner->QueryInterface(GET_IID(IIndividualHumanHIV), (void**)&p_hiv_individual) != s_OK ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pPartner", "IIndividualHumanHIV", "IIndividualHumanSTI*" ); } return p_hiv_individual ; }
IHIVMedicalHistory* HIVRelationshipStartReporter::GetMedicalHistory( IIndividualHumanHIV* pPartner ) { IHIVMedicalHistory * p_med_history = nullptr; if( pPartner->GetHIVInterventionsContainer()->QueryInterface(GET_IID(IHIVMedicalHistory), (void**)&p_med_history) != s_OK) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pPartner->GetHIVInterventionsContainer()", "IHIVMedicalHistory", "IHIVInterventionsContainer" ); } return p_med_history ; }
void NodeSTI::Update( float dt ) { // Update relationships (dissolution only, at this point) list<IIndividualHuman*> population; //not used by RelationshipManager relMan->Update( population, transmissionGroups, dt ); society->BeginUpdate(); for (auto& person : individualHumans) { IIndividualHumanSTI* sti_person = nullptr; if (person->QueryInterface(GET_IID(IIndividualHumanSTI), (void**)&sti_person) != s_OK) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "person", "IIndividualHumanSTI", "IIndividualHuman" ); } sti_person->UpdateEligibility(); // DJK: Could be slow to do this on every update. Could check for relationship status changes. <ERAD-1869> } if (pfa_burnin_duration > 0) { pfa_burnin_duration -= dt; society->UpdatePairFormationRates( GetTime(), dt ); } for (auto& person : individualHumans) { IIndividualHumanSTI* sti_person = nullptr; if (person->QueryInterface(GET_IID(IIndividualHumanSTI), (void**)&sti_person) != s_OK) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "person", "IIndividualHumanSTI", "IIndividualHuman" ); } sti_person->ConsiderRelationships(dt); } society->UpdatePairFormationAgents( GetTime(), dt ); { RouteToContagionDecayMap_t decayMap; decayMap[string("contact")] = 1.0f; transmissionGroups->Build( decayMap, 1, 1 ); } Node::Update( dt ); }
void DiagnosticTreatNeg::negativeTestDistribute() { LOG_DEBUG_F( "Individual %d tested 'negative', receiving negative intervention.\n", parent->GetSuid().data ); // Important: Use the instance method to obtain the intervention factory obj instead of static method to cross the DLL boundary IGlobalContext *pGC = nullptr; const IInterventionFactory* ifobj = nullptr; if (s_OK == parent->QueryInterface(GET_IID(IGlobalContext), (void**)&pGC)) { ifobj = pGC->GetInterventionFactory(); } if (!ifobj) { throw NullPointerException( __FILE__, __LINE__, __FUNCTION__, "parent->GetInterventionFactoryObj()" ); } if( use_event_or_config == EventOrConfig::Event ) { INodeTriggeredInterventionConsumer* broadcaster = nullptr; if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster)) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext" ); } broadcaster->TriggerNodeEventObservers( parent->GetEventContext(), negative_diagnosis_event ); } else if( negative_diagnosis_config._json.Type() != ElementType::NULL_ELEMENT ) { auto tmp_config = Configuration::CopyFromElement( negative_diagnosis_config._json, "campaign" ); // Distribute the test-negative intervention IDistributableIntervention *di = const_cast<IInterventionFactory*>(ifobj)->CreateIntervention( tmp_config ); delete tmp_config; tmp_config = nullptr; ICampaignCostObserver* pICCO; // Now make sure cost of the test-positive intervention is reported back to node if (s_OK == parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&pICCO) ) { di->Distribute( parent->GetInterventionsContext(), pICCO ); pICCO->notifyCampaignEventOccurred( (IBaseIntervention*)di, (IBaseIntervention*)this, parent ); } else { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "ICampaignCostObserver", "INodeEventContext" ); } } else { throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, "neither event or config defined" ); } expired = true; }
void AbstractBednet::SetContextTo( IIndividualHumanContext *context ) { BaseIntervention::SetContextTo( context ); if( s_OK != context->GetInterventionsContext()->QueryInterface( GET_IID( IBednetConsumer ), (void**)&m_pConsumer ) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "IBednetConsumer", "IIndividualHumanContext" ); } m_pEffectKilling->SetContextTo( context ); m_pEffectBlocking->SetContextTo( context ); }
void HIVInterventionsContainer::SetContextTo(IIndividualHumanContext* context) { STIInterventionsContainer::SetContextTo( context ); release_assert( parent ); if( s_OK != parent->QueryInterface(GET_IID(IIndividualHumanHIV), (void**) &hiv_parent) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent", "IIndividualHumanHIV", "IIndividualHumanContext" ); } }
void HIVInterventionsContainer::BroadcastNewHIVInfection() { //function called when we externally put in HIV infections through AcquireInfectionHIV //first get the pointer to the person, parent is the generic individual release_assert(parent); IIndividualHumanEventContext * HIVEventContext = NULL; if (s_OK != parent->QueryInterface(GET_IID(IIndividualHumanEventContext), (void**)&HIVEventContext)) { throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext"); } INodeTriggeredInterventionConsumer* broadcaster = nullptr; if (s_OK != HIVEventContext->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster)) { throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "HIVEventContext-->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext"); } broadcaster->TriggerNodeEventObservers(parent->GetEventContext(), EventTrigger::NewExternalHIVInfection); }
std::string HIVReportEventRecorder::GetOtherData( IIndividualHumanEventContext *context, const std::string& StateChange ) { IIndividualHumanHIV * iindividual_hiv = nullptr; if (s_OK != context->QueryInterface(GET_IID(IIndividualHumanHIV), (void**)&iindividual_hiv) ) { throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "context", "IIndividualHumanHIV", "IIndividualHumanEventContext"); } const char has_hiv = iindividual_hiv->HasHIV() ? 'Y' : 'N' ; const char on_ART = iindividual_hiv->GetHIVInterventionsContainer()->OnArtQuery() ? 'Y' : 'N' ; float cd4 = 1e6; float who_stage = -1.0f; if( iindividual_hiv->HasHIV() ) { cd4 = iindividual_hiv->GetHIVSusceptibility()->GetCD4count(); who_stage = iindividual_hiv->GetHIVInfection()->GetWHOStage(); } IHIVCascadeOfCare *ihcc = nullptr; if ( s_OK != context->GetInterventionsContext()->QueryInterface(GET_IID(IHIVCascadeOfCare), (void **)&ihcc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context->GetInterventionsContext()", "IHIVCascadeOfCare", "IIndividualHumanEventContext" ); } std::string cascade_state = ihcc->getCascadeState(); if( cascade_state.length() == 0 ) { cascade_state = "None"; } std::stringstream ss ; ss << "," << has_hiv << "," << on_ART << "," << cd4 << "," << who_stage << "," << cascade_state; return ss.str() ; }
void PropertyValueChanger::SetContextTo( IIndividualHumanContext *context ) { parent = context; if (s_OK != context->GetInterventionsContext()->QueryInterface(GET_IID(IPropertyValueChangerEffects), (void**)&ibc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "IPropertyValueChangerEffects", "IIndividualHumanContext" ); } }
void SimpleVaccine::SetContextTo( IIndividualHumanContext *context ) { parent = context; if (s_OK != parent->GetInterventionsContext()->QueryInterface(GET_IID(IVaccineConsumer), (void**)&ivc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context->GetInterventionsContext()", "IVaccineConsumer", "IIndividualHumanInterventionsContext" ); } LOG_DEBUG_F( "Vaccine configured with type %d and take %f for individual %d\n", vaccine_type, vaccine_take, parent->GetSuid().data ); } // needed for VaccineTake
void SimpleHousingModification::SetContextTo( IIndividualHumanContext *context ) { LOG_DEBUG("SimpleHousingModification::SetContextTo (probably deserializing)\n"); if (s_OK != context->GetInterventionsContext()->QueryInterface(GET_IID(IHousingModificationConsumer), (void**)&ihmc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "IHousingModificationConsumer", "IIndividualHumanContext" ); } }
void IndividualHumanMalaria::PropagateContextToDependents() { IndividualHumanVector::PropagateContextToDependents(); if( malaria_susceptibility == nullptr && susceptibility != nullptr) { if ( s_OK != susceptibility->QueryInterface(GET_IID(IMalariaSusceptibility), (void**)&malaria_susceptibility) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "susceptibility", "IMalariaSusceptibility", "Susceptibility" ); } } }
void StiRelationshipConsummatedReporter::onNewNode(Kernel::INodeContext* node) { INodeSTI* sti = nullptr; if (node->QueryInterface(GET_IID(INodeSTI), (void**)&sti) != s_OK) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "node", "INodeSTI*", "INodeContext*" ); } auto manager = sti->GetRelationshipManager(); manager->RegisterRelationshipConsummationObserver([&](IRelationship* relationship){ this->onCoitalAct(relationship); }); }
void IndividualHumanVector::UpdateInfectiousness(float dt) { infectiousness = 0; float tmp_infectiousness = 0; typedef std::map< StrainIdentity, float > strain_infectivity_map_t; typedef strain_infectivity_map_t::value_type strain_infectivity_t; strain_infectivity_map_t infectivity_by_strain; StrainIdentity tmp_strainIDs; // Loop once over all infections, caching strains and infectivity. // If total infectiousness exceeds unity, we will normalize all strains down accordingly. for (auto infection : infections) { release_assert( infection ); tmp_infectiousness = infection->GetInfectiousness(); infectiousness += tmp_infectiousness; if ( tmp_infectiousness > 0 ) { infection->GetInfectiousStrainID(&tmp_strainIDs); infectivity_by_strain[tmp_strainIDs] += tmp_infectiousness; } } // Effects of transmission-reducing immunity. N.B. interventions on vector success are not here, since they depend on vector-population-specific behavior release_assert( susceptibility ); release_assert( interventions ); float modtransmit = susceptibility->GetModTransmit() * interventions->GetInterventionReducedTransmit(); // Maximum individual infectiousness is set here, capping the sum of unmodified infectivity at prob=1 float truncate_infectious_mod = (infectiousness > 1 ) ? 1.0f/infectiousness : 1.0f; infectiousness *= truncate_infectious_mod * modtransmit; // Host weight is the product of MC weighting and relative biting float host_vector_weight = float(GetMonteCarloWeight() * GetRelativeBitingRate()); // Effects from vector intervention container IVectorInterventionsEffects* ivie = nullptr; if ( s_OK != interventions->QueryInterface(GET_IID(IVectorInterventionsEffects), (void**)&ivie) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "interventions", "IVectorInterventionsEffects", "IndividualHumanVector" ); } // Loop again over infection strains, depositing (downscaled) infectivity modified by vector intervention effects etc. (indoor + outdoor) for (auto& infectivity : infectivity_by_strain) { const StrainIdentity *id = &(infectivity.first); parent->DepositFromIndividual( const_cast<StrainIdentity*>(id), host_vector_weight * infectivity.second * truncate_infectious_mod * modtransmit * ivie->GetblockIndoorVectorTransmit(), &NodeVector::human_to_vector_indoor ); parent->DepositFromIndividual( const_cast<StrainIdentity*>(id), host_vector_weight * infectivity.second * truncate_infectious_mod * modtransmit * ivie->GetblockOutdoorVectorTransmit(), &NodeVector::human_to_vector_outdoor ); } }
bool PropertyValueChanger::Distribute( IIndividualHumanInterventionsContext *context, ICampaignCostObserver * const pCCO ) { if (s_OK != context->QueryInterface(GET_IID(IPropertyValueChangerEffects), (void**)&ibc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "IPropertyValueChangerEffects", "IIndividualHumanInterventionsContext" ); } return BaseIntervention::Distribute( context, pCCO ); }
INodeTriggeredInterventionConsumer* CommunityHealthWorkerEventCoordinator::GetNodeTriggeredConsumer( INodeEventContext* pNEC ) { release_assert( pNEC ); INodeTriggeredInterventionConsumer* pNTIC = nullptr; if( pNEC->QueryInterface( GET_IID(INodeTriggeredInterventionConsumer), (void**)&pNTIC ) != s_OK ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pNEC", "INodeTriggeredInterventionConsumer", "INodeEventContext" ); } release_assert( pNTIC ); return pNTIC ; }
bool IndividualHumanTB::IsTreatmentNaive() const { // Query for intervention container, in future cache TB Intervention container when we create it IIndividualHumanInterventionsContext *context = GetInterventionsContext(); ITBInterventionsContainer * itbivc = nullptr; if (s_OK != context->QueryInterface(GET_IID(ITBInterventionsContainer), (void**)&itbivc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "ITBInterventionsContainer", "IIndividualHumanInterventionsContext" ); } return itbivc->GetTxNaiveStatus(); }
bool IndividualHumanTB::HasEverRelapsedAfterTreatment() const { // Query for intervention container IIndividualHumanInterventionsContext *context = GetInterventionsContext(); ITBInterventionsContainer * itbivc = nullptr; if (s_OK != context->QueryInterface(GET_IID(ITBInterventionsContainer), (void**)&itbivc) ) { throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "ITBInterventionsContainer", "IIndividualHumanInterventionsContext" ); } return itbivc->GetTxEverRelapsedStatus(); }