L&R REF Magic

Photo Analysis
Must use L&R REF Magic Form.
Manual Entry
'); w.document.close(); }catch(e){} // Pricing is helpful but must never prevent the already-open print view from rendering. // v255 PDF-only reliability: pricing enrichment must never leave the already-open // Safari print tab parked on the placeholder. Give enrichment a bounded window, // then render the current completed results exactly as they exist. await Promise.race([ Promise.allSettled(patientTargets.map(t=>Promise.resolve().then(()=>ensureAllPricing(t)))), new Promise(resolve=>setTimeout(resolve,3000)) ]); const c=document.createElement('div'); c.className='patient-export'; patientTargets.forEach(t=>c.appendChild(t.cloneNode(true))); cleanManualKneeTrialExport(c); resolveKneeFinalState(c); resolveFootctPrintFinalState(c); moveReadyWrapSideInsideFinalCard(c,{groupSelector:'[data-footct-side],[data-footct-trial-color-group]',dataKey:'footctSide',productName:'ReadyWrap Foot CT'}); resolveReadywrapToePrintFinalState(c); resolveExobkPrintFinalState(c); moveReadyWrapSideInsideFinalCard(c,{groupSelector:'[data-exobk-side],[data-exobk-trial-color-group]',dataKey:'exobkSide',productName:'ExoStrong Below Knee'}); c.querySelectorAll('[data-readywrap-toe-side],[data-readywrap-toe-trial-color-group]').forEach(group=>{ const heading=group.querySelector(':scope > .fusion-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; card.insertBefore(h,card.firstChild); heading.remove(); } }); // Toe Cap Manual PDF: ExoSoft/ExoStrong mirror the proven ReadyWrap Toe export structure. c.querySelectorAll('[data-exo-toe-side],[data-exotoe-side],[data-toe-cap-side]').forEach(group=>{ const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(!card||!/Exo(?:Soft|Strong) Toe Cap/i.test(String(card.textContent||''))) return; let heading=group.querySelector(':scope > .fusion-screen-side-heading'); let side=String(group.dataset?.exoToeSide||group.dataset?.exotoeSide||group.dataset?.toeCapSide||heading?.textContent||'').trim().toUpperCase(); if(!/^(LEFT|RIGHT)$/.test(side)){ const m=String(group.textContent||'').match(/\b(LEFT|RIGHT)\b/i); side=m?m[1].toUpperCase():''; } if(!/^(LEFT|RIGHT)$/.test(side)) return; card.querySelectorAll(':scope > .fusion-screen-side-heading').forEach(x=>x.remove()); const h=heading?heading.cloneNode(true):document.createElement('div'); h.className='fusion-screen-side-heading'; h.textContent=side; h.style.fontWeight='900'; h.style.marginBottom='10px'; h.style.display='block'; card.insertBefore(h,card.firstChild); if(heading) heading.remove(); }); // ExoStrong Below Knee side is already normalized above for both deterministic OTS and OTS Trial. resolveExothighPrintFinalState(c); // ExoStrong Thigh High PDF: LEFT/RIGHT exactly once, bold, inside the colored final card. moveReadyWrapSideInsideFinalCard(c,{groupSelector:'[data-exothigh-side],[data-exothigh-trial-color-group]',dataKey:'exothighSide',productName:'ExoStrong Thigh High'}); resolveThighPrintFinalState(c); moveReadyWrapSideInsideFinalCard(c,{groupSelector:'[data-thigh-side],[data-thigh-trial-color-group]',dataKey:'thighSide',productName:'ReadyWrap Thigh'}); resolveCalfPrintFinalState(c); moveReadyWrapSideInsideFinalCard(c,{groupSelector:'[data-calf-side],[data-calf-trial-color-group]',dataKey:'calfSide',productName:'ReadyWrap Calf'}); cleanFusionFinalExport(c); resolveArmPrintFinalState(c); resolveMcpPrintFinalState(c); resolveWristPrintFinalState(c); // v446 Tribute Wrap Glove PDF: hard-replace the legacy print path with the // same completed-trial final-state architecture used by ReadyWrap Arm/Wrist. resolveGlovePrintFinalState(c); resolveBraPrintFinalState(c); resolveBelowKneePrintFinalState(c); // Below Knee v12 print-only: remove repeated trial headings, retain side cards. c.querySelectorAll('.below-knee-trial-inline-group,.manual-below-knee-side-group').forEach(group=>{ group.querySelectorAll('.bra-verified-trial-label,.fusion-trial-selected-heading').forEach(label=>{ if(/OTS Trial\s*-\s*Clinician\/DME Selected/i.test(label.textContent||''))label.remove(); }); }); c.querySelectorAll('.ktt-trial-inline-group,.manual-ktt-side-group').forEach(group=>{ group.querySelectorAll('.bra-verified-trial-label,.fusion-trial-selected-heading').forEach(label=>{ if(/OTS Trial\s*-\s*Clinician\/DME Selected/i.test(label.textContent||''))label.remove(); }); }); resolveKttPrintFinalState(c); resolveFullLegPrintFinalState(c); cleanFullLegFinalExport(c); removeIncompleteFullLegExport(c); // Tribute Wrap Below Knee / Knee to Thigh PDF parity: final generated result only. // move LEFT/RIGHT inside the finalized product card, for both Manual Entry and Photo Analysis. c.querySelectorAll('.manual-below-knee-side-group,.below-knee-trial-inline-group,.bk-trial-inline-group,.manual-ktt-side-group,.ktt-trial-inline-group').forEach(group=>{ const heading=group.querySelector(':scope > .fusion-screen-side-heading,:scope > .bk-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; h.style.display='block'; if(group.classList.contains('left')||card.classList.contains('left')) h.textContent='LEFT'; else if(group.classList.contains('right')||card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); resolveGauntletPrintFinalState(c); normalizeArmManualSideLabels(c); // v394 ReadyWrap Arm PDF parity with the locked Fusion/Knee presentation: // move the organizational LEFT/RIGHT heading inside the final blue/green product box. c.querySelectorAll('[data-arm-side],[data-arm-trial-color-group]').forEach(group=>{ const heading=group.querySelector(':scope > .fusion-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; if(card.classList.contains('left')) h.textContent='LEFT'; else if(card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); // v426 Tribute Wrap MCP to Axilla PDF parity with ReadyWrap Arm: // move LEFT/RIGHT inside the final blue/green MCP product card. c.querySelectorAll('.manual-mcp-side-group,.mcp-trial-inline-group').forEach(group=>{ const heading=group.querySelector(':scope > .mcp-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; if(card.classList.contains('left')) h.textContent='LEFT'; else if(card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); // v431 Tribute Wrap Wrist to Axilla PDF parity with ReadyWrap Arm: // move LEFT/RIGHT inside the final blue/green Wrist product card. c.querySelectorAll('.manual-wrist-side-group,.wrist-trial-inline-group').forEach(group=>{ const heading=group.querySelector(':scope > .wrist-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; if(card.classList.contains('left')) h.textContent='LEFT'; else if(card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); // v446 Tribute Wrap Glove PDF parity with ReadyWrap Arm/Wrist: // move LEFT/RIGHT inside the finalized Glove product card only after a completed REF exists. c.querySelectorAll('.manual-glove-side-group,.glove-trial-inline-group').forEach(group=>{ const heading=group.querySelector(':scope > .fusion-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.marginBottom='10px'; if(card.classList.contains('left')) h.textContent='LEFT'; else if(card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); // v404 ReadyWrap Gauntlet PDF parity with the locked ReadyWrap Arm presentation: // move LEFT/RIGHT inside the upper-left of the final blue/green Gauntlet product card and bold it. c.querySelectorAll('[data-gauntlet-side],[data-gauntlet-trial-color-group]').forEach(group=>{ const heading=group.querySelector(':scope > .fusion-screen-side-heading'); const card=group.querySelector(':scope > .manual-component,:scope > .refblock,:scope > .photo-side-result'); if(heading&&card){ const h=heading.cloneNode(true); h.style.fontWeight='900'; h.style.margin='0 0 10px 0'; h.style.display='block'; if(card.classList.contains('left')) h.textContent='LEFT'; else if(card.classList.contains('right')) h.textContent='RIGHT'; card.insertBefore(h,card.firstChild); heading.remove(); } }); cleanArmFinalExport(c); cleanManualExotoeFinalExport(c); cleanMcpFinalExport(c); cleanWristFinalExport(c); cleanGloveFinalExport(c); cleanBraFinalExport(c); cleanBelowKneeFinalExport(c); prepareManualGauntletCopySideLabels(c); cleanGauntletFinalExport(c); cleanFootctFinalExport(c); cleanReadywrapToeFinalExport(c); prepareManualExobkCopySideLabels(c); cleanExobkFinalExport(c); prepareManualExothighCopySideLabels(c); cleanExothighFinalExport(c); c.querySelectorAll('[data-exothigh-side] > .fusion-screen-side-heading,[data-exothigh-trial-color-group] > .fusion-screen-side-heading').forEach(n=>n.remove()); prepareManualThighCopySideLabels(c); cleanThighFinalExport(c); prepareManualCalfCopySideLabels(c); resolveCalfPrintFinalState(c); cleanCalfFinalExport(c); cleanCalfFinalExport(c); simplifyExportComparisons(c); // v306 patient-file PDF: decision aids stay on-screen only. Export the finalized product cards, not // comparison tables, rules, Custom/trial guidance, color/size controls, or alternate-size workflow. c.querySelectorAll('.fusion-trial-size-verification,.fl-compare,.fusion-trial-selected-heading,[data-manual-fusion-final-choice]').forEach(n=>n.remove()); c.querySelectorAll('.result-actions,.pricing-billing-btn,.fl-compare-btn,.fl-hide,button,.custom-form-link').forEach(n=>n.remove()); c.querySelectorAll('.pricing-billing-output').forEach(n=>n.style.display='block'); c.querySelectorAll('[hidden],.hidden').forEach(n=>n.remove()); // Bra Manual PDF: render exactly the same verified final REF card as Copy. if(patientTargets.length===1 && patientTargets[0].id==='refStatus' && /Tribute Wrap Bra/i.test(patientTargets[0].textContent||'')){ const verified=await braManualFinalExport(); if(verified)c.replaceChildren(verified); else c.replaceChildren(); // Custom without trial has no generated REF export. } // Export-only parity: use the same complete side card for Photo Analysis and Manual Entry. const printBlocks=[...c.querySelectorAll('.refblock,.manual-component,.photo-side-result')]; printBlocks.forEach(block=>{ const t=String(block.textContent||'').trim(); const isRight=/^RIGHT\b/i.test(t)||block.classList.contains('right'); const isLeft=/^LEFT\b/i.test(t)||block.classList.contains('left'); block.classList.toggle('export-right',isRight); block.classList.toggle('export-left',!isRight&&isLeft); block.innerHTML=block.innerHTML.replace(/\b(Beige)(\s*[—-]\s*REF\s*#?\s*\d{6})/gi,'$1$2'); // v258 PDF-only parity: Photo Analysis builds some Black REF lines as two // adjacent inline elements ("Black — " + "REF 123456"). Safari may wrap // between those elements. Collapse only that export clone into the same // single-element structure already rendering correctly elsewhere. [...block.querySelectorAll('.black-ref')].forEach(n=>{ if(!/^\s*Black\s*[—-]\s*$/i.test(String(n.textContent||''))) return; const next=n.nextElementSibling; if(!next||!next.classList.contains('black-ref')||!/^\s*REF\s*#?\s*\d{6}/i.test(String(next.textContent||''))) return; const one=document.createElement('span'); one.className='black-ref export-black-ref'; one.textContent=(String(n.textContent||'').trimEnd()+' '+String(next.textContent||'').trim()).replace(/\s+/g,' '); n.replaceWith(one); next.remove(); }); // v260 PDF-only spacing parity: after Black REF normalization, remove any // leftover export-clone nodes between the Beige REF and Black REF and // replace them with exactly one line break. This matches the compact // spacing already used by the correctly rendered RIGHT-side cards. [...block.querySelectorAll('.beige-ref')].forEach(beige=>{ const black=[...block.querySelectorAll('.black-ref')].find(n=> /^\s*Black\s*[—-]\s*REF\s*#?\s*\d{6}/i.test(String(n.textContent||'')) && (beige.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_FOLLOWING) ); if(!black) return; let cur=beige.nextSibling; while(cur && cur!==black){ const next=cur.nextSibling; cur.remove(); cur=next; } if(beige.nextSibling===black) beige.after(document.createElement('br')); }); }); const css=`body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;margin:28px;color:#111;background:#fff}.result,.resultbox,#refStatus{max-width:760px;margin:auto}.refblock,.manual-component{break-inside:avoid;margin:0 0 18px;padding:18px;border-radius:14px;background:#dfeaff;line-height:1.35}.refblock.right,.right,.export-right{background:#e0f2e4!important}.photo-side-result.left,.export-left{background:#dfeaff!important}.export-left :is(h1,h2,h3,h4,.result-product-name,.side-title),.export-left>.result-product-name{color:#244a86}.export-right :is(h1,h2,h3,h4,.result-product-name,.side-title),.export-right>.result-product-name{color:#2d6b3a}.export-beige{color:#96652f;font-weight:800}.patient-export .beige-text,.patient-export .black-text,.patient-export .export-beige{white-space:nowrap;display:inline-block}.patient-export .result-product-name{overflow-wrap:anywhere}.patient-export .manual-fusion-side-group{max-width:100%;box-sizing:border-box}.patient-export .hn-architecture-group{background:#eef2f7!important;padding:14px 18px 16px!important;border-radius:16px!important}.patient-export .hn-architecture-group>.manual-component{background:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:4px 0 9px!important;margin:0!important;color:#222!important}.patient-export .hn-architecture-group>.manual-component+.manual-component{margin-top:3px!important;padding-top:11px!important;border-top:1px solid rgba(80,100,130,.18)!important}.patient-export .hn-architecture-group>.manual-component .result-product-name{display:block!important;margin:0 0 3px!important;font-weight:900!important}.patient-export .refblock,.patient-export .manual-component{min-width:0;overflow-wrap:anywhere}.export-trial-summary{margin:14px 0;padding:14px;border:1px solid #d5d5d5;border-radius:10px;background:#fff;color:#111}.pricing-billing-wrap{border-top:1px solid #d8dee6;margin-top:14px;padding-top:12px}.pricing-billing-card{break-inside:avoid;margin-top:10px;padding:12px;border:1px solid #d8dee6;border-radius:9px;background:#f8fafc;line-height:1.45}.result-product-name,strong{font-weight:800}.fusion-trial-size-verification{break-inside:avoid;margin-top:16px}.fusion-trial-size-verification .fl-grid{display:grid!important;grid-template-columns:1.05fr repeat(5,1fr)!important}.fusion-trial-size-verification .fl-key{grid-column:1/7;padding:6px 0;font-weight:700}.fusion-trial-size-verification .fl-cell{padding:8px 6px;border-right:1px solid #d7d7d7;border-bottom:1px solid #d7d7d7;text-align:center}.fusion-trial-size-verification .fl-head,.fusion-trial-size-verification .fl-label{font-weight:800;color:#2f6b38}.fusion-trial-size-verification .fit{color:#2f8b37;font-weight:800}.fusion-trial-size-verification .nofit{color:#d33;font-weight:800}.fusion-trial-size-verification .fusion-selected-size-top{box-shadow:inset 2px 2px 0 #2f7d32,inset -2px 0 0 #2f7d32}.fusion-trial-size-verification .fusion-selected-size-bottom{box-shadow:inset 2px 0 0 #2f7d32,inset -2px -2px 0 #2f7d32}@media print{body{margin:0}.patient-export{width:100%;max-width:100%}.refblock,.manual-component,.photo-side-result{max-width:100%;box-sizing:border-box;overflow-wrap:anywhere}.fl-grid{display:none!important}}@page{size:auto;margin:.45in}`; if(w.closed)return; const returnBar=''; const navCss='.print-return{max-width:760px;margin:0 auto 18px}.print-return button{width:auto;margin:0;padding:10px 14px;border:1px solid #aeb6c2;border-radius:9px;background:#fff;color:#111;font:700 15px -apple-system,BlinkMacSystemFont,\"Segoe UI\",Arial,sans-serif}@media print{.print-return{display:none!important}}'; w.document.open();w.document.write('L&R REF Generator Results'+returnBar+c.outerHTML+' ');w.document.close(); setTimeout(()=>{w.focus();w.print();},250); } function activePatientTargets(){ const all=[]; const manual=document.getElementById('refStatus'); if(manual && /REF\s*#?\s*\d{6}/i.test(String(manual.textContent||''))) all.push(manual); document.querySelectorAll('.result').forEach(el=>{ if(el.querySelector('.refblock') && /REF\s*#?\s*\d{6}/i.test(String(el.textContent||''))) all.push(el); }); return all.filter(el=>{ const card=el.closest('.card'); return !card || !card.classList.contains('hidden'); }); } function addPatientActions(){ const targets=activePatientTargets(); const last=targets[targets.length-1]; const rows=[...document.querySelectorAll('.result-actions.patient-actions')]; if(!last){ rows.forEach(r=>r.remove()); return; } if(rows.length===1 && rows[0].parentElement===last) return; rows.forEach(r=>r.remove()); const row=document.createElement('div');row.className='result-actions patient-actions'; const label=document.createElement('div');label.className='patient-actions-label';label.textContent='Patient Results'; const buttons=document.createElement('div');buttons.className='patient-actions-buttons'; const copy=document.createElement('button');copy.type='button';copy.className='result-action-btn';copy.textContent='Copy Results';copy.onclick=()=>copyText(last,copy); const pdf=document.createElement('button');pdf.type='button';pdf.className='result-action-btn secondary';pdf.textContent='Print / Save PDF';pdf.onclick=()=>printTarget(last); buttons.append(copy,pdf);row.append(label,buttons);last.appendChild(row); } function enhance(){ addPatientActions(); } window.__refreshPatientActions=enhance; const style=document.createElement('style');style.textContent=`.result-actions{margin:20px 0 4px;padding:18px 14px 4px;border-top:1px solid #d8dee6;text-align:center}.patient-actions-label{font-size:13px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;color:#6b7280;margin-bottom:11px}.patient-actions-buttons{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}.result-action-btn{width:auto!important;margin:0!important;padding:10px 14px!important;border-radius:9px!important;font-size:14px!important;font-weight:800!important;background:#2457a7!important;color:#fff!important;border:1px solid #2457a7!important}.result-action-btn.secondary{background:#fff!important;color:#111!important;border-color:#aeb6c2!important}.result-action-btn.copying{background:#8a8a8a!important;border-color:#8a8a8a!important;opacity:1!important}`;document.head.appendChild(style); let q=false;new MutationObserver(()=>{if(q)return;q=true;requestAnimationFrame(()=>{q=false;enhance()})}).observe(document.body,{childList:true,subtree:true,characterData:true});enhance(); })();