50 female came with BP 200/110 diagoned as hypertensive urgency now on Amlodipine 5 and losartan 50 mg came for follow up now her BP is 100/70 how to manage this case

Reading File
Finding Sources
Finding Sources
Searching PubMed

hypertensive urgency outpatient management blood pressure

Finding Sources
Finding Sources
Reading File
Reading File
Reading File
I now have enough high-quality textbook content to give a thorough, well-structured answer.

Management of Over-Treated Hypertension: BP 100/70 at Follow-up

This is a case of over-correction/over-treatment following hypertensive urgency. The patient presented with BP 200/110 (hypertensive urgency - no target organ damage), was started on Amlodipine 5 mg + Losartan 50 mg, and now presents with BP 100/70 mmHg - which is below optimal and potentially symptomatic.

Step 1: Assess the Patient Clinically (BEFORE adjusting medications)

First, determine whether she is symptomatic from the low BP:
SymptomSignificance
Dizziness, lightheadedness, especially on standingOrthostatic hypotension - clinically significant
Fatigue, weaknessPossible hypoperfusion
Syncope or near-syncopeRequires immediate dose reduction
Headache, visual changesRule out rebound
PalpitationsReflex tachycardia from CCB vasodilation
Also check:
  • Orthostatic BP (lying, sitting, standing) - a drop of >20 mmHg systolic or >10 mmHg diastolic is orthostatic hypotension
  • Heart rate (Amlodipine-related reflex tachycardia is common)
  • Renal function + electrolytes (Losartan can cause hyperkalemia/AKI if over-perfusion drops GFR)

Step 2: Understand Why This Happened

Hypertensive urgency should be managed with gradual BP reduction using long-acting oral agents, with the goal of normalizing BP over days to weeks - not hours. As noted in Harrison's Principles of Internal Medicine 22E:
"Hypertensive urgency is far more common than hypertensive emergency and should be treated with institution, reinstitution, or intensification of oral antihypertensive agents in an outpatient setting."
The combination of Amlodipine 5 mg (a long-acting dihydropyridine CCB) + Losartan 50 mg (an ARB) is an appropriate long-term regimen, but together in a de-novo hypertensive patient they may have lowered BP more aggressively than anticipated - especially if the patient:
  • Was initially volume-depleted (natriuresis from sustained high BP is common)
  • Has white-coat hypertension component
  • Is salt-restricted or has poor oral intake
  • Is unusually sensitive to renin-angiotensin blockade

Step 3: Medication Adjustment Strategy

Target BP for a 50-year-old woman with hypertension (no diabetes, no CKD documented): <130/80 mmHg (ACC/AHA 2017 guidelines). BP 100/70 is below target and may indicate over-treatment.

If asymptomatic (BP 100/70 but feeling well):

  • Do not panic - some patients, especially lean females, run lower BPs
  • Consider reducing Amlodipine to 2.5 mg (this is the lower starting dose) - Amlodipine is available in 2.5 mg tablets or can be given on alternate days as a practical measure
  • Continue Losartan 50 mg - it provides organ protection (renal and cardiovascular) and the dose is already at the low end
  • Re-check BP in 1-2 weeks

If symptomatic (dizziness, orthostasis, fatigue):

  • Withhold Amlodipine for 2-3 days and reassess - Amlodipine has a long half-life (~35-50 hours), so it will take time to wear off
  • Reduce to Amlodipine 2.5 mg once daily when restarting
  • Consider whether Losartan is the right choice - if she has volume depletion contributing, the ARB may be excessively lowering BP; Losartan dose can be halved to 25 mg
  • Advise liberal salt and fluid intake in the short term while BP recovers

Practical stepdown approach:

Current: Amlodipine 5 mg + Losartan 50 mg  →  BP 100/70

Option A (asymptomatic): Amlodipine 2.5 mg + Losartan 50 mg
Option B (symptomatic):  Stop Amlodipine temporarily; Losartan 25 mg
Option C (mild symptoms): Amlodipine 5 mg alternate days + Losartan 25 mg

Step 4: Workup to Guide Long-term Management

At this follow-up visit, also assess:
  1. Medication adherence - was she actually taking both drugs regularly? (If yes, the combination is too strong at current doses)
  2. Secondary hypertension workup (if not done) - in a 50-year-old woman, consider:
    • Renal artery stenosis (bilateral disease + ACE inhibitor/ARB can cause severe hypotension)
    • Primary hyperaldosteronism (aldosterone-renin ratio)
    • Thyroid function
  3. Metabolic panel - K+, creatinine, especially with Losartan use
  4. Lifestyle counseling - DASH diet, sodium restriction, weight management, exercise - these alone can reduce BP 5-10 mmHg

Step 5: Reassess BP Target and Follow-up Plan

Visit timingGoal
NowAdjust medications, check for symptoms, labs
2 weeksRepeat BP measurement, reassess
6-8 weeksConfirm stable BP in 120-130/80 mmHg range
OngoingAnnual monitoring, reassess need for both agents
Note: Amlodipine + ARB (Losartan) is actually a preferred combination per guidelines (it reduces side effects vs ARB+diuretic and provides good CV protection). The goal is to find the right dose of each - not to abandon the combination.

Key Teaching Point

Comprehensive Clinical Nephrology (7th Ed.) specifically warns against sublingual short-acting nifedipine (causes precipitous hypotension/stroke/MI), and emphasizes that long-acting agents like amlodipine do not have a role in rapidly reducing BP in acute settings - but are the ideal agents for long-term BP control. The problem here is that two effective long-acting agents together have now overshot the target.
The situation is correctable with a simple dose reduction, reassurance, and close follow-up. There is no need for hospitalization unless the patient has severe symptomatic hypotension, syncope, or signs of end-organ hypoperfusion.

50 female came with BP 200/110 diagoned as hypertensive urgency now on Amlodipine 5 and losartan 50 mg came for follow up after 3 months now her BP is 100/70 how to manage this case

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Excellent. I have solid textbook-based evidence. Now let me deliver a thorough, clinically-focused answer.

Managing BP 100/70 at 3-Month Follow-up After Hypertensive Urgency

The 3-month time frame is the key clinical distinction here. This is not early overshoot - this is a patient who has been stable on a dual-agent regimen for 3 months and is now presenting with a BP that is below the acceptable treatment threshold. The approach is therefore more systematic than a simple dose adjustment.

Step 1: Full Clinical Assessment at This Visit

Symptoms of Hypoperfusion

Before touching medications, establish whether the patient is symptomatic:
SymptomClinical Significance
Dizziness, lightheadednessCerebral hypoperfusion, orthostatic hypotension
Fatigue, weaknessReduced cardiac output
Syncope or near-syncopeUrgent dose reduction needed
Ankle edemaAmlodipine-related (not hypotension per se)
Headache, blurred visionCould be rebound or unrelated

Orthostatic BP Check (Mandatory)

Measure BP lying, sitting, and after 2 minutes of standing. A drop of >20 mmHg systolic or >10 mmHg diastolic on standing = orthostatic hypotension - clinically significant and a fall risk, especially important in a 50-year-old perimenopausal woman.

Heart Rate

  • Amlodipine (dihydropyridine CCB) causes reflex tachycardia via vasodilation. If HR is high with low BP, Amlodipine is likely the main driver.

Step 2: Why Has This Happened After 3 Months?

After 3 months on a stable regimen, BP 100/70 suggests one or more of these mechanisms:

A. The Initial Presentation Was Not "True" Sustained Hypertension

This is the most common and most important scenario. The presenting BP of 200/110 during a hypertensive urgency may have been driven by:
  • Pain or acute stress at the time of presentation
  • White-coat hypertension amplified in an acute setting
  • Non-adherence to a prior regimen followed by re-initiation effect
  • Anxiety, panic at the time of the acute visit
As Comprehensive Clinical Nephrology (7th Ed.) notes, guidelines recommend confirming hypertension with ambulatory blood pressure monitoring (ABPM) or home BP monitoring to identify white-coat hypertension - which is "not necessary when BP is markedly elevated in patients requiring urgent treatment," but becomes very relevant at follow-up when BP has normalized significantly.

B. Significant Lifestyle Modification Over 3 Months

  • Weight loss, sodium restriction, regular exercise, reduced alcohol - each can reduce SBP by 4-10 mmHg independently
  • Combined effect over 3 months can be substantial

C. Regression to Mean

A single very high "urgency" BP reading often reflects a transient peak; the patient's actual baseline may be much lower.

D. Drug Combination Effect Is Additive

Amlodipine 5 mg + Losartan 50 mg is a synergistic combination:
  • Amlodipine causes vasodilation (reduces peripheral vascular resistance)
  • Losartan blocks angiotensin II (reduces vascular tone + sodium retention)
  • Together in a patient whose "true" BP is lower than the urgency reading, the effect is exaggerated

Step 3: Investigations to Order

InvestigationPurpose
Repeat BP both arms, 3 readingsConfirm true BP; rule out measurement artifact
Home BP log review (if available)Assess if 100/70 is consistent or a one-off low reading
Serum creatinine + eGFRLosartan at lower BP may reduce renal perfusion - check for AKI
Serum potassiumLosartan causes potassium retention; hypotension + ARB = hyperkalemia risk
Fasting glucose + lipidsComplete cardiovascular risk assessment at 3 months
ECGRule out LVH regression (a positive sign), arrhythmia
ABPM or 7-day home BP monitoringDistinguish true hypotension from white-coat effect in reverse (now under-reading in office?)
TSHHypothyroidism can cause rebound BP changes; common in 50-year-old women
Urinalysis + uACRAssess for proteinuria - guides whether ARB must be continued regardless of BP

Step 4: Medication Adjustment

Decision Framework

BP 100/70 at 3 months on Amlodipine 5 mg + Losartan 50 mg

Is she symptomatic? (dizziness, orthostasis, syncope)
        │
   YES ─┴─ NO
    │           │
Reduce          Confirm with home readings / ABPM
both agents     │
immediately     Still consistently 100-110/60-75?
                │
                YES → Reduce one agent (see below)

Recommended Adjustments

Option 1 (Preferred - if no compelling indication to keep Losartan):
  • Reduce Amlodipine from 5 mg to 2.5 mg (halve the dose; Amlodipine 2.5 mg is the lowest approved dose)
  • Continue Losartan 50 mg (provides renal and cardiovascular organ protection regardless of BP)
  • Review in 4 weeks
Option 2 (If proteinuria absent and no diabetic nephropathy):
  • Stop Amlodipine temporarily for 1-2 weeks and reassess BP
  • Amlodipine half-life is 35-50 hours, so it will clear in ~7 days
  • Restart at 2.5 mg if BP rises again
Option 3 (If truly low-risk patient with white-coat urgency presentation):
  • Consider stopping both agents and repeating ABPM/home monitoring over 2 weeks
  • If home BP averages <130/80, she may not need pharmacotherapy at all - manage with lifestyle alone
  • This is appropriate only if no proteinuria, no LVH, no diabetes, no CKD
The Comprehensive Clinical Nephrology (7th Ed.) and Harrison's Principles of Internal Medicine 22E both emphasize that the BP treatment goal for uncomplicated hypertension is <130/80 mmHg (ACC/AHA 2017) or <140/90 mmHg (ESC/ESH 2018). A BP of 100/70 is significantly below both targets.

Step 5: Special Considerations for a 50-Year-Old Woman

FactorImplication
Perimenopausal statusEstrogen fluctuations cause BP variability; consider hormonal evaluation
Bone healthNot directly relevant here, but thiazides are preferred over Losartan if diuretic needed in future for fracture protection
PregnancyAt 50, unlikely but Losartan is teratogenic - confirm contraception status
Falls riskOrthostatic hypotension at this age significantly increases falls and fracture risk - must be addressed
Cardiovascular risk recalculationAt 3 months, recalculate 10-year ASCVD risk; if low, less aggressive BP target acceptable

Summary: Practical Action Plan

  1. Take a thorough symptom history - especially dizziness on standing, falls, fatigue
  2. Measure orthostatic BP - if drop confirmed, medications need immediate adjustment
  3. Order labs: creatinine, potassium, glucose, lipids, TSH, urinalysis with ACR
  4. Order ABPM or instruct home BP monitoring for 7 days before changing medications, unless symptomatic
  5. Reduce Amlodipine to 2.5 mg as the first step - this is the gentler, safer reduction
  6. Retain Losartan 50 mg unless proteinuria is absent, CKD is excluded, and patient prefers to trial off medications
  7. Intensify lifestyle counseling - DASH diet, exercise, weight - and attribute BP improvement to these efforts as positive reinforcement
  8. Follow up in 4 weeks with BP recheck after dose adjustment
Key teaching point: A BP of 100/70 after 3 months of treatment in a patient diagnosed with hypertensive urgency should prompt you to ask - "Did she truly have sustained hypertension, or was the urgency reading a one-time extreme?" The answer determines whether this patient needs lifelong therapy at all. - Comprehensive Clinical Nephrology, 7th Ed.; Harrison's Principles 22E

How to do diatery counselling for a patient of diabetes in opd

Finding Sources
Finding Sources
Searching PubMed

"diabetes mellitus"[MeSH Terms] AND "diet therapy"[MeSH Terms]

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Excellent - I now have comprehensive, authoritative content from Harrison's 22E and Textbook of Family Medicine 9e. Here is the full, structured dietary counselling guide:

Dietary Counselling for a Diabetic Patient in OPD

This is called Medical Nutrition Therapy (MNT) - the ADA's term for the optimal coordination of caloric intake with all other aspects of diabetes therapy (insulin, exercise, weight management). It is not a one-time chat; it is an ongoing, individualized process.

Part 1: The Mindset Before You Begin

"Clinicians should be viewed as coaches who direct diabetes care, although patients are ultimately responsible for carrying out the complex daily self-management regimen." - Textbook of Family Medicine 9e
  • Never blame the patient for poor glycemic control - multiple variables affect glucose daily
  • Individualize all advice: ask about cultural food preferences, religious practices (fasting), work schedule, income
  • Keep language simple, practical, and non-judgmental
  • The goal is sustainable behaviour change, not a rigid diet

Part 2: The Structure of an OPD Dietary Counselling Session

Step 1: Assess the Patient First (5-7 minutes)

Ask before you advise:
QuestionWhat you are assessing
"What do you typically eat in a day?"Current diet baseline
"How many meals do you eat? At what times?"Meal frequency and timing
"Do you eat rice/roti/bread? How much?"Carbohydrate load per meal
"Do you drink tea/coffee with sugar?"Hidden sugar intake
"Do you eat fruits? Which ones?"Fruit sugar awareness needed
"Do you fast for religious reasons?"Hypoglycemia risk during fasts
"Are you vegetarian/vegan?"Protein source planning
"Who cooks at home? Can they be involved?"Family engagement
"What is your budget for food?"Practical feasibility

Step 2: Explain the Core Concept Clearly (2-3 minutes)

Use this simple explanation:
"Your blood sugar rises because of carbohydrates - rice, roti, bread, sugar, fruits. Your body cannot process these fast enough. The goal is not to stop eating these, but to eat less of them at one time, eat more frequently in smaller portions, and choose slower-digesting forms."
Key messages to convey:
  • 3 main meals + 1-2 small snacks is better than 2 large meals
  • Skipping meals is harmful - it causes hypoglycemia (especially if on medications)
  • It is not about "dieting" - it is about consistent, balanced eating patterns

Part 3: The Actual Dietary Advice (Content of Counselling)

1. Carbohydrates - The Most Important Component

"Monitor carbohydrate intake in regard to calories and set limits for meals to reduce postprandial glycemia... Avoid fructose- and sucrose-containing beverages and minimize consumption of foods with added sugar." - Harrison's Principles of Internal Medicine 22E
Practical instructions:
  • Reduce portion size of rice/roti - use a smaller plate; one cup of cooked rice = ~45 g carbs
  • Choose complex over simple carbs: whole wheat roti > white bread; brown rice > white rice; oats > cornflakes
  • Glycemic index (GI) concept (explain in simple terms):
High GI (avoid/limit)Low GI (prefer)
White rice, white bread, maidaBrown rice, whole wheat, oats
Sugar, jaggery, honeyDals, legumes, barley
Fruit juice, cold drinksWhole fruits (in moderation)
Potato (especially mashed)Sweet potato, yam
Cornflakes, puffed riceOatmeal, daliya
"Use of the glycemic index may reduce postprandial glucose excursions and improve glycemic control." - Harrison's 22E
  • Limit sugar to zero - advise sugar-free tea/coffee; avoid sugary drinks entirely
  • Reduced-calorie sweeteners (stevia, sucralose) are acceptable substitutes

2. Vegetables - Encourage Freely

  • Non-starchy vegetables can be eaten liberally: spinach, methi, bhindi, karela, cucumber, tomato, capsicum, cabbage, cauliflower, brinjal
  • Starchy vegetables should be limited: potato, sweet corn, peas, raw banana
  • Aim for at least 2-3 servings of vegetables per day
  • Karela (bitter gourd) has evidence for modest glucose reduction - include it

3. Fruits - In Moderation, Not Freely

Many patients believe "natural sugar is safe" - correct this misconception:
  • Low GI fruits (1 small serving/day): guava, papaya, apple, pear, orange, berries, jamun
  • High GI fruits to limit: mango, banana, grapes, chikoo, dates
  • Never fruit juice - it lacks fibre and causes rapid glucose spike
  • Best timing: eat fruit mid-morning or mid-afternoon, not at night

4. Proteins - Adequate and Protective

"Optimal percentage of protein in diet is not known; should be individualized." - Harrison's 22E
  • Protein does not raise blood sugar - reassure patients
  • Include protein in every meal: it slows gastric emptying and blunts glucose spikes
  • Good sources: dals, legumes, curd (low fat), paneer (in moderation), eggs, fish, chicken (without skin)
  • Limit red meat and processed meat (increases cardiovascular risk)
  • If CKD present: restrict protein to 0.6-0.8 g/kg/day (refer to nephrologist)

5. Fats - Quality Matters More Than Quantity

"Encourage Mediterranean-style diet rich in monounsaturated and polyunsaturated fatty acids. Minimal or no trans fat consumption." - Harrison's 22E
  • Reduce cooking oil to 3-4 teaspoons per day per person
  • Best oils: mustard oil, olive oil, groundnut oil (MUFA-rich)
  • Avoid: vanaspati ghee, partially hydrogenated oils, dalda, trans fats in biscuits/namkeen/bakery items
  • Limit ghee and butter - small amounts acceptable; not multiple tablespoons
  • Nuts (5-6 daily): almonds, walnuts are beneficial - healthy fats + good for CV risk
  • Coconut oil: limit - high in saturated fat

6. Fibre - A Diabetic's Best Friend

  • Soluble fibre slows glucose absorption and reduces postprandial spikes
  • Advise: whole grains, psyllium husk (isabgol in water before meals), vegetables, legumes
  • Simple tip: "Fill half your plate with vegetables at every meal"

7. Beverages and Hidden Sugars

Avoid completelyAllowed
Cold drinks, packaged juicesWater, buttermilk (chaas), plain lassi
Energy drinks, packed flavoured milkGreen tea, herbal teas (no sugar)
Sweet tea/coffee (4+ cups/day)1-2 cups tea/coffee with no sugar or stevia
Packaged soups, instant noodlesHomemade thin soups
Alcohol (or strict limits if unavoidable)Coconut water (in moderation - contains sugar)

8. Sodium - Important for Concurrent Hypertension

"Sodium intake as advised for general population: <2300 mg/d." - Harrison's 22E
  • Limit salt to <5 g per day (about 1 teaspoon)
  • Avoid pickles, papads, processed/packaged snacks, instant foods
  • Especially important if the patient also has hypertension or CKD

Part 4: The Plate Method - Easy Visual Teaching Tool

Use this when patients struggle with portions:
┌─────────────────────────────────────────────┐
│         YOUR DIABETIC MEAL PLATE            │
│                                             │
│    ½ plate = NON-STARCHY VEGETABLES         │
│    (salad, sabzi, soup)                     │
│                                             │
│    ¼ plate = WHOLE GRAINS / CARBS           │
│    (1-2 rotis OR ½ cup rice)                │
│                                             │
│    ¼ plate = PROTEIN                        │
│    (dal, curd, egg, chicken, paneer)        │
│                                             │
│    + 1 small fruit OR glass of buttermilk   │
└─────────────────────────────────────────────┘

Part 5: Meal Timing and Frequency

TimeMeal
7:00-8:00 AMBreakfast (must not skip)
10:30-11:00 AMMid-morning snack (handful of nuts or 1 fruit)
1:00-1:30 PMLunch
4:00-4:30 PMEvening snack (roasted chana, sprouts, handful nuts)
7:30-8:30 PMDinner (lighter than lunch; early preferred)
  • Avoid eating after 9 PM
  • Do not skip meals - especially if on sulfonylureas or insulin
  • Bedtime snack (if on insulin): 1 small cup of low-fat curd or handful of nuts to prevent nocturnal hypoglycemia

Part 6: Special Situations in Counselling

If on Insulin:

  • Must understand carb counting - 15 g carbs = 1 carb exchange
  • Meal must happen within 15-30 minutes of rapid insulin
  • Consistency in meal timing is more important than perfection

If Fasting (Religious):

"Note risk of hypoglycemia associated with religious fasting." - Harrison's 22E
  • Adjust medication timing with your doctor before fasting
  • Sehri/pre-fast meal should include slow-digesting foods
  • Break fast with small, low-GI food; avoid large quantities suddenly

If Overweight (Most Type 2 Diabetics):

"Encourage modest weight reduction of 5%-10% from baseline." - Textbook of Family Medicine 9e
  • Even 5-7 kg weight loss significantly improves insulin sensitivity
  • Reduce total calorie intake by 300-500 kcal/day rather than extreme restriction
  • Intermittent fasting (16:8) may help some patients; evidence is emerging but not conclusive per current guidelines

If Elderly:

  • Protein needs may be higher (sarcopenia risk)
  • Avoid overly restrictive diets that reduce overall food intake
  • Social eating (with family) should be encouraged, not isolated dieting

Part 7: Metabolic Targets to Share with Patient

From the Textbook of Family Medicine 9e (ADA guidelines):
ParameterTarget
HbA1c≤7.0%
Fasting blood glucose70-130 mg/dL
2-hour post-meal glucose<180 mg/dL
Blood pressure<140/80 mmHg
LDL cholesterol<100 mg/dL
Triglycerides<150 mg/dL
Tell the patient: "Good diet will help you reach all of these targets, not just sugar."

Part 8: What to Give the Patient Before They Leave

  1. A written diet chart in their local language if possible (or simple verbal summary)
  2. One clear takeaway message per visit - do not overwhelm
  3. Next appointment - MNT is not a one-time event; reinforce at every visit
  4. Referral to dietician if available - certified diabetes educators/dieticians provide structured, ongoing MNT

Summary: The 10-Point Diabetes Diet Message for Patients

  1. Eat on time - never skip meals
  2. Eat less rice/roti - use a smaller plate
  3. Fill half your plate with vegetables
  4. Choose whole grains over refined grains
  5. No sugar, no sugary drinks
  6. Fruits in moderation - no juice
  7. Eat protein (dal, curd, egg) at every meal
  8. Reduce oil, avoid trans fats completely
  9. Drink plenty of water
  10. Exercise 30 minutes daily - it is part of diet therapy
"Dietary advice should be individualized, acknowledging personal preferences, cultural, and religious traditions." - Harrison's Principles of Internal Medicine 22E (2025, McGraw Hill)

Create a diabetes nutrition handout or visual guide for OPD

Asking for Preferences
Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"

Running Command

python3 -c "import reportlab; print('reportlab ok')" && python3 -c "from reportlab.lib.pagesizes import A4; print('A4 ok')"

Writing File

~/diabetes-handout/create_handout.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import Flowable
import os

os.makedirs("/home/daytona/workspace/diabetes-handout", exist_ok=True)
OUTPUT = "/home/daytona/workspace/diabetes-handout/Diabetes_Nutrition_Handout.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
GREEN      = colors.HexColor("#2E7D32")   # dark green
LIGHT_GRN  = colors.HexColor("#E8F5E9")   # mint background
MED_GRN    = colors.HexColor("#66BB6A")   # medium green
RED        = colors.HexColor("#C62828")   # danger red
LIGHT_RED  = colors.HexColor("#FFEBEE")   # light red
ORANGE     = colors.HexColor("#E65100")   # orange accent
LIGHT_ORG  = colors.HexColor("#FFF3E0")   # light orange
BLUE       = colors.HexColor("#1565C0")   # blue accent
LIGHT_BLUE = colors.HexColor("#E3F2FD")   # light blue
TEAL       = colors.HexColor("#00695C")   # teal
LIGHT_TEAL = colors.HexColor("#E0F2F1")   # light teal
GREY_DARK  = colors.HexColor("#37474F")
GREY_LIGHT = colors.HexColor("#ECEFF1")
WHITE      = colors.white
YELLOW     = colors.HexColor("#F9A825")
LIGHT_YEL  = colors.HexColor("#FFFDE7")

# ── Styles ───────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def make_style(name, parent="Normal", **kw):
    s = ParagraphStyle(name, parent=base[parent], **kw)
    return s

title_style = make_style("Title2", "Normal",
    fontSize=22, leading=26, textColor=WHITE, alignment=TA_CENTER,
    fontName="Helvetica-Bold")

subtitle_style = make_style("Sub", "Normal",
    fontSize=11, leading=14, textColor=WHITE, alignment=TA_CENTER,
    fontName="Helvetica")

section_title = make_style("SecTitle", "Normal",
    fontSize=12, leading=15, textColor=WHITE,
    fontName="Helvetica-Bold", alignment=TA_LEFT)

body = make_style("Body2", "Normal",
    fontSize=9.5, leading=13, textColor=GREY_DARK,
    fontName="Helvetica")

body_bold = make_style("BodyBold", "Normal",
    fontSize=9.5, leading=13, textColor=GREY_DARK,
    fontName="Helvetica-Bold")

bullet_style = make_style("Bullet", "Normal",
    fontSize=9, leading=12.5, textColor=GREY_DARK,
    fontName="Helvetica", leftIndent=8)

small_style = make_style("Small", "Normal",
    fontSize=8, leading=11, textColor=GREY_DARK,
    fontName="Helvetica")

footer_style = make_style("Footer", "Normal",
    fontSize=7.5, leading=10, textColor=colors.HexColor("#78909C"),
    fontName="Helvetica-Oblique", alignment=TA_CENTER)

tip_style = make_style("Tip", "Normal",
    fontSize=9, leading=12, textColor=ORANGE,
    fontName="Helvetica-Bold", alignment=TA_CENTER)

# ── Custom Flowable: Coloured Box Header ─────────────────────────────────────
class BoxHeader(Flowable):
    def __init__(self, text, subtext=None, bg=GREEN, width=None, height=None):
        Flowable.__init__(self)
        self.text = text
        self.subtext = subtext
        self.bg = bg
        self._width = width or (A4[0] - 2*cm)
        self._height = height or (subtext and 30*mm or 20*mm)

    def draw(self):
        c = self.canv
        c.setFillColor(self.bg)
        c.roundRect(0, 0, self._width, self._height, 6, fill=1, stroke=0)
        c.setFillColor(WHITE)
        c.setFont("Helvetica-Bold", 18 if not self.subtext else 20)
        y_title = self._height/2 + (5 if self.subtext else 0)
        c.drawCentredString(self._width/2, y_title, self.text)
        if self.subtext:
            c.setFont("Helvetica", 10)
            c.drawCentredString(self._width/2, self._height/2 - 8, self.subtext)

    def wrap(self, availW, availH):
        return self._width, self._height


class SectionHeader(Flowable):
    def __init__(self, emoji, title, bg=GREEN, width=None):
        Flowable.__init__(self)
        self.emoji = emoji
        self.title = title
        self.bg = bg
        self._width = width or (A4[0] - 2*cm)
        self._height = 10*mm

    def draw(self):
        c = self.canv
        c.setFillColor(self.bg)
        c.roundRect(0, 0, self._width, self._height, 4, fill=1, stroke=0)
        c.setFillColor(WHITE)
        c.setFont("Helvetica-Bold", 11)
        c.drawString(8, 3, f"  {self.emoji}  {self.title}")

    def wrap(self, availW, availH):
        return self._width, self._height


class PlateVisual(Flowable):
    """Draws the diabetes meal plate graphic."""
    def __init__(self, width=110*mm, height=110*mm):
        Flowable.__init__(self)
        self._width = width
        self._height = height

    def wrap(self, availW, availH):
        return self._width, self._height

    def draw(self):
        import math
        c = self.canv
        cx = self._width / 2
        cy = self._height / 2
        r = 46*mm

        # Outer plate shadow
        c.setFillColor(colors.HexColor("#B0BEC5"))
        c.circle(cx+1.5, cy-1.5, r+3*mm, fill=1, stroke=0)

        # Plate rim
        c.setFillColor(colors.HexColor("#FAFAFA"))
        c.circle(cx, cy, r+3*mm, fill=1, stroke=0)

        # ── Segment 1: Vegetables (bottom half = 180°) ────────────────────
        c.setFillColor(colors.HexColor("#A5D6A7"))
        p = c.beginPath()
        p.moveTo(cx, cy)
        p.arcTo(cx-r, cy-r, cx+r, cy+r, startAng=0, extent=180)
        p.close()
        c.drawPath(p, fill=1, stroke=0)

        # ── Segment 2: Grains (top-left = 90°) ───────────────────────────
        c.setFillColor(colors.HexColor("#FFCC80"))
        p = c.beginPath()
        p.moveTo(cx, cy)
        p.arcTo(cx-r, cy-r, cx+r, cy+r, startAng=180, extent=90)
        p.close()
        c.drawPath(p, fill=1, stroke=0)

        # ── Segment 3: Protein (top-right = 90°) ─────────────────────────
        c.setFillColor(colors.HexColor("#EF9A9A"))
        p = c.beginPath()
        p.moveTo(cx, cy)
        p.arcTo(cx-r, cy-r, cx+r, cy+r, startAng=270, extent=90)
        p.close()
        c.drawPath(p, fill=1, stroke=0)

        # Dividers
        c.setStrokeColor(WHITE)
        c.setLineWidth(2)
        c.line(cx, cy, cx, cy+r)          # vertical top
        c.line(cx, cy, cx-r, cy)          # horizontal left
        c.line(cx, cy, cx+r, cy)          # horizontal right

        # Centre circle
        c.setFillColor(WHITE)
        c.circle(cx, cy, 7*mm, fill=1, stroke=0)

        # Labels inside segments
        c.setFillColor(colors.HexColor("#1B5E20"))
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(cx, cy - 28*mm, "1/2 PLATE")
        c.setFont("Helvetica", 7)
        c.drawCentredString(cx, cy - 35*mm, "Vegetables")
        c.drawCentredString(cx, cy - 41*mm, "(sabzi, salad)")

        c.setFillColor(colors.HexColor("#E65100"))
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(cx - 23*mm, cy + 22*mm, "1/4 PLATE")
        c.setFont("Helvetica", 7)
        c.drawCentredString(cx - 23*mm, cy + 15*mm, "Grains")
        c.drawCentredString(cx - 23*mm, cy + 9*mm, "(roti/rice)")

        c.setFillColor(colors.HexColor("#B71C1C"))
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(cx + 23*mm, cy + 22*mm, "1/4 PLATE")
        c.setFont("Helvetica", 7)
        c.drawCentredString(cx + 23*mm, cy + 15*mm, "Protein")
        c.drawCentredString(cx + 23*mm, cy + 9*mm, "(dal/curd/egg)")

        # Title below
        c.setFillColor(GREEN)
        c.setFont("Helvetica-Bold", 9.5)
        c.drawCentredString(cx, 4*mm, "The Diabetes Meal Plate")


# ── Document ─────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=1.8*cm, leftMargin=1.8*cm,
    topMargin=1.5*cm, bottomMargin=1.5*cm
)

W = A4[0] - 3.6*cm   # usable width
story = []

# ════════════════════════════════════════════════════════════════════════════
# TITLE BANNER
# ════════════════════════════════════════════════════════════════════════════
story.append(BoxHeader(
    "DIABETES DIET GUIDE",
    subtext="Your Daily Nutrition Plan for Better Blood Sugar Control",
    bg=GREEN, width=W, height=28*mm
))
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════════════
# TARGETS ROW
# ════════════════════════════════════════════════════════════════════════════
story.append(SectionHeader("🎯", "YOUR GLUCOSE TARGETS", bg=TEAL, width=W))
story.append(Spacer(1, 2*mm))

targets = [
    ["HbA1c", "Fasting Glucose", "Post-meal (2 hr)", "Blood Pressure"],
    ["≤ 7.0%", "70–130 mg/dL", "< 180 mg/dL", "< 140/80 mmHg"],
]
t = Table(targets, colWidths=[W/4]*4)
t.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,0), TEAL),
    ("TEXTCOLOR",    (0,0), (-1,0), WHITE),
    ("FONTNAME",     (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",     (0,0), (-1,0), 9),
    ("BACKGROUND",   (0,1), (-1,1), LIGHT_TEAL),
    ("FONTNAME",     (0,1), (-1,1), "Helvetica-Bold"),
    ("FONTSIZE",     (0,1), (-1,1), 11),
    ("TEXTCOLOR",    (0,1), (-1,1), TEAL),
    ("ALIGN",        (0,0), (-1,-1), "CENTER"),
    ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
    ("ROWBACKGROUNDS",(0,0),(-1,-1),[TEAL, LIGHT_TEAL]),
    ("GRID",         (0,0), (-1,-1), 0.5, WHITE),
    ("TOPPADDING",   (0,0), (-1,-1), 5),
    ("BOTTOMPADDING",(0,0), (-1,-1), 5),
    ("ROUNDEDCORNERS", [4]),
]))
story.append(t)
story.append(Spacer(1, 4*mm))

# ════════════════════════════════════════════════════════════════════════════
# TWO-COLUMN LAYOUT: Plate visual + Meal timing
# ════════════════════════════════════════════════════════════════════════════
plate = PlateVisual(width=95*mm, height=100*mm)

timing_data = [
    ["Time", "Meal / Snack"],
    ["7:00 – 8:00 AM",  "Breakfast  (DO NOT skip)"],
    ["10:30 – 11:00 AM","Mid-morning snack"],
    ["1:00 – 1:30 PM",  "Lunch"],
    ["4:00 – 4:30 PM",  "Evening snack"],
    ["7:30 – 8:30 PM",  "Dinner  (light & early)"],
    ["Bedtime\n(if on insulin)","Small snack: curd / nuts"],
]
tw = Table(timing_data, colWidths=[38*mm, 52*mm])
tw.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,0), BLUE),
    ("TEXTCOLOR",    (0,0), (-1,0), WHITE),
    ("FONTNAME",     (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",     (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[LIGHT_BLUE, WHITE]),
    ("ALIGN",        (0,0), (-1,-1), "LEFT"),
    ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
    ("GRID",         (0,0), (-1,-1), 0.4, colors.HexColor("#B0BEC5")),
    ("TOPPADDING",   (0,0), (-1,-1), 4),
    ("BOTTOMPADDING",(0,0), (-1,-1), 4),
    ("LEFTPADDING",  (0,0), (-1,-1), 5),
    ("FONTNAME",     (0,1), (-1,-1), "Helvetica"),
    ("FONTNAME",     (0,2), (0,2), "Helvetica-Bold"),
    ("BACKGROUND",   (0,2), (-1,2), LIGHT_BLUE),
    ("BACKGROUND",   (0,4), (-1,4), LIGHT_BLUE),
    ("BACKGROUND",   (0,6), (-1,6), LIGHT_BLUE),
]))

timing_section = Table(
    [[
        plate,
        Table([
            [Paragraph("<b>MEAL TIMING</b>", make_style("BH","Normal",
                fontSize=10, fontName="Helvetica-Bold",
                textColor=BLUE, alignment=TA_CENTER))],
            [tw],
            [Spacer(1,2*mm)],
            [Paragraph(
                "<i>Never skip meals. Eat every 3-4 hours.\nConsistency = better sugar control.</i>",
                make_style("tip2","Normal", fontSize=8, fontName="Helvetica-Oblique",
                           textColor=ORANGE, alignment=TA_CENTER)
            )],
        ], colWidths=[90*mm]),
    ]],
    colWidths=[95*mm, 90*mm]
)
timing_section.setStyle(TableStyle([
    ("VALIGN",  (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 0),
    ("RIGHTPADDING", (0,0),(-1,-1), 0),
]))
story.append(timing_section)
story.append(Spacer(1, 4*mm))

# ════════════════════════════════════════════════════════════════════════════
# FOODS: CHOOSE vs LIMIT vs AVOID
# ════════════════════════════════════════════════════════════════════════════
story.append(SectionHeader("🥗", "FOOD GUIDE  —  CHOOSE / LIMIT / AVOID", bg=GREEN, width=W))
story.append(Spacer(1, 2*mm))

food_headers = [
    Paragraph("✅  CHOOSE FREELY", make_style("fh","Normal",
        fontSize=10, fontName="Helvetica-Bold", textColor=GREEN, alignment=TA_CENTER)),
    Paragraph("⚠️  EAT IN MODERATION", make_style("fh2","Normal",
        fontSize=10, fontName="Helvetica-Bold", textColor=ORANGE, alignment=TA_CENTER)),
    Paragraph("🚫  AVOID / LIMIT", make_style("fh3","Normal",
        fontSize=10, fontName="Helvetica-Bold", textColor=RED, alignment=TA_CENTER)),
]

def bullets(items, color=GREY_DARK):
    return Paragraph(
        "".join(f"• {i}<br/>" for i in items),
        make_style(f"bl{id(items)}", "Normal",
                   fontSize=8.5, leading=13, textColor=color,
                   fontName="Helvetica", leftIndent=4)
    )

choose_items = [
    "All non-starchy vegetables",
    "Spinach, bhindi, karela",
    "Cucumber, tomato, cabbage",
    "Dal, legumes, chana",
    "Whole wheat roti",
    "Oats, daliya (broken wheat)",
    "Brown rice (small portion)",
    "Low-fat curd, buttermilk",
    "Eggs, fish, chicken (no skin)",
    "Nuts: 5–6 almonds / walnuts",
    "Water, green tea (no sugar)",
    "Guava, papaya, jamun, apple",
]
limit_items = [
    "White rice (½ cup cooked)",
    "Potato (boiled, not fried)",
    "Fruits: 1 serving/day",
    "(banana, mango: limit)",
    "Low-fat paneer",
    "1–2 tsp ghee/day",
    "Coconut (high sat. fat)",
    "Tea/coffee (no sugar)",
    "Sweet potato, peas",
    "Whole milk → prefer skim",
    "Lean red meat (once/week)",
    "Whole fruits (not juice)",
]
avoid_items = [
    "SUGAR — in any form",
    "Cold drinks, packaged juice",
    "White bread, maida products",
    "Biscuits, cakes, sweets",
    "Deep-fried foods",
    "Vanaspati / trans fats",
    "Packaged / instant noodles",
    "Alcohol",
    "Pickles, papads (high salt)",
    "Fruit juice — even 'natural'",
    "Energy drinks",
    "Processed meats",
]

food_table = Table(
    [[food_headers[0], food_headers[1], food_headers[2]],
     [bullets(choose_items, GREEN), bullets(limit_items, ORANGE), bullets(avoid_items, RED)]],
    colWidths=[W/3]*3
)
food_table.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (0,-1), LIGHT_GRN),
    ("BACKGROUND",   (1,0), (1,-1), LIGHT_ORG),
    ("BACKGROUND",   (2,0), (2,-1), LIGHT_RED),
    ("ALIGN",        (0,0), (-1,-1), "LEFT"),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
    ("GRID",         (0,0), (-1,-1), 0.5, WHITE),
    ("TOPPADDING",   (0,0), (-1,-1), 6),
    ("BOTTOMPADDING",(0,0), (-1,-1), 6),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 4),
    ("LINEBELOW",    (0,0), (-1,0),  1, WHITE),
]))
story.append(food_table)
story.append(Spacer(1, 4*mm))

# ════════════════════════════════════════════════════════════════════════════
# CARBS & GLYCEMIC INDEX TABLE
# ════════════════════════════════════════════════════════════════════════════
story.append(SectionHeader("📊", "GLYCEMIC INDEX (GI) — Choose LOW GI Foods", bg=BLUE, width=W))
story.append(Spacer(1, 2*mm))

gi_data = [
    [Paragraph("<b>HIGH GI — Spike Sugar Fast (AVOID)</b>",
        make_style("gih","Normal",fontSize=9,fontName="Helvetica-Bold",textColor=RED,alignment=TA_CENTER)),
     Paragraph("<b>MEDIUM GI — OK in Small Amounts</b>",
        make_style("gim","Normal",fontSize=9,fontName="Helvetica-Bold",textColor=ORANGE,alignment=TA_CENTER)),
     Paragraph("<b>LOW GI — Slow Release (PREFER)</b>",
        make_style("gil","Normal",fontSize=9,fontName="Helvetica-Bold",textColor=GREEN,alignment=TA_CENTER))],
    [bullets(["White rice, white bread","Cornflakes, puffed rice",
              "Mashed potato","Sugar, jaggery, honey",
              "Fruit juice, cold drinks","Instant oats"], RED),
     bullets(["White roti (limit qty)","Boiled potato","Banana, grapes",
              "Basmati rice (small)","Whole milk","Pineapple"], ORANGE),
     bullets(["Whole wheat roti","Brown rice, oats","Dal, rajma, chana",
              "Most vegetables","Apple, guava, pear",
              "Low-fat curd / buttermilk"], GREEN)],
]
gi_table = Table(gi_data, colWidths=[W/3]*3)
gi_table.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (0,-1), LIGHT_RED),
    ("BACKGROUND",   (1,0), (1,-1), LIGHT_ORG),
    ("BACKGROUND",   (2,0), (2,-1), LIGHT_GRN),
    ("ALIGN",        (0,0), (-1,-1), "LEFT"),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
    ("GRID",         (0,0), (-1,-1), 0.5, WHITE),
    ("TOPPADDING",   (0,0), (-1,-1), 5),
    ("BOTTOMPADDING",(0,0), (-1,-1), 5),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
]))
story.append(gi_table)
story.append(Spacer(1, 4*mm))

# ════════════════════════════════════════════════════════════════════════════
# SPECIAL TIPS BOX
# ════════════════════════════════════════════════════════════════════════════
story.append(SectionHeader("💡", "IMPORTANT TIPS", bg=ORANGE, width=W))
story.append(Spacer(1, 2*mm))

tips = [
    ("🥣 Breakfast", "NEVER skip. Have within 1 hour of waking. Include protein (egg / curd / dal)."),
    ("🍽️ Portion Size", "Use a smaller plate. Fill ½ vegetables, ¼ grains, ¼ protein."),
    ("🧃 No Juice", "Even 'natural' fruit juice spikes sugar fast. Eat whole fruit instead."),
    ("🧂 Limit Salt", "Less than 5 g/day (1 teaspoon). Avoid pickles, papads, packaged food."),
    ("💧 Stay Hydrated", "Drink 8–10 glasses of water/day. Avoid sweet drinks completely."),
    ("🏃 Exercise Daily", "30 min walk/day reduces blood sugar by 10–20 mg/dL."),
    ("🌙 Eat Early", "Have dinner before 8:30 PM. Avoid eating late at night."),
    ("💊 If on Insulin", "Never skip a meal after taking insulin — always eat on time."),
]

tips_data = [[
    Paragraph(f"<b>{t[0]}</b><br/><font size='8'>{t[1]}</font>",
              make_style(f"tip{i}","Normal",fontSize=9,leading=13,
                         textColor=GREY_DARK,fontName="Helvetica",leftIndent=3))
    for t in tips[i*4:(i+1)*4]
] for i in range(2)]

tips_table = Table(tips_data, colWidths=[W/4]*4)
tips_table.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,-1), LIGHT_YEL),
    ("GRID",         (0,0), (-1,-1), 0.5, WHITE),
    ("TOPPADDING",   (0,0), (-1,-1), 6),
    ("BOTTOMPADDING",(0,0), (-1,-1), 6),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
]))
story.append(tips_table)
story.append(Spacer(1, 4*mm))

# ════════════════════════════════════════════════════════════════════════════
# SAMPLE MEAL PLAN
# ════════════════════════════════════════════════════════════════════════════
story.append(SectionHeader("📋", "SAMPLE DAY MEAL PLAN", bg=TEAL, width=W))
story.append(Spacer(1, 2*mm))

meal_plan = [
    ["Meal", "Vegetarian Option", "Non-Vegetarian Option"],
    ["Breakfast\n7:00–8:00 AM",
     "2 whole wheat rotis + 1 cup vegetable sabzi + 1 cup low-fat curd",
     "2 egg whites omelette + 1 whole wheat toast + green tea (no sugar)"],
    ["Mid-Morning\n10:30–11:00 AM",
     "6 almonds + 1 small guava or apple",
     "6 walnuts + 1 small orange"],
    ["Lunch\n1:00–1:30 PM",
     "½ cup brown rice + 1 cup dal + large salad + 1 small bowl sabzi",
     "½ cup rice + grilled fish/chicken (100g) + salad + sabzi"],
    ["Evening Snack\n4:00–4:30 PM",
     "Roasted chana (30g) OR cucumber slices with hummus",
     "Boiled egg (1) OR handful of mixed nuts"],
    ["Dinner\n7:30–8:00 PM",
     "2 whole wheat rotis + paneer bhurji (100g) + soup",
     "2 rotis + chicken curry (lean, no skin, 100g) + sabzi"],
]

mp = Table(meal_plan, colWidths=[28*mm, (W-28*mm)/2, (W-28*mm)/2])
mp.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
    ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 8),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[LIGHT_TEAL, WHITE]),
    ("ALIGN",         (0,0), (0,-1), "CENTER"),
    ("ALIGN",         (1,0), (-1,-1), "LEFT"),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#B0BEC5")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("FONTNAME",      (0,1), (0,-1), "Helvetica-Bold"),
    ("TEXTCOLOR",     (0,1), (0,-1), TEAL),
]))
story.append(mp)
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════════════
# 10 COMMANDMENTS BOTTOM STRIP
# ════════════════════════════════════════════════════════════════════════════
commandments = [
    "Eat on time",
    "Less rice/roti",
    "Half plate = vegetables",
    "Choose whole grains",
    "No sugar / sweet drinks",
    "Fruits — not juice",
    "Protein at every meal",
    "Reduce oil; no trans fats",
    "Drink 8 glasses of water",
    "Walk 30 minutes daily",
]
nums = [[Paragraph(
    f"<b>{i+1}.</b>  {commandments[i]}",
    make_style(f"cmd{i}","Normal",fontSize=8.5,leading=12,
               textColor=GREY_DARK,fontName="Helvetica")
) for i in range(5)], [Paragraph(
    f"<b>{i+6}.</b>  {commandments[i+5]}",
    make_style(f"cmd2{i}","Normal",fontSize=8.5,leading=12,
               textColor=GREY_DARK,fontName="Helvetica")
) for i in range(5)]]

cmd_hdr = Table(
    [[Paragraph("10 RULES FOR DIABETES DIET SUCCESS",
        make_style("cmdhdr","Normal",fontSize=11,fontName="Helvetica-Bold",
                   textColor=WHITE,alignment=TA_CENTER))]],
    colWidths=[W])
cmd_hdr.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(-1,-1), GREEN),
    ("TOPPADDING", (0,0),(-1,-1), 5),
    ("BOTTOMPADDING",(0,0),(-1,-1),5),
]))
story.append(cmd_hdr)

cmd_table = Table(nums, colWidths=[W/5]*5)
cmd_table.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,-1), LIGHT_GRN),
    ("GRID",         (0,0), (-1,-1), 0.5, WHITE),
    ("TOPPADDING",   (0,0), (-1,-1), 5),
    ("BOTTOMPADDING",(0,0), (-1,-1), 5),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
]))
story.append(cmd_table)
story.append(Spacer(1, 3*mm))

# ════════════════════════════════════════════════════════════════════════════
# FOOTER
# ════════════════════════════════════════════════════════════════════════════
story.append(HRFlowable(width=W, color=colors.HexColor("#B0BEC5"), thickness=0.5))
story.append(Spacer(1, 2*mm))
story.append(Paragraph(
    "This handout is for educational purposes only. Please follow your doctor's specific instructions. "
    "Consult a certified diabetes educator or registered dietician for a personalised meal plan.\n"
    "Based on ADA Standards of Care | Harrison's Principles of Internal Medicine 22E | Textbook of Family Medicine 9e",
    footer_style
))

# ── Build ───────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/diabetes-handout && python3 create_handout.py 2>&1

Running Command

ls -lh /home/daytona/workspace/diabetes-handout/Diabetes_Nutrition_Handout.pdf

Running Command

cd /home/daytona/workspace/diabetes-handout && python3 -c " from pypdf import PdfReader r = PdfReader('Diabetes_Nutrition_Handout.pdf') print('Pages:', len(r.pages)) print('Page size:', r.pages[0].mediabox) "

Running Command

cd /home/daytona/workspace/diabetes-handout && python3 -c " import pdfplumber with pdfplumber.open('Diabetes_Nutrition_Handout.pdf') as pdf: for i, page in enumerate(pdf.pages): print(f'--- PAGE {i+1} ---') print(page.extract_text()[:800]) print() "

Your Diabetes Nutrition Handout is ready as a printable A4 PDF:

Diabetes Nutrition Handout

PDF Document · PDF


What's inside (2 pages, print-ready):
SectionContent
Title bannerColour-coded header with purpose statement
Glucose TargetsHbA1c, fasting, post-meal, BP targets in a table
Diabetes Meal PlateVisual pie-chart plate (½ vegetables / ¼ grains / ¼ protein)
Meal Timing5-meal schedule from breakfast to bedtime snack
Food Guide3-column green/orange/red: Choose / Limit / Avoid
Glycemic Index TableHigh GI vs Medium GI vs Low GI foods
8 Important TipsBreakfast, portion size, juice warning, salt, hydration, exercise, meal timing, insulin precaution
Sample Day Meal PlanVeg + Non-veg options for all 5 meals
10 Rules for SuccessQuick takeaway strip for patients
FooterEvidence source + referral note
It is designed to be handed directly to OPD patients - no medical jargon, practical Indian food examples, and printable in black-and-white or colour.
This is a shared conversation. Sign in to Orris to start your own chat.