Safe drug in pregnancy make a flow chart with doses according to current guidelines

Asking for Preferences
Reading File
Searching the Web

safe drugs in pregnancy doses current guidelines 2024 2025 all categories

Searching PubMed

drug safety pregnancy guidelines pharmacotherapy

Finding Sources
Reading Web Page

https://www.merckmanuals.com/professional/gynecology-and-obs…

Finding Sources
Searching the Web

antibiotics antihypertensives antidiabetics antidepressants safe pregnancy doses 2024 guidelines ACOG

Reading File
Reading File
Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC11998890

Running Command

ls -la /home/daytona/workspace/ && mkdir -p /home/daytona/workspace/drug-pregnancy-flowchart

Writing File

~/drug-pregnancy-flowchart/generate_flowchart.py

#!/usr/bin/env python3
"""
Safe Drugs in Pregnancy - Comprehensive Flowchart Generator
Based on ACOG, AAFP, Katzung Pharmacology, and current guidelines (2024-2025)
"""

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
import numpy as np

fig = plt.figure(figsize=(28, 38), dacecolor='white')
fig.patch.set_facecolor('#FAFBFC')

# ── Colour palette ──────────────────────────────────────────────────────────
C_HEADER   = '#1A237E'   # deep navy
C_SAFE     = '#1B5E20'   # dark green
C_CAUTION  = '#E65100'   # deep orange
C_AVOID    = '#B71C1C'   # dark red
C_CAT_BG   = '#E8EAF6'   # light lavender for category headers
C_SAFE_BG  = '#E8F5E9'   # light green bg
C_CAUT_BG  = '#FFF3E0'   # light orange bg
C_AVOID_BG = '#FFEBEE'   # light red bg
C_NOTE_BG  = '#E3F2FD'   # light blue for notes
C_SUBHDR   = '#283593'   # medium navy
C_TEXT     = '#212121'
C_LINE     = '#546E7A'
C_TITLE_BG = '#1A237E'

ax = fig.add_axes([0, 0, 1, 1])
ax.set_xlim(0, 28)
ax.set_ylim(0, 38)
ax.axis('off')

# ── Helper functions ─────────────────────────────────────────────────────────
def rounded_box(x, y, w, h, fc, ec, lw=1.2, radius=0.3, zorder=2, alpha=1.0):
    box = FancyBboxPatch((x, y), w, h,
                         boxstyle=f"round,pad=0.05,rounding_size={radius}",
                         linewidth=lw, edgecolor=ec, facecolor=fc,
                         zorder=zorder, alpha=alpha)
    ax.add_patch(box)
    return box

def text(x, y, txt, fs=8, fc=C_TEXT, ha='center', va='center',
         bold=False, wrap=False, style='normal'):
    weight = 'bold' if bold else 'normal'
    ax.text(x, y, txt, fontsize=fs, color=fc, ha=ha, va=va,
            fontweight=weight, fontstyle=style,
            zorder=5, wrap=wrap,
            multialignment='left' if ha == 'left' else 'center')

def section_header(x, y, w, h, title, subtitle=''):
    rounded_box(x, y, w, h, C_CAT_BG, C_SUBHDR, lw=2, radius=0.25, zorder=3)
    ax.plot([x, x+w], [y+h-0.38, y+h-0.38], color=C_SUBHDR, lw=1.5, zorder=4)
    text(x+w/2, y+h-0.19, title, fs=9.5, fc=C_SUBHDR, bold=True)
    if subtitle:
        text(x+w/2, y+0.15, subtitle, fs=7.5, fc='#546E7A', style='italic')

def drug_row(x, y, w, drug, dose, status, note=''):
    """status: 'safe','caution','avoid'"""
    colors = {'safe':(C_SAFE_BG, C_SAFE), 'caution':(C_CAUT_BG, C_CAUTION),
              'avoid':(C_AVOID_BG, C_AVOID)}
    bg, ec = colors[status]
    h = 0.52 if not note else 0.68
    rounded_box(x, y, w, h, bg, ec, lw=1, radius=0.18, zorder=3)
    # coloured left bar
    bar = FancyBboxPatch((x, y), 0.12, h,
                         boxstyle="round,pad=0,rounding_size=0.05",
                         linewidth=0, facecolor=ec, zorder=4)
    ax.add_patch(bar)
    # drug name
    text(x+0.22, y+h-(0.26 if not note else 0.38), drug, fs=7.2, fc=ec,
         ha='left', va='center', bold=True)
    # dose
    text(x+0.22, y+(0.14 if not note else 0.22), dose, fs=6.8, fc=C_TEXT,
         ha='left', va='center')
    if note:
        text(x+0.22, y+0.08, note, fs=6.2, fc='#5D4037', ha='left',
             va='center', style='italic')
    return h

# ═══════════════════════════════════════════════════════════════════════════════
#  TITLE BANNER
# ═══════════════════════════════════════════════════════════════════════════════
rounded_box(0.3, 36.4, 27.4, 1.35, C_TITLE_BG, C_TITLE_BG, lw=0, radius=0.4, zorder=2)
text(14, 37.28, '⬥  SAFE DRUGS IN PREGNANCY  ⬥', fs=18, fc='white', bold=True)
text(14, 36.72, 'Comprehensive Guide with Doses — Based on ACOG / AAFP / RCOG / EULAR / Katzung Guidelines (Updated 2024–2025)',
     fs=8, fc='#B0BEC5')

# ── Legend ───────────────────────────────────────────────────────────────────
rounded_box(0.3, 35.35, 27.4, 0.82, '#ECEFF1', '#90A4AE', lw=1, radius=0.2, zorder=2)
for xpos, label, color in [(1.0, '■  Generally Safe (use as indicated)', C_SAFE),
                             (9.5, '■  Use with Caution (trimester-dependent)', C_CAUTION),
                             (19.0, '■  Avoid / Contraindicated', C_AVOID)]:
    text(xpos, 35.76, label, fs=8.2, fc=color, ha='left', bold=True)

# ── Trimester note ────────────────────────────────────────────────────────────
rounded_box(0.3, 34.52, 27.4, 0.6, '#E3F2FD', '#1565C0', lw=1.2, radius=0.2, zorder=2)
text(14, 34.82, '⚠  1st Trimester (0–12 wks): Organogenesis — highest teratogenic risk  |  '
               '2nd Trimester (13–26 wks): Generally safest window  |  '
               '3rd Trimester (27–40 wks): Neonatal effects / labour concerns',
     fs=7.8, fc='#0D47A1', bold=False)

# ═══════════════════════════════════════════════════════════════════════════════
#  COLUMN LAYOUT  — 4 columns
#  col1: x=0.3   col2: x=7.1   col3: x=13.9   col4: x=20.7
# ═══════════════════════════════════════════════════════════════════════════════
COL = [0.35, 7.15, 13.95, 20.75]
CW  = 6.55   # column width

# ══════════════════════════ COLUMN 1 ══════════════════════════════════════════
cy = 33.8

# 1A: ANALGESICS / ANTIPYRETICS
section_header(COL[0], cy-0.45, CW, 0.72, '💊 ANALGESICS / ANTIPYRETICS')
cy -= 0.5

drugs_analgesic = [
    ('Paracetamol (Acetaminophen)', '500–1000 mg q4-6h  Max 4 g/day', 'caution',
     'Preferred. Recent data: caution with prolonged use (neurodevelopmental concern, ACOG 2025)'),
    ('Codeine', '15–60 mg q4h (short-term)', 'caution',
     'Avoid near term; neonatal opioid withdrawal risk'),
    ('Low-dose Aspirin', '81–150 mg/day (preeclampsia prophylaxis)', 'safe',
     'ACOG recommends from 12–16 wks in high-risk. Avoid high doses.'),
    ('NSAIDs (Ibuprofen etc.)', 'Avoid after 20 wks gestation', 'avoid',
     'Premature ductus arteriosus closure; oligohydramnios (FDA 2020)'),
    ('Opioids (morphine, etc.)', 'Only if clearly needed; lowest dose', 'caution',
     'Neonatal abstinence syndrome risk; avoid near delivery'),
]
for drug, dose, st, note in drugs_analgesic:
    h = drug_row(COL[0], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

cy -= 0.2
# 1B: ANTIEMETICS
section_header(COL[0], cy-0.45, CW, 0.72, '💊 ANTIEMETICS')
cy -= 0.5
drugs_antiemetic = [
    ('Pyridoxine (Vit B6)', '10–25 mg TID or 25 mg QID  (<100 mg/day)', 'safe',
     'First-line (ACOG). Alone or combined with doxylamine'),
    ('Doxylamine + Pyridoxine', '10/10 mg at bedtime (Diclegis/Bonjesta)', 'safe',
     'FDA-approved for NVP; safe throughout pregnancy'),
    ('Promethazine', '12.5–25 mg q4-6h PO/PR/IM', 'safe',
     '2nd-line; sedating; avoid IV due to gangrene risk'),
    ('Metoclopramide', '5–10 mg TID (before meals)', 'safe',
     'Generally safe; limit to <12 weeks continuous use'),
    ('Ondansetron', '4–8 mg TID PO/IV', 'caution',
     'Use in refractory NVP. Some data: small oral cleft risk 1st trim — limited to 2nd/3rd trim if possible'),
    ('Ginger', '250 mg QID or 1000–1500 mg/day', 'safe',
     'Evidence-based (multiple RCTs); safe for mild-moderate NVP'),
]
for drug, dose, st, note in drugs_antiemetic:
    h = drug_row(COL[0], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

cy -= 0.2
# 1C: GI DRUGS
section_header(COL[0], cy-0.45, CW, 0.72, '💊 GASTROINTESTINAL')
cy -= 0.5
drugs_gi = [
    ('Calcium carbonate antacids', '500–1000 mg PO with meals / PRN', 'safe', ''),
    ('Magnesium hydroxide', 'Standard antacid doses PRN', 'safe',
     'Avoid near term in large doses (neonatal hypermagnesemia)'),
    ('Omeprazole / Pantoprazole', '20–40 mg OD (PPI)', 'safe',
     'Safe for GERD; omeprazole preferred; avoid 1st trim if possible'),
    ('Ranitidine / Famotidine', 'Famotidine 20 mg BD (H2RA)', 'safe',
     'Ranitidine withdrawn (NDMA); famotidine now preferred'),
    ('Lactulose', '15–30 mL BD-TID for constipation', 'safe', ''),
    ('Psyllium / Ispaghula', 'Standard doses; increase fluids', 'safe', 'First-line for constipation'),
    ('Bisacodyl', '5–10 mg PO PRN', 'caution', 'Occasional use acceptable; avoid chronic use'),
]
for drug, dose, st, note in drugs_gi:
    h = drug_row(COL[0], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

# ══════════════════════════ COLUMN 2 ══════════════════════════════════════════
cy = 33.8

# 2A: ANTIBIOTICS
section_header(COL[1], cy-0.45, CW, 0.72, '💊 ANTIBIOTICS')
cy -= 0.5
drugs_abx = [
    ('Penicillins', 'Standard doses (Amoxicillin 500 mg TID)', 'safe',
     'Drug of choice across all trimesters (PMC 2025)'),
    ('Cephalosporins (all gen.)', 'Standard doses (Cephalexin 500 mg QID)', 'safe',
     'Generally safe. Ceftriaxone: caution at term — kernicterus risk'),
    ('Azithromycin', '500 mg Day 1, then 250 mg Days 2–5', 'safe',
     'Preferred macrolide; avoid erythromycin (hepatotoxicity in pregnancy)'),
    ('Clindamycin', '300–600 mg q6-8h', 'safe', 'Safe all trimesters'),
    ('Nitrofurantoin', '100 mg BD (modified release) × 5–7 days', 'safe',
     'Safe 1st–2nd trim (UTI). AVOID at term: neonatal haemolysis'),
    ('Fosfomycin', '3 g single dose (UTI)', 'safe',
     'Safe 1st trim; limited data 2nd/3rd; good for uncomplicated UTI'),
    ('Metronidazole (systemic)', '400–500 mg BD–TID', 'caution',
     'AVOID 1st trim systemically. Safe 2nd/3rd trim for BV, trichomoniasis'),
    ('Metronidazole (topical/vaginal)', 'Standard vaginal preparation', 'safe', 'Safe all trimesters'),
    ('Vancomycin', '15–20 mg/kg IV q8-12h', 'safe',
     'Use for serious Gram+ infections; TDM required'),
    ('Fluoroquinolones', 'Avoid if alternatives exist', 'avoid',
     'Cartilage damage, CNS toxicity; reserve for no-alternative situations'),
    ('Tetracyclines', 'Avoid in all trimesters', 'avoid',
     'Teeth discolouration, bone growth inhibition in fetus'),
    ('TMP-SMX', 'Avoid (use only if no alternative)', 'avoid',
     'Folate antagonist; neonatal jaundice; supplement with folic acid 4 mg/day if used'),
    ('Aminoglycosides', 'Avoid; short-term only if life-saving', 'avoid',
     'Congenital deafness (streptomycin). Others: short-term acceptable with monitoring'),
    ('Chloramphenicol', 'Avoid especially at term', 'avoid', '"Grey baby syndrome"'),
]
for drug, dose, st, note in drugs_abx:
    h = drug_row(COL[1], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.08)

# ══════════════════════════ COLUMN 3 ══════════════════════════════════════════
cy = 33.8

# 3A: ANTIHYPERTENSIVES
section_header(COL[2], cy-0.45, CW, 0.72, '💊 ANTIHYPERTENSIVES')
cy -= 0.5
drugs_htn = [
    ('Labetalol', '100–400 mg BD-TID PO\nIV: 20 mg bolus → 40–80 mg q10min (acute)', 'safe',
     'ACOG first-line oral agent for chronic HTN in pregnancy'),
    ('Nifedipine (extended-release)', '30–60 mg OD; acute: 10 mg immediate-release', 'safe',
     'First-line; preferred over short-acting (avoid sublingual)'),
    ('Methyldopa', '250 mg BD–TID; max 3 g/day', 'safe',
     'Longest safety record; first-line especially in 1st trim'),
    ('Hydralazine', 'IV: 5–10 mg q20min for acute crisis', 'safe',
     'Second-line for hypertensive emergency; PO also used'),
    ('Hydrochlorothiazide', '12.5–25 mg OD', 'caution',
     'Second-line; avoid if pre-eclampsia; possible neonatal electrolyte issues'),
    ('ACE Inhibitors', 'CONTRAINDICATED', 'avoid',
     'Fetal renal dysgenesis, oligohydramnios, skull hypoplasia — ALL trimesters'),
    ('ARBs (e.g. losartan)', 'CONTRAINDICATED', 'avoid',
     'Same fetal toxicity as ACEi; avoid all trimesters'),
    ('Magnesium Sulphate', 'Loading 4–6 g IV over 20 min, then 1–2 g/h infusion', 'safe',
     'DRUG OF CHOICE for eclampsia seizure prophylaxis/treatment (MAGPIE trial)'),
]
for drug, dose, st, note in drugs_htn:
    h = drug_row(COL[2], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

cy -= 0.2
# 3B: ANTIDIABETIC AGENTS
section_header(COL[2], cy-0.45, CW, 0.72, '💊 ANTIDIABETIC AGENTS')
cy -= 0.5
drugs_dm = [
    ('Insulin (all types)', 'Individualised — target FBG <5.3 mmol/L\nPostprandial 1h <7.8 mmol/L', 'safe',
     'GOLD STANDARD. Drug of choice for all types of diabetes in pregnancy'),
    ('Metformin', '500 mg OD–BD; max 2500 mg/day', 'caution',
     'Used in GDM/T2DM; crosses placenta; long-term fetal effects unknown. ACOG & NICE allow it.'),
    ('Glibenclamide (Glyburide)', 'Starting 2.5 mg OD; max 20 mg/day', 'caution',
     'Used in GDM if insulin refused; neonatal hypoglycaemia risk; crosses placenta'),
    ('Other oral hypoglycaemics', 'Avoid', 'avoid',
     'Insufficient safety data in pregnancy; switch to insulin'),
    ('GLP-1 agonists / SGLT-2i', 'STOP before conception / immediately', 'avoid',
     'Potential fetal harm; no safety data'),
]
for drug, dose, st, note in drugs_dm:
    h = drug_row(COL[2], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

cy -= 0.2
# 3C: ANTICOAGULANTS
section_header(COL[2], cy-0.45, CW, 0.72, '💊 ANTICOAGULANTS / ANTITHROMBOTICS')
cy -= 0.5
drugs_ac = [
    ('LMWH (enoxaparin)', 'Prophylaxis: 40 mg SC OD\nTreatment: 1 mg/kg SC BD', 'safe',
     'DRUG OF CHOICE for VTE in pregnancy. Does not cross placenta.'),
    ('UFH (Unfractionated Heparin)', '5000 units SC q8-12h (prophylaxis)\nTherapeutic: TDM-guided IV/SC', 'safe',
     'Does not cross placenta. Use if LMWH unavailable or near delivery'),
    ('Low-dose Aspirin', '81–150 mg/day', 'safe',
     'Preeclampsia prophylaxis (ACOG: start 12–16 wks in high-risk)'),
    ('Warfarin', 'AVOID (especially 1st trim)', 'avoid',
     'Warfarin embryopathy (6–12 wks); fetal haemorrhage; fetal CNS defects'),
    ('DOACs (apixaban, rivaroxaban)', 'CONTRAINDICATED', 'avoid',
     'Cross placenta; no safety data; fetal haemorrhage'),
]
for drug, dose, st, note in drugs_ac:
    h = drug_row(COL[2], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

# ══════════════════════════ COLUMN 4 ══════════════════════════════════════════
cy = 33.8

# 4A: PSYCHIATRIC / NEUROLOGICAL
section_header(COL[3], cy-0.45, CW, 0.72, '💊 PSYCHIATRIC / NEUROLOGICAL')
cy -= 0.5
drugs_psych = [
    ('SSRIs (Sertraline preferred)', 'Sertraline: 50–200 mg/day\nFluoxetine: 20–60 mg/day', 'safe',
     'ACOG 2025: safe in pregnancy; do not discontinue for pregnancy alone. Paroxetine: avoid (cardiac defects).'),
    ('Sertraline', '50–200 mg/day', 'safe', 'Most-studied SSRI in pregnancy; preferred choice'),
    ('SNRIs (Venlafaxine)', '75–225 mg/day', 'caution',
     'Use if SSRIs insufficient; neonatal adaptation syndrome possible'),
    ('TCAs (Amitriptyline)', '10–75 mg nocte', 'caution',
     '3rd trim: neonatal withdrawal symptoms. Avoid clomipramine near term.'),
    ('Lithium', '300–600 mg BD-TID (TDM: 0.6–1.0 mEq/L)', 'caution',
     'Risk of Ebstein anomaly (weaker than historically thought); fetal cardiac USS. Perinatal toxicity.'),
    ('Valproate', 'AVOID in women of childbearing age', 'avoid',
     'Neural tube defects (1–2%), fetal valproate syndrome; IQ reduction. Banned/restricted (EMA).'),
    ('Carbamazepine', 'If essential: 400–1200 mg/day + folic acid 5 mg/day', 'caution',
     'Neural tube defects (~0.5–1%); supplemental folic acid mandatory'),
    ('Lamotrigine', '100–400 mg/day (doses may need increase in pregnancy)', 'caution',
     'Preferred AED in pregnancy; monitor levels (clearance increases markedly)'),
    ('Haloperidol', '0.5–5 mg OD–BD', 'caution',
     'If antipsychotic needed; avoid high doses near term (EPS in neonate)'),
    ('Quetiapine', '50–400 mg/day', 'caution',
     'Most data among atypicals; gestational diabetes risk; monitor blood glucose'),
    ('Benzodiazepines', 'Avoid prolonged use; lorazepam for acute seizure', 'caution',
     'Neonatal withdrawal, "floppy infant syndrome" with chronic use'),
    ('Phenobarbital', '60–180 mg/day if essential', 'caution',
     'Neonatal withdrawal; vitamin K for neonate at birth'),
]
for drug, dose, st, note in drugs_psych:
    h = drug_row(COL[3], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.08)

cy -= 0.2
# 4B: RESPIRATORY
section_header(COL[3], cy-0.45, CW, 0.72, '💊 RESPIRATORY')
cy -= 0.5
drugs_resp = [
    ('SABA (Salbutamol inhaled)', '100–200 mcg (1–2 puffs) PRN via inhaler', 'safe',
     'Preferred reliever. GINA: safe in pregnancy.'),
    ('ICS (Budesonide inhaled)', '200–400 mcg BD (preferred ICS)', 'safe',
     'Most data in pregnancy; preferred ICS for asthma control'),
    ('LABA + ICS (Budesonide/Formoterol)', 'Standard doses per severity', 'safe',
     'Formoterol safe in pregnancy; combination preferred over separate inhalers'),
    ('Oral prednisolone', '40 mg OD (acute exacerbation, reducing course)', 'caution',
     'Use for severe/uncontrolled asthma; slight cleft palate risk 1st trim at high doses'),
    ('Montelukast', '10 mg nocte', 'caution',
     'Limited human data; generally considered acceptable if asthma inadequately controlled'),
    ('Antihistamines (loratadine/cetirizine)', 'Loratadine 10 mg OD; Cetirizine 10 mg OD', 'safe',
     'Both safe; cetirizine & loratadine preferred (non-sedating). Diphenhydramine also safe.'),
    ('Pseudoephedrine', 'Avoid', 'avoid',
     'Placental vasoconstriction; gastroschisis risk; avoid 1st trim'),
]
for drug, dose, st, note in drugs_resp:
    h = drug_row(COL[3], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

cy -= 0.2
# 4C: THYROID / ENDOCRINE
section_header(COL[3], cy-0.45, CW, 0.72, '💊 THYROID / SUPPLEMENTS')
cy -= 0.5
drugs_thy = [
    ('Levothyroxine', 'Adjusted doses — TSH target 1st trim: 0.1–2.5 mIU/L', 'safe',
     'Continue in hypothyroidism; dose often needs increase 25–50% in pregnancy'),
    ('Propylthiouracil (PTU)', '100–150 mg TID (1st trimester only)', 'caution',
     '1st trim preferred antithyroid; switch to carbimazole 2nd/3rd trim if possible'),
    ('Carbimazole / Methimazole', '10–40 mg OD (2nd/3rd trim preferred)', 'caution',
     'AVOID 1st trim: aplasia cutis, choanal/oesophageal atresia risk'),
    ('Folic Acid', '400 mcg/day (standard); 5 mg/day (high risk)', 'safe',
     'MANDATORY: start 3 months before conception, continue through 1st trim'),
    ('Iron (ferrous sulphate)', '200 mg BD-TID', 'safe', 'Treat iron-deficiency anaemia'),
    ('Calcium + Vit D', 'Ca 1000–1500 mg/day + Vit D 600–800 IU/day', 'safe',
     'WHO: 1.5–2g elemental Ca/day for preeclampsia prevention in low-Ca populations'),
    ('Vitamin K (neonatal)', 'Neonate: 1 mg IM at birth', 'safe',
     'MANDATORY for all neonates; prevents haemorrhagic disease of newborn'),
]
for drug, dose, st, note in drugs_thy:
    h = drug_row(COL[3], cy-0.72, CW, drug, dose, st, note)
    cy -= (h + 0.1)

# ── Footer ────────────────────────────────────────────────────────────────────
footer_y = 0.05
rounded_box(0.3, footer_y, 27.4, 0.7, '#ECEFF1', '#90A4AE', lw=1, radius=0.2, zorder=2)
text(14, footer_y + 0.35,
     'Sources: ACOG 2023-25 | AAFP AFP 2023 | RCOG | EULAR 2024 | Katzung Pharmacology 16e | '
     'Fishman Pulmonary Diseases | PMC Antibiotic Review 2025 | FDA PLLR  |  '
     'This chart is for clinical guidance only — always verify with current labelling and consult specialist.',
     fs=6.5, fc='#607D8B')

plt.tight_layout(pad=0)
plt.savefig('/home/daytona/workspace/drug-pregnancy-flowchart/safe_drugs_pregnancy.png',
            dpi=180, bbox_inches='tight', facecolor='#FAFBFC',
            format='png', transparent=False)
print("Saved successfully.")
plt.close()
Running Command

cd /home/daytona/workspace/drug-pregnancy-flowchart && python3 generate_flowchart.py 2>&1

Editing File

~/drug-pregnancy-flowchart/generate_flowchart.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/drug-pregnancy-flowchart/generate_flowchart.py'
Running Command

cd /home/daytona/workspace/drug-pregnancy-flowchart && python3 generate_flowchart.py 2>&1

Running Command

ls -lh /home/daytona/workspace/drug-pregnancy-flowchart/safe_drugs_pregnancy.png

Running Command

cd /home/daytona/workspace/drug-pregnancy-flowchart && python3 -c " import matplotlib matplotlib.use('Agg') # Replace emoji section headers with ASCII alternatives to ensure clean render import re with open('generate_flowchart.py','r') as f: src = f.read() # Replace emoji symbols with clean ASCII alternatives src = src.replace('⬥ SAFE DRUGS IN PREGNANCY ⬥', 'SAFE DRUGS IN PREGNANCY') src = src.replace('💊 ANALGESICS / ANTIPYRETICS', '[ ANALGESICS / ANTIPYRETICS ]') src = src.replace('💊 ANTIEMETICS', '[ ANTIEMETICS ]') src = src.replace('💊 GASTROINTESTINAL', '[ GASTROINTESTINAL ]') src = src.replace('💊 ANTIBIOTICS', '[ ANTIBIOTICS ]') src = src.replace('💊 ANTIHYPERTENSIVES', '[ ANTIHYPERTENSIVES ]') src = src.replace('💊 ANTIDIABETIC AGENTS', '[ ANTIDIABETIC AGENTS ]') src = src.replace('💊 ANTICOAGULANTS / ANTITHROMBOTICS', '[ ANTICOAGULANTS / ANTITHROMBOTICS ]') src = src.replace('💊 PSYCHIATRIC / NEUROLOGICAL', '[ PSYCHIATRIC / NEUROLOGICAL ]') src = src.replace('💊 RESPIRATORY', '[ RESPIRATORY ]') src = src.replace('💊 THYROID / SUPPLEMENTS', '[ THYROID / SUPPLEMENTS ]') src = src.replace('⚠ 1st Trimester', '** 1st Trimester') with open('generate_flowchart_clean.py','w') as f: f.write(src) print('Done') "

Running Command

cd /home/daytona/workspace/drug-pregnancy-flowchart && python3 -c " import re with open('generate_flowchart_clean.py','r') as f: src = f.read() # fix output filename to _v2.png src = src.replace('safe_drugs_pregnancy.png','safe_drugs_pregnancy_v2.png') with open('generate_flowchart_clean.py','w') as f: f.write(src) print('Done') " && python3 generate_flowchart_clean.py 2>&1

Running Command

ls -lh /home/daytona/workspace/drug-pregnancy-flowchart/

Your flowchart is ready! Here are both versions:
Safe Drugs in Pregnancy Flowchart (Clean) - recommended

safe drugs pregnancy v2

Image · PNG

safe drugs pregnancy

Image · PNG


What's in the flowchart

The chart covers 10 major drug categories across 4 columns, color-coded by safety:
ColorMeaning
GreenGenerally safe - use as indicated
OrangeUse with caution - trimester-dependent
RedAvoid / Contraindicated

Categories included:

  1. Analgesics/Antipyretics - Paracetamol (preferred), low-dose aspirin, NSAID restrictions (avoid after 20 wks per FDA 2020)
  2. Antiemetics - Pyridoxine B6 + doxylamine (FDA-approved first-line), metoclopramide, ondansetron caution in 1st trim
  3. Gastrointestinal - PPIs, H2 blockers, lactulose, psyllium
  4. Antibiotics - Penicillins/cephalosporins (safe), fluoroquinolones/tetracyclines (avoid), full trimester guidance
  5. Antihypertensives - Labetalol, nifedipine, methyldopa (first-line); ACEi/ARBs strictly contraindicated; MgSO4 for eclampsia
  6. Antidiabetics - Insulin (gold standard), metformin (ACOG acceptable), GLP-1/SGLT-2 (stop immediately)
  7. Anticoagulants - LMWH (drug of choice), warfarin/DOACs avoided
  8. Psychiatric/Neurological - SSRIs safe (ACOG 2025), valproate contraindicated, lamotrigine preferred AED
  9. Respiratory - Salbutamol, budesonide ICS (safe); antihistamines (loratadine/cetirizine preferred)
  10. Thyroid/Supplements - Levothyroxine, PTU (1st trim), folic acid (mandatory), Ca+Vit D
Sources: ACOG 2023-25, AAFP AFP 2023, RCOG, EULAR 2024, Katzung Pharmacology 16e, PMC Antibiotic Review 2025, FDA PLLR
Clinical note: Always verify doses against current product labelling. Doses in pregnancy may require adjustment due to expanded blood volume, increased GFR, and altered hepatic metabolism - levels can be 10-50% lower than in non-pregnant adults.
This is a shared conversation. Sign in to Orris to start your own chat.