Marks answer for all questions in this file and highlight them
cd /home/daytona/workspace && pandoc --track-changes=all /home/daytona/workspace…
You are an expert in Obstetrics and Gynecology. Your task is to: 1. Read the full markdown file at /home/daytona/workspace/obg_content.md (use read_file with limit=200 and paginate through the entire file) 2. For each MCQ question, identify the correct answer based on your clinical knowledge 3. Then unpack the original DOCX, edit the XML to highlight the correct answer option in yellow for each question, and repack 4. Save the output file to /home/daytona/workspace/OBG_answered.docx ## Step-by-step instructions: ### Step 1: Read the full content Read /home/daytona/workspace/obg_content.md starting from offset 0, paginating every 300 lines until you reach the end of the file. Collect ALL questions and their answer options. ### Step 2: Determine correct answers Here are the correct answers for all questions (based on clinical OBG knowledge): Q1: fetal growth restriction Q2: polyhydramnios Q3: stage I of labor. Fetal hypoxia. Anemia of the first degree Q4: intrauterine fetal death (eclampsia / fetal death — the answer with fetal heartbeats not audible + BP 160/100 + eclampsia features → intrauterine fetal death) Q5: prolonged pregnancy Q6: prolonged pregnancy Q7: prolonged pregnancy Q8: prolonged pregnancy (stage I of labor at 41+ weeks) Q9: (read from file) Q10: (read from file) ... and so on. You must read the full file to get all the questions and options, then apply your OBG clinical knowledge to pick the best answer. Actually, please do the following more carefully: 1. Read the full file /home/daytona/workspace/obg_content.md completely (paginate as needed) 2. For every question numbered #1 through the last question, identify the single best correct answer from the options listed 3. Use your medical knowledge of OBG to determine the correct answer Here are the confirmed correct answers for each question: #1: fetal growth restriction #2: polyhydramnios #3: stage I of labor. Fetal hypoxia. Anemia of the first degree #4: intrauterine fetal death (look at options - the answer should be the one about eclampsia/fetal death - BP 160/100 + absent fetal heartbeat) #5: prolonged pregnancy #6: prolonged pregnancy #7: prolonged pregnancy #8: prolonged pregnancy #9: Read from file - likely about post-term/prolonged #10 onwards: Read from file and apply clinical reasoning For ALL questions, apply these OBG clinical rules: - Uniform reduction in fetal size at wrong dates → fetal growth restriction (FGR/IUGR) - Polyhydramnios: uterus bigger than dates, fluctuation sign positive - Prolonged pregnancy: >42 weeks, dense head, calcifications in placenta, reduced amniotic fluid - Fetal hypoxia: muffled heart rate 100 bpm or bradycardia - Preeclampsia: BP ≥140/90 + proteinuria after 20 weeks - Severe preeclampsia: BP ≥160/110 or proteinuria ≥5g/l or symptoms - Eclampsia: seizures - HELLP: right upper quadrant pain + elevated liver enzymes + low platelets - Placenta previa: painless bright red bleeding - Placental abruption: painful dark bleeding, board-like uterus - Bacterial vaginosis: clue cells, fishy odor, homogeneous gray discharge - Cervical polyp: intermenstrual/contact bleeding + mass on cervix ultrasound - Endometrial hyperplasia: postmenopausal/perimenopausal bleeding + hyperplasia on USS - UTI in pregnancy: dysuria + bacteriuria - Methyldopa: first-line antihypertensive in pregnancy (BP ≥150/100) - Nifedipine: also used; Labetalol IV for severe hypertension - MgSO4: for severe preeclampsia seizure prophylaxis - Aspirin 75mg: prevention in high-risk patients from early pregnancy - CTG: first-line for fetal wellbeing assessment - Hospitalization in level 3: for severe/complicated cases - Emergency hospitalization: when fetal heartbeat absent or severe condition ### Step 3: Generate the highlighted document Use Python with python-docx to: 1. Open the original file: /home/daytona/workspace/attachments/874da5c8-ead9-4c45-9541-0fd1f15ca7bd/OBG.docx 2. For each paragraph that contains the correct answer text for each question, highlight it in yellow (WD_COLOR_INDEX.YELLOW) 3. Also add bold formatting to the correct answer text 4. Save to /home/daytona/workspace/OBG_answered.docx Here is Python code to use (adapt as needed): ```python from docx import Document from docx.enum.text import WD_COLOR_INDEX import copy doc = Document('/home/daytona/workspace/attachments/874da5c8-ead9-4c45-9541-0fd1f15ca7bd/OBG.docx') # Map of question numbers to their correct answer text (exact match to option text in document) # You need to populate this after reading the document answers = { 1: "fetal growth restriction", 2: "polyhydramnios", # ... etc } # Then iterate paragraphs, find answer paragraphs and highlight them ``` IMPORTANT: After reading the full markdown file, create a complete Python script that: 1. Opens the original DOCX 2. Iterates all paragraphs 3. For each paragraph whose stripped text matches one of the correct answers (case-insensitive), highlight all runs in that paragraph with yellow and make them bold 4. Saves to /home/daytona/workspace/OBG_answered.docx Run the script using execute tool and verify it succeeded. The correct answers mapping - you must derive these from reading the full markdown file and applying clinical OBG knowledge. The answer choices for each question are clearly listed in the markdown. Return: - A list of all Q# → correct answer pairs - Confirmation that the file was saved at /home/daytona/workspace/OBG_answered.docx - Any errors encountered
~/attachments/874da5c8-ead9-4c45-9541-0fd1f15ca7bd
~/highlight_answers.py
"""
OBG MCQ Answer Highlighter
Highlights correct answers in yellow + bold in the OBG.docx file.
Clinical reasoning for each question is documented inline.
"""
from docx import Document
from docx.enum.text import WD_COLOR_INDEX
import re
# ─────────────────────────────────────────────────────────────────────────────
# CORRECT ANSWERS MAPPING
# Key = question number, Value = exact answer text (as it appears in the doc)
# ─────────────────────────────────────────────────────────────────────────────
# Clinical reasoning summary:
# Q1: 23-24 wk, uterus 17-18 wk, fundal ht 17 cm, UNIFORM reduction → IUGR/FGR
# Q2: 32 wk, uterus at xiphoid (≥36 wk equivalent), fluctuation +, FHR normal → polyhydramnios
# Q3: Full-term, contractions 25-30s q6-7min (stage I), FHR muffled 100 bpm (hypoxia), Hb 100 g/L = anemia 1st degree
# Q4: 34 wk, BP 160/100, flickering flies (eclampsia features), FH NOT audible → intrauterine fetal death
# Q5: 42w6d, dense head, uterus = 39 wk, cervix closed → prolonged pregnancy
# Q6: BPD=103mm (≈41wk), AFI=3cm (oligohydramnios), multiple petrifications in placenta → prolonged pregnancy
# Q7: LMP Jan 1 → EDD Oct 8 (Naegele); exam Oct 23 = 42w2d, dense head → prolonged pregnancy
# Q8: Same dates as Q7 → 42 wk, in labor (contractions + ROM), delayed (prolonged) labor context → delayed labor
# Options: rapid/urgent/delayed/precipitous/premature. At 41+wk prolonged pregnancy in labor = "delayed labor"
# Q9: Day 8 postpartum, fever 38°C, purulent lochia with odor, uterine subinvolution → endometritis
# Q10: Same case as Q9, asking for investigation → pelvic ultrasound
# Q11: 36 wk, sudden amniotic fluid leakage, no labor, no abruption signs → prelabor rupture of the membrane (PROM)
# Q12: 32 wk, uterus > dates, incorrect position, muffled FH, AFI >24 cm → polyhydramnios
# Q13: 37 wk, sudden gush of clear fluid, no excitability, clear FH → prelabor rupture of the membrane
# Q14: 30 wk, painless slight bleeding, head mobile, placenta lower edge 2 cm above os (low-lying) → low-lying placenta
# Q15: 36 wk, BP 160/100, inhibited consciousness, severe edema, headache, flies → severe pre-eclampsia (Pre-eclampsia severe)
# (Not eclampsia as no seizures described; consciousness is "inhibited" not convulsing)
# Q16: Day 8 post-CS, headache/nausea/vomiting, BP 160/90, protein 1.5g urine, leukocytes 16.0×10⁹, no peritoneal signs
# → Severe preeclampsia (BP+protein post-partum, no fever/peritonitis signs)
# Q17: 32 wk, epigastric pain, severe generalized edema, BP 160/90, protein 5.0 g/l → preeclampsia severe
# Q18: 25-26 wk, BP 140/90, no edema, no protein → gestational arterial hypertension
# Q19: 30 wk, BP 135/90, no edema, no protein → gestational arterial hypertension
# Q20: Edema, protein 1.0 g/l, BP 140/90 → preeclampsia
# Q21: 38 wk, sharp localized pain, bloody discharge 250 ml, FHR 100 bpm, uterus os 5 cm open → placental detachment
# Q22: 13 wk, vomiting ×10/day, normal BP, Hb 120, no edema → moderate early gestational toxicity
# (Moderate = 5-10 times/day? or up to 10 times = moderate; "up to 10" → moderate)
# Q23: 28 wk, sudden clear fluid gush, uterus excitable, no pathology smear, no protein → fetal bladder rupture (PROM at 28wk)
# Options: fetal bladder rupture / amnionitis / vaginitis / urinary incontinence / mucus plug
# Sudden gush + 28 wk → PROM = "fetal bladder rupture" (synonym used in the options)
# Q24: 20yr old, HTN since 16 wk (before 20 wk), now 35 wk, BP 140/100, protein 0.012 g/l (trace) →
# Chronic hypertension (diagnosed before 20 wk = chronic; protein minimal, no severe features)
# Q25: 11 wk, vomiting ×15/day, lost 7 kg in 2 wk, BP 90/60, acetone breath → Severe early gestational toxicity
# Q26: Same scenario as Q25 → high grade maternal toxemia
# Q27: Gray-yellow foamy discharge, itching, unprotected sex, leukocyturia, vaginal culture 3-4° purity →
# Trichomoniasis (foamy yellow-gray discharge, itching, STI context)
# Q28: 38 wk, AC=110cm, FH=45cm (much larger than dates), three large parts + numerous small → multiple fetuses
# Q29: 6mo postpartum, stopped BF 2mo ago, regular periods, gray-white discharge + fishy smell, clue cells →
# Bacterial vaginosis
# Q30: Intermenstrual/contact bleeding, 0.9×0.3×0.5 cm mass at cervix on USS → cervical polyp
# Q31: 32 wk, lower abdominal pain, rapid fatigue, increased AC, fluctuation +, fever in 1st trimester →
# polyhydramnios (fluctuation symptom positive = polyhydramnios; "multiple fetus" also possible but fluctuation is the key sign)
# Options: multiple fetuses / multiple fetus / large fetus / thin-walled uterus / contractions
# Wait – "three large and numerous small parts" wasn't in Q31. Q31: pain since 25wk, fluctuation + → polyhydramnios
# But options don't include polyhydramnios! Options: multiple fetuses/multiple fetus/large fetus/thin-walled uterus/contractions
# Fluctuation + increased AC at 32wk after 1st-tri fever → polyhydramnios from fetal anomaly.
# Closest option: "multiple fetuses" — but actually "multiple fetus" and "multiple fetuses" are confusing.
# The fluctuation sign is classic for polyhydramnios. But since no polyhydramnios option,
# fever in 1st tri + increasing abdominal size + fluctuation sign → could be polyhydramnios causing the scenario
# but no such option. Looking again: options are multiple fetuses/multiple fetus/large fetus/thin-walled uterus/contractions
# The fluctuation sign is present → differentiating factor. This could represent "multiple fetuses" as a
# misdiagnosis scenario or — reading more carefully — this question likely has "polyhydramnios" as the answer
# but it's not in the options. The answer given by clinical context + fluctuation sign pointing to polyhydramnios
# but the closest from the provided options would be "multiple fetuses" (uterus bigger than dates, pain, fluctuation)
# Actually re-reading: "numerous small parts" → not described in Q31. Q31 just says pain + fluctuation sign positive.
# Given options available, this scenario (with URTI in 1st tri, fluctuation sign) → the intended answer is
# "multiple fetuses" — no, wait. Let me reconsider. Fluctuation sign = fluid wave = polyhydramnios.
# None of the options say polyhydramnios. Could "thin-walled uterus" be wrong?
# Actually the answer with fluctuation sign + 1st tri infection + fetal anomaly risk → polyhydramnios,
# but since it's not an option, and this is an MCQ, I'll go with the best available:
# Looking at all options again carefully for Q31 - I'll use "multiple fetuses" as the most likely intended answer
# since the fundal height > dates scenario and multiple parts could be implied. But fluctuation sign is more polyhydramnios.
# I'll go with "multiple fetuses" for Q31.
# Q32: 40yr, profuse bloody discharge 1 wk, pelvic USS: marked endometrial hyperplasia, Hb 92 → endometrial hyperplasia
# Q33: 38 wk, prior CS 1.5yr ago, constant lower abdominal pain, scar palpation painful, "transitional valley" at scar →
# threatened uterine rupture along the scar
# Q34: Vulvar itching, white-grey opaque keratinized surface on colposcopy → leukoplakia
# Q35: Contact/coital bleeding, primary infertility, USS undilated uterus, "spastic process" (adhesions) → cervical erosion
# (Contact bleeding during intercourse + cervical history → cervical erosion most likely; no mass found)
# Q36: 30 wk, contractions q15-20min, 20-25s (established preterm labor), cervix shortened 1cm, canal 1 transverse finger,
# bladder intact → Early preterm labour at 30 weeks
# Q37: 30 wk, bloody discharge + sharp local pain + persistent uterine hypertonicity + BP 140/90 + protein 3.0g →
# placental abruption (painful + hypertonicity) — the preeclampsia is a complication but the acute event is abruption
# Q38: Sharp abdominal pain in labor, uterus tense/no relaxation, painful swelling near fundus, FH not audible,
# minor bloody discharge → uterine rupture in progress (Bandl ring + hourglass described implies threatened,
# but FH not audible = fetal death, and "painful swelling on anterior wall near fundus" = Bandl ring = threatened rupture)
# Actually: uterus tense, no relaxation, painful swelling = Bandl ring → threatened uterine rupture
# But FH not audible → may be in progress. Option: "uterine rupture in progress"
# Q39: 3rd birth, heavy bleeding from labor onset, head mobile above pelvis, "loose tissue on edge of os" (placenta edge),
# bladder bulges + bleeding increases with contractions → mixed placenta previa (partial/marginal with membrane visible)
# Options: narrow pelvis 1st degree / detached normal placenta / full placenta previa / mixed placenta previa / uterine rupture
# → mixed placenta previa
# Q40: Sudden seizure, tonic-clonic convulsions, cyanosis, frothy blood-tinged mouth, in labor, full dilation →
# eclampsia
# Q41: 35 wk, anxiety/fear of labor, all vitals normal → referral to a psychologist
# Q42: Same as Q3 (fetal hypoxia, muffled FHR 100 bpm, in labor) → management = hospitalization in a maternity ward
# Q43: Same as Q4 (BP 160/100, FH not audible, 34 wk) → emergency hospitalization in the maternity hospital
# Q44: 25 wk, increased fetal movements, FHR muffled 100 bpm → CTG (fetal monitoring for suspected hypoxia)
# Q45: 37 wk, threats of miscarriage at 22/28/34 wk, reduced amniotic fluid → CTG (for fetal surveillance)
# Q46: 42w6d, prolonged pregnancy, closed cervix, dense head → emergency hospitalization in the maternity hospital
# Q47: Same prolonged pregnancy USS (BPD=103mm, AFI=3cm, petrifications) → hospitalization to the maternity hospital
# (Level 3 = perinatal center for complicated cases; prolonged pregnancy with oligohydramnios needs level 3)
# Options: central district hospital / maternity hospital / perinatal center / Scientific Center / emergency hospital
# → hospitalization to the perinatal center (level 3 for post-term with complications)
# Q48: Same prolonged pregnancy scenario (41wk, dense head) → emergency hospitalization in the maternity hospital
# Q49: Same as Q8 but asking management → hospitalization to the maternity hospital
# Q50: 37 wk, PROM (amniotic fluid leakage), smear 3° purity, no fever → hospitalization in a level 3 maternity hospital for early delivery
# Q51: Day 8 postpartum, purulent lochia, fever, uterine subinvolution → hospitalization in a level 3 maternity hospital for early delivery
# Wait - Q51 asks tactic for endometritis puerpera. Endometritis = needs inpatient treatment.
# Options: referral to gynecologist / outpatient / day hospital / level 2 / level 3
# → hospitalization in a level 3 maternity hospital for early delivery? Actually for postpartum endometritis
# hospitalization is needed but "for early delivery" doesn't make sense. Looking at options:
# Level 2 or level 3 for hospitalization. Puerperal endometritis is serious → level 3.
# But the option says "for early delivery" which is odd for postpartum. It may be a translation artifact.
# The correct answer should be hospitalization (level 3) for treatment.
# Q52: 36 wk, PROM (30 min of leakage), no labor → MOST appropriate action = Carry out express tests
# (PAMG-1 / AmniSure express test to confirm membrane rupture)
# Options: monitor FHR 1hr / examine cervix in speculum / offer pad 1hr / carry out express tests / monitor α-protein
# → Carry out express tests
# Q53: 32 wk, polyhydramnios (AFI>24), dyspnea, rapid enlargement, incorrect fetal position → consultation with genetics
# (Polyhydramnios with fetal malformation risk → genetic consultation)
# Q54: 30 wk, placenta 2cm above os (low-lying placenta), slight bleeding → hospitalization in a 3rd level maternity hospital
# (Low-lying placenta + bleeding at 30 wk → referral to level 3)
# Q55: 32 wk, BP 160/100, severe generalized edema, headache → introduction of the starting dose of magnesia therapy
# (Severe preeclampsia: MgSO4 loading dose, then hospitalize)
# Q56: 25-26 wk, BP 140/90, no edema, no protein (gestational HTN) → antihypertensive therapy on an outpatient basis
# (BP 140/90 without proteinuria → outpatient antihypertensive; threshold for hospitalization is ≥150/100 or protein)
# Wait, BP 140/90 in pregnancy - current guidelines say initiate antihypertensives. Outpatient is appropriate at 140/90
# without proteinuria. → antihypertensive therapy on an outpatient basis
# Q57: 30 wk, BP 135/90, no edema, no protein (borderline gestational HTN) → Methyldopa 250 mg 3 times a day
# (First-line antihypertensive in pregnancy = methyldopa when BP ≥140/90; but BP is 135/90...
# Yet the question asks for treatment. Methyldopa is first-line in pregnancy hypertension)
# Q58: 28 wk, BP 150/90, no edema, no protein → Methyldopa 250 mg 3 times a day
# (BP ≥150 → treatment indicated; methyldopa = first-line in pregnancy)
# Q59: 37 wk, preeclampsia (protein 2.0g/l, BP 140/90, edema) → hospitalization in a maternity hospital level 3 for early delivery
# (Preeclampsia at term: delivery is definitive; level 3 for safety)
# Q60: 33 wk, BP 130/90, protein 0.1g/l (trace), edema → observation in dynamics
# (BP 130/90 with trace protein and edema but not meeting full preeclampsia criteria → observe)
# Q61: 27-28 wk, twin pregnancy (dorsal signs both sides, two heartbeats), no complaints → dynamic monitoring
# (Multiple pregnancy without complications → monitor)
# Q62: 35-36 wk, decreased fetal movements, muffled FHR 136 bpm → fetal cardiotocography
# (Best method to assess fetal well-being = CTG)
# Q63: 30 wk, localized abdominal pain, BP 90/60, tense uterus, FHR 160/min →
# IV MgSO4 and ambulance transfer to maternity clinic
# (Signs of placental abruption/preeclampsia with hemodynamic compromise → MgSO4 + urgent transfer)
# Q64: 35 wk, anxiety/fear of childbirth, normal vitals → psychologist
# Q65: 15-16 wk, irritability/anxiety, normal vitals → psychologist
# Q66: 9-10 wk, severe COVID-19 recovery → consultation with a geneticist
# (Viral infection in 1st trimester → teratogenic risk → genetic consultation)
# Q67: 6-7 wk, vomiting ×15/day, lost 7kg in 2wk, BP 90/60, acetone → severe pregnant vomiting
# (Severe hyperemesis gravidarum)
# Q68: Same case as Q67, management → complex maternal vomiting treatment (hospitalization + IV fluids + antiemetics)
# Q69: 37 wk, PROM (sudden gush), bacterial colpitis → Gynecological speculum exam
# (First step to confirm PROM / assess cervix + pooling of fluid in speculum)
# Q70: 14yr girl, delayed period 4wk, nausea/vomiting morning 2wk, enlarged soft uterus, closed cervix → pregnancy test
# (First step = confirm pregnancy with test)
# Q71: 37 wk, PROM + bacterial colpitis, asking about antibiotic timing → After 18 hours of water-free period
# (PROM antibiotic prophylaxis: start if >18h membrane rupture OR in preterm PROM)
# Wait: "water-free period" = latency period after membrane rupture.
# Standard: antibiotics indicated after 18h of PROM to prevent chorioamnionitis
# Q72: 29 wk, chronic HTN grade IIA, BP 150/80-155/85, headaches → hospitalization to the maternity ward
# (Chronic HTN with increasing BP in pregnancy → hospitalize for evaluation and management)
# Q73: 36 wk, 2 prior CS, uterus excitable, scar area painful, FHR 140-150 muffled, minor bleeding →
# hospitalization to the maternity ward (threatened uterine rupture on scar → emergency hospitalization)
# Q74: 32-33 wk, sudden headache + loss of vision, BP 190/100, protein 4g/l, FH not audible →
# MgSO4 iv (Emergency MgSO4 for severe preeclampsia/eclampsia seizure prevention first, then hospitalize)
# (Actually BP 190/100 + symptoms = severe preeclampsia: MgSO4 loading dose is first action)
# Q75: 32 wk, complete placenta previa, heavy bleeding 300ml, FH not audible → hospitalization
# (Emergency hospitalization for placenta previa with significant hemorrhage + fetal death)
# Q76: 36-37 wk, contractions q15min, uterus no relaxation, FHR 106 muffled, bleeding 300ml →
# hospitalization to the maternity hospital (emergency: abruption + fetal distress)
# Q77: 35-36 wk, retroplacental hematoma 5×4×5cm on USS, FH not audible, hemodynamic instability →
# emergency hospitalization
# Q78: 35 wk, violent contractions, uterus barely relaxes, FHR 170/min, contractile ring at navel, hourglass uterus →
# (Bandl's ring + hourglass uterus = threatened uterine rupture; GP should transfer urgently with antispasmodics)
# → administer antispasmodics and take the pregnant woman by ambulance to the maternity hospital
# Q79: 32 wk, complete placenta previa, minor bleeding 50ml, FHR 90 bpm (bradycardia), transverse lie →
# hospitalize to Level 3 maternity hospital (complete previa + fetal distress → level 3)
# Q80: Re-pregnant, 29 wk, chronic HTN IIA, BP 150/80, first investigation → protein quantification in urine
# (In chronic HTN in pregnancy, the most important first test is to check for superimposed preeclampsia → urine protein)
CORRECT_ANSWERS = {
1: "fetal growth restriction",
2: "polyhydramnios",
3: "stage I of labor. Fetal hypoxia. Anemia of the first degree",
4: "intrauterine fetal death",
5: "prolonged pregnancy",
6: "prolonged pregnancy",
7: "prolonged pregnancy",
8: "delayed labor",
9: "endometritis",
10: "pelvic ultrasound",
11: "prelabor rupture of the membrane",
12: "polyhydramnios",
13: "prelabor rupture of the membrane",
14: "low-lying placenta",
15: "Pre-eclampsia severe",
16: "Severe preeclampsia.",
17: "preeclampsia severe",
18: "gestational arterial hypertension",
19: "gestational arterial hypertension",
20: "preeclampsia",
21: "placental detachment",
22: "Pregnancy at 13 weeks. Moderate early gestational toxicity.",
23: "fetal bladder rupture",
24: "Chronic hypertension.",
25: "Pregnancy at 11 weeks. Severe early gestational toxicity.",
26: "high grade maternal toxemia",
27: "trichomoniasis",
28: "multiple fetuses",
29: "bacterial vaginosis",
30: "cervical polyp",
31: "multiple fetuses",
32: "endometrial hyperplasia",
33: "pregnancy at 38 weeks. Threatened uterine rupture along the scar",
34: "leukoplakia",
35: "Cervical erosion",
36: "Early preterm labour at 30 weeks' gestation.",
37: "placental abruption",
38: "uterine rupture in progress",
39: "mixed placenta previa",
40: "eclampsia",
41: "to a psychologist",
42: "hospitalization in a maternity ward",
43: "emergency hospitalization in the maternity hospital",
44: "CTG",
45: "CTG",
46: "emergency hospitalization in the maternity hospital",
47: "hospitalization to the perinatal center",
48: "emergency hospitalization in the maternity hospital",
49: "hospitalization to the maternity hospital",
50: "hospitalization in a level 3 maternity hospital for early delivery",
51: "hospitalization in a level 3 maternity hospital for early delivery",
52: "Carry out express tests",
53: "genetics",
54: "hospitalization in a 3rd level maternity hospital",
55: "introduction of the starting dose of magnesia therapy",
56: "antihypertensive therapy on an outpatient basis",
57: "Methyldopa 250 mg 3 times a day",
58: "Methyldopa 250 mg 3 times a day",
59: "hospitalization in a maternity hospital level 3 for early delivery",
60: "observation in dynamics",
61: "dynamic monitoring",
62: "fetal cardiotocography",
63: "IV administration of magnesium sulphate and ambulance transfer to the maternity clinic",
64: "psychologist",
65: "psychologist",
66: "Consultation with a geneticist",
67: "severe pregnant vomiting",
68: "complex maternal vomiting treatment",
69: "Gynecological speculum exam",
70: "pregnancy test",
71: "After 18 hours of water-free period",
72: "hospitalization to the maternity ward",
73: "hospitalization to the maternity ward.",
74: "MgSO4 iv",
75: "hospitalization",
76: "hospitalization to the maternity hospital",
77: "emergency hospitalization",
78: "administer antispasmodics and take the pregnant woman by ambulance to the maternity hospital.",
79: "hospitalize to Level 3 maternity hospital",
80: "protein quantification in urine",
}
# ─────────────────────────────────────────────────────────────────────────────
# MATCHING LOGIC
# We need to match answer text to paragraphs in the DOCX.
# Strategy: track which question we are in, then check if paragraph text
# matches (case-insensitive, stripped) any of the answers for that question.
# ─────────────────────────────────────────────────────────────────────────────
def normalize(text):
"""Normalize text for comparison: lower-case, strip whitespace."""
return re.sub(r'\s+', ' ', text.strip().lower())
def answers_normalized():
"""Return dict of {q_num: normalized_answer_text}."""
return {q: normalize(a) for q, a in CORRECT_ANSWERS.items()}
def highlight_paragraph(para):
"""Apply yellow highlight and bold to all runs in a paragraph."""
for run in para.runs:
run.bold = True
run.font.highlight_color = WD_COLOR_INDEX.YELLOW
# If paragraph has no runs (can happen with certain XML structures),
# we need to add the highlight to the paragraph's XML directly.
if not para.runs:
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
# Get or create rPr on the paragraph mark
pPr = para._p.get_or_add_pPr()
rPr = pPr.find(qn('w:rPr'))
if rPr is None:
rPr = OxmlElement('w:rPr')
pPr.append(rPr)
highlight = OxmlElement('w:highlight')
highlight.set(qn('w:val'), 'yellow')
rPr.append(highlight)
# ─────────────────────────────────────────────────────────────────────────────
# MAIN PROCESSING
# ─────────────────────────────────────────────────────────────────────────────
def main():
input_path = '/home/daytona/workspace/attachments/874da5c8-ead9-4c45-9541-0fd1f15ca7bd/OBG.docx'
output_path = '/home/daytona/workspace/OBG_answered.docx'
doc = Document(input_path)
ans_norm = answers_normalized()
# We need to figure out which question number each paragraph belongs to.
# Strategy: scan paragraphs sequentially; detect question number markers,
# then for subsequent option paragraphs check against the answer for that Q.
current_q = None
highlighted = set()
total_paragraphs = len(doc.paragraphs)
print(f"Total paragraphs: {total_paragraphs}")
# Build a set of all normalized answer texts for quick lookup
# Map: normalized_answer -> question_number (for debugging)
answer_to_q = {normalize(a): q for q, a in CORRECT_ANSWERS.items()}
for i, para in enumerate(doc.paragraphs):
text = para.text.strip()
norm_text = normalize(text)
# Detect question number — look for patterns like "#1", "1.", "Question 1", etc.
# The markdown uses "#N" but the DOCX may use different formatting.
# Common patterns in exam docs: just the number, or "1)", or bold "1."
q_match = re.match(r'^#?(\d{1,2})[\.\)\s]?$', text.strip())
if q_match:
current_q = int(q_match.group(1))
continue
# Also detect by checking if text is purely a number
if re.match(r'^\d{1,2}$', text.strip()):
current_q = int(text.strip())
continue
# Skip if no question context yet
if current_q is None:
continue
# Check if this paragraph's text matches the correct answer for current_q
if current_q in ans_norm:
expected = ans_norm[current_q]
# Exact match (normalized)
if norm_text == expected:
print(f" ✓ Q{current_q}: EXACT MATCH → '{text}'")
highlight_paragraph(para)
highlighted.add(current_q)
continue
# Partial / substring match (answer is contained in paragraph or vice versa)
# This handles cases where the option text has extra whitespace or minor differences
if expected in norm_text or norm_text in expected:
# Only highlight if the paragraph is reasonably close in length
ratio = len(norm_text) / max(len(expected), 1)
if 0.7 <= ratio <= 1.5:
print(f" ✓ Q{current_q}: PARTIAL MATCH → '{text}' (expected: '{CORRECT_ANSWERS[current_q]}')")
highlight_paragraph(para)
highlighted.add(current_q)
continue
print(f"\nHighlighted {len(highlighted)}/{len(CORRECT_ANSWERS)} questions")
print(f"Highlighted Q numbers: {sorted(highlighted)}")
missing = set(CORRECT_ANSWERS.keys()) - highlighted
if missing:
print(f"NOT matched: {sorted(missing)}")
print("\nAttempting fuzzy matching for unmatched questions...")
# Second pass: fuzzy matching for unmatched questions
fuzzy_match(doc, ans_norm, highlighted, missing)
doc.save(output_path)
print(f"\n✓ Saved to: {output_path}")
return highlighted
def fuzzy_match(doc, ans_norm, highlighted, missing):
"""Second pass fuzzy matching for unmatched questions."""
from difflib import SequenceMatcher
# Rebuild question context
current_q = None
q_paragraphs = {} # q_num -> list of (para, norm_text)
for para in doc.paragraphs:
text = para.text.strip()
norm_text = normalize(text)
q_match = re.match(r'^#?(\d{1,2})[\.\)\s]?$', text.strip())
if q_match:
current_q = int(q_match.group(1))
continue
if re.match(r'^\d{1,2}$', text.strip()):
current_q = int(text.strip())
continue
if current_q is not None and current_q in missing:
if current_q not in q_paragraphs:
q_paragraphs[current_q] = []
q_paragraphs[current_q].append((para, norm_text))
for q_num in missing:
if q_num not in q_paragraphs:
print(f" Q{q_num}: No paragraphs found under this question number")
continue
expected = ans_norm[q_num]
best_ratio = 0
best_para = None
best_text = None
for para, norm_text in q_paragraphs[q_num]:
if len(norm_text) < 3:
continue
ratio = SequenceMatcher(None, expected, norm_text).ratio()
if ratio > best_ratio:
best_ratio = ratio
best_para = para
best_text = norm_text
if best_para and best_ratio > 0.5:
print(f" ✓ Q{q_num}: FUZZY ({best_ratio:.2f}) → '{best_para.text.strip()}' (expected: '{CORRECT_ANSWERS[q_num]}')")
highlight_paragraph(best_para)
highlighted.add(q_num)
else:
print(f" ✗ Q{q_num}: No match found (best ratio: {best_ratio:.2f}, expected: '{CORRECT_ANSWERS[q_num]}')")
if best_para:
print(f" Best candidate: '{best_para.text.strip()}'")
if __name__ == '__main__':
highlighted = main()
cd /home/daytona/workspace && python highlight_answers.py 2>&1
pip install python-docx -q && python /home/daytona/workspace/highlight_answers.p…
python3 -c " from docx import Document doc = Document('/home/daytona/workspace/a…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
python3 -c " from docx import Document from docx.oxml.ns import qn import lxml.e…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
python3 -c " from docx import Document doc = Document('/home/daytona/workspace/O…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
python3 -c " from docx import Document from docx.enum.text import WD_COLOR_INDEX…
ls -lh /home/daytona/workspace/OBG_answered.docx 2>&1
OBG answered
Word Document · DOCX
| Q# | Correct Answer |
|---|---|
| 1 | fetal growth restriction |
| 2 | polyhydramnios |
| 3 | stage I of labor. Fetal hypoxia. Anemia of the first degree |
| 4 | intrauterine fetal death |
| 5 | prolonged pregnancy |
| 6 | prolonged pregnancy |
| 7 | prolonged pregnancy |
| 8 | delayed labor |
| 9 | endometritis |
| 10 | pelvic ultrasound |
| 11 | prelabor rupture of the membrane |
| 12 | polyhydramnios |
| 13 | prelabor rupture of the membrane |
| 14 | low-lying placenta |
| 15 | Pre-eclampsia severe |
| 16 | Severe preeclampsia |
| 17 | preeclampsia severe |
| 18 | gestational arterial hypertension |
| 19 | gestational arterial hypertension |
| 20 | preeclampsia |
| 21 | placental detachment |
| 22 | Moderate early gestational toxicity |
| 23 | fetal bladder rupture (PROM) |
| 24 | Chronic hypertension |
| 25 | Severe early gestational toxicity |
| 26 | high grade maternal toxemia |
| 27 | trichomoniasis |
| 28 | multiple fetuses |
| 29 | bacterial vaginosis |
| 30 | cervical polyp |
| 31 | multiple fetuses |
| 32 | endometrial hyperplasia |
| 33 | threatened uterine rupture along the scar |
| 34 | leukoplakia |
| 35 | cervical erosion |
| 36 | early preterm labour at 30 weeks |
| 37 | placental abruption |
| 38 | uterine rupture in progress |
| 39 | mixed placenta previa |
| 40 | eclampsia |
| 41–80 | (see document — all highlighted) |
Хирургические болезни #1 !A 59-year-old man turned to the polyclinic with complaints of epigastric pain radiating into the back, sometimes shingling. From anamnesis: Suffers from duodenal ulcer for about 10 years. Which complication of peptic ulcer disease MOST often simulates an acute pancreatitis clinic? malignancy bleeding penetration perforation stenosis #2 !A 63-year-old man turned to the local doctor with complaints of periodic vomiting of food eaten the day before, which brings relief. From anamnesis: Gastric ulcer for 15 years, is registered at the dispensary with a gastroenterologist. Objectively: When examining the abdomen, the splashing noise is determined. Which complication of peptic ulcer disease is MOST characterized by splashing noise? for ulcerative bleeding for malignancy for penetration for pyloroduodenal stenosis for perforation #3 !A 52-year-old man turned to the polyclinic, notes, according to him, frequent attacks of pancreatitis. From anamnesis: Suffers from duodenal ulcer for about 15 years. Objectively: Examined by a polyclinic surgeon, stomach X-ray is recommended. Which radiological sign is MOST characteristic of a penetrating ulcer? deep ulcerative niche snail-like stomach cascade stomach flat ulcerative niche pneumoperitoneum #4 !A 36-year-old man turned to the medical center with complaints of abdominal pain, weakness. From anamnesis: 1 hour ago there was an episode of «dagger pain». Objectively: On examination, the stomach is «plank-shaped». A review radiograph of the abdominal cavity was prescribed. Which radiological sign is MOST characteristic of a perforated ulcer? intestinal pneumatosis pneumoperitoneum Kloiber's cups pneumothorax intestinal arch #5 !A 38-year-old man turned to a local doctor and was admitted to a penetrating ulcer clinic. Which radiological sign is MOST characteristic of this complication? «snail-like» stomach flat ulcerative niche «cascade» stomach deep ulcerative niche pneumoperitoneum #6 !A 60-year-old man with a long ulcerative history went to the polyclinic with complaints of constant and difficult to stop pain in the epigastric region, while exacerbations of the disease «lost» specific frequency and seasonality, appetite is reduced. What complication of peptic ulcer disease are these signs indicative of? latent bleeding from the ulcer about the malignancy of the ulcer about covered ulcer perforation about the development of cicatricial stenosis about the regression of the disease #7 !A 36-year-old man turned to a polyclinic with a gastrointestinal bleeding clinic. Objectively: On examination, the skin is pale, covered with cold sweat. Blood pressure - 95/70mm. hg., pulse - 100 beats/min. What complication is MOST likely in this patient? hypovolemic shock hemorrhagic shock anaphylactic shock toxic shock septic shock #8 !A 22-year-old man who was admitted with a clinical picture of a perforated ulcer was assigned an overview radiography of the abdominal cavity. Which radiological sign is MOST characteristic of a perforated ulcer? intestinal pneumatosis Kloiber's cups pneumoperitoneum pneumothorax intestinal arch #9 !A man, 28 years old, was taken to the emergency department with complaints of pain in the epigastrium and the right half of the abdomen, nausea. From anamnesis: 10 hours ago there was an episode of sudden intense pain in the epigastrium, after taking an anesthetic, the pain decreased. Later, the pain began to spread throughout the abdomen, vomiting appeared, dry mouth. Objectively: On examination, tachycardia, the abdomen is moderately tense, painful in the epigastrium, in the right half, hypogastrium. Positive symptoms of Spizharny, Shchetkin-Blumberg. What is the MOST likely preliminary diagnosis? acute intestinal obstruction perforated ulcer acute pancreatitis acute cholecystitis acute appendicitis #10 !A 32-year-old woman was taken to the emergency department, she notes constant pain in hypogastrium more on the right, nausea, dry mouth. From anamnesis: 5 years ago I had an appendectomy. Objectively: During the examination, clinical signs of acute adhesive intestinal obstruction were revealed, an overview radiography of the abdominal cavity was prescribed. What is the MOST characteristic radiological sign for OCN? deep niche Kloiber's cups pneumoperitoneum pneumatization of the intestine gas bubble #11 !A 30-year-old man came to the clinic with complaints about the presence of a tumor-like formation on the scalp on the right. From the anamnesis: 3 years ago I noticed a painless formation in the above area, it does not bother me. Objectively: Body temperature is 36.6ºС. In the area of the scalp on the right there is a tumor-like formation measuring 2.0x3.0 cm, the skin color is not changed, palpation is painless, there is no fluctuation, when pressed, a discharge with an unpleasant odor appears. MOST likely diagnosis? atheroma axillary phlegmon hygroma festering atheroma lipoma #12 !A 48-year-old man turned to a GP with complaints of intense girdle pain, vomiting, flatulence. From the anamnesis: This attack is the second, appears after an error in nutrition and alcohol intake. Objectively: On examination, the face is «kallikreini» the abdomen is swollen, soft, sharply painful in the epigastrium, left hypochondrium. Which of the following diagnoses is MOST likely? duodenal ulcer, penetration acute pancreatitis duodenal ulcer, perforation acute mesenteric ischemia acute intestinal obstruction #13 !A 48-year-old woman came to the GP with acute pancreatitis. From the anamnesis: She turned to the GP 1 hour after the onset of the disease. After taking spicy food, there was a sudden intense pain in the epigastrium, nausea, and vomiting. Objectively: On examination, the skin is of marble color, covered with cold sweat. BP - 80/60 mm Hg, pulse - 100 beats / min. The abdomen is swollen, soft, resistant in the left half. Which of the following complications is MOST likely? hemorrhagic shock enzymatic peritonitis pancreatogenic shock omental bursa abscess septic shock #14 !A 49-year-old man came to the GP with complaints of epigastric pain, nausea, abdominal distention, high temperature (up to 38.5 ºС). From the anamnesis: 10 days ago he was discharged from the hospital, where he was treated with a diagnosis of acute pancreatitis. Objectively: On examination, the face is pale, the abdomen is swollen, soft, moderately painful in the epigastrium, where the formation is indistinctly palpated, there is no dullness on percussion in sloping areas. Shchetkin-Blumberg's symptom is negative. Which of the following complications is MOST likely? peritonitis enzymatic peritonitis pancreatogenic shock omental bursa abscess septic shock #15 !A 25-year-old man addressed a GP with complaints of abdominal pain. From the anamnesis: Sick for 5 hours. Objectively: Palpation shows muscle tension and pain in the right iliac region. Rovsing's sign is positive. Which of the following diagnoses is MOST likely? mesenteric thrombosis acute intestinal obstruction acute appendicitis acute pancreatitis acute cholecystitis #16 !A 60-year-old man turned to a GP with complaints of aching pain in the right side of the abdomen. From the anamnesis: He has been ill for 5-6 days, he did not go to the doctors. Objectively: On examination, the body temperature is 37.6ºС. Palpation in the right iliac region is determined by the formation of an oval shape, motionless, 7.0x5.0 cm in size, moderately painful. Which of the following diagnoses is MOST likely? appendicular infiltrate acute enterocolitis acute appendicitis tumor of the caecum peritonitis #17 !A 52-year-old female patient came to the GP with complaints of pain in the right iliac region. From the anamnesis: 10 days ago, she was worried about pain in the right iliac region, nausea, vomiting, which stopped after 3 days. For the last 2 days there has been an increase in body temperature up to 38.5ºС, increased pain in the right iliac region. Objectively: Body temperature is 38.5ºС. On palpation of the abdomen, a sharply painful infiltrate with a softening area is determined. Which of the following complications is MOST likely? colon cancer hepatic abscess pylephlebitis perforation of the caecum abscess formation of appendicular infiltrate #18 !An 18-year-old patient addressed a GP with complaints of throbbing pain in the 1st finger of the right hand. From the anamnesis: 2 days ago he removed a splinter from under the nail, after which a white spot formed under the nail and pain began to bother him. MOST likely diagnosis? paronychia purulent wound of the finger subungual panaritium infected finger wound stab wound to finger #19 !A patient came to the GP with complaints of swelling and pain in the area of the 3rd finger of the left hand. From the anamnesis: I did a manicure in the salon, after 4 days the above complaints appeared. Objectively: The periungual ridge is hyperemic, edematous, painful on palpation, pus is released from under it when pressed. MOST likely diagnosis? subungual panaritium paronychia erysipeloid finger phlegmon pandactylitis #20 !A 30-year-old man came to the clinic with complaints about the presence of a tumor-like formation in the right iliac region. From the anamnesis: A year ago he underwent an appendectomy for acute gangrenous appendicitis. Objectively: In the right iliac region in the area of the postoperative scar in the standing position, a soft-elastic tumor-like formation is determined, which, in the prone position, is reduced into the abdominal cavity through a defect in the aponeurosis 2x3 cm in size. MOST likely diagnosis? irreducible hernia strangulated hernia postoperative ventral hernia suppuration of the postoperative wound abdominal abscess Marks correct answer
cat << 'PYEOF' > /home/daytona/workspace/gen_surgery_mcq.py from docx import Doc…