Add appropriate images in this ppt
~/
"diffuse alveolar hemorrhage"
diffuse alveolar hemorrhage imaging CT radiograph review
~/attachments/04fdd8c8-aa11-40b1-807e-2e2f805f855f
diffuse alveolar hemorrhage chest CT ground glass opacity radiograph bronchoscopy hemosiderin macrophages pulmonary capillaritis diagram
mkdir -p "/tmp/workspace/dah_ppt_images/src" "/tmp/workspace/dah_ppt_images/assets" "/tmp/workspace/dah_ppt_images/output" && python - <<'PY' from pptx import Presentation from pptx.util import Emu p='/tmp/workspace/attachments/04fdd8c8-aa11-40b1-807e-2e2f805f855f/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides.pptx' prs=Presentation(p) print('slides',len(prs.slides),'size',prs.slide_width,prs.slide_height) for i,s in enumerate(prs.slides,1): texts=[] for sh in s.shapes: if getattr(sh,'has_text_frame',False) and sh.text.strip(): texts.append(sh.text.replace('\n',' | ')) pics=sum(1 for sh in s.shapes if sh.shape_type==13) print(f'[{i}] pics={pics} ' + ' || '.join(texts)[:1000]) PY
site:commons.wikimedia.org diffuse alveolar hemorrhage chest x ray CT pulmonary capillaritis
site:pmc.ncbi.nlm.nih.gov diffuse alveolar hemorrhage CT bronchoscopy figure
https://pmc.ncbi.nlm.nih.gov/articles/PMC7120649
Create a medically accurate educational cutaway illustration of diffuse alveolar hemorrhage: close-up pulmonary alveoli and surrounding capillary network, with damaged capillary wall and red blood cells leaking into alveolar air spaces. Include normal alveolus at left, immune capillaritis injury at center, and bland hemorrhage at right. No labels, no text.
Create an educational medical infographic of the diffuse alveolar hemorrhage diagnostic triad: a pair of lungs with bilateral cloudy alveolar opacities, a blood test tube with falling hemoglobin line, and a small bronchoscopy lavage vial containing blood. No labels, no text.
Create a clean educational medical illustration of bronchoscopy with bronchoalveolar lavage. Show a flexible bronchoscope entering a bronchus and three clear specimen containers in sequence becoming progressively bloodier from pale pink to deep red. No labels, no text.
Create a medical educational diagram of pulmonary renal syndrome: lungs with diffuse alveolar hemorrhage and kidneys with glomerular inflammation, connected by small vessel immune-mediated vasculitis. No labels, no text.
Create a clean educational medical illustration of emergency supportive management for severe diffuse alveolar hemorrhage: oxygen delivery interface, blood product bag, coagulation medication reversal syringe, and intensive care monitor. No labels, no text.
python /tmp/skills/shared/scripts/fetch_images.py "https://cdn.orris.care/image-gen/e502fab86d2241039e8a18ebacb2a81e.png" "https://cdn.orris.care/image-gen/5c2de2da784f4024988337c7dee870f2.png" "https://cdn.orris.care/image-gen/aaa31e0b992645bdaf41f0fc56959871.png" "https://cdn.orris.care/image-gen/bbe4e6279a094a4496f7d9a26b72a0ea.png" "https://cdn.orris.care/image-gen/3ad9f44bc77b4650ba8c670ff2722d97.png" > "/tmp/workspace/dah_ppt_images/assets/fetched.json" && python - <<'PY' import json,base64,os j=json.load(open('/tmp/workspace/dah_ppt_images/assets/fetched.json')) for i,x in enumerate(j): if not x.get('base64'): raise RuntimeError(x) header,data=x['base64'].split(',',1) ext='png' if 'png' in header else 'jpg' fn=f'/tmp/workspace/dah_ppt_images/assets/img{i+1}.{ext}' open(fn,'wb').write(base64.b64decode(data)) print(fn,os.path.getsize(fn)) PY
python - <<'PY' from pptx import Presentation from pptx.util import Emu p='/tmp/workspace/attachments/04fdd8c8-aa11-40b1-807e-2e2f805f855f/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides.pptx' prs=Presentation(p) for idx in [1,2,3,5,7,8,10,11,12,15,17,18,19,20,22,23,24]: s=prs.slides[idx-1] print('\nSLIDE',idx) for n,sh in enumerate(s.shapes): txt=(sh.text[:60].replace('\n',' | ') if getattr(sh,'has_text_frame',False) else '') print(n,sh.shape_type, round(Emu(sh.left).inches,2),round(Emu(sh.top).inches,2),round(Emu(sh.width).inches,2),round(Emu(sh.height).inches,2),txt) PY
python /tmp/skills/shared/scripts/fetch_images.py "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_1e60c61a7f25120eeac8f0a91d289d1e632f1e7d9abb4ed2cf7fbd56d47e70d1.jpg" > "/tmp/workspace/dah_ppt_images/assets/ct_fetch.json" && python - <<'PY' import json,base64 x=json.load(open('/tmp/workspace/dah_ppt_images/assets/ct_fetch.json'))[0] assert x.get('base64'), x open('/tmp/workspace/dah_ppt_images/assets/dah_ct.jpg','wb').write(base64.b64decode(x['base64'].split(',',1)[1])) print('saved') PY
Create a medically plausible frontal chest radiograph for educational use, showing diffuse bilateral patchy central alveolar opacities consistent with diffuse alveolar hemorrhage. Grayscale x-ray appearance only, no labels, no text.
python /tmp/skills/shared/scripts/fetch_images.py "https://cdn.orris.care/image-gen/fc993f59bacc4ebcb029cac1882fe92c.png" > "/tmp/workspace/dah_ppt_images/assets/xray_fetch.json" && python - <<'PY' import json,base64 x=json.load(open('/tmp/workspace/dah_ppt_images/assets/xray_fetch.json'))[0] assert x.get('base64'), x open('/tmp/workspace/dah_ppt_images/assets/dah_xray.jpg','wb').write(base64.b64decode(x['base64'].split(',',1)[1])) print('saved') PY
cat > "/tmp/workspace/dah_ppt_images/src/add_images.py" <<'PY' from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.shapes import MSO_SHAPE_TYPE from pptx.enum.text import PP_ALIGN from PIL import Image import os IN='/tmp/workspace/attachments/04fdd8c8-aa11-40b1-807e-2e2f805f855f/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides.pptx' OUT='/tmp/workspace/dah_ppt_images/output/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides_with_images.pptx' A='/tmp/workspace/dah_ppt_images/assets' prs=Presentation(IN) # Center-crop image to a specified rectangle, retaining correct aspect ratio. def add_cover(slide, path, x, y, w, h): iw,ih=Image.open(path).size ir=iw/ih; tr=w/h if ir>tr: crop_w=int(ih*tr); crop_h=ih; left=(iw-crop_w)//2; top=0 else: crop_w=iw; crop_h=int(iw/tr); left=0; top=(ih-crop_h)//2 pic=slide.shapes.add_picture(path, Inches(x), Inches(y), Inches(w), Inches(h)) # crop properties are ratios of removed parts from each edge pic.crop_left=left/iw; pic.crop_right=(iw-left-crop_w)/iw pic.crop_top=top/ih; pic.crop_bottom=(ih-top-crop_h)/ih return pic def remove_indices(slide, indices): # Resolve from original list, then remove elements. shapes=list(slide.shapes) for i in sorted(indices, reverse=True): el=shapes[i]._element el.getparent().remove(el) def label(slide,text,x,y,w): tb=slide.shapes.add_textbox(Inches(x),Inches(y),Inches(w), Inches(.18)) p=tb.text_frame.paragraphs[0]; p.text=text; p.alignment=PP_ALIGN.CENTER p.font.name='Aptos'; p.font.size=Pt(8); p.font.color.rgb=__import__('pptx').dml.color.RGBColor(88,96,104) return tb # 1: strong opening visual, occupying previously decorative empty right field. s=prs.slides[0] add_cover(s,os.path.join(A,'img1.jpg'),8.65,1.32,3.75,4.82) label(s,'Illustrative alveolar-capillary injury',8.65,6.16,3.75) # 3: replace stylized capillary motif with an explanatory cutaway illustration. s=prs.slides[2] remove_indices(s, list(range(8,19))) add_cover(s,os.path.join(A,'img1.jpg'),7.0,1.70,5.10,3.55) label(s,'Alveolar-capillary barrier injury',7.0,5.30,5.10) # 5: clinical syndrome visual, added as a narrow supporting band below heading. s=prs.slides[4] add_cover(s,os.path.join(A,'img2.jpg'),0.75,1.76,11.75,.54) # 8: pulmonary-renal syndrome visual replaces generic right panel background but keeps text lower. s=prs.slides[7] remove_indices(s,[7]) add_cover(s,os.path.join(A,'img4.jpg'),6.65,1.72,5.42,3.12) # Re-add a translucent text backing to preserve legibility of title and explanation. from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE back=s.shapes.add_shape(MSO_AUTO_SHAPE_TYPE.ROUNDED_RECTANGLE,Inches(6.84),Inches(1.88),Inches(5.03),Inches(2.65)) back.fill.solid(); back.fill.fore_color.rgb=__import__('pptx').dml.color.RGBColor(255,255,255); back.fill.transparency=24 back.line.fill.background() # Text copied conceptually with clean legibility for text,y,h,size,bold in [ ('Pulmonary-renal syndrome',2.05,.28,17,True), ('The combination of DAH and glomerulonephritis strongly suggests\nsmall-vessel vasculitis or anti-GBM disease. Either pulmonary\nor renal manifestations may predominate.',2.54,1.20,12,False)]: tb=s.shapes.add_textbox(Inches(6.98),Inches(y),Inches(4.65),Inches(h)); tf=tb.text_frame; tf.clear();p=tf.paragraphs[0];p.text=text;p.font.name='Aptos';p.font.size=Pt(size);p.font.bold=bold;p.font.color.rgb=__import__('pptx').dml.color.RGBColor(20,55,79) # 10: real-style CXR image replaces schematic opacity illustration. s=prs.slides[9] remove_indices(s,[6,7,8,9]) add_cover(s,os.path.join(A,'dah_xray.jpg'),.80,1.72,4.15,3.90) label(s,'Illustrative bilateral alveolar opacity pattern',.80,5.72,4.15) # 11: CT image replaces schematic lung illustration. s=prs.slides[10] remove_indices(s,[6,7,8,9,10,11]) add_cover(s,os.path.join(A,'dah_ct.jpg'),.75,1.72,4.25,3.92) label(s,'Illustrative CT: bilateral ground-glass opacities',.75,5.78,4.25) # 15: bronchoscopy/BAL illustration replaces drawn containers. s=prs.slides[14] remove_indices(s,[7,8,10,11,13,14,16,17,18]) add_cover(s,os.path.join(A,'img3.jpg'),.78,2.35,10.95,2.42) # Retain key sequential labels, repositioned clear of visual. for text,x in [('Aliquot 1',1.55),('Aliquot 2',5.13),('Aliquot 3',8.70)]: label(s,text,x,4.92,1.55) label(s,'Progressively bloodier return',9.55,2.10,2.12) # 18: Emergency management illustration inserted subtly as a top banner. s=prs.slides[17] add_cover(s,os.path.join(A,'img5.jpg'),.75,6.30,11.84,.52) # 22: use pulmonary-renal illustration in unused lower right space while retaining case text. s=prs.slides[21] add_cover(s,os.path.join(A,'img4.jpg'),10.45,5.95,1.67,.86) # Reference slide: add transparent provenance line. s=prs.slides[23] tb=s.shapes.add_textbox(Inches(.78),Inches(6.35),Inches(11.2),Inches(.22)) p=tb.text_frame.paragraphs[0];p.text='Educational illustrations added to support teaching. Imaging visuals are illustrative, not diagnostic patient images.' p.font.name='Aptos';p.font.size=Pt(8);p.font.italic=True;p.font.color.rgb=__import__('pptx').dml.color.RGBColor(88,96,104) prs.save(OUT) print(OUT) PY python "/tmp/workspace/dah_ppt_images/src/add_images.py" python - <<'PY' from pptx import Presentation p='/tmp/workspace/dah_ppt_images/output/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides_with_images.pptx' prs=Presentation(p) print('slides',len(prs.slides),'pictures',sum(1 for s in prs.slides for sh in s.shapes if sh.shape_type==13)) for n in [1,3,5,8,10,11,15,18,22,24]: print(n, sum(1 for sh in prs.slides[n-1].shapes if sh.shape_type==13)) PY
python - <<'PY' from pptx import Presentation from pptx.enum.shapes import MSO_SHAPE_TYPE from pathlib import Path p=Path('/tmp/workspace/dah_ppt_images/output/Diffuse_Alveolar_Hemorrhage_Harrison_Expanded_24_Slides_with_images.pptx') assert p.exists() and p.stat().st_size > 100000 prs=Presentation(str(p)) assert len(prs.slides)==24 for i,slide in enumerate(prs.slides,1): for sh in slide.shapes: if sh.shape_type == MSO_SHAPE_TYPE.PICTURE: assert sh.left >= 0 and sh.top >= 0 assert sh.left+sh.width <= prs.slide_width assert sh.top+sh.height <= prs.slide_height print('verified:',p.name,'bytes=',p.stat().st_size,'slides=',len(prs.slides),'pictures=',sum(sh.shape_type==MSO_SHAPE_TYPE.PICTURE for s in prs.slides for sh in s.shapes)) PY
Make an ppt for diffused alveolar hemorrhage of 24 pages according to harrison with diagnostic images
~/
diffuse alveolar hemorrhage diagnostic chest radiograph bilateral infiltrates CT ground glass bronchoalveolar lavage bloody serial aliquots
"diffuse alveolar hemorrhage"
diffuse alveolar hemorrhage chest x-ray CT bronchoalveolar lavage images PMC
https://pmc.ncbi.nlm.nih.gov/articles/PMC7120649
python /tmp/skills/shared/scripts/fetch_images.py "https://cdn.ncbi.nlm.nih.gov/pmc/blobs/2689/7120649/e11418a94089/329322_2_En_33_Fig1_HTML.jpg" "https://cdn.ncbi.nlm.nih.gov/pmc/blobs/2689/7120649/b2fb8c3a2eb1/329322_2_En_33_Fig2_HTML.jpg" "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_362eb67bebc468469679f2779dccae0b666f55a562d19de62a1881ebdbeaad33.jpg" "https://cdn.orris.care/cdss_images/f8b8d7febb17a2ac54f735263ee27f0d30613265cfd78347ce3cdb930b3ba858.png" > "/tmp/workspace/dah_ppt_images/assets/diagnostic_fetch.json" && python - <<'PY' import json,base64,os out='/tmp/workspace/dah_new/assets';os.makedirs(out,exist_ok=True) for i,x in enumerate(json.load(open('/tmp/workspace/dah_ppt_images/assets/diagnostic_fetch.json')),1): if x.get('base64'): ext='png' if 'png' in x['base64'][:50] else 'jpg' open(f'{out}/diag{i}.{ext}','wb').write(base64.b64decode(x['base64'].split(',',1)[1])) print(i,ext) else: print('ERR',i,x) PY
~/dah_new
~/dah_ppt_images/assets
mkdir -p "/tmp/workspace/dah_new/src" "/tmp/workspace/dah_new/output" && cp "/tmp/workspace/dah_ppt_images/assets/img1.jpg" "/tmp/workspace/dah_new/assets/mechanism.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/img2.jpg" "/tmp/workspace/dah_new/assets/triad.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/img3.jpg" "/tmp/workspace/dah_new/assets/bal.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/img4.jpg" "/tmp/workspace/dah_new/assets/pulmrenal.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/img5.jpg" "/tmp/workspace/dah_new/assets/support.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/dah_xray.jpg" "/tmp/workspace/dah_new/assets/xray_illustrative.jpg" && cp "/tmp/workspace/dah_ppt_images/assets/dah_ct.jpg" "/tmp/workspace/dah_new/assets/ct_illustrative.jpg" && ls -lh "/tmp/workspace/dah_new/assets"
cat > "/tmp/workspace/dah_new/src/create_dah_deck.py" <<'PY' from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR from pptx.enum.text import PP_ALIGN, MSO_ANCHOR from pptx.dml.color import RGBColor from pptx.enum.dml import MSO_THEME_COLOR from PIL import Image import os OUT='/tmp/workspace/dah_new/output/Diffuse_Alveolar_Hemorrhage_Harrison_24_Slides_Diagnostic_Images.pptx' A='/tmp/workspace/dah_new/assets' prs=Presentation(); prs.slide_width=Inches(13.333); prs.slide_height=Inches(7.5) blank=prs.slide_layouts[6] NAVY=RGBColor(12,43,63); TEAL=RGBColor(20,115,130); RED=RGBColor(177,48,58); GOLD=RGBColor(210,153,62); INK=RGBColor(35,48,59); GREY=RGBColor(90,101,109); PALE=RGBColor(240,246,247); PALE2=RGBColor(249,251,251); WHITE=RGBColor(255,255,255); LINE=RGBColor(210,222,225) def rect(s,x,y,w,h,color,rad=False, line=None): sh=s.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE if rad else MSO_SHAPE.RECTANGLE, Inches(x),Inches(y),Inches(w),Inches(h)) sh.fill.solid(); sh.fill.fore_color.rgb=color sh.line.color.rgb=line if line else color return sh def tx(s,text,x,y,w,h,size=16,color=INK,bold=False,align=PP_ALIGN.LEFT,italic=False,margin=.04): sh=s.shapes.add_textbox(Inches(x),Inches(y),Inches(w),Inches(h)); tf=sh.text_frame; tf.clear();tf.word_wrap=True;tf.margin_left=tf.margin_right=Inches(margin);tf.margin_top=tf.margin_bottom=Inches(margin);tf.vertical_anchor=MSO_ANCHOR.MIDDLE p=tf.paragraphs[0];p.text=text;p.alignment=align for r in p.runs: r.font.name='Aptos';r.font.size=Pt(size);r.font.bold=bold;r.font.italic=italic;r.font.color.rgb=color return sh def bullet(s,items,x,y,w,h,size=15, color=INK): sh=s.shapes.add_textbox(Inches(x),Inches(y),Inches(w),Inches(h));tf=sh.text_frame;tf.clear();tf.word_wrap=True;tf.margin_left=Inches(.06);tf.margin_right=Inches(.02);tf.margin_top=Inches(.02);tf.margin_bottom=0 for j,item in enumerate(items): p=tf.paragraphs[0] if j==0 else tf.add_paragraph();p.text=item;p.level=0;p.font.name='Aptos';p.font.size=Pt(size);p.font.color.rgb=color;p.space_after=Pt(9);p.text='• '+item return sh def header(s,num,title,kicker='DIFFUSE ALVEOLAR HEMORRHAGE'): rect(s,0,0,13.333,.15,NAVY); tx(s,kicker,.58,.27,9.6,.22,10,TEAL,True);tx(s,title,.58,.58,11.9,.48,25,NAVY,True);rect(s,.58,1.24,12.15,.018,LINE) tx(s,f'{num:02d}',12.15,.26,.62,.25,11,GREY,True,PP_ALIGN.RIGHT);tx(s,'Harrison-aligned teaching deck',.60,7.12,4.0,.15,8,GREY) def footer(s, source='Harrison’s Principles of Internal Medicine, 22nd ed.'): tx(s,source,.60,7.10,8.2,.16,8,GREY) def add_img(s,path,x,y,w,h,caption=None): iw,ih=Image.open(path).size; ir=iw/ih; tr=w/h pic=s.shapes.add_picture(path, Inches(x),Inches(y),Inches(w),Inches(h)) if ir>tr: crop=(1-tr/ir)/2;pic.crop_left=pic.crop_right=crop else: crop=(1-ir/tr)/2;pic.crop_top=pic.crop_bottom=crop if caption: tx(s,caption,x,y+h+.03,w,.22,8,GREY,False,PP_ALIGN.CENTER) return pic def card(s,x,y,w,h,title,body,accent=TEAL): rect(s,x,y,w,h,WHITE,True,LINE);rect(s,x,y,.07,h,accent);tx(s,title,x+.22,y+.16,w-.35,.26,15,NAVY,True);bullet(s,body if isinstance(body,list) else [body],x+.18,y+.54,w-.35,h-.62,12.5,INK) def section(s,n,title,subtitle,image=None): rect(s,0,0,13.333,7.5,NAVY); rect(s,.62,1.16,.09,4.8,TEAL);tx(s,f'{n:02d}',.86,1.10,1,.38,15,GOLD,True);tx(s,title,.84,1.65,6.0,1.25,36,WHITE,True);tx(s,subtitle,.86,3.15,5.6,.7,18,RGBColor(205,222,226)); if image: add_img(s,image,7.25,1.15,5.35,5.1) tx(s,'Diffuse alveolar hemorrhage | Harrison-aligned review',.86,6.78,6.5,.18,9,RGBColor(180,205,211)) # 1 s=prs.slides.add_slide(blank);rect(s,0,0,13.333,7.5,NAVY);rect(s,.65,1.06,.1,5.15,TEAL);tx(s,'HARRISON-ALIGNED CLINICAL REVIEW',.95,1.08,5,.25,12,GOLD,True);tx(s,'Diffuse Alveolar\nHemorrhage',.92,1.58,6.2,1.40,37,WHITE,True);tx(s,'Recognition, confirmation, etiologic reasoning, and immediate management',.96,3.30,5.75,.52,17,RGBColor(210,224,227));add_img(s,os.path.join(A,'mechanism.jpg'),7.55,1.12,4.88,4.95);tx(s,'Diagnostic images included',.95,5.10,3.6,.35,15,WHITE,True);tx(s,'Chest radiograph • CT • BAL • cytology • histopathology',.96,5.53,5.4,.35,13,RGBColor(210,224,227));tx(s,'24-slide teaching presentation | Educational use only',.95,6.75,5.4,.18,9,RGBColor(180,205,211)) #2 s=prs.slides.add_slide(blank);header(s,2,'Learning objectives and roadmap');tx(s,'At the end of this session, learners should be able to:',.75,1.55,7.1,.3,16,INK,True) items=[('01','Recognize','Identify the syndrome, including DAH without hemoptysis.'),('02','Confirm','Use imaging, serial BAL, laboratory testing, and infection assessment.'),('03','Phenotype','Separate capillaritis, bland hemorrhage, and diffuse alveolar damage.'),('04','Treat','Stabilize physiology while delivering cause-directed therapy.')] for i,(n,t,b) in enumerate(items): y=2.05+i*1.08;rect(s,.78,y,.72,.62,TEAL,True);tx(s,n,.78,y+.16,.72,.2,14,WHITE,True,PP_ALIGN.CENTER);tx(s,t,1.75,y+.05,2.1,.25,15,NAVY,True);tx(s,b,3.72,y+.03,7.65,.5,13,INK) add_img(s,os.path.join(A,'triad.jpg'),9.35,1.6,2.5,2.5,'Syndrome overview') #3 s=prs.slides.add_slide(blank);header(s,3,'Definition: a syndrome of alveolar bleeding');tx(s,'DAH is widespread intra-alveolar bleeding from the pulmonary microcirculation: arterioles, capillaries, and venules.',.76,1.52,6.0,.75,18,NAVY,True);add_img(s,os.path.join(A,'mechanism.jpg'),7.25,1.55,4.7,3.7,'Illustrative alveolar-capillary injury') for i,(t,b,c) in enumerate([('Clinical syndrome','Diffuse opacities + hypoxemia + falling hemoglobin ± hemoptysis',TEAL),('Not a diagnosis','The underlying mechanism and cause must be identified urgently.',RED),('Emergency','May progress rapidly to acute hypoxemic respiratory failure.',GOLD)]):card(s,.78+i*3.95,5.52,3.58,1.02,t,b,c) #4 s=prs.slides.add_slide(blank);header(s,4,'Why DAH matters'); for i,(t,b,c) in enumerate([('Physiologic threat','Alveoli fill with blood, impairing gas exchange and producing severe hypoxemia.',RED),('Diagnostic threat','Mimics infection, pulmonary edema, and acute respiratory distress syndrome.',GOLD),('Therapeutic threat','Delaying therapy for vasculitis or anti-GBM disease may sacrifice organ function.',TEAL)]):card(s,.75+i*4.05,1.8,3.7,3.95,t,b,c) tx(s,'Hemoptysis may be absent: retained alveolar blood does not necessarily reach the airway.',.85,6.20,11.4,.36,16,NAVY,True,PP_ALIGN.CENTER) #5 s=prs.slides.add_slide(blank);header(s,5,'Clinical presentation: the classic syndrome');add_img(s,os.path.join(A,'triad.jpg'),.85,1.52,3.35,3.35,'Illustrative clinical triad') for i,(t,b) in enumerate([('Dyspnea / hypoxemia','Often acute or subacute'),('Hemoptysis','May be absent'),('New infiltrates','Bilateral alveolar opacities'),('Anemia','Falling hemoglobin concentration')]): x=4.75+(i%2)*3.65;y=1.7+(i//2)*2.0;card(s,x,y,3.25,1.45,t,b, RED if i in [1,3] else TEAL) #6 s=prs.slides.add_slide(blank);header(s,6,'Clinical red flags and systemic clues'); for i,(t,arr,c) in enumerate([('Respiratory severity',['Escalating oxygen requirement','Tachypnea, fatigue, refractory hypoxemia','Ventilatory support may be needed'],RED),('Vasculitis clues',['Purpura or rash','Sinus, otic, or nasal disease','Neuropathy, arthralgia, constitutional features'],TEAL),('Renal clues',['Hematuria and proteinuria','Red-cell casts / active sediment','Rising creatinine'],GOLD)]):card(s,.75+i*4.05,1.7,3.7,4.7,t,arr,c) #7 section s=prs.slides.add_slide(blank);section(s,7,'Mechanism matters','Classify the pathology before treating the cause.',os.path.join(A,'mechanism.jpg')) #8 s=prs.slides.add_slide(blank);header(s,8,'Three pathologic patterns of DAH'); for i,(t,b,c) in enumerate([('Pulmonary capillaritis','Neutrophilic injury to alveolar capillaries. Typical of ANCA vasculitis, anti-GBM disease, and connective-tissue disease.',RED),('Bland hemorrhage','Intra-alveolar blood without capillaritis. Consider anticoagulation, coagulopathy, thrombocytopenia, mitral disease, and venous hypertension.',TEAL),('Diffuse alveolar damage','Hemorrhage accompanying acute lung injury: ARDS, infection, toxins, or transplantation.',GOLD)]):card(s,.72+i*4.12,1.62,3.77,4.88,t,b,c) #9 s=prs.slides.add_slide(blank);header(s,9,'Capillaritis: immune injury at the alveolar-capillary barrier');add_img(s,os.path.join(A,'diag4.jpg'),.8,1.6,4.8,3.95,'Histopathology of DAH. Murray & Nadel, Fig 94.5.') card(s,6.1,1.7,5.65,1.5,'Histologic concept','Neutrophils infiltrate the alveolar interstitium, disrupt the basement membrane, and permit red cells to enter air spaces.',RED) card(s,6.1,3.5,5.65,1.4,'What to look for','Capillary necrosis, leukocytoclasis, edema, fibrin, and intra-alveolar red blood cells.',TEAL) card(s,6.1,5.15,5.65,1.15,'Clinical correlate','Pulmonary-renal syndrome should trigger urgent ANCA and anti-GBM testing.',GOLD) #10 s=prs.slides.add_slide(blank);header(s,10,'Etiologic framework: start with mechanism'); cols=[('Immune capillaritis',['GPA / MPA','Anti-GBM disease','SLE and CTD','Drug-induced ANCA vasculitis'],RED),('Hemostatic / pressure',['Anticoagulants','Thrombocytopenia / DIC','Mitral stenosis','Left-sided failure'],TEAL),('Injury / exposure',['ARDS and infection','Inhalants or vaping','Transplant-related','Idiopathic hemosiderosis'],GOLD)] for i,(t,a,c) in enumerate(cols):card(s,.75+i*4.05,1.7,3.7,4.7,t,a,c) #11 s=prs.slides.add_slide(blank);header(s,11,'Pulmonary-renal syndrome: a high-risk phenotype');add_img(s,os.path.join(A,'pulmrenal.jpg'),7.15,1.55,4.8,4.25,'Illustrative pulmonary-renal syndrome') tx(s,'DAH + glomerulonephritis = urgent evaluation',.78,1.58,5.7,.38,21,NAVY,True);bullet(s,['Urinalysis: hematuria, proteinuria, dysmorphic red cells, red-cell casts','Renal function and electrolytes','ANCA: proteinase-3 and myeloperoxidase','Anti-GBM antibody','Prompt nephrology, pulmonary, and rheumatology input'],.85,2.2,5.65,3.3,15) rect(s,.80,5.8,5.75,.55,PALE,True,LINE);tx(s,'Either pulmonary or renal manifestations may predominate.',1.03,5.97,5.25,.18,12,RED,True,PP_ALIGN.CENTER) #12 section diagnostic s=prs.slides.add_slide(blank);section(s,12,'Confirming DAH','Imaging supports suspicion. Serial bronchoalveolar lavage confirms the syndrome.',os.path.join(A,'diag3.jpg')) #13 xray s=prs.slides.add_slide(blank);header(s,13,'Diagnostic image: chest radiograph');add_img(s,os.path.join(A,'diag1.jpg'),.78,1.58,5.25,4.65,'Chest radiograph: multifocal bilateral alveolar opacities. PMC7120649, Fig 33.1.') card(s,6.55,1.7,5.45,1.65,'Typical pattern','Diffuse or patchy bilateral air-space opacities. The distribution and tempo vary.',TEAL) card(s,6.55,3.65,5.45,1.35,'Important limitation','Radiography alone cannot distinguish DAH from edema, infection, or ARDS.',GOLD) card(s,6.55,5.3,5.45,1.02,'Interpret in context','Combine image + hemoglobin trend + urine findings + BAL.',RED) #14 CT s=prs.slides.add_slide(blank);header(s,14,'Diagnostic image: computed tomography');add_img(s,os.path.join(A,'diag2.jpg'),.78,1.58,5.25,4.65,'CT: diffuse bilateral alveolar opacities. PMC7120649, Fig 33.2.') card(s,6.55,1.7,5.45,1.65,'Typical CT features','Ground-glass opacity, patchy or diffuse consolidation, and variable central or diffuse distribution.',TEAL) card(s,6.55,3.65,5.45,1.35,'CT contribution','Defines extent and evaluates alternative or accompanying disease. It does not establish DAH.',GOLD) card(s,6.55,5.3,5.45,1.02,'Teaching point','Ground-glass opacity reflects partial alveolar filling and is not specific for hemorrhage.',RED) #15 BAL s=prs.slides.add_slide(blank);header(s,15,'Diagnostic image: bronchoscopy and serial BAL');add_img(s,os.path.join(A,'bal.jpg'),.75,1.55,5.35,3.85,'Illustrative serial lavage: return becomes progressively bloodier.') card(s,6.55,1.62,5.35,1.4,'Confirmatory finding','In a wedged segment, sequential BAL aliquots become increasingly bloody or fail to clear.',RED) card(s,6.55,3.3,5.35,1.35,'Diagnostic work-up','Send lavage for microbiology while evaluating for immune disease. Infection must be considered before immunosuppression.',TEAL) card(s,6.55,4.95,5.35,1.28,'Cytology','Hemosiderin-laden macrophages support prior or ongoing hemorrhage, particularly after sufficient time has elapsed.',GOLD) #16 image combo s=prs.slides.add_slide(blank);header(s,16,'Diagnostic image: imaging, BAL cytology, and hemosiderophages');add_img(s,os.path.join(A,'diag3.jpg'),.8,1.5,7.0,4.9,'Composite: radiograph, CT, and BAL cytology with hemosiderin-laden macrophages. Open-access PMC image.') card(s,8.25,1.7,3.8,1.5,'Imaging','Bilateral diffuse infiltrates or geographic ground-glass attenuation suggest an alveolar filling process.',TEAL) card(s,8.25,3.5,3.8,1.35,'BAL cytology','Perls stain highlights iron within macrophages, reflecting erythrocyte breakdown.',RED) card(s,8.25,5.15,3.8,1.02,'Use the whole pattern','No single image establishes etiology.',GOLD) #17 s=prs.slides.add_slide(blank);header(s,17,'Initial laboratory and etiologic evaluation'); for i,(t,a,c) in enumerate([('Immediate',['CBC and serial hemoglobin','Platelets, PT/INR, aPTT','Renal function, electrolytes','Type and screen when significant bleeding'],RED),('Pulmonary-renal',['Urinalysis with microscopy','Proteinuria and active sediment','ANCA: PR3/MPO','Anti-GBM antibody'],TEAL),('Targeted',['ANA, dsDNA, complements','Antiphospholipid testing when indicated','Microbiology','Medication / exposure review and cardiac assessment'],GOLD)]):card(s,.75+i*4.05,1.72,3.7,4.65,t,a,c) #18 s=prs.slides.add_slide(blank);header(s,18,'Role of tissue diagnosis'); card(s,.85,1.7,3.65,3.9,'Renal biopsy',['Preferred when urinary abnormalities suggest glomerulonephritis.','Can identify pauci-immune disease, anti-GBM disease, or immune-complex pathology.'],TEAL) card(s,4.84,1.7,3.65,3.9,'Lung biopsy',['Consider only when uncertainty persists and the result is likely to change management.','Risk is substantial in severe respiratory failure.'],RED) card(s,8.83,1.7,3.65,3.9,'Principle',['Do not delay stabilization or essential treatment solely to obtain tissue.','Select the safest, highest-yield diagnostic site.'],GOLD) #19 s=prs.slides.add_slide(blank);header(s,19,'Practical diagnostic algorithm');steps=[('1','Stabilize','Oxygenation, ventilation, hemodynamics'),('2','Recognize','Infiltrates + anemia ± hemoptysis'),('3','Confirm','Serial BAL if feasible; send microbiology'),('4','Phenotype','Urine, renal function, coagulation, cardiac context'),('5','Identify cause','ANCA, anti-GBM, autoimmunity, exposure review')] for i,(n,t,b) in enumerate(steps): y=1.52+i*.93;rect(s,.82,y,.52,.52,TEAL,True);tx(s,n,.82,y+.13,.52,.18,13,WHITE,True,PP_ALIGN.CENTER);tx(s,t,1.62,y+.05,1.75,.22,14,NAVY,True);tx(s,b,3.55,y+.04,7.55,.27,13,INK) if i<4: rect(s,1.06,y+.52,.03,.4,LINE) rect(s,.78,6.35,11.85,.48,PALE,True,LINE);tx(s,'Pulmonary infiltrates + active urine sediment = urgent pulmonary-renal syndrome evaluation.',.98,6.48,11.45,.15,12,RED,True,PP_ALIGN.CENTER) #20 section s=prs.slides.add_slide(blank);section(s,20,'Immediate management','Resuscitate first. Treat the driver in parallel.',os.path.join(A,'support.jpg')) #21 s=prs.slides.add_slide(blank);header(s,21,'Immediate management: stabilize the patient');add_img(s,os.path.join(A,'support.jpg'),.78,5.75,11.75,.72,'Illustrative supportive care elements') for i,(t,b,c) in enumerate([('Airway and oxygenation','Supplemental oxygen. Escalate to high-flow, noninvasive support, or intubation according to severity and airway safety.',TEAL),('Hemostasis and blood','Monitor serial hemoglobin. Correct severe coagulopathy or thrombocytopenia when indicated. Transfuse according to clinical context.',RED),('Medication and setting','Hold or reverse anticoagulant / antiplatelet therapy when appropriate. Use intensive care for severe hypoxemia.',GOLD)]):card(s,.75+i*4.05,1.62,3.7,3.7,t,b,c) #22 s=prs.slides.add_slide(blank);header(s,22,'Cause-directed treatment: immune-mediated DAH'); for i,(t,b,c) in enumerate([('ANCA-associated vasculitis','Severe disease is generally treated with glucocorticoids plus remission induction with rituximab or cyclophosphamide. Specialist guidance is required.',TEAL),('Anti-GBM disease','Urgent glucocorticoids and cyclophosphamide, with plasma exchange as a key disease-specific therapy and nephrology involvement.',RED),('Systemic lupus erythematosus','High-dose glucocorticoids plus immunosuppression selected for severity, organ involvement, infection assessment, and specialist plan.',GOLD)]):card(s,.75+i*4.05,1.65,3.7,4.7,t,b,c) #23 s=prs.slides.add_slide(blank);header(s,23,'Cause-directed treatment: nonimmune DAH and key nuance'); card(s,.75,1.65,3.7,4.65,'Hemostatic cause',['Stop or reverse provoking anticoagulants as clinically appropriate.','Correct platelets, coagulation factors, and other defects.'],RED) card(s,4.82,1.65,3.7,4.65,'Cardiac / pressure cause',['Treat decompensated heart failure, mitral disease, and volume or pressure overload.','Use cardiac assessment to guide the phenotype.'],TEAL) card(s,8.89,1.65,3.7,4.65,'Infection / exposure',['Give antimicrobial therapy or discontinue culprit drug / exposure.','Avoid uncritical immunosuppression until infection is assessed.'],GOLD) tx(s,'Plasma exchange is not a universal DAH therapy. Its role is cause-specific, particularly central in anti-GBM disease.',.9,6.48,11.4,.24,12,RED,True,PP_ALIGN.CENTER) #24 s=prs.slides.add_slide(blank);header(s,24,'Take-home messages and sources'); for i,(n,t,b) in enumerate([('01','Recognize','DAH may occur without hemoptysis. Combine hypoxemia, infiltrates, and falling hemoglobin.'),('02','Confirm','Progressively bloody serial BAL supports the diagnosis while microbiology is assessed.'),('03','Search for renal disease','Urine microscopy and renal function identify the high-risk pulmonary-renal pattern.'),('04','Treat the driver','Support oxygenation and hemostasis while urgently directing therapy to the cause.')]): y=1.5+i*1.05;rect(s,.75,y,.78,.55,TEAL,True);tx(s,n,.75,y+.15,.78,.18,12,WHITE,True,PP_ALIGN.CENTER);tx(s,1.85,y+.03,2.8,.22,15,NAVY,True);tx(s,b,4.55,y+.02,7.25,.45,12.5,INK) rect(s,.76,5.95,11.7,.82,PALE,True,LINE);tx(s,'Primary teaching source: Harrison’s Principles of Internal Medicine, 22nd ed. (2025). Diagnostic images: PMC7120649 and open-access PMC composite image. Supporting evidence check: PMID 40056479; PMID 39558618.',.96,6.12,11.25,.44,9,GREY,False) prs.save(OUT); print(OUT) PY python "/tmp/workspace/dah_new/src/create_dah_deck.py"
~/dah_new/src/create_dah_deck.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/dah_new/src/create_dah_deck.py'
python "/tmp/workspace/dah_new/src/create_dah_deck.py" && python - <<'PY' from pptx import Presentation from pptx.enum.shapes import MSO_SHAPE_TYPE from pathlib import Path p=Path('/tmp/workspace/dah_new/output/Diffuse_Alveolar_Hemorrhage_Harrison_24_Slides_Diagnostic_Images.pptx') prs=Presentation(str(p)) print('slides:',len(prs.slides),'size:',p.stat().st_size,'pictures:',sum(1 for s in prs.slides for sh in s.shapes if sh.shape_type==MSO_SHAPE_TYPE.PICTURE)) for i,s in enumerate(prs.slides,1): pics=sum(1 for sh in s.shapes if sh.shape_type==MSO_SHAPE_TYPE.PICTURE) text=' '.join(sh.text for sh in s.shapes if getattr(sh,'has_text_frame',False)) assert text.strip(), f'empty {i}' print(i,pics) PY
python - <<'PY' from pptx import Presentation from pptx.enum.shapes import MSO_SHAPE_TYPE from pathlib import Path p=Path('/tmp/workspace/dah_new/output/Diffuse_Alveolar_Hemorrhage_Harrison_24_Slides_Diagnostic_Images.pptx') prs=Presentation(str(p)) assert p.exists() and p.stat().st_size > 1_000_000 assert len(prs.slides)==24 for sn,slide in enumerate(prs.slides,1): for sh in slide.shapes: assert sh.left >= 0 and sh.top >= 0, (sn,sh.name) assert sh.left+sh.width <= prs.slide_width, (sn,sh.name,'right') assert sh.top+sh.height <= prs.slide_height, (sn,sh.name,'bottom') print('PASS: 24 slides; all shapes on canvas; file bytes',p.stat().st_size) print('Diagnostic-image slides: 13 CXR, 14 CT, 15 serial BAL, 16 multimodality/cytology, 9 histopathology') PY
Diffuse Alveolar Hemorrhage Harrison 24 Slides Diagnostic Images
Presentation · PPTX