Sec C and E what
cd /tmp/workspace/attachments/41da4840-80a8-45a3-9224-5dac874f867f && python3 -c " import pdfplumber with pdfplumber.open('Form 2 – ANM first brief investigation report (1).pdf') as pdf: print('Pages:', len(pdf.pages)) for i, page in enumerate(pdf.pages): print(f'--- Page {i+1} ---') text = page.extract_text() print(text) "
What cause can be in sec c
Child Death Review Form 2 ANM "Section C" respondent cause of death India
What can be write in sec E option
Hypoglycaemia he has borad dead to medical
"hypoglycemia" AND child mortality
h. Any other cause (specify): Hypoglycaemia
1. Delay at home - if the seriousness of the weakness/lethargy/poor feeding wasn't recognized in time, or treatment (checking blood sugar, glucose administration) wasn't sought early.
They sleep and come to medical on morning when already dead what to write for C And E
As an anm write me 3 points
Sec c cause of death
"Child was weak and not feeding well in the evening. He was put to sleep as usual. In the morning, the family found the child not breathing/unresponsive. The family does not know the exact cause - they thought the child was only tired/sleeping and would be fine by morning."
"Weakness and poor feeding noted before sleep; found dead in the morning - exact cause not known to family."
Write sec c and E in short lines
Write in that pdf
cd /tmp/workspace/attachments/41da4840-80a8-45a3-9224-5dac874f867f && python3 -c " from pypdf import PdfReader r = PdfReader('Form 2 – ANM first brief investigation report (1).pdf') print('fields:', r.get_fields()) for i,p in enumerate(r.pages): print(i, p.mediabox) "
cd /tmp/workspace/attachments/41da4840-80a8-45a3-9224-5dac874f867f && python3 /tmp/skills/pdf/scripts/extract_form_structure.py "Form 2 – ANM first brief investigation report (1).pdf" /tmp/workspace/form_structure.json 2>&1 | tail -20
cd /tmp/workspace && python3 -c " import json data = json.load(open('form_structure.json')) labels = data.get('labels') or data.get('text_labels') or data if isinstance(data, dict): print(list(data.keys())) "
cd /tmp/workspace && python3 -c " import json data = json.load(open('form_structure.json')) for l in data['labels']: txt = l.get('text','') if 'Section C' in txt or 'Section E' in txt or ('respondent' in txt.lower()) or ('avert' in txt.lower()): print(l) "
cd /tmp/workspace && python3 -c " import json data = json.load(open('form_structure.json')) print('--- page2 top>600 ---') for l in sorted([x for x in data['labels'] if x['page']==2 and x['top']>600], key=lambda x:x['top']): print(round(x['top'],1), round(x['x0'],1), round(x['x1'],1), repr(x['text'])) print('--- page3 top<400 ---') for l in sorted([x for x in data['labels'] if x['page']==3 and x['top']<400], key=lambda x:x['top']): print(round(x['top'],1), round(x['x0'],1), round(x['x1'],1), repr(x['text'])) print('--- page3 lines ---') for l in data['lines']: if l.get('page')==3: print(l) "
cd /tmp/workspace && python3 -c " import json data = json.load(open('form_structure.json')) print('--- page2 top>600 ---') for l in sorted([x for x in data['labels'] if x['page']==2 and x['top']>600], key=lambda a:a['top']): print(round(l['top'],1), round(l['x0'],1), round(l['x1'],1), repr(l['text'])) print('--- page3 top<400 ---') for l in sorted([x for x in data['labels'] if x['page']==3 and x['top']<400], key=lambda a:a['top']): print(round(l['top'],1), round(l['x0'],1), round(l['x1'],1), repr(l['text'])) print('--- page3 lines ---') for l in data['lines']: if l.get('page')==3: print(l) "
mkdir -p /tmp/workspace/output && cat > /tmp/workspace/fill_form.py << 'EOF' from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 from pypdf import PdfReader, PdfWriter import io src_path = "/tmp/workspace/attachments/41da4840-80a8-45a3-9224-5dac874f867f/Form 2 – ANM first brief investigation report (1).pdf" out_path = "/tmp/workspace/output/Form2_ANM_Filled.pdf" reader = PdfReader(src_path) page_w = float(reader.pages[0].mediabox.width) page_h = float(reader.pages[0].mediabox.height) # Build overlay for page 2 (index 1) - Section C buf1 = io.BytesIO() c1 = canvas.Canvas(buf1, pagesize=(page_w, page_h)) c1.setFont("Helvetica", 9) c1.drawString(108, 150.5, "Child was weak and not feeding well before sleep; found dead in the") c1.drawString(108, 138.5, "morning - exact cause not known to family.") c1.save() buf1.seek(0) overlay_page2 = PdfReader(buf1).pages[0] # Build overlay for page 3 (index 2) - Section E, 3 lines buf2 = io.BytesIO() c2 = canvas.Canvas(buf2, pagesize=(page_w, page_h)) c2.setFont("Helvetica", 9) c2.drawString(95, 592.0, "Weakness/poor feeding before sleep should have been treated as a danger sign needing same-night care.") c2.drawString(95, 560.0, "Child should have been monitored periodically through the night, not left unchecked till morning.") c2.drawString(95, 528.0, "Timely medical attention that night could have corrected the hypoglycaemia and averted death.") c2.save() buf2.seek(0) overlay_page3 = PdfReader(buf2).pages[0] writer = PdfWriter() for i, page in enumerate(reader.pages): if i == 1: page.merge_page(overlay_page2) elif i == 2: page.merge_page(overlay_page3) writer.add_page(page) with open(out_path, "wb") as f: writer.write(f) print("Saved:", out_path) EOF python3 /tmp/workspace/fill_form.py
cd /tmp/workspace/output && python3 -c " import pdfplumber with pdfplumber.open('Form2_ANM_Filled.pdf') as pdf: for i in [1,2]: print(f'--- Page {i+1} ---') print(pdf.pages[i].extract_text()) "
Form2 ANM Filled
PDF Document · PDF