From 4b245c6884d100ea2faff3701c821ca1422a9042 Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Sun, 9 Apr 2017 01:23:24 -0400 Subject: [PATCH 1/6] Added models of female sexual activity and reproductive cycle --- lib/generic/modules/female_reproduction.json | 509 +++++++++++++++++++ lib/generic/modules/sexual_activity.json | 267 ++++++++++ 2 files changed, 776 insertions(+) create mode 100644 lib/generic/modules/female_reproduction.json create mode 100644 lib/generic/modules/sexual_activity.json diff --git a/lib/generic/modules/female_reproduction.json b/lib/generic/modules/female_reproduction.json new file mode 100644 index 0000000000..8f20110dfa --- /dev/null +++ b/lib/generic/modules/female_reproduction.json @@ -0,0 +1,509 @@ +{ + "name": "Female Reproduction", + "remarks": [ + "This module models female reproduction from birth to death. Once females ", + "reach reproductive age, this module operates on a monthly cycle. Each month ", + "a sexually active female has a non-zero chance of becoming pregnant. This ", + "chance is greatly reduced by taking a contraceptive.", + + "If a female becomes pregnant, the monthly cycles are suspended until the ", + "pregnancy terminates. The pregnancy module is responsible for ending any ", + "active contraceptive method once the pregnancy is diagnosed.", + + "The monthly reproductive cycles end once a female reaches menopause, ", + "typically around the age of 50.", + + "This module of course operates on several assumptions: ", + "2. All females have regular, monthly reproductive cycles (some don't) ", + "4. All females reach menopause at age 50 " + ], + "states": { + + "Initial": { + "type": "Initial", + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Delay_For_Reproductive_Age" + }, + { + "transition": "Terminal" + } + ] + }, + + "Delay_For_Reproductive_Age": { + "type": "Delay", + "range": { + "low": 11, + "high": 14, + "unit": "years" + }, + "direct_transition": "Female_Reproductive_Cycle" + }, + + "Female_Reproductive_Cycle": { + "type": "Delay", + "remarks": [ + "Adults have a cycle of 21 - 35 days (avg. 28). Source: ", + "https://www.womenshealth.gov/a-z-topics/menstruation-and-menstrual-cycle" + ], + "range": { + "low": 21, + "high": 35, + "unit": "days" + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": ">", + "quantity": 50, + "unit": "years" + }, + "transition": "Menopause_Reached" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Pregnancy_Guard" + }, + { + "transition": "Reproductive_Cycle_Outcome" + } + ] + }, + + "Menopause_Reached": { + "type": "Simple", + "remarks": [ + "This state just exists to make the graph look nicer. Once menopause is ", + "reached, head to Terminal." + ], + "direct_transition": "Terminal" + }, + + "Pregnancy_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": false + }, + "direct_transition": "Female_Reproductive_Cycle" + }, + + "Reproductive_Cycle_Outcome": { + "type": "Simple", + "remarks": [ + "======================================================================", + " REPRODUCTIVE CYCLE OUTCOMES ", + "======================================================================", + "This is where the magic happens. If females are sexually active, there is ", + "a non-zero chance of becoming pregnant. The 'sexually_active' attribute is ", + "set by the 'sexual_activity' module." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "sexually_active", + "operator": "==", + "value": true + }, + "transition": "Sexually_Active" + }, + { + "transition": "Not_Sexually_Active" + } + ] + }, + + "Sexually_Active": { + "type": "Simple", + "remarks": [ + "2 attributes determine the current state of a female's contraceptive use: ", + "1. contraceptive - if not nil, references a contraceptive medication ", + "2. contraceptive_type - if not nil, describes the type of contraceptive in-use ", + + "contraceptive_type may be non-nil even if contraceptive is nil, e.g. for condoms ", + "or primitive contraceptive methods like awareness or withdrawal." + ], + "conditional_transition": [ + { + "remarks": [ + "Not taking a contraceptive of any type." + ], + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "contraceptive", + "operator": "is nil" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + } + ] + }, + "transition": "Unprotected_Incidence" + }, + { + "remarks": [ + "Using a contraceptive type that is not prescribed, e.g. condom." + ], + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "contraceptive", + "operator": "is nil" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is not nil" + } + ] + }, + "transition": "Contraceptive_Incidence" + }, + { + "remarks": [ + "Using a contraceptive type that is prescribed, e.g. pill." + ], + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "contraceptive", + "operator": "is not nil" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is not nil" + } + ] + }, + "transition": "Active_Contraceptive?" + }, + { + "remarks": [ + "This is an error state where contraceptive is not nil, but no ", + "contraceptive type is specified. In this instance, default to the ", + "unprotected incidence." + ], + "transition": "Unprotected_Incidence" + } + ] + }, + + "Active_Contraceptive?": { + "type": "Simple", + "remarks": [ + "If the contraceptive medication prescribed is inactive, assume the ", + "patient is not taking it and is therefore having unprotected sex." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Active Medication", + "referenced_by_attribute": "contraceptive" + }, + "transition": "Contraceptive_Incidence" + }, + { + "transition": "Unprotected_Incidence" + } + ] + }, + + "Contraceptive_Incidence": { + "type": "Simple", + "remarks": [ + "======================================================================", + " CONTACEPTIVE INCIDENCE ", + "======================================================================", + "Effectiveness of different prescription contraceptives. The following percentages ", + "indicate the number out of 100 women who experience unplanned pregnancy within ", + "the first year of use. These percentages are scaled for a monthly time step: ", + + "| Method | Annual Chance of Pregnancy | Monthly Chance of Pregnancy | ", + "|----------------|----------------------------|-----------------------------| ", + "| awareness ** | 24% | 2.26% | ", + "| withdrawal | 22% | 2.05% | ", + "| condom | 18% | 1.640% | ", + "| pill | 9% | 0.692% | ", + "| patch | 9% | 0.692% | ", + "| ring | 9% | 0.692% | ", + "| injectable | 6% | 0.514% | ", + "| IUD | 0.2 - 0.8% | 0.0167 - 0.0669% | ", + "| sterilization | 0.15 - 0.5% | 0.0125 - 0.0418% | ", + "| implant | 0.05% | 0.00417% | ", + "'---------------------------------------------------------------------------' ", + + "** fertility awareness is planning around a woman's ovulation cycle, ", + "obstaining from sex or using a condom during peak fertility.", + + "Source: https://www.cdc.gov/reproductivehealth/unintendedpregnancy/pdf/contraceptive_methods_508.pdf" + + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "awareness" + }, + "distributions": [ + { + "distribution": 0.0226, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.9774, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "withdrawal" + }, + "distributions": [ + { + "distribution": 0.0205, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.9795, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "condom" + }, + "distributions": [ + { + "distribution": 0.0164, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.9836, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "pill" + }, + "distributions": [ + { + "distribution": 0.00692, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99318, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "patch" + }, + "distributions": [ + { + "distribution": 0.00692, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99318, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "ring" + }, + "distributions": [ + { + "distribution": 0.00692, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99318, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "injectable" + }, + "distributions": [ + { + "distribution": 0.00514, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99486, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "iud" + }, + "distributions": [ + { + "distribution": 0.00342, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99658, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "sterilization" + }, + "distributions": [ + { + "distribution": 0.00271, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.99729, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "implant" + }, + "distributions": [ + { + "distribution": 0.000417, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.999583, + "transition": "Next_Reproductive_Cycle" + } + ] + } + ] + }, + + "Unprotected_Incidence": { + "type": "Simple", + "distributed_transition": [ + { + "distribution": 0.193, + "transition": "Potentially_Pregnant" + }, + { + "distribution": 0.817, + "transition": "Next_Reproductive_Cycle" + } + ] + }, + + "Not_Sexually_Active": { + "type": "Simple", + "direct_transition": "Next_Reproductive_Cycle" + }, + + "Potentially_Pregnant": { + "type": "Simple", + "remarks": [ + "Unless the female is infertile, she will become pregnant." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "infertile", + "operator": "==", + "value": true + }, + "transition": "Next_Reproductive_Cycle" + }, + { + "transition": "Become_Pregnant" + } + ] + }, + + "Become_Pregnant": { + "type": "SetAttribute", + "remarks": [ + "When true, the 'pregnant' attribute triggers the start of a cycle in ", + "the Pregnancy module." + ], + "attribute": "pregnant", + "value": true, + "direct_transition": "Pregnancy_Guard" + }, + + "Next_Reproductive_Cycle": { + "type": "Simple", + "direct_transition": "Female_Reproductive_Cycle" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/sexual_activity.json b/lib/generic/modules/sexual_activity.json new file mode 100644 index 0000000000..8ef1547b05 --- /dev/null +++ b/lib/generic/modules/sexual_activity.json @@ -0,0 +1,267 @@ +{ + "name": "Sexual Activity", + "remarks": [ + "This module models the sexual activity of males and females, from puberty ", + "to old age. Most of the incidence in this module is based on a recent study ", + "from Indiana University: http://www.nationalsexstudy.indiana.edu/graph.html", + + "Omitting the male sexual incidence since male sexual activity does not, ", + "at present, influence any other module." + ], + "states": { + + "Initial": { + "type": "Initial", + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Initially_Inactive" + }, + { + "transition": "Terminal" + } + ] + }, + + "Initially_Inactive": { + "type": "SetAttribute", + "remarks": [ + "Initially, everyone is not sexually active. I hope." + ], + "attribute": "sexually_active", + "value": false, + "direct_transition": "Delay_For_Sexual_Activity" + }, + + "Delay_For_Sexual_Activity": { + "type": "Delay", + "remarks": [ + "There is no data on female sexual activity before the age of 14." + ], + "exact": { + "quantity": 14, + "unit": "years" + }, + "direct_transition": "Female_Sexual_Activity" + }, + + "Female_Sexual_Activity": { + "type": "Delay", + "remarks": [ + "Female sexual activity is now modelled on a yearly basis, to match ", + "the Indiana University study. In the future, this may be scaled to a ", + "monthly incidence to match the female reproductive cycle.", + + "The incidence used here matches the percentage of 'Vaginal Intercourse' ", + "for women in the chart." + ], + "exact": { + "quantity": 1, + "unit": "years" + }, + "complex_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 16, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.11, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.89, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 18, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.30, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.70, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 20, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.62, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.38, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 25, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.80, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.20, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 30, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.87, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.13, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 40, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.74, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.26, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 50, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.70, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.30, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 60, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.51, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.49, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 70, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.42, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.58, + "transition": "Female_Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 70, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.22, + "transition": "Female_Sexually_Active" + }, + { + "distribution": 0.78, + "transition": "Female_Not_Sexually_Active" + } + ] + } + ] + }, + + "Female_Sexually_Active": { + "type": "SetAttribute", + "attribute": "sexually_active", + "value": true, + "direct_transition": "Female_Sexual_Activity" + }, + + "Female_Not_Sexually_Active": { + "type": "SetAttribute", + "attribute": "sexually_active", + "value": false, + "direct_transition": "Female_Sexual_Activity" + }, + + "Terminal": { + "type": "Terminal" + } + } +} From 909d3ef8b68e5f15e48d6f95b46aeb3a0aa2aa05 Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Tue, 11 Apr 2017 10:08:37 -0400 Subject: [PATCH 2/6] Female Reproduction and Contraceptives 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. --- lib/generic/modules/contraceptives.json | 549 ++++++++++++++++ .../contraceptives/clear_contraceptive.json | 64 ++ .../contraceptives/female_sterilization.json | 135 ++++ .../contraceptives/implant_contraceptive.json | 456 ++++++++++++++ .../injectable_contraceptive.json | 364 +++++++++++ .../contraceptives/intrauterine_device.json | 591 ++++++++++++++++++ .../contraceptives/male_sterilization.json | 133 ++++ .../contraceptives/oral_contraceptive.json | 535 ++++++++++++++++ .../contraceptives/patch_contraceptive.json | 92 +++ .../contraceptives/ring_contraceptive.json | 90 +++ lib/generic/modules/female_reproduction.json | 171 ++--- lib/generic/modules/pregnancy.json | 205 +----- lib/generic/modules/sexual_activity.json | 328 ++++++++-- lib/tasks/graphviz.rb | 7 +- 14 files changed, 3364 insertions(+), 356 deletions(-) create mode 100644 lib/generic/modules/contraceptives.json create mode 100644 lib/generic/modules/contraceptives/clear_contraceptive.json create mode 100644 lib/generic/modules/contraceptives/female_sterilization.json create mode 100644 lib/generic/modules/contraceptives/implant_contraceptive.json create mode 100644 lib/generic/modules/contraceptives/injectable_contraceptive.json create mode 100644 lib/generic/modules/contraceptives/intrauterine_device.json create mode 100644 lib/generic/modules/contraceptives/male_sterilization.json create mode 100644 lib/generic/modules/contraceptives/oral_contraceptive.json create mode 100644 lib/generic/modules/contraceptives/patch_contraceptive.json create mode 100644 lib/generic/modules/contraceptives/ring_contraceptive.json diff --git a/lib/generic/modules/contraceptives.json b/lib/generic/modules/contraceptives.json new file mode 100644 index 0000000000..8419484677 --- /dev/null +++ b/lib/generic/modules/contraceptives.json @@ -0,0 +1,549 @@ +{ + "name": "Contraceptives", + "remarks": [ + "This module prescribes many types of contraceptives to all potentially reproductive ", + "age groups. The availablility of different medicines and methods is historically ", + "accurate by year, based on these articles: ", + "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", + "http://www.pbs.org/wnet/need-to-know/health/a-brief-history-of-the-birth-control-pill/480/", + + "Hormonal contraceptives cause a slightly elevated risk of blood clots, heart attack, and ", + "stroke (1.6x) in females, especially in heavy smokers over the age of 35. No change was ", + "made to the existing cardiovascular disease module.", + + "While male sterilization is used as a contraceptive method (8%), it's not modeled here. ", + "Instead, the 8% is folded into the female sterilization incidence. However, 6% of males ", + "age 30 - 55 are selected for sterilization to create accurate male patient records.", + + "The use of a diaphragm and emergency contraceptives (e.g. Plan B) is not modeled here. ", + "Diaphragms are not modeled due to a lack of usage data and popularity, and emergency ", + "contraceptives are out-of-scope." + ], + "states": { + + "Initial": { + "type": "Initial", + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Delay_Until_Reproductive_Age" + }, + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Select_For_Male_Sterilization" + } + ] + }, + + "Delay_Until_Reproductive_Age": { + "type": "Delay", + "exact": { + "quantity": 14, + "unit": "years" + }, + "direct_transition": "Female_Contraceptive_Use" + }, + + "Select_For_Male_Sterilization": { + "type": "Simple", + "remarks": [ + "======================================================================", + " MALE STERLIZATION ", + "======================================================================", + "Male sterilization accounts for 8% of all contraceptive use, predominantly ", + "in older males. However, this does not mean 8% of all males are sterilized. ", + "According to the NIH, 6% of males have had a vasectomy. Source: ", + "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2784091/", + + "The percentage of males seeking vasectomies has remained approximately the ", + "same for the last 40 years. Vasectomies were first used as a form of ", + "contraceptive starting around WWII." + ], + "distributed_transition": [ + { + "distribution": 0.06, + "transition": "Delay_For_Male_Sterilization" + }, + { + "distribution": 0.94, + "transition": "Terminal" + } + ] + }, + + "Delay_For_Male_Sterilization": { + "type": "Delay", + "range": { + "low": 30, + "high": 55, + "unit": "years" + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": ">", + "year": 1945 + }, + "transition": "Male_Sterilization_Procedure" + }, + { + "transition": "Terminal" + } + ] + }, + + "Male_Sterilization_Procedure": { + "type": "CallSubmodule", + "submodule": "contraceptives/male_sterilization", + "direct_transition": "Terminal" + }, + + "Female_Contraceptive_Use": { + "type": "Simple", + "remarks": [ + "======================================================================", + " FEMALE CONTRACEPTIVE USE ", + "======================================================================", + "Female use of contraceptives is recomputed 3 times in a patient's life, ", + "once for each major reproductive age bracket: ", + + "1. Young (teen/20's) contraceptive users, age 14 - 24 ", + "2. Mid-age contraceptive users, age 25 - 34 ", + "3. Mature contraceptive users, age 35+ (limited by menopause at age 50) ", + + "Combined with sexual_activity, this yields a full range of contraceptive ", + "users and outcomes, from those who never use contraceptives (and who likely ", + "have several children as a result), to lifetime contraceptive users with ", + "no children.", + + "Whenever a woman becomes pregnancy her current contraceptive method is stopped. ", + "After the pregnancy terminates, she is re-routed here to re-up her contraceptive ", + "(or not)." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 25, + "unit": "years" + }, + "transition": "Young_Contraceptive_Use" + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 35, + "unit": "years" + }, + "transition": "Mid_Contraceptive_Use" + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 50, + "unit": "years" + }, + "transition": "Mature_Contraceptive_Use" + } + ] + }, + + "Young_Contraceptive_Use": { + "type": "Simple", + "remarks": [ + "======================================================================", + " TEEN/20'S CONTRACEPTIVE USE ", + "======================================================================", + "18% of teens do not use any contraceptive method. The majority use a ", + "short-term solution such as withdrawal, condoms, or the pill. A select ", + "few use an IUD or long-acting contraceptive like an implant. A statistically ", + "insignificant number use sterilization, so it's omitted for this age group. ", + "Source: https://www.guttmacher.org/fact-sheet/contraceptive-use-united-states", + + "There is significant overlap between those using a condom and those ", + "using a hormonal method (e.g. pill, patch, ring). The incidence of ", + "condom use below therefore represents those using ONLY a condom." + ], + "distributed_transition": [ + { + "distribution": 0.35, + "transition": "Using_Oral_Contraceptive" + }, + { + "distribution": 0.20, + "transition": "Using_Withdrawal" + }, + { + "distribution": 0.18, + "transition": "Using_No_Contraceptive" + }, + { + "distribution": 0.18, + "transition": "Using_Condom_Only" + }, + { + "distribution": 0.03, + "transition": "Using_Injectable" + }, + { + "distribution": 0.02, + "transition": "Using_Ring" + }, + { + "distribution": 0.02, + "transition": "Using_IUD" + }, + { + "distribution": 0.01, + "transition": "Using_Implant" + }, + { + "distribution": 0.01, + "transition": "Using_Patch" + } + ] + }, + + "Mid_Contraceptive_Use": { + "type": "Simple", + "remarks": [ + "======================================================================", + " MID-LIFE CONTRACEPTIVE USE ", + "======================================================================", + "In the 25 - 35 age bracket, more women are intentionally trying to get ", + "pregnant as they start families. For those not trying to become pregnant, ", + "long-acting contraceptives or sterilization are favored. Source: ", + "https://www.cdc.gov/nchs/data/databriefs/db173.pdf" + ], + "distributed_transition": [ + { + "distribution": 0.283, + "transition": "Using_No_Contraceptive" + }, + { + "distribution": 0.169, + "transition": "Using_Oral_Contraceptive" + }, + { + "distribution": 0.146, + "transition": "Using_Sterilization" + }, + { + "distribution": 0.115, + "transition": "Using_Condom_Only" + }, + { + "distribution": 0.099, + "transition": "Using_Withdrawal" + }, + { + "distribution": 0.07, + "transition": "Using_IUD" + }, + { + "distribution": 0.047, + "transition": "Using_Implant" + }, + { + "distribution": 0.045, + "transition": "Using_Injectable" + }, + { + "distribution": 0.016, + "transition": "Using_Ring" + }, + { + "distribution": 0.01, + "transition": "Using_Patch" + } + ] + }, + + "Mature_Contraceptive_Use": { + "type": "Simple", + "remarks": [ + "======================================================================", + " MATURE CONTRACEPTIVE USE ", + "======================================================================", + "Most women in this age bracket are done having children and are seeking ", + "a long-term or permanent solution. The highest percentage of sterilization ", + "is in this category. (Again, note that 8% of the sterilization incidence ", + "in this category is male sterilization folded into female)." + ], + "distributed_transition": [ + { + "distribution": 0.39, + "transition": "Using_Sterilization" + }, + { + "distribution": 0.209, + "transition": "Using_Oral_Contraceptive" + }, + { + "distribution": 0.113, + "transition": "Using_Condom_Only" + }, + { + "distribution": 0.052, + "transition": "Using_No_Contraceptive" + }, + { + "distribution": 0.048, + "transition": "Using_Withdrawal" + }, + { + "distribution": 0.07, + "transition": "Using_IUD" + }, + { + "distribution": 0.047, + "transition": "Using_Implant" + }, + { + "distribution": 0.045, + "transition": "Using_Injectable" + }, + { + "distribution": 0.016, + "transition": "Using_Ring" + }, + { + "distribution": 0.01, + "transition": "Using_Patch" + } + ] + }, + + "Using_No_Contraceptive": { + "type": "SetAttribute", + "remarks": [ + "======================================================================", + " CONTRACEPTIVE PRESCRIPTIONS ", + "======================================================================", + "These contraceptive prescriptions do not require maintenance. Fire and forget." + ], + "attribute": "contraceptive_type", + "value": "none", + "direct_transition": "Not_Guarded" + }, + + "Using_Withdrawal": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "withdrawal", + "direct_transition": "Not_Guarded" + }, + + "Using_Oral_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/oral_contraceptive", + "direct_transition": "Not_Guarded" + }, + + "Using_Condom_Only": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "condom", + "direct_transition": "Not_Guarded" + }, + + "Using_Sterilization": { + "type": "Simple", + "remarks": [ + "This is the combination male-female sterilization incidence.", + "While only female patients are routed to this state, a portion ", + "are identified as using sterilization as a contraceptive method ", + "even though they are not given the sterilization procedure.", + "The ratio of female:male sterilization is 3:1." + ], + "distributed_transition": [ + { + "distribution": 0.75, + "transition": "Using_Female_Sterilization" + }, + { + "distribution": 0.25, + "transition": "Using_Male_Sterilization" + } + ] + }, + + "Using_Male_Sterilization": { + "type": "SetAttribute", + "remarks": [ + "No female sterilization procedure is performed in this case." + ], + "attribute": "contraceptive_type", + "value": "sterilization", + "direct_transition": "Not_Guarded" + }, + + "Using_Female_Sterilization": { + "type": "CallSubmodule", + "submodule": "contraceptives/female_sterilization", + "direct_transition": "Terminal" + }, + + "Using_Ring": { + "type": "CallSubmodule", + "submodule": "contraceptives/ring_contraceptive", + "direct_transition": "Not_Guarded" + }, + + "Using_Patch": { + "type": "CallSubmodule", + "submodule": "contraceptives/patch_contraceptive", + "direct_transition": "Not_Guarded" + }, + + "Using_IUD": { + "type": "CallSubmodule", + "remarks": [ + "======================================================================", + " CONTRACEPTIVES REQUIRING MAINTENANCE ", + "======================================================================", + "IUDs, implants, and injectables require periodic maintenance during a ", + "given age bracket. IUDs must be replaced every 5-10 years, implants every ", + "3 years, and injectables every 3 months. Maintenance is handled internally ", + "within the submodules.", + + "These submodules are also 'self guarded', meaning they do not need the ", + "regular age guards to ensure the correct timing for the next age bracket ", + "(since they do so internally)." + ], + "submodule": "contraceptives/intrauterine_device", + "direct_transition": "Self_Guarded" + }, + + "Using_Implant": { + "type": "CallSubmodule", + "submodule": "contraceptives/implant_contraceptive", + "direct_transition": "Self_Guarded" + }, + + "Using_Injectable": { + "type": "CallSubmodule", + "submodule": "contraceptives/injectable_contraceptive", + "direct_transition": "Self_Guarded" + }, + + "Self_Guarded": { + "type": "Simple", + "direct_transition": "Reset_Contraceptive_Use" + }, + + "Not_Guarded": { + "type": "Simple", + "direct_transition": "Route_To_Guard" + }, + + "Route_To_Guard": { + "type": "Simple", + "remarks": [ + "======================================================================", + " AGE GUARDS ", + "======================================================================", + "This state routes patients to the appropriate age guard that will ", + "eventually transition them to the next age bracket." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 25, + "unit": "years" + }, + "transition": "Young_To_Mid_Guard" + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 35, + "unit": "years" + }, + "transition": "Mid_To_Mature_Guard" + }, + { + "transition": "Menopause_Guard" + } + ] + }, + + "Young_To_Mid_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + "direct_transition": "Reset_Contraceptive_Use" + }, + + "Mid_To_Mature_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + "direct_transition": "Reset_Contraceptive_Use" + }, + + "Menopause_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + }, + "direct_transition": "Reset_Contraceptive_Use" + }, + + "Reset_Contraceptive_Use": { + "type": "CallSubmodule", + "remarks": [ + "Prior to setting a new contraceptive, the previous contraceptive ", + "method is cleared." + ], + "submodule": "contraceptives/clear_contraceptive", + "conditional_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + }, + "transition": "Menopause_Reached" + }, + { + "transition": "Female_Contraceptive_Use" + } + ] + }, + + "Menopause_Reached": { + "type": "Simple", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/clear_contraceptive.json b/lib/generic/modules/contraceptives/clear_contraceptive.json new file mode 100644 index 0000000000..cf17a260e4 --- /dev/null +++ b/lib/generic/modules/contraceptives/clear_contraceptive.json @@ -0,0 +1,64 @@ +{ + "name": "Clear Contraceptive", + "remarks": [ + "This submodule ends any active contraceptive medication assigned to the ", + "'contraceptive' attribute and clears the 'contraceptive_type' attribute ", + "for reassignment." + ], + "states": { + + "Initial": { + "type": "Initial", + "direct_transition": "Clear_Contraceptive_Med" + }, + + "Clear_Contraceptive_Med": { + "type": "Simple", + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive", + "operator": "is not nil" + }, + "transition": "Active_Medication_Check" + }, + { + "transition": "Clear_Contraceptive_Type" + } + ] + }, + + "Active_Medication_Check": { + "type": "Simple", + "conditional_transition": [ + { + "condition": { + "condition_type": "Active Medication", + "referenced_by_attribute": "contraceptive" + }, + "transition": "End_Contraceptive_Med" + }, + { + "transition": "Clear_Contraceptive_Type" + } + ] + }, + + "End_Contraceptive_Med": { + "type": "MedicationEnd", + "referenced_by_attribute": "contraceptive", + "direct_transition": "Clear_Contraceptive_Type" + }, + + "Clear_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/female_sterilization.json b/lib/generic/modules/contraceptives/female_sterilization.json new file mode 100644 index 0000000000..37023d49ec --- /dev/null +++ b/lib/generic/modules/contraceptives/female_sterilization.json @@ -0,0 +1,135 @@ +{ + "name": "Female Sterilization", + "remarks": [ + "This submodule performs a female sterilization procedure. This procedure ", + "is not reversible." + ], + "states": { + + "Initial": { + "type": "Initial", + "direct_transition": "Set_Contraceptive_Type" + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "sterilization", + "direct_transition": "Consultation_Encounter" + }, + + "Consultation_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "End_Consultation" + }, + + "End_Consultation": { + "type": "EncounterEnd", + "direct_transition": "Delay_For_Procedure" + }, + + "Delay_For_Procedure": { + "type": "Delay", + "range": { + "low": 1, + "high": 3, + "unit": "weeks" + }, + "direct_transition": "Tubal_Ligation_Surgery_Encounter" + }, + + "Tubal_Ligation_Surgery_Encounter": { + "type": "Encounter", + "encounter_class": "inpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "305408004", + "display": "Admission to surgical department" + } + ], + "direct_transition": "Tubal_Ligation_Procedure" + }, + + "Tubal_Ligation_Procedure": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "287664005", + "display": "Bilateral tubal ligation" + } + ], + "duration": { + "low": 2, + "high": 3, + "unit": "hours" + }, + "direct_transition": "Become_Infertile" + }, + + "Become_Infertile": { + "type": "SetAttribute", + "attribute": "infertile", + "value": true, + "direct_transition": "Post_Surgery_Care" + }, + + "Post_Surgery_Care": { + "type": "CarePlanStart", + "codes": [ + { + "system": "SNOMED-CT", + "code": "787301000000101", + "display": "Surgery care management" + } + ], + "activities": [ + { + "system": "SNOMED-CT", + "code": "183051005", + "display": "Recommendation to rest" + }, + { + "system": "SNOMED-CT", + "code": "243077000", + "display": "Recommendation to limit sexual activity" + } + ], + "direct_transition": "End_Surgery_Encounter" + }, + + "End_Surgery_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Recovery_Period" + }, + + "Recovery_Period": { + "type": "Delay", + "range": { + "low": 2, + "high": 3, + "unit": "weeks" + }, + "direct_transition": "End_Post_Surgery_Care" + }, + + "End_Post_Surgery_Care": { + "type": "CarePlanEnd", + "careplan": "Post_Surgery_Care", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/implant_contraceptive.json b/lib/generic/modules/contraceptives/implant_contraceptive.json new file mode 100644 index 0000000000..efb4d6bc17 --- /dev/null +++ b/lib/generic/modules/contraceptives/implant_contraceptive.json @@ -0,0 +1,456 @@ +{ + "name": "Implant Contraceptive", + "remarks": [ + "This submodule prescribes a long-acting, implanted contraceptive if one is ", + "available for the current year of the simulation. The first implanted ", + "contraceptive was available in 1990, marketed as Norplant. Norplant was ", + "discontinued in 2002 in favor of newer alternatives, but implants remain ", + "available today.", + + "Since implants must be readministered once every 3-4 years, this submodule ", + "regularly administers additional doses until the current age bracket is exhausted.", + + "Sources for historical availability: ", + "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", + "http://www.pbs.org/wnet/need-to-know/health/a-brief-history-of-the-birth-control-pill/480/" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 1991 ", + "do not get implant contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1991 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "implant", + "direct_transition": "Implant_Contraceptive_Encounter" + }, + + "Implant_Contraceptive_Encounter": { + "type": "Encounter", + "remarks": [ + "======================================================================", + " NEW IMPLANT PRESCRIPTION ", + "======================================================================" + ], + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Prescribe_Implant_Contraceptive" + }, + + "Prescribe_Implant_Contraceptive": { + "type": "Simple", + "remarks": [ + "Norplant was available in January 1991. The original production ended ", + "in 2002, with supplies available until 2004-ish. Implanon became available ", + "in 2006 and an improvement, Nexplanon, in 2011. Implanon was taken off the ", + "market in 2012, so Nexplanon remains the only currently available implant ", + "in the United States.", + + "While not *technically* historically accurate, the use of Norplant is stretched ", + "until 2006 to maintain continuity." + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2006 + }, + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Norplant" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2011 + }, + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Implanon" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2012 + }, + "distributions": [ + { + "distribution": 0.8, + "transition": "Prescribe_Nexplanon" + }, + { + "distribution": 0.8, + "transition": "Prescribe_Implanon" + } + ] + }, + { + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Nexplanon" + } + ] + } + ] + }, + + "Prescribe_Norplant": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1366342", + "display": "Levonorgestrel 0.00354 MG/HR [Norplant]" + } + ], + "direct_transition": "Initial_Implant" + }, + + "Prescribe_Implanon": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "646250", + "display": "Implanon 68 MG Drug Implant" + } + ], + "direct_transition": "Initial_Implant" + }, + + "Prescribe_Nexplanon": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1111011", + "display": "Nexplanon 68 MG Drug Implant" + } + ], + "direct_transition": "Initial_Implant" + }, + + "Initial_Implant": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "169553002", + "display": "Insertion of subcutaneous contraceptive" + } + ], + "duration": { + "low": 20, + "high": 40, + "unit": "minutes" + }, + "direct_transition": "End_Initial_Encounter" + }, + + "End_Initial_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Implant_Maintenance" + }, + + "Implant_Maintenance": { + "type": "Guard", + "remarks": [ + "======================================================================", + " ADDITIONAL DOSE(S) ", + "======================================================================", + "Every 3-4 years the implant must be removed or replaced." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Initial_Implant", + "within": { "quantity": 4, "unit": "years" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Renew_Contraceptive_Implant", + "within": { "quantity": 4, "unit": "years" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Remove_Implant_Encounter" + }, + { + "transition": "Continue_Or_Stop" + } + ] + }, + + "Continue_Or_Stop": { + "type": "Simple", + "conditional_transition": [ + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + } + ] + }, + "transition": "Remove_Implant_Encounter" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Remove_Implant_Encounter" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Young_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Remove_Implant_Encounter" + }, + { + "transition": "Renew_Implant_Encounter" + } + ] + }, + + "Renew_Implant_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Renew_Contraceptive_Implant" + }, + + "Renew_Contraceptive_Implant": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "755621000000101", + "display": "Replacement of subcutaneous contraceptive" + } + ], + "duration": { + "low": 20, + "high": 40, + "unit": "minutes" + }, + "direct_transition": "End_Renewal_Encounter" + }, + + "End_Renewal_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Implant_Maintenance" + }, + + "Remove_Implant_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Remove_Implant" + }, + + "Remove_Implant": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "301807007", + "display": "Removal of subcutaneous contraceptive" + } + ], + "duration": { + "low": 20, + "high": 40, + "unit": "minutes" + }, + "direct_transition": "End_Removal_Encounter" + }, + + "End_Removal_Encounter": { + "type": "EncounterEnd", + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Pregnancy_Guard" + }, + { + "transition": "Terminal" + } + ] + }, + + "Pregnancy_Guard": { + "type": "Guard", + "remarks": [ + "After the pregnancy ends, resume using the implant. From the top..." + ], + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": false + }, + "direct_transition": "Reset_Implant_Contraceptive" + }, + + "Reset_Implant_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/clear_contraceptive", + "direct_transition": "Initial" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/injectable_contraceptive.json b/lib/generic/modules/contraceptives/injectable_contraceptive.json new file mode 100644 index 0000000000..d36dcc998a --- /dev/null +++ b/lib/generic/modules/contraceptives/injectable_contraceptive.json @@ -0,0 +1,364 @@ +{ + "name": "Injectable Contraceptive", + "remarks": [ + "This submodule prescribes a long-acting, injectable contraceptive if one is ", + "available for the current year of the simulation. The first injectable ", + "contraceptive was available in 1992, marketed as Depo-Provera. Depo remains ", + "the only available injectable option in the U.S.", + + "Since injectables must be readministered once every 3 months, this submodule ", + "regularly administers additional doses until the current age bracket is exhausted.", + + "Sources for historical availability: ", + "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", + "http://www.pbs.org/wnet/need-to-know/health/a-brief-history-of-the-birth-control-pill/480/" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 1992 ", + "do not get injectable contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1992 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "injectable", + "direct_transition": "Injectable_Contraceptive_Encounter" + }, + + "Injectable_Contraceptive_Encounter": { + "type": "Encounter", + "remarks": [ + "======================================================================", + " NEW PRESCRIPTION ", + "======================================================================" + ], + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Prescribe_Injectable_Contraceptive" + }, + + "Prescribe_Injectable_Contraceptive": { + "type": "Simple", + "remarks": [ + "Depo-Provera (150 mg/mL MPA) became available in 1992. A lower-dose, ", + "subcutaneous version became available in Dec. 2004 as Depo-SubQ Provera ", + "(104 mg/0.65 mL MPA)." + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2005 + }, + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Depo_Provera" + } + ] + }, + { + "distributions": [ + { + "distribution": 0.7, + "transition": "Prescribe_Depo_Provera" + }, + { + "distribution": 0.3, + "transition": "Prescribe_Depo_SubQ" + } + ] + } + ] + }, + + "Prescribe_Depo_Provera": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1000128", + "display": "1 ML Depo-Provera 150 MG/ML Injection" + } + ], + "direct_transition": "Initial_Injection_By_Physician" + }, + + "Prescribe_Depo_SubQ": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1000158", + "display": "0.65 ML depo-subQ provera 160 MG/ML Prefilled Syringe" + } + ], + "direct_transition": "Initial_Injection_By_Physician" + }, + + "Initial_Injection_By_Physician": { + "type": "Procedure", + "duration": { + "low": 10, + "high": 20, + "unit": "minutes" + }, + "codes": [ + { + "system": "SNOMED-CT", + "code": "76601001", + "display": "Intramuscular injection" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "End_Consultation_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Injectable_Maintenance" + }, + + "Injectable_Maintenance": { + "type": "Guard", + "remarks": [ + "======================================================================", + " ADDITIONAL DOSE(S) ", + "======================================================================", + "Every 3 months an additional dose is given. If the age limit for the current ", + "age bracket is reached, no more additional doses are given." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Initial_Injection_By_Physician", + "within": { "quantity": 3, "unit": "months" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Regular_Contraceptive_Injection", + "within": { "quantity": 3, "unit": "months" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Pregnancy_Guard" + }, + { + "transition": "Continue_Or_Stop" + } + ] + }, + + "Pregnancy_Guard": { + "type": "Guard", + "remarks": [ + "After the pregnancy ends, resume using the injectable. From the top..." + ], + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": false + }, + "direct_transition": "Reset_Injectable_Contraceptive" + }, + + "Reset_Injectable_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/clear_contraceptive", + "direct_transition": "Initial" + }, + + "Continue_Or_Stop": { + "type": "Simple", + "conditional_transition": [ + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + } + ] + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Young_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Terminal" + }, + { + "transition": "Regular_Injection_Encounter" + } + ] + }, + + "Regular_Injection_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Regular_Contraceptive_Injection" + }, + + "Regular_Contraceptive_Injection": { + "type": "Procedure", + "duration": { + "low": 10, + "high": 20, + "unit": "minutes" + }, + "codes": [ + { + "system": "SNOMED-CT", + "code": "76601001", + "display": "Intramuscular injection" + } + ], + "direct_transition": "End_Regular_Injection_Encounter" + }, + + "End_Regular_Injection_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Injectable_Maintenance" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/intrauterine_device.json b/lib/generic/modules/contraceptives/intrauterine_device.json new file mode 100644 index 0000000000..195c235e91 --- /dev/null +++ b/lib/generic/modules/contraceptives/intrauterine_device.json @@ -0,0 +1,591 @@ +{ + "name": "Intrauterine Device", + "remarks": [ + "This submodule prescribes an intrauterine device (IUD) for contraception.", + "FDA approval of IUDs in the U.S. was in 1968. Early designs were flexible ", + "thermoplastic. Copper IUDs were introduced in the 1970's. One IUD in particular ", + "was problematic - the Dalkon Shield caused infections in 200k women and 10 ", + "deaths. It was discontinued in 1974. This caused widespread abandonment and ", + "distrust of IUDs in the 1980's.", + + "Modern IUDs are again becoming popular. They are copper or combine low-dose ", + "hormones with plastic.", + + "Sources for availability: ", + "https://www.wired.com/2011/07/ff_iud/", + "http://kff.org/womens-health-policy/fact-sheet/intrauterine-devices-iuds-access-for-women-in-the-u-s/" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 1968 ", + "do not get IUDs." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1968 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "iud", + "direct_transition": "IUD_Consultation_Encounter" + }, + + "IUD_Consultation_Encounter": { + "type": "Encounter", + "remarks": [ + "======================================================================", + " NEW PRESCRIPTION ", + "======================================================================" + ], + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Prescribe_IUD" + }, + + "Prescribe_IUD": { + "type": "Simple", + "remarks": [ + "Unfortunately, RxNorm codes are not available for: ", + "Lippes Lopp, Safe-T-Coil, Copper 7, Dalkon Shield, or Paragard ", + + "However, the contraceptive_type attribute remains set and the ", + "incidence of pregnancy will reflect that the woman is using an IUD." + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1971 + }, + "distributions": [ + { + "distribution": 0.5, + "transition": "Prescribe_Lippes_Loop" + }, + { + "distribution": 0.5, + "transition": "Prescribe_Safe_T_Coil" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1975 + }, + "distributions": [ + { + "distribution": 0.34, + "transition": "Prescribe_Lippes_Loop" + }, + { + "distribution": 0.33, + "transition": "Prescribe_Safe_T_Coil" + }, + { + "distribution": 0.33, + "transition": "Prescribe_Dalkon_Shield" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1986 + }, + "distributions": [ + { + "distribution": 0.3, + "transition": "Prescribe_Lippes_Loop" + }, + { + "distribution": 0.3, + "transition": "Prescribe_Safe_T_Coil" + }, + { + "distribution": 0.4, + "transition": "Prescribe_Copper_7" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2001 + }, + "remarks": [ + "Because of the Dalkon Shield scare, all IUDs but one (Paragard) ", + "were taken off the market by 1986." + ], + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Paragard" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2015 + }, + "distributions": [ + { + "distribution": 0.4, + "transition": "Prescribe_Paragard" + }, + { + "distribution": 0.6, + "transition": "Prescribe_Mirena" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2016 + }, + "remarks": [ + "Hormonal, plastic IUDs were introduced in 2001." + ], + "distributions": [ + { + "distribution": 0.3, + "transition": "Prescribe_Paragard" + }, + { + "distribution": 0.3, + "transition": "Prescribe_Mirena" + }, + { + "distribution": 0.4, + "transition": "Prescribe_Liletta" + } + ] + }, + { + "distributions": [ + { + "distribution": 0.25, + "transition": "Prescribe_Paragard" + }, + { + "distribution": 0.25, + "transition": "Prescribe_Mirena" + }, + { + "distribution": 0.25, + "transition": "Prescribe_Liletta" + }, + { + "distribution": 0.25, + "transition": "Prescribe_Kyleena" + } + ] + } + ] + }, + + "Prescribe_Lippes_Loop": { + "type": "Simple", + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Safe_T_Coil": { + "type": "Simple", + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Dalkon_Shield": { + "type": "Simple", + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Copper_7": { + "type": "Simple", + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Paragard": { + "type": "Simple", + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Mirena": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "807283", + "display": "Mirena 52 MG Intrauterine System" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Liletta": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1605257", + "display": "Liletta 52 MG Intrauterine System" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "Prescribe_Kyleena": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1856546", + "display": "Kyleena 19.5 MG Intrauterine System" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "End_Consultation_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Delay_For_IUD_Insertion" + }, + + "Delay_For_IUD_Insertion": { + "type": "Delay", + "range": { + "low": 2, + "high": 5, + "unit": "days" + }, + "direct_transition": "Initial_IUD_Insertion_Encounter" + }, + + "Initial_IUD_Insertion_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "IUD_Insertion" + }, + + "IUD_Insertion": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "65200003", + "display": "Insertion of intrauterine contraceptive device" + } + ], + "duration": { + "low": 40, + "high": 70, + "unit": "minutes" + }, + "direct_transition": "End_IUD_Insertion_Encounter" + }, + + "End_IUD_Insertion_Encounter": { + "type": "EncounterEnd", + "direct_transition": "IUD_Lifetime_Guard" + }, + + "IUD_Lifetime_Guard": { + "type": "Guard", + "remarks": [ + "Allow module progression if the IUD's lifetime is up (~4 years) ", + "or if the patient becomes pregnant." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "IUD_Insertion", + "within": { "quantity": 4, "unit": "years" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "IUD_Replacement", + "within": { "quantity": 4, "unit": "years" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Remove_IUD_Encounter" + }, + { + "transition": "Renew_Or_Remove" + } + ] + }, + + "Renew_Or_Remove": { + "type": "Simple", + "conditional_transition": [ + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + } + ] + }, + "transition": "Remove_IUD_Encounter" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Remove_IUD_Encounter" + }, + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "PriorState", + "name": "Young_Contraceptive_Use" + }, + { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mid_Contraceptive_Use" + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Mature_Contraceptive_Use" + } + } + ] + }, + "transition": "Remove_IUD_Encounter" + }, + { + "transition": "Renew_IUD_Encounter" + } + ] + }, + + "Renew_IUD_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "IUD_Replacement" + }, + + "IUD_Replacement": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "46706006", + "display": "Replacement of contraceptive intrauterine device" + } + ], + "duration": { + "low": 40, + "high": 70, + "unit": "minutes" + }, + "direct_transition": "End_IUD_Replacement_Encounter" + }, + + "End_IUD_Replacement_Encounter": { + "type": "EncounterEnd", + "direct_transition": "IUD_Lifetime_Guard" + }, + + "Remove_IUD_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "IUD_Removal" + }, + + "IUD_Removal": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "68254000", + "display": "Removal of intrauterine device" + } + ], + "duration": { + "low": 40, + "high": 70, + "unit": "minutes" + }, + "direct_transition": "End_IUD_Removal_Encounter" + }, + + "End_IUD_Removal_Encounter": { + "type": "EncounterEnd", + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Pregnancy_Guard" + }, + { + "transition": "Terminal" + } + ] + }, + + "Pregnancy_Guard": { + "type": "Guard", + "remarks": [ + "After the pregnancy ends, resume using an IUD. From the top..." + ], + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": false + }, + "direct_transition": "Reset_IUD_Contraceptive" + }, + + "Reset_IUD_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/clear_contraceptive", + "direct_transition": "Initial" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/male_sterilization.json b/lib/generic/modules/contraceptives/male_sterilization.json new file mode 100644 index 0000000000..55b87d2e49 --- /dev/null +++ b/lib/generic/modules/contraceptives/male_sterilization.json @@ -0,0 +1,133 @@ +{ + "name": "Male Sterilization", + "remarks": [ + "This submodule performs a male sterilization procedure. This procedure ", + "is irreversible, and sets 'contraceptive_type' = 'sterilization'. " + ], + "states": { + + "Initial": { + "type": "Initial", + "direct_transition": "Consultation_Encounter" + }, + + "Consultation_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "End_Consultation" + }, + + "End_Consultation": { + "type": "EncounterEnd", + "direct_transition": "Delay_For_Procedure" + }, + + "Delay_For_Procedure": { + "type": "Delay", + "range": { + "low": 1, + "high": 3, + "unit": "weeks" + }, + "direct_transition": "Vasectomy_Encounter" + }, + + "Vasectomy_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "remarks": [ + "Male vasectomies are typically performed right in the doctor's office. ", + "Unlike female sterilization, male sterilization is a relatively simple ", + "procedure." + ], + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Vasectomy" + }, + + "Vasectomy": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "22523008", + "display": "Vasectomy" + } + ], + "duration": { + "low": 1, + "high": 2, + "unit": "hours" + }, + "direct_transition": "Become_Infertile" + }, + + "Become_Infertile": { + "type": "SetAttribute", + "attribute": "infertile", + "value": true, + "direct_transition": "Post_Procedure_Care" + }, + + "Post_Procedure_Care": { + "type": "CarePlanStart", + "codes": [ + { + "system": "SNOMED-CT", + "code": "787301000000101", + "display": "Surgery care management" + } + ], + "activities": [ + { + "system": "SNOMED-CT", + "code": "183051005", + "display": "Recommendation to rest" + }, + { + "system": "SNOMED-CT", + "code": "243077000", + "display": "Recommendation to limit sexual activity" + } + ], + "direct_transition": "End_Vasectomy_Encounter" + }, + + "End_Vasectomy_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Delay_For_Recovery" + }, + + "Delay_For_Recovery": { + "type": "Delay", + "range": { + "low": 1, + "high": 2, + "unit": "weeks" + }, + "direct_transition": "End_Vasectomy_Care" + }, + + "End_Vasectomy_Care": { + "type": "CarePlanEnd", + "careplan": "Post_Procedure_Care", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/oral_contraceptive.json b/lib/generic/modules/contraceptives/oral_contraceptive.json new file mode 100644 index 0000000000..9607a9bddd --- /dev/null +++ b/lib/generic/modules/contraceptives/oral_contraceptive.json @@ -0,0 +1,535 @@ +{ + "name": "Oral Contraceptive", + "remarks": [ + "This module prescribes an oral, hormonal contraceptive if one is available ", + "for the current year of the simulation. There are 2 classes of oral contraceptives: ", + "1. Combination (estrogen, progestin), either monophasic and triphasic ", + "2. Minipill (progestin-only)", + + "Combination pills may be either monophasic (same dosage, all month long) or triphasic ", + "(dosage increases progressively throughout the month). Potential side-effects of oral ", + "contraceptives include nausea, breast tenderness, mood swings, headaches, weight gain, ", + "spotting, and decreased libido. None of these side-effects are currently modeled.", + + "Smoking, especially over the age of 35, significantly increases the risk of: ", + "1. Blood clots (1.6x with minipill, 2x with estrogen) ", + "2. Myocardial Infarction (1.6x) ", + "3. Ischemic Stroke (1.7x) ", + "Source: https://www.ncbi.nlm.nih.gov/pubmedhealth/PMH0079002/", + "No changes were made to the cardiovascular disease module.", + + "Minipill (progestin-only) contraceptives are safe for smokers, those at risk of ", + "heart disease, and new mothers who are breastfeeding. They carry a slightly elevated ", + "risk of ectopic pregnancy, are less effective than combination pills (91 - 99% effective), ", + "and must be taken very consistently to be effective. Source: ", + "http://www.feministcenter.org/en/health-wellness-services/comprehensive-gyn/birth-control-options/birth-control-information/101-mini-pills", + + "The majority of women taking oral contraceptives take the combination pill.", + + "Sources for historical availability: ", + "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", + "http://www.pbs.org/wnet/need-to-know/health/a-brief-history-of-the-birth-control-pill/480/" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 1960 ", + "do not get oral contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1960 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "pill", + "direct_transition": "Encounter_For_Oral_Contraceptive" + }, + + "Encounter_For_Oral_Contraceptive": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Combination_Or_Minipill" + }, + + "Combination_Or_Minipill": { + "type": "Simple", + "remarks": [ + "If the patient has a high BMI (>30), was recently pregnant (w/in 6 months), smokes, ", + "or has high blood pressure (systolic > 130) the minipill is prescribed. Otherwise, a ", + "combination pill is prescribed.", + + "TODO: Check if the patient was recently pregnant. We need a 'Prior Condition', or ", + "'Prior Event' condition to check for this. If the mother is breastfeeding, the ", + "combination pill should not be used." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "smoker", + "operator": "==", + "value": true + }, + { + "condition_type": "Vital Sign", + "vital_sign": "BMI", + "operator": ">", + "value": 30 + }, + { + "condition_type": "Vital Sign", + "vital_sign": "Systolic Blood Pressure", + "operator": ">", + "value": 130 + } + ] + }, + "transition": "Prescribe_Minipill" + }, + { + "transition": "Prescribe_Combination_Pill" + } + ] + }, + + "Prescribe_Minipill": { + "type": "Simple", + "remarks": [ + "======================================================================", + " MINIPILL ", + "======================================================================", + "What type of pill is prescribed (if any) depends on the current year ", + "of the simulation." + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2002 + }, + "remarks": [ + "If before 2002, the patient instead gets prescribed a combination pill.", + "This will have averse affects on that patient's health if they meet one ", + "of the conditions above." + ], + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Combination_Pill" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2003 + }, + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Camila" + } + ] + }, + { + "distributions": [ + { + "distribution": 0.3, + "transition": "Prescribe_Camila" + }, + { + "distribution": 0.3, + "transition": "Prescribe_Errin" + }, + { + "distribution": 0.4, + "transition": "Prescribe_Jolivette" + } + ] + } + ] + }, + + "Prescribe_Camila": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "748962", + "display": "Camila 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Errin": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "831533", + "display": "Errin 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Jolivette": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "757594", + "display": "Jolivette 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Combination_Pill": { + "type": "Simple", + "remarks": [ + "======================================================================", + " COMBINATION PILL ", + "======================================================================", + "What type of pill is prescribed (if any) depends on the current year ", + "of the simulation." + ], + "complex_transition": [ + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1974 + }, + "remarks": [ + "Enovid got FDA approval in May, 1960 for contraceptive use.", + "10mg mestranol/noretynodrel, high-dose hormone pill." + ], + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Enovid" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1988 + }, + "remarks": [ + "Use of the high dose 10mg mestranol/noretynodrel (Enovid) steadily grew. ", + "The first documented case of blood clots (likely in a smoker), were in ", + "1961. Norinyl (norethindrone-ethinyl estradiol) was introduced in 1974." + ], + "distributions": [ + { + "distribution": 0.5, + "transition": "Prescribe_Enovid" + }, + { + "distribution": 0.5, + "transition": "Prescribe_Norinyl" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1989 + }, + "remarks": [ + "Enovid was taken off the market in 1988 in favor of low-dose alternatives." + ], + "distributions": [ + { + "distribution": 1, + "transition": "Prescribe_Norinyl" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 1998 + }, + "remarks": [ + "Ortho-Tri Cyclen was introduced in 1989." + ], + "distributions": [ + { + "distribution": 0.4, + "transition": "Prescribe_Norinyl" + }, + { + "distribution": 0.6, + "transition": "Prescribe_Ortho_Tri_Cyclen" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2003 + }, + "remarks": [ + "Estrostep introduced in 1997, Ortho-Novum 1998 (same composition as Norinyl)." + ], + "distributions": [ + { + "distribution": 0.3, + "transition": "Prescribe_Norinyl" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Ortho_Tri_Cyclen" + }, + { + "distribution": 0.3, + "transition": "Prescribe_Estrostep" + } + ] + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2010 + }, + "remarks": [ + "Trinessa and Seasonique (2003), Yaz (2006)." + ], + "distributions": [ + { + "distribution": 0.2, + "transition": "Prescribe_Ortho_Tri_Cyclen" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Estrostep" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Trinessa" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Seasonique" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Yaz" + } + ] + }, + { + "remarks": [ + "Natazia (2010), Levora (2016)." + ], + "distributions": [ + { + "distribution": 0.2, + "transition": "Prescribe_Trinessa" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Seasonique" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Yaz" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Natazia" + }, + { + "distribution": 0.2, + "transition": "Prescribe_Levora" + } + ] + } + ] + }, + + "Prescribe_Enovid": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "235389", + "display": "Mestranol / Norethynodrel [Enovid]" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Norinyl": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "749882", + "display": "Norinyl 1+50 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Estrostep": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1359133", + "display": "Estrostep Fe 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Ortho_Tri_Cyclen": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "749785", + "display": "Ortho Tri-Cyclen 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Trinessa": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "751905", + "display": "Trinessa 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Seasonique": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "remarks": [ + "These are long-term, low-dose hormones that cause only 4 menstruations per year." + ], + "codes": [ + { + "system": "RxNorm", + "code": "749762", + "display": "Seasonique 91 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Yaz": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "748856", + "display": "Yaz 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Natazia": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "978950", + "display": "Natazia 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "Prescribe_Levora": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "748879", + "display": "Levora 0.15/30 28 Day Pack" + } + ], + "direct_transition": "End_Encounter" + }, + + "End_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/patch_contraceptive.json b/lib/generic/modules/contraceptives/patch_contraceptive.json new file mode 100644 index 0000000000..3554320a55 --- /dev/null +++ b/lib/generic/modules/contraceptives/patch_contraceptive.json @@ -0,0 +1,92 @@ +{ + "name": "Patch Contraceptive", + "remarks": [ + "This module prescribes a hormonal patch if one is available ", + "for the current year of the simulation.", + + "Sources for historical availability: ", + "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", + "http://www.pbs.org/wnet/need-to-know/health/a-brief-history-of-the-birth-control-pill/480/" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 2002 ", + "do not get patch contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2002 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "patch", + "direct_transition": "Patch_Contraceptive_Consultation" + }, + + "Patch_Contraceptive_Consultation": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Prescribe_Xulane" + }, + + "Prescribe_Xulane": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1536586", + "display": "Xulane 150/35 MCG/Day Weekly Transdermal System" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "End_Consultation_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives/ring_contraceptive.json b/lib/generic/modules/contraceptives/ring_contraceptive.json new file mode 100644 index 0000000000..2497950879 --- /dev/null +++ b/lib/generic/modules/contraceptives/ring_contraceptive.json @@ -0,0 +1,90 @@ +{ + "name": "Vaginal Ring Contraceptive", + "remarks": [ + "This submodule prescribes a hormonal contraceptive ring if one ", + "is available for the current year of the simulation. The ring is ", + "inserted into the vagina and may be removed at will, or for short ", + "periods of time during sexual intercourse." + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "Males, pregnant females, and those arriving here before the year 2001 ", + "do not get ring contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Date", + "operator": "<", + "year": 2001 + }, + "transition": "Terminal" + }, + { + "transition": "Set_Contraceptive_Type" + } + ] + }, + + "Set_Contraceptive_Type": { + "type": "SetAttribute", + "attribute": "contraceptive_type", + "value": "ring", + "direct_transition": "Ring_Contraceptive_Consultation" + }, + + "Ring_Contraceptive_Consultation": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "698314001", + "display": "Consultation for treatment" + } + ], + "direct_transition": "Prescribe_Nuvaring" + }, + + "Prescribe_Nuvaring": { + "type": "MedicationOrder", + "assign_to_attribute": "contraceptive", + "codes": [ + { + "system": "RxNorm", + "code": "1367439", + "display": "NuvaRing 0.12/0.015 MG per 24HR 21 Day Vaginal Ring" + } + ], + "direct_transition": "End_Consultation_Encounter" + }, + + "End_Consultation_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/female_reproduction.json b/lib/generic/modules/female_reproduction.json index 8f20110dfa..995751a8f5 100644 --- a/lib/generic/modules/female_reproduction.json +++ b/lib/generic/modules/female_reproduction.json @@ -2,20 +2,17 @@ "name": "Female Reproduction", "remarks": [ "This module models female reproduction from birth to death. Once females ", - "reach reproductive age, this module operates on a monthly cycle. Each month ", + "reach reproductive age, this module operates on a monthly cycle. Each month, ", "a sexually active female has a non-zero chance of becoming pregnant. This ", "chance is greatly reduced by taking a contraceptive.", "If a female becomes pregnant, the monthly cycles are suspended until the ", - "pregnancy terminates. The pregnancy module is responsible for ending any ", - "active contraceptive method once the pregnancy is diagnosed.", - - "The monthly reproductive cycles end once a female reaches menopause, ", - "typically around the age of 50.", + "pregnancy terminates. The monthly reproductive cycles permanently end once ", + "a female reaches menopause at age 50.", "This module of course operates on several assumptions: ", - "2. All females have regular, monthly reproductive cycles (some don't) ", - "4. All females reach menopause at age 50 " + "1. All females have regular, monthly reproductive cycles (some don't) ", + "2. All females reach menopause at age 50 " ], "states": { @@ -37,9 +34,8 @@ "Delay_For_Reproductive_Age": { "type": "Delay", - "range": { - "low": 11, - "high": 14, + "exact": { + "quantity": 14, "unit": "years" }, "direct_transition": "Female_Reproductive_Cycle" @@ -129,107 +125,7 @@ "Sexually_Active": { "type": "Simple", - "remarks": [ - "2 attributes determine the current state of a female's contraceptive use: ", - "1. contraceptive - if not nil, references a contraceptive medication ", - "2. contraceptive_type - if not nil, describes the type of contraceptive in-use ", - - "contraceptive_type may be non-nil even if contraceptive is nil, e.g. for condoms ", - "or primitive contraceptive methods like awareness or withdrawal." - ], - "conditional_transition": [ - { - "remarks": [ - "Not taking a contraceptive of any type." - ], - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "contraceptive", - "operator": "is nil" - }, - { - "condition_type": "Attribute", - "attribute": "contraceptive_type", - "operator": "is nil" - } - ] - }, - "transition": "Unprotected_Incidence" - }, - { - "remarks": [ - "Using a contraceptive type that is not prescribed, e.g. condom." - ], - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "contraceptive", - "operator": "is nil" - }, - { - "condition_type": "Attribute", - "attribute": "contraceptive_type", - "operator": "is not nil" - } - ] - }, - "transition": "Contraceptive_Incidence" - }, - { - "remarks": [ - "Using a contraceptive type that is prescribed, e.g. pill." - ], - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "contraceptive", - "operator": "is not nil" - }, - { - "condition_type": "Attribute", - "attribute": "contraceptive_type", - "operator": "is not nil" - } - ] - }, - "transition": "Active_Contraceptive?" - }, - { - "remarks": [ - "This is an error state where contraceptive is not nil, but no ", - "contraceptive type is specified. In this instance, default to the ", - "unprotected incidence." - ], - "transition": "Unprotected_Incidence" - } - ] - }, - - "Active_Contraceptive?": { - "type": "Simple", - "remarks": [ - "If the contraceptive medication prescribed is inactive, assume the ", - "patient is not taking it and is therefore having unprotected sex." - ], - "conditional_transition": [ - { - "condition": { - "condition_type": "Active Medication", - "referenced_by_attribute": "contraceptive" - }, - "transition": "Contraceptive_Incidence" - }, - { - "transition": "Unprotected_Incidence" - } - ] + "direct_transition": "Contraceptive_Incidence" }, "Contraceptive_Incidence": { @@ -238,13 +134,14 @@ "======================================================================", " CONTACEPTIVE INCIDENCE ", "======================================================================", - "Effectiveness of different prescription contraceptives. The following percentages ", - "indicate the number out of 100 women who experience unplanned pregnancy within ", - "the first year of use. These percentages are scaled for a monthly time step: ", + "Effectiveness of different contraceptive types. The following percentages ", + "indicate the number out of 100 women who experience planned or unplanned ", + "pregnancy within the first year of use. These percentages are scaled for ", + "a monthly time step: ", "| Method | Annual Chance of Pregnancy | Monthly Chance of Pregnancy | ", "|----------------|----------------------------|-----------------------------| ", - "| awareness ** | 24% | 2.26% | ", + "| none | 85% | 19.3% | ", "| withdrawal | 22% | 2.05% | ", "| condom | 18% | 1.640% | ", "| pill | 9% | 0.692% | ", @@ -256,27 +153,43 @@ "| implant | 0.05% | 0.00417% | ", "'---------------------------------------------------------------------------' ", - "** fertility awareness is planning around a woman's ovulation cycle, ", - "obstaining from sex or using a condom during peak fertility.", - "Source: https://www.cdc.gov/reproductivehealth/unintendedpregnancy/pdf/contraceptive_methods_508.pdf" ], "complex_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + }, + "remarks": [ + "contraceptive_type == nil is treated as an error state and ", + "deferred to the next reproductive cycle. This may occur when ", + "the reproductive cycle completes on the same time step as ", + "the contraceptive_type is recomputed." + ], + "distributions": [ + { + "distribution": 1, + "transition": "Next_Reproductive_Cycle" + } + ] + }, { "condition": { "condition_type": "Attribute", "attribute": "contraceptive_type", "operator": "==", - "value": "awareness" + "value": "none" }, "distributions": [ { - "distribution": 0.0226, + "distribution": 0.193, "transition": "Potentially_Pregnant" }, { - "distribution": 0.9774, + "distribution": 0.807, "transition": "Next_Reproductive_Cycle" } ] @@ -446,20 +359,6 @@ ] }, - "Unprotected_Incidence": { - "type": "Simple", - "distributed_transition": [ - { - "distribution": 0.193, - "transition": "Potentially_Pregnant" - }, - { - "distribution": 0.817, - "transition": "Next_Reproductive_Cycle" - } - ] - }, - "Not_Sexually_Active": { "type": "Simple", "direct_transition": "Next_Reproductive_Cycle" diff --git a/lib/generic/modules/pregnancy.json b/lib/generic/modules/pregnancy.json index d77f4cbe7c..7822c78022 100644 --- a/lib/generic/modules/pregnancy.json +++ b/lib/generic/modules/pregnancy.json @@ -1,13 +1,11 @@ { "name": "Pregnancy", "remarks": [ - "Most of the statistics in this module come from the CDC. It's difficult to find very", - "recent statistics for pregnancy - they simply haven't been compiled yet. The latest", - "comprehensive stats I could find for the United States were from 2010, compiled by the", - "CDC in 2013, see: http://www.cdc.gov/nchs/data/hestat/pregnancy/2010_pregnancy_rates.htm.", - "Although the birth rate in the United States is still declining these statistics are still", - "consistent (< 1 percentage point difference) with some 2014 statistics collected by", - "the Guttmacher Institute, see: https://www.guttmacher.org/fact-sheet/induced-abortion-united-states.", + "Whenever a female becomes pregnant, the 'pregnant' attribute is set to true ", + "by the Female Reproduction module. The likelihood of becoming pregnant is ", + "determined by a wide variety of factors including age, sexual activity, ", + "and contraceptive use.", + "Some notable complications NOT modeled in this module:", "1. Maternal death (very low incidence in developed countries)", "2. Gestational diabetes (because of the complex interplay with the diabetes module)", @@ -23,131 +21,35 @@ "condition_type": "Gender", "gender": "F" }, - "transition": "Wait_For_Maturity" - }, - { - "transition": "Terminal" - } - ] - }, - - "Wait_For_Maturity": { - "type": "Delay", - "exact": { - "quantity": 15, - "unit": "years" - }, - "direct_transition": "Wellness_Visit" - }, - - "Wellness_Visit": { - "type": "Encounter", - "wellness": true, - "remarks": [ - "======================================================================", - " INCIDENCE ", - "======================================================================", - "From the U.S. Census: https://www.census.gov/content/dam/Census/library/publications/2014/demo/p20-575.pdf ", - "Of women age 15 - 50 about 59% are mothers. 17.2% had one child, 23.1% had two, and 18.5% had 3 or more. ", - "About 11% of women are infertile." - ], - "distributed_transition": [ - { - "distribution": 0.11, - "transition": "Is_Infertile", - "remarks": [ - "Source: https://www.asrm.org/detail.aspx?id=2322 (CDC)" - ] + "transition": "Initially_Not_Pregnant" }, { - "distribution": 0.588, - "transition": "Distribute_Number_Of_Children" - }, - { - "distribution": 0.312, "transition": "Terminal" } ] }, - "Is_Infertile": { - "type": "ConditionOnset", - "target_encounter": "Wellness_Visit", - "codes": [ - { - "system": "SNOMED-CT", - "code": "6738008", - "display": "Female infertility" - } - ], - "direct_transition": "Terminal" - }, - - "Distribute_Number_Of_Children": { - "type": "Simple", - "remarks": [ - "To match the CDC statistics for the number of children mothers typically have, we start the ", - "'pregnancy_iterator' at different values." - ], - "distributed_transition": [ - { - "distribution": 0.293, - "transition": "Will_Have_One_Child" - }, - { - "distribution": 0.393, - "transition": "Will_Have_Two_Children" - }, - { - "distribution": 0.314, - "transition": "Will_Have_Three_Or_More_Children" - } - ] - }, - - "Will_Have_One_Child": { + "Initially_Not_Pregnant": { "type": "SetAttribute", - "attribute": "pregnancy_iterator", - "value": 4, - "remarks": [ - "This leaves the mother with 3 remaining passes through the pregnancy module (out of 7 total). ", - "Additional passes account for potential miscarriages or abortions." - ], - "direct_transition": "Wait_For_First_Conception" + "attribute": "pregnant", + "value": false, + "direct_transition": "Initially_No_Children" }, - "Will_Have_Two_Children": { + "Initially_No_Children": { "type": "SetAttribute", - "attribute": "pregnancy_iterator", - "value": 2, - "remarks": [ - "This leaves the mother with 5 remaining passes through the pregnancy module (out of 7 total). ", - "Additional passes account for potential miscarriages or abortions." - ], - "direct_transition": "Wait_For_First_Conception" - }, - - "Will_Have_Three_Or_More_Children": { - "type": "SetAttribute", - "attribute": "pregnancy_iterator", + "attribute": "number_of_children", "value": 0, - "remarks": [ - "This leaves the mother with 7 remaining passes through the pregnancy module (out of 7 total). ", - "Additional passes account for potential miscarriages or abortions." - ], - "direct_transition": "Wait_For_First_Conception" + "direct_transition": "Become_Pregnant_Guard" }, - "Wait_For_First_Conception": { - "type": "Delay", - "remarks": [ - "After establishing fertility we wait for 1-20 years (between age 16 and 35) ", - "for the first pregnancy to occur." - ], - "range": { - "low": 1, - "high": 20, - "unit": "years" + "Become_Pregnant_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true }, "direct_transition": "Become_Pregnant" }, @@ -1279,11 +1181,16 @@ }, "Normal_Pregnancy_Completion": { - "type": "Simple", + "type": "Counter", + "action": "increment", + "attribute": "number_of_children", "remarks": [ "======================================================================", " PREGNANCY COMPLETION ", - "======================================================================" + "======================================================================", + + "A pregnancy resulting in live birth increments the 'number_of_children' ", + "counter. This allows us to track how many children are born to each mother." ], "conditional_transition": [ { @@ -1326,60 +1233,14 @@ "Pregnancy_Ends": { "type": "ConditionEnd", "condition_onset": "Become_Pregnant", - "direct_transition": "Potential_For_Another_Pregnancy" - }, - - "Potential_For_Another_Pregnancy": { - "type": "Simple", - "conditional_transition": [ - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "pregnancy_iterator", - "operator": "<", - "value": 7, - "remarks": [ - "We use 7 as a hard limit. Given the probabilities of miscarriage and abortion ", - "if a woman goes through the module all 7 times we expect 3-4 pregnancies." - ] - }, - { - "condition_type": "Age", - "operator": "<", - "quantity": 50, - "unit": "years" - } - ] - }, - "transition": "Wait_For_Next_Conception" - }, - { - "transition": "Terminal", - "remarks": [ - "That's all folks..." - ] - } - ] + "direct_transition": "Unset_Pregnant_Attribute" }, - "Wait_For_Next_Conception": { - "type": "Delay", - "range": { - "low": 1, - "high": 5, - "unit": "years" - }, - "direct_transition": "Increment_Pregnancy_Count" - }, - - "Increment_Pregnancy_Count": { - "type": "Counter", - "action": "increment", - "attribute": "pregnancy_iterator", - "direct_transition": "Become_Pregnant" + "Unset_Pregnant_Attribute": { + "type": "SetAttribute", + "attribute": "pregnant", + "value": false, + "direct_transition": "Become_Pregnant_Guard" }, "Terminal": { diff --git a/lib/generic/modules/sexual_activity.json b/lib/generic/modules/sexual_activity.json index 8ef1547b05..b47b50f954 100644 --- a/lib/generic/modules/sexual_activity.json +++ b/lib/generic/modules/sexual_activity.json @@ -1,29 +1,18 @@ { "name": "Sexual Activity", "remarks": [ - "This module models the sexual activity of males and females, from puberty ", + "This module models the sexual activity of males and females from puberty ", "to old age. Most of the incidence in this module is based on a recent study ", "from Indiana University: http://www.nationalsexstudy.indiana.edu/graph.html", - "Omitting the male sexual incidence since male sexual activity does not, ", - "at present, influence any other module." + "This module operates on the assumption that these incidences for human sexual ", + "activity have remained similar throughout modern history." ], "states": { "Initial": { "type": "Initial", - "conditional_transition": [ - { - "condition": { - "condition_type": "Gender", - "gender": "F" - }, - "transition": "Initially_Inactive" - }, - { - "transition": "Terminal" - } - ] + "direct_transition": "Initially_Inactive" }, "Initially_Inactive": { @@ -39,24 +28,39 @@ "Delay_For_Sexual_Activity": { "type": "Delay", "remarks": [ - "There is no data on female sexual activity before the age of 14." + "There is no data on sexual activity before the age of 14." ], "exact": { "quantity": 14, "unit": "years" }, - "direct_transition": "Female_Sexual_Activity" + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Male_Sexual_Activity" + }, + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Female_Sexual_Activity" + } + ] }, "Female_Sexual_Activity": { "type": "Delay", "remarks": [ - "Female sexual activity is now modelled on a yearly basis, to match ", - "the Indiana University study. In the future, this may be scaled to a ", - "monthly incidence to match the female reproductive cycle.", - - "The incidence used here matches the percentage of 'Vaginal Intercourse' ", - "for women in the chart." + "======================================================================", + " FEMALE SEXUAL ACTIVITY ", + "======================================================================", + "Sexual activity is modeled on a yearly basis, matching the Indiana University ", + "study. The incidences used here match the 'Vaginal Intercourse' numbers from ", + "the study." ], "exact": { "quantity": 1, @@ -73,11 +77,11 @@ "distributions": [ { "distribution": 0.11, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.89, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -91,11 +95,11 @@ "distributions": [ { "distribution": 0.30, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.70, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -109,11 +113,11 @@ "distributions": [ { "distribution": 0.62, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.38, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -127,11 +131,11 @@ "distributions": [ { "distribution": 0.80, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.20, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -145,11 +149,11 @@ "distributions": [ { "distribution": 0.87, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.13, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -163,11 +167,11 @@ "distributions": [ { "distribution": 0.74, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.26, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -181,11 +185,11 @@ "distributions": [ { "distribution": 0.70, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.30, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -199,11 +203,11 @@ "distributions": [ { "distribution": 0.51, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.49, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -217,11 +221,11 @@ "distributions": [ { "distribution": 0.42, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.58, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" } ] }, @@ -235,29 +239,259 @@ "distributions": [ { "distribution": 0.22, - "transition": "Female_Sexually_Active" + "transition": "Sexually_Active" }, { "distribution": 0.78, - "transition": "Female_Not_Sexually_Active" + "transition": "Not_Sexually_Active" + } + ] + } + ] + }, + + "Male_Sexual_Activity": { + "type": "Delay", + "remarks": [ + "======================================================================", + " MALE SEXUAL ACTIVITY ", + "======================================================================", + "Also matching the 'Vaginal Intercourse' numbers from the study." + ], + "exact": { + "quantity": 1, + "unit": "years" + }, + "complex_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 16, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.09, + "transition": "Sexually_Active" + }, + { + "distribution": 0.91, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 18, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.30, + "transition": "Sexually_Active" + }, + { + "distribution": 0.70, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 20, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.53, + "transition": "Sexually_Active" + }, + { + "distribution": 0.47, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 25, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.63, + "transition": "Sexually_Active" + }, + { + "distribution": 0.37, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 30, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.86, + "transition": "Sexually_Active" + }, + { + "distribution": 0.14, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 40, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.85, + "transition": "Sexually_Active" + }, + { + "distribution": 0.15, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 50, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.74, + "transition": "Sexually_Active" + }, + { + "distribution": 0.26, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 60, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.58, + "transition": "Sexually_Active" + }, + { + "distribution": 0.42, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": "<", + "quantity": 70, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.54, + "transition": "Sexually_Active" + }, + { + "distribution": 0.46, + "transition": "Not_Sexually_Active" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 70, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.43, + "transition": "Sexually_Active" + }, + { + "distribution": 0.57, + "transition": "Not_Sexually_Active" } ] } ] }, - "Female_Sexually_Active": { + "Sexually_Active": { "type": "SetAttribute", "attribute": "sexually_active", "value": true, - "direct_transition": "Female_Sexual_Activity" + "direct_transition": "Old_Age_Check" }, - "Female_Not_Sexually_Active": { + "Not_Sexually_Active": { "type": "SetAttribute", "attribute": "sexually_active", "value": false, - "direct_transition": "Female_Sexual_Activity" + "direct_transition": "Old_Age_Check" + }, + + "Old_Age_Check": { + "type": "Simple", + "remarks": [ + "Once patients reach 70+ years old, their sexual activity no longer changes.", + "Those who are still sexually active at 70 years old stay that way ;). Most will ", + "remain sexually inactive for the rest of their lives :| ." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 70, + "unit": "years" + }, + "transition": "Terminal" + }, + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Male_Sexual_Activity" + }, + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Female_Sexual_Activity" + } + ] }, "Terminal": { diff --git a/lib/tasks/graphviz.rb b/lib/tasks/graphviz.rb index 9ab4e75b67..3460226291 100644 --- a/lib/tasks/graphviz.rb +++ b/lib/tasks/graphviz.rb @@ -455,7 +455,12 @@ def self.logicDetails(logic) when 'Symptom' "Symptom: '#{logic['symptom']}' \\#{logic['operator']} #{logic['value']}\\l" when 'PriorState' - "state '#{logic['name']}' has been processed\\l" + within = logic['within'] + if within + "state '#{logic['name']}' has been processed within #{within['quantity']} #{within['unit']}\\l" + else + "state '#{logic['name']}' has been processed\\l" + end when 'Attribute' "Attribute: '#{logic['attribute']}' \\#{logic['operator']} #{logic['value']}\\l" when 'Observation' From 87872a7b499999ef180203d69e02f03458235bd8 Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Wed, 19 Apr 2017 10:57:12 -0400 Subject: [PATCH 3/6] Added model of natural infertility 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. --- lib/generic/modules/female_reproduction.json | 27 ++--- lib/generic/modules/infertility.json | 106 +++++++++++++++++++ 2 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 lib/generic/modules/infertility.json diff --git a/lib/generic/modules/female_reproduction.json b/lib/generic/modules/female_reproduction.json index 995751a8f5..89d998e4df 100644 --- a/lib/generic/modules/female_reproduction.json +++ b/lib/generic/modules/female_reproduction.json @@ -108,6 +108,15 @@ "set by the 'sexual_activity' module." ], "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "infertile", + "operator": "==", + "value": true + }, + "transition": "Terminal" + }, { "condition": { "condition_type": "Attribute", @@ -366,23 +375,7 @@ "Potentially_Pregnant": { "type": "Simple", - "remarks": [ - "Unless the female is infertile, she will become pregnant." - ], - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "infertile", - "operator": "==", - "value": true - }, - "transition": "Next_Reproductive_Cycle" - }, - { - "transition": "Become_Pregnant" - } - ] + "direct_transition": "Become_Pregnant" }, "Become_Pregnant": { diff --git a/lib/generic/modules/infertility.json b/lib/generic/modules/infertility.json new file mode 100644 index 0000000000..19e2353ddb --- /dev/null +++ b/lib/generic/modules/infertility.json @@ -0,0 +1,106 @@ +{ + "name": "Infertility", + "remarks": [ + "The chance of infertility (independent of sterilization) increases significantly with age.", + "Impaired fecundity affects 8% percent of women aged 15-29, increasing to 30.2 percent of ", + "women aged 40-44. Source: ", + "https://mchb.hrsa.gov/chusa13/perinatal-risk-factors-behaviors/p/impaired-fecundity-infertility-services.html" + ], + "states": { + + "Initial": { + "type": "Initial", + "remarks": [ + "At present, only female infertility is modeled." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "F" + }, + "transition": "Female_Infertility_Incidence" + }, + { + "transition": "Terminal" + } + ] + }, + + "Female_Infertility_Incidence": { + "type": "Simple", + "remarks": [ + "A minority of females are infertile from birth, but many more become infertile ", + "as they age. The majority will remain fertile until menopause." + ], + "distributed_transition": [ + { + "distribution": 0.08, + "transition": "Infertile_From_Birth" + }, + { + "distribution": 0.089, + "transition": "Delay_Until_Early_30s" + }, + { + "distribution": 0.096, + "transition": "Delay_Until_Late_30s" + }, + { + "distribution": 0.037, + "transition": "Delay_Until_40s" + }, + { + "distribution": 0.698, + "transition": "Terminal" + } + ] + }, + + "Infertile_From_Birth": { + "type": "Simple", + "direct_transition": "Infertile" + }, + + "Delay_Until_Early_30s": { + "type": "Delay", + "range": { + "low": 30, + "high": 34, + "unit": "years" + }, + "direct_transition": "Infertile" + }, + + "Delay_Until_Late_30s": { + "type": "Delay", + "range": { + "low": 35, + "high": 39, + "unit": "years" + }, + "direct_transition": "Infertile" + }, + + "Delay_Until_40s": { + "type": "Delay", + "range": { + "low": 40, + "high": 49, + "unit": "years" + }, + "direct_transition": "Infertile" + }, + + "Infertile": { + "type": "SetAttribute", + "attribute": "infertile", + "value": true, + "direct_transition": "Terminal" + }, + + "Terminal": { + "type": "Terminal" + } + } +} From b350879d6d3cb2c2ae4ae0f113c98bf8adef4911 Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Thu, 20 Apr 2017 13:46:07 -0400 Subject: [PATCH 4/6] Updates, tweaks, and fixes --- .../modules/contraceptive_maintenance.json | 491 ++++++++++++++++++ lib/generic/modules/contraceptives.json | 167 ++++-- .../contraceptives/clear_contraceptive.json | 26 +- .../contraceptives/implant_contraceptive.json | 245 +-------- .../injectable_contraceptive.json | 198 +------ .../contraceptives/intrauterine_device.json | 243 +-------- lib/generic/modules/female_reproduction.json | 25 +- lib/generic/modules/infertility.json | 106 ---- lib/generic/modules/pregnancy.json | 210 ++++++-- lib/world/sequential.rb | 9 + 10 files changed, 834 insertions(+), 886 deletions(-) create mode 100644 lib/generic/modules/contraceptive_maintenance.json delete mode 100644 lib/generic/modules/infertility.json diff --git a/lib/generic/modules/contraceptive_maintenance.json b/lib/generic/modules/contraceptive_maintenance.json new file mode 100644 index 0000000000..1021cfcc51 --- /dev/null +++ b/lib/generic/modules/contraceptive_maintenance.json @@ -0,0 +1,491 @@ +{ + "name": "Contraceptive Maintenance", + "remarks": [ + "Three types of contraceptives require periodic renewal to be effective: ", + "1. 'iud' - requires replacement every 5-10 years ", + "2. 'implant' - requires replacement every 3-4 years ", + "3. 'injectable' - requires another injection every 3 months ", + + "Each of these contraceptives is initially implanted/injected by the prescribing ", + "submodule. Subsequent renewal or removal of these contraceptives is handled ", + "by this maintenance module.", + + "Contraceptive maintenance automatically cancelled if either: ", + "1. 'pregnant' == true ", + "2. 'contraceptive_type' == nil " + ], + "states": { + + "Initial": { + "type": "Initial", + "conditional_transition": [ + { + "condition": { + "condition_type": "Gender", + "gender": "M" + }, + "transition": "Terminal" + }, + { + "transition": "Contraceptive_Type_Guard" + } + ] + }, + + "Clear_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/clear_contraceptive", + "direct_transition": "Contraceptive_Type_Guard" + }, + + "Contraceptive_Type_Guard": { + "type": "Guard", + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "iud" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "implant" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "injectable" + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "iud" + }, + "transition": "IUD_Maintenance" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "implant" + }, + "transition": "Implant_Maintenance" + }, + { + "condition": { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "==", + "value": "injectable" + }, + "transition": "Injectable_Maintenance" + } + ] + }, + + "IUD_Maintenance": { + "type": "Guard", + "remarks": [ + "======================================================================", + " IUD CONTRACEPTIVE MAINTENANCE ", + "======================================================================", + "Allow module progression if the IUD's lifetime is up (~4 years) ", + "or if the patient becomes pregnant." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Contraceptive_Type_Guard", + "within": { "quantity": 5, "unit": "years" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "IUD_Replacement", + "within": { "quantity": 5, "unit": "years" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + } + ] + }, + "transition": "Remove_IUD_Encounter" + }, + { + "transition": "Renew_IUD_Encounter" + } + ] + }, + + "Renew_IUD_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "IUD_Replacement" + }, + + "IUD_Replacement": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "46706006", + "display": "Replacement of contraceptive intrauterine device" + } + ], + "duration": { + "low": 40, + "high": 70, + "unit": "minutes" + }, + "direct_transition": "End_IUD_Replacement_Encounter" + }, + + "End_IUD_Replacement_Encounter": { + "type": "EncounterEnd", + "direct_transition": "IUD_Maintenance" + }, + + "Remove_IUD_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "IUD_Removal" + }, + + "IUD_Removal": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "68254000", + "display": "Removal of intrauterine device" + } + ], + "duration": { + "low": 40, + "high": 70, + "unit": "minutes" + }, + "direct_transition": "End_IUD_Removal_Encounter" + }, + + "End_IUD_Removal_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Clear_Contraceptive" + }, + + "Implant_Maintenance": { + "type": "Guard", + "remarks": [ + "======================================================================", + " IMPLANT CONTRACEPTIVE MAINTENANCE ", + "======================================================================", + "Every 3-4 years the implant must be removed or replaced." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Contraceptive_Type_Guard", + "within": { "quantity": 4, "unit": "years" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Renew_Contraceptive_Implant", + "within": { "quantity": 4, "unit": "years" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + } + ] + }, + "transition": "Remove_Implant_Encounter" + }, + { + "transition": "Renew_Implant_Encounter" + } + ] + }, + + "Renew_Implant_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Renew_Contraceptive_Implant" + }, + + "Renew_Contraceptive_Implant": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "755621000000101", + "display": "Replacement of subcutaneous contraceptive" + } + ], + "duration": { + "low": 20, + "high": 40, + "unit": "minutes" + }, + "direct_transition": "End_Renew_Implant_Encounter" + }, + + "End_Renew_Implant_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Implant_Maintenance" + }, + + "Remove_Implant_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Remove_Implant" + }, + + "Remove_Implant": { + "type": "Procedure", + "codes": [ + { + "system": "SNOMED-CT", + "code": "301807007", + "display": "Removal of subcutaneous contraceptive" + } + ], + "duration": { + "low": 20, + "high": 40, + "unit": "minutes" + }, + "direct_transition": "End_Remove_Implant_Encounter" + }, + + "End_Remove_Implant_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Clear_Contraceptive" + }, + + "Injectable_Maintenance": { + "type": "Guard", + "remarks": [ + "======================================================================", + " INJECTABLE CONTRACEPTIVE MAINTENANCE ", + "======================================================================", + "Every 3 months an additional dose is given. If the age limit for the current ", + "age bracket is reached, no more additional doses are given." + ], + "allow": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + }, + { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Contraceptive_Type_Guard", + "within": { "quantity": 3, "unit": "months" } + } + }, + { + "condition_type": "Not", + "condition": { + "condition_type": "PriorState", + "name": "Regular_Injection_Encounter", + "within": { "quantity": 3, "unit": "months" } + } + } + ] + } + ] + }, + "conditional_transition": [ + { + "condition": { + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + } + ] + }, + "transition": "Clear_Contraceptive" + }, + { + "transition": "Regular_Injection_Encounter" + } + ] + }, + + "Regular_Injection_Encounter": { + "type": "Encounter", + "encounter_class": "outpatient", + "codes": [ + { + "system": "SNOMED-CT", + "code": "308335008", + "display": "Patient encounter procedure" + } + ], + "direct_transition": "Regular_Contraceptive_Injection" + }, + + "Regular_Contraceptive_Injection": { + "type": "Procedure", + "duration": { + "low": 10, + "high": 20, + "unit": "minutes" + }, + "codes": [ + { + "system": "SNOMED-CT", + "code": "76601001", + "display": "Intramuscular injection" + } + ], + "direct_transition": "End_Regular_Injection_Encounter" + }, + + "End_Regular_Injection_Encounter": { + "type": "EncounterEnd", + "direct_transition": "Injectable_Maintenance" + }, + + "Terminal": { + "type": "Terminal" + } + } +} diff --git a/lib/generic/modules/contraceptives.json b/lib/generic/modules/contraceptives.json index 8419484677..05b2aa8cd7 100644 --- a/lib/generic/modules/contraceptives.json +++ b/lib/generic/modules/contraceptives.json @@ -154,6 +154,9 @@ "unit": "years" }, "transition": "Mature_Contraceptive_Use" + }, + { + "transition": "Terminal" } ] }, @@ -334,27 +337,27 @@ ], "attribute": "contraceptive_type", "value": "none", - "direct_transition": "Not_Guarded" + "direct_transition": "Route_To_Guard" }, "Using_Withdrawal": { "type": "SetAttribute", "attribute": "contraceptive_type", "value": "withdrawal", - "direct_transition": "Not_Guarded" - }, - - "Using_Oral_Contraceptive": { - "type": "CallSubmodule", - "submodule": "contraceptives/oral_contraceptive", - "direct_transition": "Not_Guarded" + "direct_transition": "Route_To_Guard" }, "Using_Condom_Only": { "type": "SetAttribute", "attribute": "contraceptive_type", "value": "condom", - "direct_transition": "Not_Guarded" + "direct_transition": "Route_To_Guard" + }, + + "Using_Oral_Contraceptive": { + "type": "CallSubmodule", + "submodule": "contraceptives/oral_contraceptive", + "direct_transition": "Contraceptive_Prescribed?" }, "Using_Sterilization": { @@ -385,7 +388,7 @@ ], "attribute": "contraceptive_type", "value": "sterilization", - "direct_transition": "Not_Guarded" + "direct_transition": "Route_To_Guard" }, "Using_Female_Sterilization": { @@ -397,13 +400,13 @@ "Using_Ring": { "type": "CallSubmodule", "submodule": "contraceptives/ring_contraceptive", - "direct_transition": "Not_Guarded" + "direct_transition": "Contraceptive_Prescribed?" }, "Using_Patch": { "type": "CallSubmodule", "submodule": "contraceptives/patch_contraceptive", - "direct_transition": "Not_Guarded" + "direct_transition": "Contraceptive_Prescribed?" }, "Using_IUD": { @@ -422,29 +425,75 @@ "(since they do so internally)." ], "submodule": "contraceptives/intrauterine_device", - "direct_transition": "Self_Guarded" + "direct_transition": "Contraceptive_Prescribed?" }, "Using_Implant": { "type": "CallSubmodule", "submodule": "contraceptives/implant_contraceptive", - "direct_transition": "Self_Guarded" + "direct_transition": "Contraceptive_Prescribed?" }, "Using_Injectable": { "type": "CallSubmodule", "submodule": "contraceptives/injectable_contraceptive", - "direct_transition": "Self_Guarded" + "direct_transition": "Contraceptive_Prescribed?" }, - "Self_Guarded": { + "Contraceptive_Prescribed?": { "type": "Simple", - "direct_transition": "Reset_Contraceptive_Use" + "remarks": [ + "If a contraceptive wasn't prescribed by the submodule (for example, because ", + "none was available for the current year of the simulation) both contraceptive ", + "attributes will be nill. ", + + "Since no contraceptive was prescribed, default to the historically avaialable ", + "set of contraceptives." + ], + "conditional_transition": [ + { + "condition": { + "condition_type": "And", + "conditions": [ + { + "condition_type": "Attribute", + "attribute": "contraceptive", + "operator": "is nil" + }, + { + "condition_type": "Attribute", + "attribute": "contraceptive_type", + "operator": "is nil" + } + ] + }, + "transition": "Historical_Contraceptive_Use" + }, + { + "transition": "Route_To_Guard" + } + ] }, - "Not_Guarded": { + "Historical_Contraceptive_Use": { "type": "Simple", - "direct_transition": "Route_To_Guard" + "remarks": [ + "These were available methods prior to the 1960's." + ], + "distributed_transition": [ + { + "distribution": 0.2, + "transition": "Using_No_Contraceptive" + }, + { + "distribution": 0.4, + "transition": "Using_Withdrawal" + }, + { + "distribution": 0.4, + "transition": "Using_Condom_Only" + } + ] }, "Route_To_Guard": { @@ -484,10 +533,21 @@ "Young_To_Mid_Guard": { "type": "Guard", "allow": { - "condition_type": "Age", - "operator": ">=", - "quantity": 25, - "unit": "years" + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + } + ] }, "direct_transition": "Reset_Contraceptive_Use" }, @@ -495,10 +555,21 @@ "Mid_To_Mature_Guard": { "type": "Guard", "allow": { - "condition_type": "Age", - "operator": ">=", - "quantity": 35, - "unit": "years" + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + } + ] }, "direct_transition": "Reset_Contraceptive_Use" }, @@ -506,10 +577,21 @@ "Menopause_Guard": { "type": "Guard", "allow": { - "condition_type": "Age", - "operator": ">=", - "quantity": 50, - "unit": "years" + "condition_type": "Or", + "conditions": [ + { + "condition_type": "Age", + "operator": ">=", + "quantity": 50, + "unit": "years" + }, + { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + } + ] }, "direct_transition": "Reset_Contraceptive_Use" }, @@ -522,6 +604,15 @@ ], "submodule": "contraceptives/clear_contraceptive", "conditional_transition": [ + { + "condition": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": true + }, + "transition": "Pregnant_Guard" + }, { "condition": { "condition_type": "Age", @@ -537,6 +628,20 @@ ] }, + "Pregnant_Guard": { + "type": "Guard", + "remarks": [ + "Once a female is no longer pregnant, she will re-select a contraceptive type." + ], + "allow": { + "condition_type": "Attribute", + "attribute": "pregnant", + "operator": "==", + "value": false + }, + "direct_transition": "Female_Contraceptive_Use" + }, + "Menopause_Reached": { "type": "Simple", "direct_transition": "Terminal" diff --git a/lib/generic/modules/contraceptives/clear_contraceptive.json b/lib/generic/modules/contraceptives/clear_contraceptive.json index cf17a260e4..32c0b3b3bf 100644 --- a/lib/generic/modules/contraceptives/clear_contraceptive.json +++ b/lib/generic/modules/contraceptives/clear_contraceptive.json @@ -14,6 +14,10 @@ "Clear_Contraceptive_Med": { "type": "Simple", + "remarks": [ + "If the 'contraceptive' attribute is currently set, the medication it ", + "references will be active." + ], "conditional_transition": [ { "condition": { @@ -21,22 +25,6 @@ "attribute": "contraceptive", "operator": "is not nil" }, - "transition": "Active_Medication_Check" - }, - { - "transition": "Clear_Contraceptive_Type" - } - ] - }, - - "Active_Medication_Check": { - "type": "Simple", - "conditional_transition": [ - { - "condition": { - "condition_type": "Active Medication", - "referenced_by_attribute": "contraceptive" - }, "transition": "End_Contraceptive_Med" }, { @@ -48,6 +36,12 @@ "End_Contraceptive_Med": { "type": "MedicationEnd", "referenced_by_attribute": "contraceptive", + "direct_transition": "Clear_Contraceptive" + }, + + "Clear_Contraceptive": { + "type": "SetAttribute", + "attribute": "contraceptive", "direct_transition": "Clear_Contraceptive_Type" }, diff --git a/lib/generic/modules/contraceptives/implant_contraceptive.json b/lib/generic/modules/contraceptives/implant_contraceptive.json index efb4d6bc17..e352551edf 100644 --- a/lib/generic/modules/contraceptives/implant_contraceptive.json +++ b/lib/generic/modules/contraceptives/implant_contraceptive.json @@ -203,250 +203,7 @@ "End_Initial_Encounter": { "type": "EncounterEnd", - "direct_transition": "Implant_Maintenance" - }, - - "Implant_Maintenance": { - "type": "Guard", - "remarks": [ - "======================================================================", - " ADDITIONAL DOSE(S) ", - "======================================================================", - "Every 3-4 years the implant must be removed or replaced." - ], - "allow": { - "condition_type": "Or", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Initial_Implant", - "within": { "quantity": 4, "unit": "years" } - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Renew_Contraceptive_Implant", - "within": { "quantity": 4, "unit": "years" } - } - } - ] - } - ] - }, - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - "transition": "Remove_Implant_Encounter" - }, - { - "transition": "Continue_Or_Stop" - } - ] - }, - - "Continue_Or_Stop": { - "type": "Simple", - "conditional_transition": [ - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 50, - "unit": "years" - } - ] - }, - "transition": "Remove_Implant_Encounter" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 35, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Remove_Implant_Encounter" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Young_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 25, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Remove_Implant_Encounter" - }, - { - "transition": "Renew_Implant_Encounter" - } - ] - }, - - "Renew_Implant_Encounter": { - "type": "Encounter", - "encounter_class": "outpatient", - "codes": [ - { - "system": "SNOMED-CT", - "code": "308335008", - "display": "Patient encounter procedure" - } - ], - "direct_transition": "Renew_Contraceptive_Implant" - }, - - "Renew_Contraceptive_Implant": { - "type": "Procedure", - "codes": [ - { - "system": "SNOMED-CT", - "code": "755621000000101", - "display": "Replacement of subcutaneous contraceptive" - } - ], - "duration": { - "low": 20, - "high": 40, - "unit": "minutes" - }, - "direct_transition": "End_Renewal_Encounter" - }, - - "End_Renewal_Encounter": { - "type": "EncounterEnd", - "direct_transition": "Implant_Maintenance" - }, - - "Remove_Implant_Encounter": { - "type": "Encounter", - "encounter_class": "outpatient", - "codes": [ - { - "system": "SNOMED-CT", - "code": "308335008", - "display": "Patient encounter procedure" - } - ], - "direct_transition": "Remove_Implant" - }, - - "Remove_Implant": { - "type": "Procedure", - "codes": [ - { - "system": "SNOMED-CT", - "code": "301807007", - "display": "Removal of subcutaneous contraceptive" - } - ], - "duration": { - "low": 20, - "high": 40, - "unit": "minutes" - }, - "direct_transition": "End_Removal_Encounter" - }, - - "End_Removal_Encounter": { - "type": "EncounterEnd", - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - "transition": "Pregnancy_Guard" - }, - { - "transition": "Terminal" - } - ] - }, - - "Pregnancy_Guard": { - "type": "Guard", - "remarks": [ - "After the pregnancy ends, resume using the implant. From the top..." - ], - "allow": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": false - }, - "direct_transition": "Reset_Implant_Contraceptive" - }, - - "Reset_Implant_Contraceptive": { - "type": "CallSubmodule", - "submodule": "contraceptives/clear_contraceptive", - "direct_transition": "Initial" + "direct_transition": "Terminal" }, "Terminal": { diff --git a/lib/generic/modules/contraceptives/injectable_contraceptive.json b/lib/generic/modules/contraceptives/injectable_contraceptive.json index d36dcc998a..a1c48fd431 100644 --- a/lib/generic/modules/contraceptives/injectable_contraceptive.json +++ b/lib/generic/modules/contraceptives/injectable_contraceptive.json @@ -158,203 +158,7 @@ "End_Consultation_Encounter": { "type": "EncounterEnd", - "direct_transition": "Injectable_Maintenance" - }, - - "Injectable_Maintenance": { - "type": "Guard", - "remarks": [ - "======================================================================", - " ADDITIONAL DOSE(S) ", - "======================================================================", - "Every 3 months an additional dose is given. If the age limit for the current ", - "age bracket is reached, no more additional doses are given." - ], - "allow": { - "condition_type": "Or", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Initial_Injection_By_Physician", - "within": { "quantity": 3, "unit": "months" } - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Regular_Contraceptive_Injection", - "within": { "quantity": 3, "unit": "months" } - } - } - ] - } - ] - }, - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - "transition": "Pregnancy_Guard" - }, - { - "transition": "Continue_Or_Stop" - } - ] - }, - - "Pregnancy_Guard": { - "type": "Guard", - "remarks": [ - "After the pregnancy ends, resume using the injectable. From the top..." - ], - "allow": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": false - }, - "direct_transition": "Reset_Injectable_Contraceptive" - }, - - "Reset_Injectable_Contraceptive": { - "type": "CallSubmodule", - "submodule": "contraceptives/clear_contraceptive", - "direct_transition": "Initial" - }, - - "Continue_Or_Stop": { - "type": "Simple", - "conditional_transition": [ - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 50, - "unit": "years" - } - ] - }, - "transition": "Terminal" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 35, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Terminal" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Young_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 25, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Terminal" - }, - { - "transition": "Regular_Injection_Encounter" - } - ] - }, - - "Regular_Injection_Encounter": { - "type": "Encounter", - "encounter_class": "outpatient", - "codes": [ - { - "system": "SNOMED-CT", - "code": "308335008", - "display": "Patient encounter procedure" - } - ], - "direct_transition": "Regular_Contraceptive_Injection" - }, - - "Regular_Contraceptive_Injection": { - "type": "Procedure", - "duration": { - "low": 10, - "high": 20, - "unit": "minutes" - }, - "codes": [ - { - "system": "SNOMED-CT", - "code": "76601001", - "display": "Intramuscular injection" - } - ], - "direct_transition": "End_Regular_Injection_Encounter" - }, - - "End_Regular_Injection_Encounter": { - "type": "EncounterEnd", - "direct_transition": "Injectable_Maintenance" + "direct_transition": "Terminal" }, "Terminal": { diff --git a/lib/generic/modules/contraceptives/intrauterine_device.json b/lib/generic/modules/contraceptives/intrauterine_device.json index 195c235e91..22e59e4591 100644 --- a/lib/generic/modules/contraceptives/intrauterine_device.json +++ b/lib/generic/modules/contraceptives/intrauterine_device.json @@ -340,248 +340,7 @@ "End_IUD_Insertion_Encounter": { "type": "EncounterEnd", - "direct_transition": "IUD_Lifetime_Guard" - }, - - "IUD_Lifetime_Guard": { - "type": "Guard", - "remarks": [ - "Allow module progression if the IUD's lifetime is up (~4 years) ", - "or if the patient becomes pregnant." - ], - "allow": { - "condition_type": "Or", - "conditions": [ - { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - { - "condition_type": "And", - "conditions": [ - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "IUD_Insertion", - "within": { "quantity": 4, "unit": "years" } - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "IUD_Replacement", - "within": { "quantity": 4, "unit": "years" } - } - } - ] - } - ] - }, - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - "transition": "Remove_IUD_Encounter" - }, - { - "transition": "Renew_Or_Remove" - } - ] - }, - - "Renew_Or_Remove": { - "type": "Simple", - "conditional_transition": [ - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 50, - "unit": "years" - } - ] - }, - "transition": "Remove_IUD_Encounter" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 35, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Remove_IUD_Encounter" - }, - { - "condition": { - "condition_type": "And", - "conditions": [ - { - "condition_type": "PriorState", - "name": "Young_Contraceptive_Use" - }, - { - "condition_type": "Age", - "operator": ">=", - "quantity": 25, - "unit": "years" - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mid_Contraceptive_Use" - } - }, - { - "condition_type": "Not", - "condition": { - "condition_type": "PriorState", - "name": "Mature_Contraceptive_Use" - } - } - ] - }, - "transition": "Remove_IUD_Encounter" - }, - { - "transition": "Renew_IUD_Encounter" - } - ] - }, - - "Renew_IUD_Encounter": { - "type": "Encounter", - "encounter_class": "outpatient", - "codes": [ - { - "system": "SNOMED-CT", - "code": "308335008", - "display": "Patient encounter procedure" - } - ], - "direct_transition": "IUD_Replacement" - }, - - "IUD_Replacement": { - "type": "Procedure", - "codes": [ - { - "system": "SNOMED-CT", - "code": "46706006", - "display": "Replacement of contraceptive intrauterine device" - } - ], - "duration": { - "low": 40, - "high": 70, - "unit": "minutes" - }, - "direct_transition": "End_IUD_Replacement_Encounter" - }, - - "End_IUD_Replacement_Encounter": { - "type": "EncounterEnd", - "direct_transition": "IUD_Lifetime_Guard" - }, - - "Remove_IUD_Encounter": { - "type": "Encounter", - "encounter_class": "outpatient", - "codes": [ - { - "system": "SNOMED-CT", - "code": "308335008", - "display": "Patient encounter procedure" - } - ], - "direct_transition": "IUD_Removal" - }, - - "IUD_Removal": { - "type": "Procedure", - "codes": [ - { - "system": "SNOMED-CT", - "code": "68254000", - "display": "Removal of intrauterine device" - } - ], - "duration": { - "low": 40, - "high": 70, - "unit": "minutes" - }, - "direct_transition": "End_IUD_Removal_Encounter" - }, - - "End_IUD_Removal_Encounter": { - "type": "EncounterEnd", - "conditional_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": true - }, - "transition": "Pregnancy_Guard" - }, - { - "transition": "Terminal" - } - ] - }, - - "Pregnancy_Guard": { - "type": "Guard", - "remarks": [ - "After the pregnancy ends, resume using an IUD. From the top..." - ], - "allow": { - "condition_type": "Attribute", - "attribute": "pregnant", - "operator": "==", - "value": false - }, - "direct_transition": "Reset_IUD_Contraceptive" - }, - - "Reset_IUD_Contraceptive": { - "type": "CallSubmodule", - "submodule": "contraceptives/clear_contraceptive", - "direct_transition": "Initial" + "direct_transition": "Terminal" }, "Terminal": { diff --git a/lib/generic/modules/female_reproduction.json b/lib/generic/modules/female_reproduction.json index 89d998e4df..9656ffb940 100644 --- a/lib/generic/modules/female_reproduction.json +++ b/lib/generic/modules/female_reproduction.json @@ -195,7 +195,7 @@ "distributions": [ { "distribution": 0.193, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.807, @@ -213,7 +213,7 @@ "distributions": [ { "distribution": 0.0205, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.9795, @@ -231,7 +231,7 @@ "distributions": [ { "distribution": 0.0164, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.9836, @@ -249,7 +249,7 @@ "distributions": [ { "distribution": 0.00692, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99318, @@ -267,7 +267,7 @@ "distributions": [ { "distribution": 0.00692, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99318, @@ -285,7 +285,7 @@ "distributions": [ { "distribution": 0.00692, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99318, @@ -303,7 +303,7 @@ "distributions": [ { "distribution": 0.00514, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99486, @@ -321,7 +321,7 @@ "distributions": [ { "distribution": 0.00342, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99658, @@ -339,7 +339,7 @@ "distributions": [ { "distribution": 0.00271, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.99729, @@ -357,7 +357,7 @@ "distributions": [ { "distribution": 0.000417, - "transition": "Potentially_Pregnant" + "transition": "Become_Pregnant" }, { "distribution": 0.999583, @@ -373,11 +373,6 @@ "direct_transition": "Next_Reproductive_Cycle" }, - "Potentially_Pregnant": { - "type": "Simple", - "direct_transition": "Become_Pregnant" - }, - "Become_Pregnant": { "type": "SetAttribute", "remarks": [ diff --git a/lib/generic/modules/infertility.json b/lib/generic/modules/infertility.json deleted file mode 100644 index 19e2353ddb..0000000000 --- a/lib/generic/modules/infertility.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "Infertility", - "remarks": [ - "The chance of infertility (independent of sterilization) increases significantly with age.", - "Impaired fecundity affects 8% percent of women aged 15-29, increasing to 30.2 percent of ", - "women aged 40-44. Source: ", - "https://mchb.hrsa.gov/chusa13/perinatal-risk-factors-behaviors/p/impaired-fecundity-infertility-services.html" - ], - "states": { - - "Initial": { - "type": "Initial", - "remarks": [ - "At present, only female infertility is modeled." - ], - "conditional_transition": [ - { - "condition": { - "condition_type": "Gender", - "gender": "F" - }, - "transition": "Female_Infertility_Incidence" - }, - { - "transition": "Terminal" - } - ] - }, - - "Female_Infertility_Incidence": { - "type": "Simple", - "remarks": [ - "A minority of females are infertile from birth, but many more become infertile ", - "as they age. The majority will remain fertile until menopause." - ], - "distributed_transition": [ - { - "distribution": 0.08, - "transition": "Infertile_From_Birth" - }, - { - "distribution": 0.089, - "transition": "Delay_Until_Early_30s" - }, - { - "distribution": 0.096, - "transition": "Delay_Until_Late_30s" - }, - { - "distribution": 0.037, - "transition": "Delay_Until_40s" - }, - { - "distribution": 0.698, - "transition": "Terminal" - } - ] - }, - - "Infertile_From_Birth": { - "type": "Simple", - "direct_transition": "Infertile" - }, - - "Delay_Until_Early_30s": { - "type": "Delay", - "range": { - "low": 30, - "high": 34, - "unit": "years" - }, - "direct_transition": "Infertile" - }, - - "Delay_Until_Late_30s": { - "type": "Delay", - "range": { - "low": 35, - "high": 39, - "unit": "years" - }, - "direct_transition": "Infertile" - }, - - "Delay_Until_40s": { - "type": "Delay", - "range": { - "low": 40, - "high": 49, - "unit": "years" - }, - "direct_transition": "Infertile" - }, - - "Infertile": { - "type": "SetAttribute", - "attribute": "infertile", - "value": true, - "direct_transition": "Terminal" - }, - - "Terminal": { - "type": "Terminal" - } - } -} diff --git a/lib/generic/modules/pregnancy.json b/lib/generic/modules/pregnancy.json index 7822c78022..033e6e939d 100644 --- a/lib/generic/modules/pregnancy.json +++ b/lib/generic/modules/pregnancy.json @@ -92,32 +92,7 @@ "display": "Prenatal initial visit" } ], - "remarks": [ - "Following an initial prenatal visit there are 3 broad outcomes for a pregnancy:", - "1. Fetal Loss: 1.053M miscarriages --> 17.1% of all pregnancies", - "2. Induced Abortion: 1.103M induced abortions --> 17.9% of all pregnancies", - "3. Birth: 3.988M live births --> 65% of all pregnancies", - "Total pregnancies: 6.155M", - "Source: http://www.cdc.gov/nchs/data/hestat/pregnancy/2010_pregnancy_rates.htm" - ], - "distributed_transition": [ - { - "distribution": 0.179, - "transition": "End_Initial_Visit_Towards_Abortion", - "remarks": [ - "See bottom of this module for abortion and miscarriage handling" - ] - }, - { - "distribution": 0.821, - "transition": "Pregnancy_Test" - } - ] - }, - - "End_Initial_Visit_Towards_Abortion" : { - "type" : "EncounterEnd", - "direct_transition" : "Wait_For_Induced_Abortion" + "direct_transition": "Pregnancy_Test" }, "Pregnancy_Test": { @@ -131,19 +106,179 @@ "display": "Standard pregnancy test" } ], - "distributed_transition": [ + "remarks": [ + "Following an initial prenatal visit there are 3 broad outcomes for a pregnancy:", + "1. Fetal Loss: 1.053M miscarriages --> 17.1% of all pregnancies", + "2. Induced Abortion: 1.103M induced abortions --> 17.9% of all pregnancies", + "3. Birth: 3.988M live births --> 65% of all pregnancies", + "Total pregnancies: 6.155M", + "Source: http://www.cdc.gov/nchs/data/hestat/pregnancy/2010_pregnancy_rates.htm", + + "In terms of trends, the likelihood of abortion peaks age 20-30, then decreases with age. ", + "Meanwhile, the likelihood of miscarriage significantly increases with age. 85% will ", + "miscarriage in the first trimester, the remaining 15% in the second.", + + "| Age | Abortion % | Miscarriage % | ", + "|-------------|--------------|---------------| ", + "| <20 | 11.4% | 8% | ", + "| 20-24 | 32.7% | 8% | ", + "| 25-29 | 25.9% | 8% | ", + "| 30-34 | 16.8% | 12% | ", + "| 35-39 | 9.2% | 19% | ", + "| 40-44 | 3.6% | 39% | ", + "| 45+ | 3.6% | 60% | ", + "'--------------------------------------------' ", + "Abortions source: https://www.cdc.gov/mmwr/volumes/65/ss/ss6512a1.htm", + "Miscarriage source: http://www.advancedfertility.com/age-miscarriage.htm" + ], + "complex_transition": [ { - "distribution": 0.177, - "transition": "Miscarriage_In_First_Trimester", - "remarks": [ - "For a total percentage of 17.1% fetal loss, of the 82.1% that do not have an ", - "abortion 20.8% must have a miscarriage. 85% of those will miscarriage in the first ", - "trimester so 17.7% of all patients that reach this state will miscarriage now." + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 45, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.036, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.51, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.454, + "transition": "Pregnancy_CarePlan" + } ] }, { - "distribution": 0.823, - "transition": "Pregnancy_CarePlan" + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 40, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.036, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.332, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.632, + "transition": "Pregnancy_CarePlan" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 35, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.092, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.162, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.746, + "transition": "Pregnancy_CarePlan" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 30, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.168, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.102, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.73, + "transition": "Pregnancy_CarePlan" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 25, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.259, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.068, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.673, + "transition": "Pregnancy_CarePlan" + } + ] + }, + { + "condition": { + "condition_type": "Age", + "operator": ">=", + "quantity": 20, + "unit": "years" + }, + "distributions": [ + { + "distribution": 0.327, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.068, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.605, + "transition": "Pregnancy_CarePlan" + } + ] + }, + { + "distributions": [ + { + "distribution": 0.114, + "transition": "End_Initial_Visit_Towards_Abortion" + }, + { + "distribution": 0.068, + "transition": "Miscarriage_In_First_Trimester" + }, + { + "distribution": 0.818, + "transition": "Pregnancy_CarePlan" + } + ] } ] }, @@ -185,6 +320,11 @@ "direct_transition": "End_Prenatal_Initial_Visit" }, + "End_Initial_Visit_Towards_Abortion": { + "type": "EncounterEnd", + "direct_transition": "Wait_For_Induced_Abortion" + }, + "End_Prenatal_Initial_Visit" : { "type" : "EncounterEnd", "direct_transition" : "Week_15" diff --git a/lib/world/sequential.rb b/lib/world/sequential.rb index ba49d74a88..0284bb08af 100644 --- a/lib/world/sequential.rb +++ b/lib/world/sequential.rb @@ -462,6 +462,15 @@ def record_stats(patient) @stats[:ethnicity][patient[:ethnicity]] += 1 @stats[:blood_type][patient[:blood_type]] += 1 + if patient[:gender] == 'F' + current_rate = if @stats[:birth_rate].nil? + patient[:number_of_children] + else + @stats[:birth_rate] + end + @stats[:birth_rate] = ((current_rate + patient[:number_of_children]) / 2.0) + end + occurrences = track_occurrences(patient, @top_level_conditions) add_occurrences(@stats[:all_occurrences], occurrences) if patient.had_event?(:death) From a4b28eee088923cced592d1c935274f9b5930fbb Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Thu, 20 Apr 2017 13:57:26 -0400 Subject: [PATCH 5/6] Appeased Rubocop --- lib/world/sequential.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/world/sequential.rb b/lib/world/sequential.rb index 0284bb08af..d5e4bf3c76 100644 --- a/lib/world/sequential.rb +++ b/lib/world/sequential.rb @@ -464,10 +464,10 @@ def record_stats(patient) if patient[:gender] == 'F' current_rate = if @stats[:birth_rate].nil? - patient[:number_of_children] - else - @stats[:birth_rate] - end + patient[:number_of_children] + else + @stats[:birth_rate] + end @stats[:birth_rate] = ((current_rate + patient[:number_of_children]) / 2.0) end From a967b13e085302f3dc7f72fe998724665b21eae5 Mon Sep 17 00:00:00 2001 From: Carlton Duffett Date: Mon, 24 Apr 2017 09:26:40 -0400 Subject: [PATCH 6/6] Cleanup and Documentation --- .../contraceptives/implant_contraceptive.json | 4 ++-- .../injectable_contraceptive.json | 4 ++-- .../contraceptives/intrauterine_device.json | 3 +++ .../contraceptives/male_sterilization.json | 3 +-- lib/generic/modules/female_reproduction.json | 19 ------------------- lib/generic/modules/sexual_activity.json | 5 ++++- 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/lib/generic/modules/contraceptives/implant_contraceptive.json b/lib/generic/modules/contraceptives/implant_contraceptive.json index e352551edf..13e98b80ff 100644 --- a/lib/generic/modules/contraceptives/implant_contraceptive.json +++ b/lib/generic/modules/contraceptives/implant_contraceptive.json @@ -7,8 +7,8 @@ "discontinued in 2002 in favor of newer alternatives, but implants remain ", "available today.", - "Since implants must be readministered once every 3-4 years, this submodule ", - "regularly administers additional doses until the current age bracket is exhausted.", + "Implants must be readministered once every 3-4 years. The Contraceptive ", + "Maintenance module handles that.", "Sources for historical availability: ", "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", diff --git a/lib/generic/modules/contraceptives/injectable_contraceptive.json b/lib/generic/modules/contraceptives/injectable_contraceptive.json index a1c48fd431..dc53bc9d51 100644 --- a/lib/generic/modules/contraceptives/injectable_contraceptive.json +++ b/lib/generic/modules/contraceptives/injectable_contraceptive.json @@ -6,8 +6,8 @@ "contraceptive was available in 1992, marketed as Depo-Provera. Depo remains ", "the only available injectable option in the U.S.", - "Since injectables must be readministered once every 3 months, this submodule ", - "regularly administers additional doses until the current age bracket is exhausted.", + "Injectables must be readministered once every 3 months. The Contraceptive ", + "Maintenance module handles that.", "Sources for historical availability: ", "http://www.ourbodiesourselves.org/health-info/a-brief-history-of-birth-control/", diff --git a/lib/generic/modules/contraceptives/intrauterine_device.json b/lib/generic/modules/contraceptives/intrauterine_device.json index 22e59e4591..73951e3402 100644 --- a/lib/generic/modules/contraceptives/intrauterine_device.json +++ b/lib/generic/modules/contraceptives/intrauterine_device.json @@ -11,6 +11,9 @@ "Modern IUDs are again becoming popular. They are copper or combine low-dose ", "hormones with plastic.", + "IUDs must be removed or replaced every 5-10 years. This is handled by the ", + "Contraceptive Maintenance module.", + "Sources for availability: ", "https://www.wired.com/2011/07/ff_iud/", "http://kff.org/womens-health-policy/fact-sheet/intrauterine-devices-iuds-access-for-women-in-the-u-s/" diff --git a/lib/generic/modules/contraceptives/male_sterilization.json b/lib/generic/modules/contraceptives/male_sterilization.json index 55b87d2e49..f86d743f03 100644 --- a/lib/generic/modules/contraceptives/male_sterilization.json +++ b/lib/generic/modules/contraceptives/male_sterilization.json @@ -1,8 +1,7 @@ { "name": "Male Sterilization", "remarks": [ - "This submodule performs a male sterilization procedure. This procedure ", - "is irreversible, and sets 'contraceptive_type' = 'sterilization'. " + "This submodule performs a male sterilization (vasectomy) procedure." ], "states": { diff --git a/lib/generic/modules/female_reproduction.json b/lib/generic/modules/female_reproduction.json index 9656ffb940..80b9654311 100644 --- a/lib/generic/modules/female_reproduction.json +++ b/lib/generic/modules/female_reproduction.json @@ -166,25 +166,6 @@ ], "complex_transition": [ - { - "condition": { - "condition_type": "Attribute", - "attribute": "contraceptive_type", - "operator": "is nil" - }, - "remarks": [ - "contraceptive_type == nil is treated as an error state and ", - "deferred to the next reproductive cycle. This may occur when ", - "the reproductive cycle completes on the same time step as ", - "the contraceptive_type is recomputed." - ], - "distributions": [ - { - "distribution": 1, - "transition": "Next_Reproductive_Cycle" - } - ] - }, { "condition": { "condition_type": "Attribute", diff --git a/lib/generic/modules/sexual_activity.json b/lib/generic/modules/sexual_activity.json index b47b50f954..00739f0c26 100644 --- a/lib/generic/modules/sexual_activity.json +++ b/lib/generic/modules/sexual_activity.json @@ -6,7 +6,10 @@ "from Indiana University: http://www.nationalsexstudy.indiana.edu/graph.html", "This module operates on the assumption that these incidences for human sexual ", - "activity have remained similar throughout modern history." + "activity have remained similar throughout modern history.", + + "No consideration is given to the age, race, socioeconomic status, or marriage ", + "status of the patient. This complexity could be added." ], "states": {