Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduction and Contraceptives #186

Merged
merged 6 commits into from
Apr 24, 2017
Merged

Reproduction and Contraceptives #186

merged 6 commits into from
Apr 24, 2017

Conversation

cjduffett
Copy link
Contributor

@cjduffett cjduffett commented Apr 14, 2017

A Conceptual Overview

Collectively this PR adds 3 new modules, 9 new submodules, and expands 1 existing module to better represent pregnancy, the use of contraceptives, and female sexual activity as a whole. The sheer scale of this endeavor was mainly due to the diverse set of contraceptives available today.

The following 6 prescription contraceptives are now represented here:

  1. Oral Pills
  2. Intrauterine Devices (IUD)
  3. The Contraceptive Ring
  4. The Contraceptive Patch
  5. Injectable Contraceptives
  6. Implanted (Subcutaneous) Contraceptives

3 non-prescription contraceptive methods are also represented:

  1. Condom
  2. Withdrawal (I don't recommend this one)
  3. Male and Female Sterilization

To make contraceptives, female reproduction, and pregnancy play nicely there is a delicate interplay between several main modules. This is facilitated by the use of 5 key attributes:

  1. sexually_active (bool) - Assigned yearly by the "Sexual Activity" module.

  2. contraceptive (MedicationOrder) - Active, prescription contraceptive medications are assigned to this attribute.

  3. contraceptive_type (string) - Indicates the current contraceptive type in-use, which directly influences the monthly probability of a sexually active female becoming pregnant.

  4. pregnant (bool) - When true, triggers a cycle of the pregnancy module and suspends the use of contraceptives.

  5. infertile (bool) - Sterilization makes you this. Some people are also infertile from birth.

To track birth rate, the number_of_children attribute is also used to record the total number of live births for each female.

A Visual Overview

synthea - female reproduction

Assumptions and Shortcomings

Because this is already complex enough.

  1. Diaphragms and emergency contraceptives are not represented here. There was little data on diaphragm use available, and emergency contraceptives are out-of-scope since they're not a preventative measure.

  2. Race, ethnicity, and socioeconomic status are all factors that influence the birth rate and contraceptive use; however, they are not modeled here.

  3. Hormonal contraceptives carry an elevated risk of blood clots and stroke, especially for smokers over the age of 35. I made no changes to the Cardiovascular Disease module at this time.

  4. Sexual activity incidence is only based on a modern study. For now I am (perhaps naively) assuming that human sexual activity has been consistent for the last century. As-is, when birth control methods are historically unavailable more people are having unprotected sex in this model.

  5. All females reach reproductive age at age 14. All women reach menopause at age 50. All women have 28-day reproductive cycles. These are all the average cases. In reality, there are outliers.

Contraceptive Use By Different Age Groups

For simplicity, I binned all contraceptive users into 3 age groups:

  1. 14-24 - Teens/20-somethings favor short-term contraceptives like the pill, condoms, or injectables.

  2. 25-34 - More of these people are actually trying to make babies. Those that aren't either use long-acting contraceptives (IUD, implant, ring, etc.) or sterilization.

  3. 35-50 - Parenting to menopause. This group favors long-acting contraceptives and sterilization. No more babies if they can help it.

New Main Modules

Sexual Activity

sexual activity

The Female Reproductive Cycle

female reproduction

Contraceptive Use

contraceptives

New Submodules

Most of these submodules prescribe a contraceptive medication given the current year of the simulation. 3 contraceptive types require additional, periodic maintenance within an age range: IUDs, implants, and injectables.

Oral Contraceptive

oral contraceptive

Intrauterine Device

intrauterine device

Implanted Contraceptive

implant contraceptive

Injectable Contraceptive

injectable contraceptive

Patch Contraceptive

patch contraceptive

Vaginal Ring Contraceptive

vaginal ring contraceptive

Female Sterilization

female sterilization

Male Sterilization

male sterilization

Clear (Reset) Contraceptive

clear contraceptive

In Summary

Who knew making babies was so hard?

@cjduffett cjduffett requested review from jawalonoski and dehall April 14, 2017 03:28
@cjduffett
Copy link
Contributor Author

cjduffett commented Apr 14, 2017

I will followup with an analysis of the new birth rate, average births per mother, contraceptive use rates, and performance changes in the next day or two.

@jeffeastman
Copy link
Collaborator

+1 This is very impressive! And also nice to see where you've taken the initial Pregnancy and Birth models I offered.

@dehall
Copy link
Contributor

dehall commented Apr 14, 2017

Eagerly awaiting the statistics. Overall looks good. Some thoughts:

  • Female reproductive cycle could short-circuit to Terminal on attribute 'infertile' == true
  • sexual activity %s over time aren't completely independent, but the model is fine for now
  • Is there a generic RxNorm code that could be used for the IUDs that don't have a specific code? Even if the code is generic the display value will say what it is. Not a huge deal since 3 of them are only prescribed before 1986, but Paragard is still available through 2016.

@dehall
Copy link
Contributor

dehall commented Apr 17, 2017

Another thought: the next logical extension to this is STDs/STIs/whatever they're called now. While this model is fresh in your head, are there any potential minor changes to this model that would make it easier to extend to STDs later? I suspect the sexually_active attribute and contraceptive info is likely enough as-is, just wanted to throw the idea out there.

@jeffeastman
Copy link
Collaborator

jeffeastman commented Apr 17, 2017 via email

@cjduffett
Copy link
Contributor Author

Analysis

At present, there is an average birth rate of 5.45 children per mother. This is 3x too high - time to start turning some of the proverbial dials down a little. The things I can see being adjusted are:

  1. Sexual activity, esp. historically. When a birth control method is not historically available, the default is no method at all. This creates a high probability of pregnancy. If a woman is consistently sexually active in that age bracket, she may get pregnant every year. I also don't model any notion of celibacy, which may be more likely for the devoutly religious or the tragically ugly.

  2. Historical contraceptive use. Instead of defaulting to no contraceptive when one isn't historically available, perhaps withdrawal or condom are more sensible alternatives that carry a significantly lower risk of pregnancy than no method.

  3. Adding additional age brackets. If a person is selected for no contraceptive use, they're consistently using no contraceptive for 10+ years. Perhaps 5-year age brackets make more sense.

  4. Pre-selecting some women to never have children. Some women intentionally never have children in their lifetime.

I noticed that prescription contraceptives are not being ended. It seems that the Active Medication check in contraceptives/clear_contraceptive is always returning false.

I also neglected to set infertile for any females or males from birth. The only infertile patients at present are those who have been sterilized. Adding the females who are infertile from birth should help reduce the birth rate a little.

Statistics, female-reproduction

The following stats come from an initial run of 100 patients with 50 years of history, exporting FHIR only. I manually trimmed the stats to just the ones relevant to pregnancy. With 50 years of history and only FHIR export, the additional reproduction modules add +30s/100 patients to the runtime.

active_conditions:
    normal_pregnancy: 7

total_conditions:
    normal_pregnancy: 392
    miscarriage_in_first_trimester: 47
    miscarriage_in_second_trimester: 10

people_afflicted:
    normal_pregnancy: 58
    miscarriage_in_first_trimester: 27
    miscarriage_in_second_trimester: 8

active_medications:
    mestranol_/_norethynodrel_[enovid]: 10
    norinyl_1+50_28_day_pack: 5
    camila_28_day_pack: 2
    errin_28_day_pack: 1
    trinessa_28_day_pack: 2
    ortho_tri-cyclen_28_day_pack: 4
    jolivette_28_day_pack: 1
    mirena_52_mg_intrauterine_system: 1
    nuvaring_0.12/0.015_mg_per_24hr_21_day_vaginal_ring: 1
    0.65_ml_depo-subq_provera_160_mg/ml_prefilled_syringe: 1

total_medications:
    mestranol_/_norethynodrel_[enovid]: 10
    norinyl_1+50_28_day_pack: 5
    camila_28_day_pack: 2
    errin_28_day_pack: 1
    trinessa_28_day_pack: 2
    ortho_tri-cyclen_28_day_pack: 4
    jolivette_28_day_pack: 1
    mirena_52_mg_intrauterine_system: 1
    nuvaring_0.12/0.015_mg_per_24hr_21_day_vaginal_ring: 1
    0.65_ml_depo-subq_provera_160_mg/ml_prefilled_syringe: 1

people_prescribed:
    mestranol_/_norethynodrel_[enovid]: 10
    norinyl_1+50_28_day_pack: 5
    camila_28_day_pack: 2
    errin_28_day_pack: 1
    trinessa_28_day_pack: 2
    ortho_tri-cyclen_28_day_pack: 4
    jolivette_28_day_pack: 1
    mirena_52_mg_intrauterine_system: 1
    nuvaring_0.12/0.015_mg_per_24hr_21_day_vaginal_ring: 1
    0.65_ml_depo-subq_provera_160_mg/ml_prefilled_syringe: 1

population_count: 152
living: 100
females: 71
age_sum: 6973
avg_num_children: 5.4465727324214095
dead: 52
Completed in 4 minute(s) 45 second(s).

Statistics, master

population_count: 149
living: 100
age_sum: 6706
dead: 49

Completed in 4 minute(s) 17 second(s).


active_conditions:
   normal_pregnancy: 2

total_conditions:
   normal_pregnancy: 209
   miscarriage_in_first_trimester: 34
   miscarriage_in_second_trimester: 5
   female_infertility: 3

@cjduffett
Copy link
Contributor Author

I also isolated the logs for 10 random female patients, several in each age bracket:

female_1.txt
female_2.txt
female_3.txt
female_4.txt
female_5.txt
female_6.txt
female_7.txt
female_8.txt
female_9.txt
female_10.txt

These offer some insight into the number of pregnancies each women had, when she was sexually active, and what contraceptives she was taking (if any).

@cjduffett
Copy link
Contributor Author

cjduffett commented Apr 17, 2017

@jeffeastman, What may be risk factors that play into promiscuity? Age, race, socioeconomic status? That may have a lot to do with family history too.

@dehall, Thinking further down the line, what would we need to do to augment this model with family history? Could we go the next step and have Synthea patient's giving birth to more Synthea children? As-is, we could easily identify who their mothers are. Do we randomly assign a Synthea father to the mix?

Also I couldn't find even a generic IUD code in RxNorm. However, I found SNOMED codes for IUDs. Do those count as "devices"?

@dehall
Copy link
Contributor

dehall commented Apr 18, 2017

Having Synthea patients give birth to other Synthea patients would be challenging. We would have to balance patients that get created out of nowhere with ones that are born. Feel free to keep thinking about that but I don't think that should be a short-term goal.

@cmoesel
Copy link
Contributor

cmoesel commented Apr 18, 2017

I agree with @cjduffett that it would be really neat to have real family lineage in Synthea, but also agree with @dehall that it would lead to many challenges. For instance, if the patients had real relatives, with real Synthea records, then we'd need to take their relatives' conditions (family history) into account for everything we do in Synthea. We'd have to build this awareness into the tool and allow the modules to somehow reference it, and if done right, It would affect many of the distributions. We'd also have to figure out how this all works in serialized generation vs parallel generation. For now, having the ability to completely fictionalize (or ignore) any family history is the simpler path.

@jeffeastman
Copy link
Collaborator

jeffeastman commented Apr 18, 2017 via email

Carlton Duffett added 3 commits April 20, 2017 12:35
To effectively model many different contraceptive types and their effectiveness, I needed to rework the pregnancy module and add new modules to model 1) female reproduction, 2) sexual activity, and 3) contraceptive use, 4) MANY contraceptive types. Collectively, these determine how likely a female will become pregnant in a given reproductive cycle.
Added model of natural infertility. Natural infertility increases with age - it becomes harder or impossible to get pregnant as you get older. This reduced the overall birth rate from 5.45 -> 4.49 births/mother.
@cjduffett cjduffett force-pushed the female-reproduction branch from 17b518a to 87872a7 Compare April 20, 2017 16:37
@cjduffett
Copy link
Contributor Author

Some updates:

  1. I actually removed the new infertility module - the increasing infertility with age is now modeled by an increasing number of miscarriages, especially over age 35. Many of these miscarriages go undetected and are a direct cause of the increased infertility rate.

  2. I refactored the way some contraceptives are maintained. IUDs, implants, and injectables are now maintained separately from the prescription by the contraceptive_maintenance module.

  3. I did 6 runs of 100 patients. I've been getting a wide range of overall birth rate numbers, so one run wasn't a consistent, comprehensive picture.

0.69, 0.58, 3.24, 1.61, 1.97, 2.13... There are clearly a lot of variables at play here. However, these various runs average out to a birth rate of about 1.7, so close to the desired 2.0.

@cjduffett
Copy link
Contributor Author

@jawalonoski, I incorporated the changes we discussed on Thursday. I removed the condition checking a nil contraceptive type, and added additional remarks to many of the contraceptive modules documenting assumptions, simplifications, etc.

I ran 3 runs of 1k patients over the weekend, with an average birth rate of 2.6 children/mother. I think that's spot on.

@jawalonoski jawalonoski merged commit decb8ce into master Apr 24, 2017
@jawalonoski jawalonoski deleted the female-reproduction branch April 24, 2017 14:18
@jeffeastman
Copy link
Collaborator

jeffeastman commented Apr 24, 2017 via email

@jeffeastman
Copy link
Collaborator

jeffeastman commented Apr 24, 2017 via email

@jawalonoski
Copy link
Member

@jeffeastman You're saying the population is declining by 50%? Or in other words, the number of deaths exceeds the number of births?

@jeffeastman
Copy link
Collaborator

Yes, its not too apparent at the beginning, but once the population size begins to drop, the trend accelerates. In my run, I saw a larger number of women choose sterilization than I would have expected (728). That by itself could have triggered the population collapse.

Female Sterilization: 12 states
Set_Contraceptive_Type: 728 instances
Consultation_Encounter: 728 instances
End_Consultation: 728 instances
Delay_For_Procedure: 1127 instances
Tubal_Ligation_Surgery_Encounter: 728 instances
Tubal_Ligation_Procedure: 728 instances
Become_Infertile: 728 instances
Post_Surgery_Care: 728 instances
End_Surgery_Encounter: 728 instances
Recovery_Period: 1485 instances
End_Post_Surgery_Care: 728 instances
Terminal: 1456 instances

@jeffeastman
Copy link
Collaborator

jeffeastman commented Apr 24, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants