Predispensing Error Recorder
รายการยาและการตั้งค่าระบบ
Loading...
รายการยา
แสดง 0 รายการ
| รหัสยา | ชื่อยา | กลุ่มยา | HAD | สถานะ | ความแรง | รูปแบบยา | หน่วย | การจัดการ |
|---|---|---|---|---|---|---|---|---|
| กำลังโหลดข้อมูล... | ||||||||
0
รายการยาทั้งหมด
0
High Alert Drug
0
ยาที่ใช้งาน
0
ยาที่ไม่ใช้งาน
ตั้งค่า Google Sheets
คำแนะนำการตั้งค่า:
- สร้าง Google Sheet พร้อม 2 tabs:
- Predispensing_Errors พร้อมคอลัมน์: วันที่, เลขที่รายงาน, เวร, ประเภท, สถานที่, กระบวนการ, ข้อผิดพลาด, รายการถูกต้อง, รายการผิด, สาเหตุ, รายละเอียดเพิ่มเติม, ผู้รายงาน
- Users พร้อมคอลัมน์: PS Code, ID 13 หลัก, ชื่อ-นามสกุล, กลุ่ม, ระดับ, อีเมล, รหัสผ่าน, status
- แชร์ Google Sheet: คลิก "แชร์" → เปลี่ยนเป็น "ทุกคนที่มีลิงก์สามารถดูได้"
- สร้าง Google Apps Script สำหรับบันทึกข้อมูล:
- ใน Google Sheet ไปที่ Extensions → Apps Script
- ลบโค้ดเดิม และคัดลอกโค้ดด้านล่างใส่แทน
- บันทึก → Deploy → New deployment
- Type: Web app → Execute as: Me → Who has access: Anyone
- คัดลอก Web app URL มาใส่ในช่องด้านบน
- หมายเหตุ: หากอัปเดตโค้ด Apps Script ต้อง Deploy ใหม่
- ไปที่ Google Cloud Console
- เปิดใช้งาน Google Sheets API: APIs & Services → Library → ค้นหา "Google Sheets API" → เปิดใช้งาน
- สร้าง API Key: APIs & Services → Credentials → Create Credentials → API Key
- คัดลอกข้อมูลผู้ใช้จากไฟล์ users.csv ไปใส่ใน Sheet Users
- ทดสอบ: คลิก "รีเฟรชรายชื่อผู้ใช้" เพื่อตรวจสอบการเชื่อมต่อ
Google Apps Script Code:
// Minimal ตัวอย่าง (อัปเดต): Apps Script ไม่รองรับ setHeaders กับ ContentService
function jsonResponse(o){return ContentService.createTextOutput(JSON.stringify(o)).setMimeType(ContentService.MimeType.JSON);}
function doPost(e){
try{
let data;
if(e.parameter && e.parameter.action){ data = e.parameter; }
else if(e.postData && e.postData.contents){ data = JSON.parse(e.postData.contents); }
else { return jsonResponse({error:'No data'}); }
const ss = SpreadsheetApp.openById('YOUR_SPREADSHEET_ID');
if(data.action==='append'){
const sheet = ss.getSheetByName(data.sheetName || 'Predispensing_Errors');
if(!sheet) return jsonResponse({error:'Sheet not found'});
if(data.timestamp){
sheet.appendRow([
data.timestamp,
data.reportId,
data.shift,
data.errorType,
data.location,
data.process,
data.errorDetail,
data.correctItem,
data.incorrectItem,
data.cause,
data.additionalDetails||'',
data.reporter
]);
return jsonResponse({success:true});
}
}
return jsonResponse({error:'Invalid action'});
}catch(err){return jsonResponse({error:err.toString()});}
}