Inference of pregnancy episodes. (A) Definition of Hierarchy-based Inference of Pregnancy (HIP) algorithm: episodes were inferred by both an initial set of gestational timing markers (gestation-based episodes) and outcomes (outcome-based episodes), shown in steps 1–6. Both types of episodes were then merged and quality checked (steps 7–9). (B) Definition of Pregnancy Progression Signature (PPS) algorithm: we leveraged further, empirically derived, gestational timing markers based on low standard deviation distance from HIP algorithm start dates across any pregnancy outcome category, followed by clinician curation of expected gestational timing ranges (N = 74 concepts). The patient records were first scanned for this new set of gestational timing concepts (step 1), followed by detailed iterations across the patient data making comparisons between pairs of concepts to determine whether to extend or start a new episode (steps 2–3). To provide further clarity, equations representing these iterations and detailed application to an example patient can be found in Figure S1. Where present, outcomes were appended to the end of the progression signatures to derive the full recorded episode (step 4). Finally, we first check for any overlap of HIP and PPS episodes. Then we have additional steps to remove episodes that overlap with more than 2 episodes—prioritizing the episodes with the closest end dates. The resulting pairs of overlapping episodes are merged using a union of the 2 source episodes (eg, taking the earliest date from both, and the latest date from both) (step 5). Note that for both algorithms these panels provide the full algorithm definition, examples are used purely to provide clarity.