1. 開啟Chrome瀏覽器,新增一個書籤,名稱輸入「診斷書產生器」,網址輸入下列內容:

    javascript:(function(){const old=document.getElementById("ntuh_cert_box");if(old)old.remove();function findDoc(d){if(d.querySelector('table[id$="GridViewInPatRecord"],table[id$="GridViewEmergencyContent"],table[id$="GridViewOutPatRecord"]'))return d;const fs=d.querySelectorAll("iframe,frame");for(let i=0;i<fs.length;i++){try{if(fs[i].contentDocument){const r=findDoc(fs[i].contentDocument);if(r)return r;}}catch(e){}}return d;}const doc=findDoc(document);const txt=(el,sel)=>{const n=el.querySelector(sel);return n?n.innerText.trim():"";};const inRecs=[],erRecs=[],opdRecs=[];doc.querySelectorAll(%27table[id$="GridViewInPatRecord"] tr%27).forEach(tr=>{const inD=txt(tr,%27span[id$="InLabelInDate"]%27);if(!inD)return;const st=txt(tr,%27span[id$="InLabelStatusName"]%27);if(st.includes("取消"))return;inRecs.push({inD,outD:txt(tr,%27span[id$="InLabelOutDate"]%27),dr:txt(tr,%27span[id$="InLabelMainDrName"]%27),st});});doc.querySelectorAll(%27table[id$="GridViewEmergencyContent"] tr%27).forEach(tr=>{const inD=txt(tr,%27span[id$="LabelEmerComeClinicDate"]%27);if(!inD)return;const st=txt(tr,%27span[id$="LabelEmerStatusName"]%27);if(st.includes("取消"))return;erRecs.push({inD,outD:txt(tr,%27span[id$="LabelEmerDischargeDate"]%27),dr:txt(tr,%27span[id$="LabelEmerMainDrName"]%27),st});});doc.querySelectorAll(%27table[id$="GridViewOutPatRecord"] tr%27).forEach(tr=>{const d=txt(tr,%27span[id$="LabelComeClinicDate"]%27);if(!d)return;const st=txt(tr,%27span[id$="LabelAccountStatusName"]%27);if(st.includes("取消"))return;opdRecs.push({d,act:txt(tr,%27span[id$="LabelSpecialCureName"]%27)||"(未分類)",dr:txt(tr,%27span[id$="LabelMainDrName"]%27),st});});const drSet=new Set();inRecs.forEach(r=>r.dr&&drSet.add(r.dr));erRecs.forEach(r=>r.dr&&drSet.add(r.dr));opdRecs.forEach(r=>r.dr&&drSet.add(r.dr));const drs=Array.from(drSet).sort((a,b)=>a.localeCompare(b,"zh-Hant"));const actSet=new Set();opdRecs.forEach(r=>r.act&&actSet.add(r.act));const acts=Array.from(actSet);const box=document.createElement("div");box.id="ntuh_cert_box";box.style="position:fixed;top:16px;right:16px;z-index:999999;background:#fff;border:2px solid #1B365D;border-radius:6px;padding:14px;box-shadow:0 6px 20px rgba(0,0,0,0.3);font-family:Microsoft JhengHei,sans-serif;width:480px;max-height:90vh;overflow-y:auto;font-size:13px;color:#222;";box.innerHTML='<div style="display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #ccc;padding-bottom:8px;margin-bottom:10px;"><b style="font-size:15px;color:#1B365D;">診斷書就診日期整理工具</b><button id="nc_close" style="cursor:pointer;padding:2px 8px;">關閉</button></div><div style="margin-bottom:10px;"><label><b>主治醫師:</b></label><select id="nc_dr" style="padding:3px 6px;font-size:13px;"><option value="__ALL__">全部主治醫師</option>'+drs.map(d=>'<option value="'+d+'">'+d+'</option>').join("")+'</select></div><div style="margin-bottom:10px;"><b>門診「行為」篩選:</b><div id="nc_acts" style="display:flex;flex-wrap:wrap;gap:8px;margin-top:4px;padding:6px;background:#f5f7fa;border:1px solid #dce3ea;border-radius:4px;">'+acts.map((a,i)=>'<label style="cursor:pointer;white-space:nowrap;"><input type="checkbox" class="nc_act_cb" value="'+a+'" checked> '+a+'</label>').join("")+'</div></div><div style="margin-bottom:8px;"><div style="display:flex;justify-content:space-between;margin-bottom:3px;"><b>【住院】文字醫囑</b><button class="nc_cp" data-t="nc_in" style="cursor:pointer;font-size:12px;">複製住院</button></div><textarea id="nc_in" style="width:100%;height:72px;font-size:12px;box-sizing:border-box;"></textarea></div><div style="margin-bottom:8px;"><div style="display:flex;justify-content:space-between;margin-bottom:3px;"><b>【急診】文字醫囑</b><button class="nc_cp" data-t="nc_er" style="cursor:pointer;font-size:12px;">複製急診</button></div><textarea id="nc_er" style="width:100%;height:72px;font-size:12px;box-sizing:border-box;"></textarea></div><div style="margin-bottom:10px;"><div style="display:flex;justify-content:space-between;margin-bottom:3px;"><b>【門診】文字醫囑</b><button class="nc_cp" data-t="nc_opd" style="cursor:pointer;font-size:12px;">複製門診</button></div><textarea id="nc_opd" style="width:100%;height:84px;font-size:12px;box-sizing:border-box;"></textarea></div><div style="text-align:right;"><button id="nc_cp_all" style="background:#1B365D;color:#fff;border:none;padding:6px 14px;border-radius:4px;cursor:pointer;font-weight:bold;">複製全部文字</button></div>';document.body.appendChild(box);function render(){const selDr=document.getElementById("nc_dr").value;const selActs=new Set(Array.from(box.querySelectorAll(".nc_act_cb:checked")).map(c=>c.value));const fIn=inRecs.filter(r=>selDr==="__ALL__"||r.dr===selDr).sort((a,b)=>a.inD.localeCompare(b.inD));const fEr=erRecs.filter(r=>selDr==="__ALL__"||r.dr===selDr).sort((a,b)=>a.inD.localeCompare(b.inD));const fOpd=opdRecs.filter(r=>(selDr==="__ALL__"||r.dr===selDr)&&selActs.has(r.act)).sort((a,b)=>a.d.localeCompare(b.d));document.getElementById("nc_in").value=fIn.length?fIn.map(r=>r.outD?'病人因上述原因,於'+r.inD+'至本院一般病房住院,經診斷治療後,於'+r.outD+'出院,宜持續追蹤治療。':'病人因上述原因,於'+r.inD+'至本院一般病房住院,目前仍住院治療中。').join("\n"):"(無符合條件之住院紀錄)";document.getElementById("nc_er").value=fEr.length?fEr.map(r=>r.outD?'病人因上述原因,於'+r.inD+'至本院急診就診候床,經診斷治療後,於'+r.outD+'自急診離部。':'病人因上述原因,於'+r.inD+'至本院急診就診候床,目前仍於急診治療中。').join("\n"):"(無符合條件之急診紀錄)";const opdDates=Array.from(new Set(fOpd.map(r=>r.d)));document.getElementById("nc_opd").value=opdDates.length?'病人因上述原因,於'+opdDates.join(", ")+', (請注意是否要加入今日就診日期)至本院門診就診,宜持續追蹤治療。':"(無符合條件之門診紀錄)";}function copyText(str,btn){navigator.clipboard?navigator.clipboard.writeText(str).then(()=>{const o=btn.innerText;btn.innerText="已複製!";setTimeout(()=>btn.innerText=o,1200);}):prompt("請按 Ctrl+C 複製:",str);}document.getElementById("nc_dr").onchange=render;box.querySelectorAll(".nc_act_cb").forEach(cb=>cb.onchange=render);box.querySelectorAll(".nc_cp").forEach(btn=>{btn.onclick=()=>copyText(document.getElementById(btn.dataset.t).value,btn);});document.getElementById("nc_cp_all").onclick=function(){const parts=[];["nc_in","nc_er","nc_opd"].forEach(id=>{const v=document.getElementById(id).value;if(v&&!v.startsWith("(無"))parts.push(v);});copyText(parts.join("\n"),this);};document.getElementById("nc_close").onclick=()=>box.remove();render();})();
    
    

    螢幕擷取畫面 2026-11-27 143340.png

  2. 用Chrome開啟患者的就診紀錄,如下:

    診斷書產生器_Demo.jpg

  3. 到書籤列點擊剛剛建立的「診斷書產生器」書籤,就會自動生成診斷書醫囑文字了。

    診斷書產生器_Demo2.jpg