हमारे patient की brain hemorrhage हो गई है। उसके बाद doctor ने PVD लगा के उसमें पानी निकाल दिया है और अब उसके कारण क्या हुआ है कि, अ, मतलब, उनका sodium level काफी बढ़ चुका है और creatinine level काफी बढ़ चुका है और doctor advice कर रहे हैं कि आप एक mini dialysis करवा लो। क्या ये dialysis हमारे patient के लिए अच्छा है? हर बार dialysis करवाना पड़ेगा या just एक sim-- one time ही होता है।
"acute kidney injury"[MeSH Terms] AND "renal replacement therapy"[MeSH Terms] AND "timing"
hypernatremia and acute kidney injury after intracerebral hemorrhage external ventricular drain, dialysis indications, is dialysis temporary
Doctor से पूछने के सवालों की एक PDF बना दीजिए
ls -la /tmp/workspace/; fc-list | grep -i -E "devanagari|hindi|noto|lohit|mangal" | head -20
ls /usr/share/fonts/google-droid-sans-fonts/ | head; fc-list :lang=hi | head; python3 -c "import weasyprint; print('weasy', weasyprint.__version__)"; python3 -c "import fpdf; print('fpdf', fpdf.__version__)"; python3 -c "import uharfbuzz; print('hb ok')"; python3 -c "import reportlab; print(reportlab.Version)"
pip install --user fpdf2 uharfbuzz 2>&1 | tail -3; python3 -c "from PIL import features; print('raqm', features.check('raqm'))"
cd /tmp && python3 -c " import fpdf; print(fpdf.__version__) from fontTools.ttLib import TTFont f=TTFont('/usr/share/fonts/google-droid-sans-fonts/DroidSansDevanagari-Regular.ttf') c=f.getBestCmap(); print('A' in map(chr,c), 97 in c, 0x2022 in c, 0x2610 in c, 0x964 in c) "
pip list --user 2>/dev/null | grep -i -E "fpdf|harfbuzz"; python3 -c "import fpdf,sys; print(fpdf.__file__)"; ls ~/.local/lib/python3*/site-packages 2>/dev/null | head -20
mkdir -p /tmp/workspace/doctor-questions && cat > /tmp/workspace/doctor-questions/make_pdf.py <<'EOF' import sys, glob sys.path.insert(0, glob.glob('/home/*/.local/lib/python3*/site-packages')[0] if glob.glob('/home/*/.local/lib/python3*/site-packages') else __import__('os').path.expanduser('~/.local/lib/python3.12/site-packages')) import fpdf print(fpdf.__version__) from fpdf import FPDF HI = '/usr/share/fonts/google-droid-sans-fonts/DroidSansDevanagari-Regular.ttf' LA = '/usr/share/fonts/google-droid-sans-fonts/DroidSans.ttf' LAB = '/usr/share/fonts/google-droid-sans-fonts/DroidSans-Bold.ttf' class PDF(FPDF): def footer(self): self.set_y(-14) self.set_font('hi', '', 8) self.set_text_color(120,120,120) self.cell(0, 8, f'पेज {self.page_no()} | यह सूची सामान्य जानकारी के लिए है, डॉक्टर की सलाह का विकल्प नहीं', align='C') pdf = PDF('P', 'mm', 'A4') pdf.set_margins(16, 14, 16) pdf.set_auto_page_break(True, 18) pdf.add_font('hi', '', HI) pdf.add_font('la', '', LA) pdf.add_font('lab', '', LAB) pdf.set_text_shaping(True) pdf.set_fallback_fonts(['la']) pdf.add_page() NAVY=(24,60,110); GREY=(90,90,90) # Title pdf.set_fill_color(*NAVY) pdf.rect(0, 0, 210, 30, 'F') pdf.set_xy(16, 7) pdf.set_text_color(255,255,255) pdf.set_font('hi', '', 20) pdf.cell(0, 9, 'डॉक्टर से पूछने के सवाल', new_x='LMARGIN', new_y='NEXT') pdf.set_font('hi', '', 10) pdf.cell(0, 6, 'Brain hemorrhage के बाद बढ़ा Sodium और Creatinine, और Dialysis की सलाह') pdf.set_y(36) pdf.set_text_color(0,0,0) pdf.set_font('hi', '', 10) for lab in ['मरीज़ का नाम:', 'तारीख़:', 'डॉक्टर / Nephrologist:']: pdf.cell(48, 7, lab) x = pdf.get_x(); y = pdf.get_y()+6 pdf.set_draw_color(150,150,150) pdf.line(x, y, 194, y) pdf.ln(8) pdf.ln(2) # Lab box pdf.set_fill_color(240,244,250) pdf.set_draw_color(200,210,225) y0 = pdf.get_y() pdf.rect(16, y0, 178, 22, 'DF') pdf.set_xy(19, y0+2) pdf.set_font('hi', '', 10) pdf.set_text_color(*NAVY) pdf.cell(0, 5, 'आज की रिपोर्ट यहाँ लिख लें:', new_x='LMARGIN', new_y='NEXT') pdf.set_text_color(0,0,0) pdf.set_x(19) pdf.cell(58, 7, 'Sodium: __________') pdf.cell(58, 7, 'Creatinine: __________') pdf.cell(58, 7, 'Potassium: __________', new_x='LMARGIN', new_y='NEXT') pdf.set_x(19) pdf.cell(58, 7, 'पेशाब (24 घंटे): _______ mL') pdf.cell(58, 7, 'Urea: __________') pdf.cell(58, 7, 'pH / Bicarbonate: ______') pdf.set_y(y0+26) sections = [ ('1. वजह क्या है?', [ 'Sodium और creatinine दोनों कितने हैं, और ये बढ़ने की वजह क्या मानी जा रही है?', 'क्या Mannitol या Hypertonic saline दी गई है या अभी चल रही है? क्या उसे कम या बंद किया जा सकता है?', 'क्या Diabetes insipidus की जाँच हुई है (पेशाब की मात्रा, urine sodium, urine osmolality)? अगर है तो क्या दवा (desmopressin) से ठीक हो सकता है?', 'क्या मरीज़ में पानी की कमी (dehydration), BP गिरना, infection, या कोई दवा/contrast kidney बिगाड़ रही है?', 'क्या मरीज़ को पहले से kidney की बीमारी, diabetes या BP था?', ]), ('2. Dialysis अभी ही क्यों?', [ 'Dialysis की सही वजह क्या है: sodium, creatinine, potassium, acidosis, पेशाब बंद होना, शरीर में पानी भरना, या uremia के लक्षण?', 'क्या सिर्फ़ fluid और दवा से कुछ समय इंतज़ार करके देखा जा सकता है? इंतज़ार करने का क्या जोखिम है?', 'क्या nephrologist ने मरीज़ को देखा है? अगर नहीं, तो क्या उनकी राय ली जा सकती है?', ]), ('3. Brain की सुरक्षा', [ 'Sodium बहुत तेज़ी से घटने से brain में सूजन (cerebral edema) का ख़तरा रहता है। Sodium कितनी धीरे और कितना घटाया जाएगा?', 'कौन-सा dialysis होगा: CRRT (धीमा, 24 घंटे) या SLED या सामान्य intermittent? इस मरीज़ के लिए यही क्यों चुना?', 'Dialysis के दौरान brain का pressure (ICP), EVD और BP की निगरानी कैसे होगी?', 'मरीज़ के सिर में bleeding है। क्या dialysis बिना heparin (anticoagulant-free) के होगा?', ]), ('4. Dialysis की प्रक्रिया और जोखिम', [ 'Catheter कहाँ लगेगा (गर्दन या जाँघ)? इसमें infection या bleeding का जोखिम कितना है?', 'Dialysis के दौरान BP गिरने, दौरे (seizure) या होश बिगड़ने की संभावना कितनी है, और तब क्या किया जाएगा?', 'एक session कितने घंटे का होगा, और कुल ख़र्च का अंदाज़ा क्या है?', ]), ('5. आगे क्या? एक बार या बार-बार?', [ 'यह dialysis अस्थायी है या लंबे समय तक चल सकता है? कितने session की उम्मीद है?', 'Kidney के ठीक होने की कितनी संभावना है, और कितने दिन में पता चलेगा?', 'ठीक होने का अंदाज़ा किन चीज़ों से लगेगा (पेशाब की मात्रा, creatinine का घटना)?', 'अगर kidney ठीक न हुई तो अगला कदम क्या होगा?', ]), ('6. अगर dialysis न करें तो?', [ 'Dialysis न करने पर मरीज़ को क्या ख़तरा है और कितने समय में?', 'कोई दूसरा विकल्प है (दवा, fluid में बदलाव, diuretic)? उनके फ़ायदे और नुकसान क्या हैं?', 'किन लक्षणों पर हमें तुरंत स्टाफ़ को बताना चाहिए?', ]), ] def section(title, qs, start): if pdf.get_y() > 255: pdf.add_page() pdf.ln(2) pdf.set_font('hi', '', 13) pdf.set_text_color(*NAVY) pdf.cell(0, 8, title, new_x='LMARGIN', new_y='NEXT') pdf.set_draw_color(*NAVY) pdf.line(16, pdf.get_y(), 194, pdf.get_y()) pdf.ln(2) n = start for q in qs: h = 6.2 * (len(q)//62 + 1) + 7 if pdf.get_y() + h > 277: pdf.add_page() y = pdf.get_y() pdf.set_draw_color(*NAVY) pdf.rect(16, y+1.2, 4, 4) pdf.set_xy(23, y) pdf.set_font('hi', '', 10.5) pdf.set_text_color(0,0,0) pdf.multi_cell(171, 6.2, f'{n}. {q}', new_x='LMARGIN', new_y='NEXT') # answer line yy = pdf.get_y() + 4.5 pdf.set_draw_color(190,190,190) pdf.set_line_width(0.2) pdf.line(23, yy, 194, yy) pdf.set_y(yy + 2) n += 1 return n n = 1 for t, qs in sections: n = section(t, qs, n) # Warning box if pdf.get_y() > 235: pdf.add_page() pdf.ln(5) y0 = pdf.get_y() pdf.set_fill_color(253,240,238); pdf.set_draw_color(220,150,140) pdf.rect(16, y0, 178, 36, 'DF') pdf.set_xy(19, y0+2) pdf.set_font('hi', '', 11); pdf.set_text_color(170,40,30) pdf.cell(0, 6, 'इन लक्षणों पर तुरंत नर्स/डॉक्टर को बुलाएँ', new_x='LMARGIN', new_y='NEXT') pdf.set_font('hi', '', 10); pdf.set_text_color(0,0,0) pdf.set_x(19) pdf.multi_cell(172, 5.8, '- होश कम होना, ज़्यादा नींद, दौरा (seizure)\n- पेशाब बिल्कुल बंद हो जाना या बहुत कम होना\n- साँस फूलना, पैरों या चेहरे पर सूजन\n- Catheter की जगह से खून बहना, बुखार या कंपकंपी', new_x='LMARGIN', new_y='NEXT') pdf.set_y(y0+40) pdf.set_font('hi', '', 8.5); pdf.set_text_color(*GREY) pdf.multi_cell(0, 4.6, 'आधार: Fischer\'s Mastery of Surgery, Frameworks for Internal Medicine, Barash\'s Clinical Anesthesia, Miller\'s Anesthesia, Comprehensive Clinical Nephrology, MSD Manual (AKI). यह सूची सामान्य समझ के लिए है। इलाज का फ़ैसला treating doctor और nephrologist ही करेंगे।') out = '/tmp/workspace/doctor-questions/Doctor_se_poochne_ke_sawal.pdf' pdf.output(out) print('saved', out) EOF cd /tmp/workspace/doctor-questions && python3 make_pdf.py
cd /tmp/workspace/doctor-questions && python3 -c " import pdfplumber with pdfplumber.open('Doctor_se_poochne_ke_sawal.pdf') as pdf: print(len(pdf.pages)) for i,p in enumerate(pdf.pages): p.to_image(resolution=70).save(f'p{i+1}.png') "; ls
cd /tmp/workspace/doctor-questions && python3 -c " import pdfplumber with pdfplumber.open('Doctor_se_poochne_ke_sawal.pdf') as pdf: im=pdf.pages[0].to_image(resolution=130) im.save('p1_hi.png') from PIL import Image i=Image.open('p1_hi.png'); print(i.size); i.crop((0,0,i.size[0],600)).save('p1_crop.png') "
cd /tmp/workspace/doctor-questions && python3 - <<'EOF' s = open('make_pdf.py').read() # helper using multi_cell (renders shaped Hindi correctly) helper = ''' def C(w, h, txt, nl=False, align='L'): if nl: pdf.multi_cell(w, h, txt, align=align, new_x='LMARGIN', new_y='NEXT') else: pdf.multi_cell(w, h, txt, align=align, new_x='RIGHT', new_y='TOP') NAVY=''' s = s.replace("\nNAVY=", helper, 1) if False else s s = s.replace("pdf = PDF('P', 'mm', 'A4')", "pdf = PDF('P', 'mm', 'A4')") # footer s = s.replace("self.cell(0, 8, f'पेज {self.page_no()} | यह सूची सामान्य जानकारी के लिए है, डॉक्टर की सलाह का विकल्प नहीं', align='C')", "self.multi_cell(0, 8, f'पेज {self.page_no()} | यह सूची सामान्य जानकारी के लिए है, डॉक्टर की सलाह का विकल्प नहीं', align='C')") # header fields s = s.replace(" pdf.cell(48, 7, lab)\n", " pdf.multi_cell(48, 7, lab, new_x='RIGHT', new_y='TOP')\n") s = s.replace(" x = pdf.get_x(); y = pdf.get_y()+6\n", " x = pdf.get_x(); y = pdf.get_y()+6\n") s = s.replace(" pdf.line(x, y, 194, y)\n pdf.ln(8)\n", " pdf.line(x, y, 194, y)\n pdf.set_xy(16, y+2)\n") # lab box s = s.replace("pdf.cell(0, 5, 'आज की रिपोर्ट यहाँ लिख लें:', new_x='LMARGIN', new_y='NEXT')", "pdf.multi_cell(0, 5, 'आज की रिपोर्ट यहाँ लिख लें:', new_x='LMARGIN', new_y='NEXT')") s = s.replace("pdf.cell(58, 7, 'पेशाब (24 घंटे): _______ mL')", "pdf.multi_cell(58, 7, 'पेशाब (24 घंटे): _____ mL', new_x='RIGHT', new_y='TOP')") s = s.replace("pdf.cell(58, 7, 'Sodium: __________')", "pdf.multi_cell(58, 7, 'Sodium: __________', new_x='RIGHT', new_y='TOP')") s = s.replace("pdf.cell(58, 7, 'Creatinine: __________')", "pdf.multi_cell(58, 7, 'Creatinine: __________', new_x='RIGHT', new_y='TOP')") s = s.replace("pdf.cell(58, 7, 'Potassium: __________', new_x='LMARGIN', new_y='NEXT')", "pdf.multi_cell(58, 7, 'Potassium: __________', new_x='LMARGIN', new_y='NEXT')") s = s.replace("pdf.cell(58, 7, 'Urea: __________')", "pdf.multi_cell(58, 7, 'Urea: __________', new_x='RIGHT', new_y='TOP')") # section titles / warning title s = s.replace("pdf.cell(0, 8, title, new_x='LMARGIN', new_y='NEXT')", "pdf.multi_cell(0, 8, title, new_x='LMARGIN', new_y='NEXT')") s = s.replace("pdf.cell(0, 6, 'इन लक्षणों पर तुरंत नर्स/डॉक्टर को बुलाएँ', new_x='LMARGIN', new_y='NEXT')", "pdf.multi_cell(0, 6, 'इन लक्षणों पर तुरंत नर्स/डॉक्टर को बुलाएँ', new_x='LMARGIN', new_y='NEXT')") open('make_pdf.py','w').write(s) EOF grep -n "cell(" make_pdf.py | grep -v multi_cell; python3 make_pdf.py && python3 -c " import pdfplumber with pdfplumber.open('Doctor_se_poochne_ke_sawal.pdf') as pdf: print(len(pdf.pages)) pdf.pages[0].to_image(resolution=110).save('p1.png') pdf.pages[1].to_image(resolution=80).save('p2.png') "
cd /tmp/workspace/doctor-questions && python3 - <<'EOF' s = open('make_pdf.py').read() patch = ''' _orig_mc = FPDF.multi_cell def _mc(self, w, h=None, text='', *a, **k): if text and '\\u0900' <= text[0] <= '\\u097f': text = ' ' + text return _orig_mc(self, w, h, text, *a, **k) FPDF.multi_cell = _mc pdf = PDF('P', 'mm', 'A4')''' s = s.replace("\npdf = PDF('P', 'mm', 'A4')", patch, 1) open('make_pdf.py','w').write(s) EOF python3 make_pdf.py && python3 -c " import pdfplumber with pdfplumber.open('Doctor_se_poochne_ke_sawal.pdf') as pdf: print(len(pdf.pages)) pdf.pages[0].to_image(resolution=110).crop((0,100,910,380)).save('p1.png') if False else pdf.pages[0].to_image(resolution=110).save('p1.png') pdf.pages[1].to_image(resolution=110).save('p2.png') from PIL import Image Image.open('p1.png').crop((0,100,910,380)).save('c1.png') i=Image.open('p2.png'); i.crop((0,780,i.size[0],i.size[1])).save('c2.png') "
Quick answer
Doctor se poochne ke sawal
PDF Document · PDF