logo


Model Inputs \(\rightarrow\) GMatH Pseudocode

//Simulate each country - all parameters are country-specific

//Initialize population trends for each country
Initialize population projections //(see Appendix A.1.1.2: Population Projections)
Initialize education projections //(see Appendix A.1.1.5 Education Projections)

//Initialize individual-level characteristics at model startup
For each woman:
    Assign subgroup (urban/rural location + education level) | Birth year 
    Assign age of sexual debut | Subgroup //(see Appendix A.1.3.1 Age of Sexual Debut)
    Assign age of menopause //(see Appendix A.1.2.9 Menopause)
    Assign hemoglobin latent variable //~Norm(0,1) (see Appendix A.1.2.10 Anemia)
    Assign desired number of children | Subgroup, Year /*(see Appendix A.1.3.3 
                                                       Desired Number of Children)*/
    Initialize current living children | Subgroup, Age, Year /*(see Appendix A.1.3.2 
                                                             Number of Living Children)*/
    Initialize history of previous miscarriages | Current living children 
    //~Pois(0.2*numLivingKids) assume 20% risk of historic miscarriage

//Simulate population going forward
for(t=0; t<numCycles; t++){ //monthly cycle length
    Add incoming females to population //(see Appendix A.1.1.2: Population Projections)
    
    for(w=0; w<numWomen; w++){ //For each woman currently in the population
        Risk background mortality | Age, Year (remove risk of maternal deaths) 
        //(see Appendices A.1.1.3: Lifetables, A.1.5.7 Indirect Maternal Deaths)
        Risk indirect maternal mortality (ages 15-49) | Year 
          (remove accidental/incidental deaths)
        /*(see Appendices A.1.5.7 Indirect Maternal Deaths,
          A.1.1.4 Proportion of Deaths due to Injury)*/
        Risk incidence of late maternal event (if >2 months and <=1 year of last delivery) 
        //(see Appendix A.1.5.6 Late Maternal Deaths)
        if(lateEvent==true){ //has late maternal event
            simulateReferral() //Simulate facility referral, see function below
            Risk late maternal death | Site, Quality, Year /*(see Appendices A.1.5.6 
                                                              Late Maternal Deaths,
                                                              A.1.4.6 Quality of Care)*/
        }
        If woman died, simulate if reported | Site, Year /*(see Appendix A.1.4.7 
                                                        Maternal Death Underreporting)*/
        
        if alive{
            Risk child mortality for each living child | Age, Sex, Year
            //(see Appendix A.1.1.3 Lifetables)
            
            //check for sexual debut (see Appendix 1.3.1 Age of Sexual Debut)
            if(sexuallyActive==false & curAge>=ageAtSexualDebut){ 
                sexuallyActive=true
                assignContraception() /*Assign contraception status + method,
                                        see function below*/
            }
            
            //check for menopause (see Appendix A.1.2.9 Menopause)
            if(menopause==false & curAge>=ageAtMenopause){
                menopause=true
            }
        
            //If fecund (sexually active, not currently pregnant, pre-menopausal)
            if(pregnant==false & sexuallyActive==true & menopause==false){
                
                //risk pregnancy
                updateContraception() //Update contraception status, see function below
                Update breastfeeding (LAM) status | Time since delivery, # living infants 
                //(see Appendix A.1.3.10 Breastfeeding)
                Risk conception | Age, LAM, Contraception method(subgroup) 
                /*(see Appendices A.1.2.1 Natural Fecundity/Fertility,
                  A.1.2.8 Lactational Amenorrhea (LAM), 
                  A.1.3.6 Contraception Failure Rates)*/
                if(conception==true){ //becomes pregnant
                    Assign ANC visits | Subgroup, Year /*(see Appendix A.1.4.1 
                                                          Antenatal Care)*/
                    Assign anemia (Hb) | Subgroup, Year, ANC /*(see Appendix A.1.2.10 
                                                                Anemia*/
                    Simulate number of fetuses | Maternal age /*(see Appendix A.1.2.3 
                                                                 Twinning Rates)*/
                    Assign sex for each fetus /(see Appendix A.1.2.2 Sex Ratio - Primary)
                    //Pre-draw pregnancy outcome and time to event 
                    Simulate risk of elective abortion if unwanted pregnancy | 
                      Subgroup, Year, Fetus sex, Secondary sex ratio(Subgroup,Year) 
                      //(see Appendices A.1.3.8 Abortion, A.1.3.9 Sex Ratio - Secondary)
                    /*risk ectopic pregnancy, miscarriage, stillbirth 
                      (estimates are conditional on no induced abortion)*/
                    if(abortion==false){ 
                        /*Note: Ectopic pregnancy, miscarriage, and stillbirth are 
                      modelled as mutually exclusive events*/
                        Simulate risk of ectopic pregnancy | 
                        Maternal age, History of ectopic pregnancy /*(see Appendix 
                                                             A.1.2.5 Ectopic Pregnancy)*/
                        Simulate risk of miscarriage | 
                        Maternal age, History of miscarriage /*(see Appendix A.1.2.4 
                                                                Miscarriage)*/
                        Simulate risk of antepartum stillbirth | Maternal age, Fetus sex 
                        //(see Appendix A.1.2.6 Stillbirths)
                        Draw time to event //(see Appendix A.1.2.7 Month of Delivery)
                    }
                }
                
                //if currently pregnant and time for pregnancy outcome
                if(pregnant==true & t==eventTime){
                    //pregnancy loss
                    if(outcome=='abortion'){ /*elective abortion (see Appendix A.1.3.8 
                                                                  Abortion)*/
                        Simulate abortion type ('safe'/'unsafe') | Subgroup, Year
                        Risk maternal death | Abortion type, Anemia
                        If woman survives, risk infertility | Abortion type
                    }
                    else if(outcome=='miscarriage'){ /*miscarriage (see Appendix A.1.2.4 
                                                                    Miscarriage)*/
                        Update miscarriage history
                    }
                    else if(outcome=='ectopic'){ /*ectopic pregnancy (see Appendix A.1.2.5 
                                                                      Ectopic Pregnancy)*/
                        Risk rupture
                        if(rupture){
                            simulateReferral() /*Simulate facility referral, 
                                                see function below*/
                            Risk maternal death | 
                            Site, Treatment Availability(Year)+Efficacy, Quality(Year) 
                            /*(see Appendices A.1.6.5 Management of Ectopic Pregnancy,
                               A.1.4.6 Quality of Care)*/
                        }
                    }
                    
                    //pregnancy is carried to delivery
                    if(outcome=='delivery'){
                        Simulate starting delivery site | Subgroup, Year 
                        //(see Appendix A.1.4.2 Starting Delivery Site)
                        Simulate elective c-section | Subgroup, Year 
                          //(see Appendix A.1.6.1 Elective Caesarean Section)
                        
                        //risk delivery complications
                        /*Preeclampsia/Eclampsia (see Appendix A.1.5.1 
                                                  Preeclampsia/Eclampsia)*/
                        if(electiveCSection==false){ 
                            Risk PE/E incidence | Maternal age, Severe anemia, 
                                                Multiple gestation, History of PE/E
                            if(hasComplication){
                                simulateReferral() /*Simulate facility referral,
                                                    see function below*/
                                Risk maternal death | Severity, Site, 
                                 Treatment Availability(Year)+Efficacy, Quality(Year) 
                              /*(see Appendices A.1.6.6 Hypertension Management,
                                 A.1.4.6 Quality of Care)*/
                                if(alive){ //woman survives
                                    Risk morbidity (subsequent infertility)
                                    Risk intrapartum stillbirth
                                }
                            }
                        }
                        //Obstructed labour (see Appendix A.1.5.2 Obstructed Labor)
                        if(alive==true & electiveCSection==false){
                            Risk OL incidence | Maternal Age, 
                          Partograph Availability(Year)+Efficacy, Quality(Year) 
                          //(see Appendices A.1.6.3 Partograph, A.1.4.6 Quality of Care)
                            if(hasComplication){
                                simulateReferral() /*Simulate facility referral,
                                                    see function below*/
                                Risk maternal death | Severity, Site, 
                              Treatment Availability(Year)+Efficacy, Quality(Year) 
                              /*(see Appendices A.1.6.7 Assisted Delivery,
                                 A.1.4.6 Quality of Care)*/
                                if(alive){ //woman survives
                                    Risk morbidity (fistula, assume subsequent infertility)
                                    Risk intrapartum stillbirth
                                }
                            }
                        }
                        //Other direct (see Appendix A.1.5.5 Other Direct Complications)
                        if(alive==true){
                            Risk other direct incidence
                            if(hasComplication){
                                simulateReferral() /*Simulate facility referral,
                                                    see function below*/
                                Risk maternal death | Site, Quality(Year) 
                              //(see Appendix A.1.4.6 Quality of Care)
                            }
                        }
                        /*Postpartum hemorrhage (see Appendix A.1.5.3 
                                                 Postpartum Hemorrhage)*/
                        if(alive==true & electiveCSection==false){
                            Risk PPH incidence | 
                            Active Management Availability(Year)+Efficacy, Quality(Year) 
                            /*(see Appendices A.1.6.2 Active Management of Labor,
                               A.1.4.6 Quality of Care)*/
                            if(hasComplication){
                                simulateReferral() /*Simulate facility referral,
                                                    see function below*/
                                Risk maternal death | Severity, Anemia, Site, 
                                Treatment Availability(Year)+Efficacy, Quality(Year) 
                                /*(see Appendices A.1.2.10 Anemia, 
                                   A.1.6.8 Hemorrhage Treatment, 
                                   A.1.4.6 Quality of Care)*/
                                if(alive){ //woman survives
                                    Risk morbidity (assume subsequent infertility)
                                    Simulate hemoglobin loss
                                }
                            }
                        }
                        //Sepsis (see Appendix A.1.5.4 Sepsis)
                        if(alive==true){
                            Risk sepsis incidence | C-section, 
                            Clean Delivery Availability(Year)+Efficacy, Quality(Year) 
                          //(see Appendix A.1.6.4 Clean delivery, A.1.4.6 Quality of Care)
                            if(hasComplication){
                                simulateReferral() /*Simulate facility referral,
                                                    see function below*/
                                Risk maternal death | Severity, Anemia, Site, 
                                Treatment Availability(Year)+Efficacy, Quality(Year)
                                /*(see Appendices A.1.2.10 Anemia, A.1.6.9 Antibiotics, 
                                   A.1.4.6 Quality of Care)*/
                                if(alive){ //woman survives
                                    Risk morbidity (secondary infertility)
                                }
                            }
                        }
                                                
                        if(woman is alive & fetus(es) is/are alive){
                            Record birth(s)
                            Add new infant child(ren)
                            Simulate breastfeeding status (exclusive/non-exclusive) 
                              and duration //(see Appendix A.1.3.10 Breastfeeding)
                        }
                    }
                                        
                    if(alive==false){ //woman died
                        Simulate if maternal death is reported | Site, Year 
                          //(see Appendix A.1.4.7 Maternal Death Underreporting)
                    }
                    else{ //woman is alive
                        assignContraception() /*Assign contraception status + method,
                                                  see function below*/
                    }
                    
                } //end pregnancy outcome
                
            } //end if fecund
        } //end if alive
    } //end woman loop
} //end cycle loop

//Simulates referral to a healthcare facility
function simulateReferral(){
    Simulate recognition | Site, Complication (type+severity), Subgroup, ANC (home only) 
    //(see Appendices A.1.4.3 Recognition/Referral, A.1.4.1 Antenatal Care)
    if(recognized){
        Simulate transport availability | Site, Subgroup /*(see Appendix A.1.4.4 
                                                            Transportation)*/
        if(transportAvailable){
            Simulate referral site | Current site, Subgroup /*(see Appendix A.1.4.5 
                                                               Referral Facility)*/
            Update current site
        }
    }
}

//Assigns contraception status and method
function assignContraception(){
    if(numCurrentChildren < numDesiredChildren){ //spacing
        Draw spacing intention | Subgroup, Age, Year //(see Appendix A.1.3.4 Unmet Need)
        if(desiresBirthSoon){
            No need for contraception (no method assigned)
        }
        else{ //wants to space children
            Check if spacing need is met | Subgroup, Age, Year /*(see Appendix A.1.3.4 
                                                                  Unmet Need)*/
            if(needMet){
                Assign contraception method | Subgroup, Spacing, Year 
                  //(see Appendix A.1.3.5 Contraception Method Mix)
                Assign intended duration of use | Method, Subgroup 
                  //(see Appendix A.1.3.7 Method Duration of Use)
            }
            else{ //unmet need
                No method assigned
            }
        }
    }
    else{ //limiting (met or exceeded desired number of children)
        Check if limited need is met | Subgroup, Age, Year /*(see Appendix A.1.3.4 
                                                              Unmet Need)*/
        if(needMet){
            Assign contraception method | Subgroup, Limiting, Year 
              //(see Appendix A.1.3.5 Contraception Method Mix)
            Assume indefinite use of method
        }
        else{ //unmet need
            No method assigned
        }
    }
}

//Updates contraception status
function updateContraception(){
    if(usingContraception & timeUse==duration){ //check if duration of use has elapsed
        Simulate if woman discontinues all methods or switches to another method 
          //(see Appendix A.1.3.7 Method Duration of Use)
        if(switchesMethods){
            Assign new contraception method | Subgroup, Spacing, Year 
              //(see Appendix A.1.3.5 Contraception Method Mix)
            Assign new intended duration of use | Method, Subgroup 
              //(see Appendix A.1.3.7 Method Duration of Use)
        }
        else{
            Discontinues all methods (no method assigned)
        }
    }
}
 
logo

GMatH (Global Maternal Health) Model - Last updated: 28 November 2022

© Copyright 2020-2022 Zachary J. Ward

zward@hsph.harvard.edu