~/asha-pdf/generate_asha_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
OUTPUT = "/home/daytona/workspace/asha-pdf/ASHA_Functions_Mnemonics.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=14*mm,
rightMargin=14*mm,
topMargin=12*mm,
bottomMargin=12*mm,
)
# ── Colour palette ──────────────────────────────────────────────────────────
TEAL = colors.HexColor("#0D6E6E")
TEAL_LITE = colors.HexColor("#D6F0EE")
AMBER = colors.HexColor("#E8800A")
AMBER_LT = colors.HexColor("#FEF3E2")
GOLD = colors.HexColor("#C8962E")
DARK = colors.HexColor("#1A1A2E")
WHITE = colors.white
GREY_BG = colors.HexColor("#F7F9FB")
GREY_LINE = colors.HexColor("#CBD5E1")
styles = getSampleStyleSheet()
def S(name, **kw):
return ParagraphStyle(name, **kw)
title_style = S("Title2",
fontSize=17, leading=22, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=0)
subtitle_style = S("Sub",
fontSize=9, leading=12, textColor=colors.HexColor("#C8E6E6"),
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=0)
sec_head = S("SecHead",
fontSize=10, leading=13, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER)
body = S("Body",
fontSize=8.2, leading=11.5, textColor=DARK,
fontName="Helvetica", alignment=TA_LEFT)
bold_body = S("BoldBody",
fontSize=8.2, leading=11.5, textColor=DARK,
fontName="Helvetica-Bold", alignment=TA_LEFT)
mnem_letter = S("MnemLetter",
fontSize=14, leading=16, textColor=TEAL,
fontName="Helvetica-Bold", alignment=TA_CENTER)
mnem_word = S("MnemWord",
fontSize=8.5, leading=11, textColor=DARK,
fontName="Helvetica-Bold", alignment=TA_LEFT)
mnem_func = S("MnemFunc",
fontSize=8.2, leading=11, textColor=colors.HexColor("#444444"),
fontName="Helvetica", alignment=TA_LEFT)
footer_style = S("Footer",
fontSize=7, leading=9, textColor=colors.HexColor("#888888"),
fontName="Helvetica-Oblique", alignment=TA_CENTER)
story = []
# ── HEADER BANNER ────────────────────────────────────────────────────────────
header_data = [[
Paragraph("ASHA WORKER FUNCTIONS & MNEMONICS", title_style),
Paragraph("Accredited Social Health Activist | Park's PSM | NRHM", subtitle_style),
]]
header_table = Table(header_data, colWidths=[182*mm])
header_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), TEAL),
("TOPPADDING", (0,0), (-1,-1), 8),
("BOTTOMPADDING",(0,0), (-1,-1), 6),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
("ROUNDEDCORNERS", [4]),
]))
story.append(header_table)
story.append(Spacer(1, 5*mm))
# ── SECTION HEADER helper ────────────────────────────────────────────────────
def section_header(text, bg=TEAL):
t = Table([[Paragraph(text, sec_head)]], colWidths=[182*mm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), bg),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0),(-1,-1), 8),
("RIGHTPADDING", (0,0),(-1,-1), 8),
]))
return t
# ── QUICK FACTS ROW ──────────────────────────────────────────────────────────
facts = [
["👩 Selection", "Woman (married/widow/divorced), age 25-45 yrs, ≥ 8th class education, village resident"],
["📊 Coverage", "1 ASHA per 1,000 population (relaxed in tribal/hilly/desert areas)"],
["💰 Payment", "Performance-linked incentive (NOT a fixed salary)"],
["🔗 Role", "Link worker between community and health services (NRHM)"],
]
facts_table = Table(
[[Paragraph(f[0], bold_body), Paragraph(f[1], body)] for f in facts],
colWidths=[38*mm, 144*mm]
)
facts_table.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), GREY_BG),
("BACKGROUND", (0,0),(0,-1), TEAL_LITE),
("GRID", (0,0),(-1,-1), 0.4, GREY_LINE),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0),(-1,-1), 6),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
]))
story.append(facts_table)
story.append(Spacer(1, 4*mm))
# ── 10 FUNCTIONS TABLE ───────────────────────────────────────────────────────
story.append(section_header(" 10 ROLES & RESPONSIBILITIES OF ASHA"))
story.append(Spacer(1, 2*mm))
functions = [
("1", "A", "Awareness",
"Create awareness on health determinants: nutrition, sanitation, hygiene, healthy living, existing services & timely utilization"),
("2", "C", "Counselling",
"Counsel women on birth preparedness, safe delivery, breastfeeding, immunization, contraception, RTI/STI prevention, child care"),
("3", "M", "Mobilize Community",
"Facilitate access to services at Anganwadi / Sub-centre / PHC — immunization, ANC, PNC, supplementary nutrition, sanitation"),
("4", "V", "Village Health Plan",
"Work with Village Health & Sanitation Committee of Gram Panchayat to develop a comprehensive village health plan"),
("5", "E", "Escort / Accompany",
"Escort/accompany pregnant women & children needing treatment/admission to PHC / CHC / First Referral Unit (FRU)"),
("6", "P", "Primary Medical Care",
"Provide primary care for minor ailments (diarrhoea, fever, first aid); act as DOTS provider under RNTCP"),
("7", "D", "Drug Depot Holder",
"Depot holder for ORS, IFA, chloroquine, disposable delivery kit, oral pills, condoms — drug kit with AYUSH & allopathic items"),
("8", "G", "Graded Role (Provider)",
"Role as provider can be enhanced by graded training — newborn care, range of common ailments, childhood illnesses"),
("9", "I", "Inform / Notify",
"Inform sub-centre / PHC about births, deaths, unusual health problems & disease outbreaks in the community"),
("10","T", "Toilet Promotion",
"Promote construction of household toilets under Total Sanitation Campaign"),
]
func_rows = []
for num, letter, name, desc in functions:
func_rows.append([
Paragraph(f"<b>{num}</b>", S("N", fontSize=9, leading=11, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER)),
Paragraph(f"<b>{letter}</b>", S("L", fontSize=13, leading=15, textColor=TEAL, fontName="Helvetica-Bold", alignment=TA_CENTER)),
Paragraph(f"<b>{name}</b>", S("NM", fontSize=8.5, leading=11, textColor=DARK, fontName="Helvetica-Bold")),
Paragraph(desc, body),
])
func_table = Table(func_rows, colWidths=[10*mm, 10*mm, 36*mm, 126*mm])
func_table.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,-1), TEAL),
("BACKGROUND", (1,0),(1,-1), TEAL_LITE),
("ROWBACKGROUNDS",(2,0),(-1,-1), [WHITE, GREY_BG]),
("GRID", (0,0),(-1,-1), 0.3, GREY_LINE),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0),(-1,-1), 5),
("RIGHTPADDING", (0,0),(-1,-1), 5),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
]))
story.append(func_table)
story.append(Spacer(1, 4*mm))
# ── MNEMONICS SECTION ────────────────────────────────────────────────────────
story.append(section_header(" MNEMONICS", bg=AMBER))
story.append(Spacer(1, 2*mm))
# Mnemonic 1
m1_header = Table([[
Paragraph("<b>Mnemonic 1 — Sentence:</b> \"A Clever Man Very Easily Provides Drugs, Gets Information Timely\"",
S("M1H", fontSize=8.5, leading=11, textColor=DARK, fontName="Helvetica-Bold")),
]], colWidths=[182*mm])
m1_header.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), AMBER_LT),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 8),
("BOX", (0,0),(-1,-1), 0.5, AMBER),
]))
story.append(m1_header)
story.append(Spacer(1, 2*mm))
mnem_items = [
("A", "Awareness", "Health determinants — nutrition, sanitation, hygiene, services"),
("C", "Counselling", "Women — safe delivery, breastfeeding, immunization, contraception"),
("M", "Mobilize", "Community to PHC / AWC / sub-centre services"),
("V", "Village Plan", "Health plan with Village Health & Sanitation Committee"),
("E", "Escort", "Pregnant women & children to PHC / CHC / FRU"),
("P", "Primary Care", "Minor ailments + DOTS (TB) provider"),
("D", "Drug Depot", "ORS, IFA, chloroquine, delivery kit, oral pills, condoms"),
("G", "Graded Role", "Enhanced provider training — newborn care, childhood illness"),
("I", "Inform", "Births, deaths, outbreaks to sub-centre / PHC"),
("T", "Toilet Promotion", "Household toilets under Total Sanitation Campaign"),
]
mnem_rows = []
for letter, word, func_text in mnem_items:
mnem_rows.append([
Paragraph(f"<b>{letter}</b>",
S("ML2", fontSize=13, leading=15, textColor=AMBER, fontName="Helvetica-Bold", alignment=TA_CENTER)),
Paragraph(f"<b>{word}</b>",
S("MW2", fontSize=8.5, leading=11, textColor=DARK, fontName="Helvetica-Bold")),
Paragraph(func_text, body),
])
mnem_table = Table(mnem_rows, colWidths=[12*mm, 34*mm, 136*mm])
mnem_table.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,-1), AMBER_LT),
("ROWBACKGROUNDS",(1,0),(-1,-1), [WHITE, GREY_BG]),
("GRID", (0,0),(-1,-1), 0.3, GREY_LINE),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING", (0,0),(-1,-1), 4),
("LEFTPADDING", (0,0),(-1,-1), 6),
("RIGHTPADDING", (0,0),(-1,-1), 6),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
]))
story.append(mnem_table)
story.append(Spacer(1, 3*mm))
# Mnemonic 2 — short form
m2_data = [
[Paragraph("<b>Mnemonic 2 — Short (6 core roles):</b>",
S("M2L", fontSize=8.5, leading=11, textColor=DARK, fontName="Helvetica-Bold")),
Paragraph("<b>A C M E – P D</b>",
S("M2V", fontSize=11, leading=13, textColor=TEAL, fontName="Helvetica-Bold", alignment=TA_CENTER)),
Paragraph("<b>A</b>ctivist · <b>C</b>ounsellor · <b>M</b>obilizer · <b>E</b>scort · <b>P</b>rovider (care+DOTS+depot) · <b>D</b>ata reporter",
S("M2D", fontSize=8, leading=10.5, textColor=DARK, fontName="Helvetica")),
]
]
m2_table = Table(m2_data, colWidths=[42*mm, 34*mm, 106*mm])
m2_table.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), TEAL_LITE),
("BOX", (0,0),(-1,-1), 0.5, TEAL),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 6),
("RIGHTPADDING", (0,0),(-1,-1), 6),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
("LINEAFTER", (0,0),(1,-1), 0.5, GREY_LINE),
]))
story.append(m2_table)
story.append(Spacer(1, 3*mm))
# ── DRUG KIT CONTENTS ────────────────────────────────────────────────────────
story.append(section_header(" ASHA DRUG KIT CONTENTS (Depot — Function 7)", bg=TEAL))
story.append(Spacer(1, 2*mm))
drugs = [
["ORS (Oral Rehydration Salts)", "Iron Folic Acid (IFA) tablets", "Chloroquine"],
["Disposable delivery kit", "Oral contraceptive pills", "Condoms"],
]
drug_table = Table(
[[Paragraph(f"• {c}", body) for c in row] for row in drugs],
colWidths=[61*mm, 61*mm, 60*mm]
)
drug_table.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), GREY_BG),
("GRID", (0,0),(-1,-1), 0.3, GREY_LINE),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0),(-1,-1), 6),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
]))
story.append(drug_table)
story.append(Spacer(1, 4*mm))
# ── FOOTER ───────────────────────────────────────────────────────────────────
story.append(HRFlowable(width="100%", thickness=0.5, color=GREY_LINE))
story.append(Spacer(1, 1.5*mm))
story.append(Paragraph(
"Source: Park's Textbook of Preventive & Social Medicine | NRHM Guidelines, MoHFW, Govt. of India",
footer_style))
doc.build(story)
print(f"PDF saved: {OUTPUT}")