Copy 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)
}