Predispensing Error Recorder

กรุณาเข้าสู่ระบบด้วย PS Code และรหัสผ่าน (4 ตัวท้ายของ ID13)

ติดต่อ IT ถ้าไม่สามารถเข้าสู่ระบบได้

Predispensing Error Recorder

รายการยาและการตั้งค่าระบบ

Loading...
บันทึกข้อผิดพลาด แดชบอร์ด สรุปรายบุคคล รายการยา ตั้งค่า

รายการยา

สถานะ Sync ภายนอก: ยังไม่ตั้งค่า อัปเดตล่าสุด: -

เพิ่มรายการยาใหม่

แสดง 0 รายการ
รหัสยา ชื่อยา กลุ่มยา HAD สถานะ ความแรง รูปแบบยา หน่วย การจัดการ
กำลังโหลดข้อมูล...
0
รายการยาทั้งหมด
0
High Alert Drug
0
ยาที่ใช้งาน
0
ยาที่ไม่ใช้งาน

ตั้งค่า Google Sheets

ยังไม่ได้กำหนดค่า Web App URL

ระบบกำลังทำงานใน Demo Mode — ข้อมูลจะไม่ถูกบันทึกจริง กรุณาตั้งค่าให้ครบก่อน Deploy:

  1. คัดลอก apps-script.js ไปวางใน Google Apps Script
  2. Deploy → New deployment → Web App → Execute as: Me, Access: Anyone
  3. คัดลอก Web App URL มาวางในช่อง "Google Apps Script Web App URL" ด้านล่าง
  4. กรอก Spreadsheet ID ของ Google Sheet ที่จะใช้เก็บข้อมูล
  5. เรียก migrateUsersToHashedPasswords() ในหน้า Apps Script Editor เพื่อ hash password ผู้ใช้
รับ API key จาก Google Cloud Console
พบใน URL ของ Google Sheet ของคุณ
Sheet นี้ใช้สำหรับดึงรายชื่อผู้ใช้ในระบบ
Sheet นี้ใช้สำหรับดึงรายชื่อรายการยาในระบบ
⚠️ หมายเหตุ CORS:
• หากเกิด CORS error ให้ deploy Apps Script ใหม่
• ตั้งค่า Execute as: "Me", Who has access: "Anyone"
• หรือใช้ Google Chrome ด้วย --disable-web-security flag
• หรือใช้ Live Server extension แทน file:// protocol
จำเป็นสำหรับการบันทึกข้อมูล (ดูคำแนะนำด้านล่าง)
URL สำหรับดึงรายการยาจากฐานข้อมูลภายนอก
กรณีข้อมูลยาอยู่ nested object ให้ระบุ path เช่น data.items
ตัวอย่างรูปแบบข้อมูล External Drug API

รองรับ JSON array ตรงๆ หรือ nested ผ่าน JSON Data Path และรองรับ CSV ที่มี header

{
  "data": [
    {
      "drugCode": "PARA500",
      "drugName": "Paracetamol 500mg",
      "group": "Analgesic",
      "had": "Regular",
      "status": "Active"
    },
    {
      "code": "INS001",
      "name": "Insulin Regular",
      "category": "Antidiabetic",
      "highAlert": true,
      "active": true
    }
  ]
}
drugCode,drugName,group,had,status
"PARA500","Paracetamol 500mg","Analgesic","Regular","Active"
"INS001","Insulin, Regular","Antidiabetic","High","Active"

คำแนะนำการตั้งค่า:

  1. สร้าง Google Sheet พร้อม 2 tabs:
    • Predispensing_Errors พร้อมคอลัมน์: วันที่, เลขที่รายงาน, เวร, ประเภท, สถานที่, กระบวนการ, ข้อผิดพลาด, รายการถูกต้อง, รายการผิด, สาเหตุ, รายละเอียดเพิ่มเติม, ผู้รายงาน
    • Users พร้อมคอลัมน์: PS Code, ID 13 หลัก, ชื่อ-นามสกุล, กลุ่ม, ระดับ, อีเมล, รหัสผ่าน, status
  2. แชร์ Google Sheet: คลิก "แชร์" → เปลี่ยนเป็น "ทุกคนที่มีลิงก์สามารถดูได้"
  3. สร้าง Google Apps Script สำหรับบันทึกข้อมูล:
    1. ใน Google Sheet ไปที่ Extensions → Apps Script
    2. ลบโค้ดเดิม และคัดลอกโค้ดด้านล่างใส่แทน
    3. บันทึก → Deploy → New deployment
    4. Type: Web app → Execute as: Me → Who has access: Anyone
    5. คัดลอก Web app URL มาใส่ในช่องด้านบน
    6. หมายเหตุ: หากอัปเดตโค้ด Apps Script ต้อง Deploy ใหม่
  4. ไปที่ Google Cloud Console
  5. เปิดใช้งาน Google Sheets API: APIs & Services → Library → ค้นหา "Google Sheets API" → เปิดใช้งาน
  6. สร้าง API Key: APIs & Services → Credentials → Create Credentials → API Key
  7. คัดลอกข้อมูลผู้ใช้จากไฟล์ users.csv ไปใส่ใน Sheet Users
  8. ทดสอบ: คลิก "รีเฟรชรายชื่อผู้ใช้" เพื่อตรวจสอบการเชื่อมต่อ

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()});}
                        }

หมายเหตุสำคัญ:

  • API Key ใช้สำหรับอ่านข้อมูลเท่านั้น (Users list)
  • Web App URL จำเป็นสำหรับการบันทึกข้อมูล
  • หากไม่ตั้งค่า Web App จะไม่สามารถบันทึกข้อผิดพลาดได้