其他巨集函數

OPENURL 開啟外部網址函數

點選按鈕開啟指定網址。

巨集函數說明

函數名稱:OPENURL

參數

  • urlstring :網址文字,也可使用函數組合成動態連結。

用法

OPENURL(urlstring)

範例:

// open UpToDate 網頁資料

OPENURL("https://www.uptodate.com/contents/pain-control-in-the-critically-ill-adult-patient?search=fentany1%20dosing&search_resecult&selectedTitle=2%7E150&sage_type=default&display_rank=1#H144549897")
小助手表單

建議按鈕名稱可設為 " ⮥ ",實際操作如下圖所示。本範例使用 AI 小助手表單為範例

MACRO 巨集函數

巨集函數 是一種可以根據指定的公式計算結果來動態更新特定元素內容的功能。本函數僅能使用在巨集按鈕。這在需要動態展示計算結果或更新頁面內容的場景中特別有用。

巨集函數說明

函數名稱MACRO

參數

  • id:需要更新內容的元素標識。

  • formula:純文字,或是函數公式,會被評估並用作更新內容的值。

用法

MACRO(id, formula)

CUSTOMFUNC 客製化函數

使用者可在表單選項的 JS Script addon 區塊,自行設計 javascript 函數,然後利用 CUSTOMFUNC() 調用

Javascript 函數範例

function checkDrug(){
	console.log('call checkDrug');
    var tracerForExam = [
        { tracer: 'Tc99m PYP', half: '360', exams: ['3-037', '3-050', '3-051'] },
        { tracer: 'Tc99m ECD', half: '360', exams: ['3-001', '3-005'] },
        { tracer: 'Tc99m MDP', half: '360', exams: ['3-060', '3-060A'] },
        { tracer: 'Tc99m DMSA', half: '360', exams: ['3-041'] },
        { tracer: 'Tc99m Phytate', half: '360', exams: ['3-056'] },
        { tracer: 'Tc99m TRODAT-1', half: '360', exams: ['3-007'] },
        { tracer: 'Tc99m ECD', half: '360', exams: ['3-001','3-005'] },
        { tracer: 'Tl-201', half: '4320', exams: ['3-052', '3-065'] },
        { tracer: 'I-131 Caps', half: '11548', exams: ['3-090', '3-016'] },
        { tracer: 'Tc99m', half: '360', exams: ['3-004', '3-005', '3-010', '3-034', '3-036', '3-038', '3-037', '3-050'] },
        { tracer: 'Tc99m MAG3', half: '360', exams: ['3-041'] },
        { tracer: 'I-131 NP59', half: '11548', exams: ['3-040'] },
        { tracer: 'Tc99m DTPA', half: '360', exams: ['3-030', '3-036', '3-038', '3-041', '3-054', '3-055'] },
        { tracer: 'Tc99m MAA', half: '360', exams: ['3-020', '3-054'] },
        { tracer: 'Tc99m Sestamibi', half: '360', exams: ['3-018', '3-052', '3-065'] },
        { tracer: 'Ga-67', half: '4698', exams: ['3-036', '3-061'] }
    ];

	var exam_ids = $('[itemid=38]').text();
	console.log('exam_ids: '+ exam_ids);		
	// Use setTimeout to delay fetching tracer_id by 100ms
	setTimeout(function() {
		var tracer_id = $('[itemid=28]').text();
		console.log('tracer_id: '+ tracer_id );	
		var allowed = false;
		
		// Loop through the tracerForExam array to find the matching tracer
        $.each(tracerForExam, function(index, tracerObj) {
            if (tracerObj.tracer === tracer_id) {
                // Set the value of tf to the corresponding half value
                $('[itemid=39]').text(tracerObj.half).keyup().blur(); 
                
                // Check if the exam_id string contains any of the exams in the tracer's list
                $.each(tracerObj.exams, function(i, exam) {
                    if (exam_ids.includes(exam)) { // Check if the exam_id string contains the current exam
                        allowed = true;
                        return false; // Exit loop once a match is found
                    }
                });
            }
        });
		console.log('allowed: '+ allowed);
		// Display result
		if (allowed) {            
			$('[itemid=40]').text("").keyup(); 
		} else {
			$('[itemid=40]').text(" 藥物錯誤 ").keyup(); 
		}
	}, 500); // Delay for 500ms (0.5 second)
}

然後在表單中使用巨集函數調用 CUSTOMFUNC("checkDrug") 呼叫調用。

CUSTOMFUNC

Last updated