Clinic

Clinic Interaction System — Telegram

BS Derma · QR → Bot → Registration → Tasks → Care → Pharmacy/Billing → Follow-up

Patient Interaction Flow — Telegram Integrated

@BSDermaBot
1

Scan QR → Telegram Bot

Patient scans clinic QR; opens @BSDermaBot

2

Registration

OPD/IPD · demographics · B2C / Insurance / CSR

3

Task Assignment

Doctor · Nurse · Lab · Imaging notified via Telegram

4

Consultation & Treatment

Notes · lab orders · imaging · treatment plan shared

5

Pharmacy & Billing

Rx · payments · Bronze/Gold/Platinum discounts

6

Follow-Up & Discharge

Reminders · discharge summary · transfer option

9

Pending/Scheduled

0

Active

0

Completed

0

Escalated/Transferred

Task Board

Seven Up

6ab6688f1b1a88cf19d09669 Pending/Scheduledconsultation

Web intake approved & assigned to Puy Reaksmey. Complaint: .

Nurse

ស៊ីម ឆានុន

6aab5c3e12f9741a28570aeb Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 17 Sept 2026 with no scheduled follow-up. Main Dx: Typhoid Fever Attending: Dr. Em Chetbrathna, MD. Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

Yun sina

6aa4d71b1699f48124389fc4 Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 09 Sept 2026 with no scheduled follow-up. Main Dx: unspecified diagnosis Attending: Dr. Em Chetbrathna, MD. Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

Ah jom

6aa4d163ea23fc257383e5e6 Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 11 Sept 2026 with no scheduled follow-up. Main Dx: Carbonpeel pico Attending: TS Clinic Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

លីម​​​ សុខសក្កិមុនី

6aa26a86c9e49f22e48c66b4 Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 05 Sept 2026 with no scheduled follow-up. Main Dx: Typoid Fever Secondary Dx: Enterocolitis Attending: Dr. Em Chetbrathna, MD. Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

យន់ ស៊ីណា

6aa271296c2b996f9b500e8e Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 10 Sept 2026 with no scheduled follow-up. Main Dx: unspecified diagnosis Attending: TS Clinic Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

Chea Kanika

6aa145dc7df16928e6578949 Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 09 Sept 2026 with no scheduled follow-up. Main Dx: Vertigo Attending: Dr. Em Chetbrathna, MD. Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

Visa

6a9e004e4534c74d54999e1e Pending/Scheduledfollowup

Auto-generated follow-up task — patient completed a visit on 06 Sept 2026 with no scheduled follow-up. Main Dx: Pre-eclampsia (O14) Attending: Dr. Em Chetbrathna, MD. Outcome: stable Action: Contact patient to schedule a follow-up appointment.

Doctor

Ambarita

Pending/Scheduledconsultation

following melasma treatment

Doctor

Telegram Bot Integration

Not connected — set TELEGRAM_BOT_TOKEN secret & test.

Register this function's public URL so Telegram forwards patient messages here.

Telegram Connection — Flow & Education

Bot token not set
Telegram bot QR

Scan to open the bot

https://t.me/your_bot_username

Print this QR at reception, on patient ID cards, and in staff onboarding packs. Scanning it opens the BS Derma Telegram bot directly — the patient or staff member taps Start, and their chat ID is captured for notifications.

Connection Flow

1

Scan QR / Open Bot

Patient or staff scans the BS Derma QR code or opens the t.me bot link.

2

Tap Start

Bot sends the main menu — Register, Book, Prescriptions, Pay.

3

Chat ID Captured

Webhook forwards the chat ID to the BS Derma system.

4

Linked to Record

Admin links the chat ID to the patient or staff profile.

5

Notifications Live

Reminders, results & task alerts flow to the right person.

For Patients (Customers)

  1. Scan the BS Derma QR at reception or on your patient ID card.
  2. Tap Start in Telegram to open the bot menu.
  3. Choose: Register · Book Appointment · My Prescriptions · Pay Bill.
  4. Consent once — we only send appointment, lab-result & billing reminders.
  5. Get appointment reminders the day before your visit.
  6. Receive lab & imaging results as soon as they are reviewed.
  7. Get billing notifications and payment confirmations.

For Medical Staff

  1. Scan the staff QR or open the bot link from your onboarding pack.
  2. Tap Start — your chat ID is captured automatically.
  3. Admin links your chat ID to your staff profile (Settings → Staff).
  4. Receive task assignments: patient, department, priority, details.
  5. Get STAT / urgent alerts instantly for critical tasks.
  6. Patient follow-up reminders routed to the right department.
  7. Only your assigned tasks are sent — no other staff see your messages.

Admin Setup Checklist

  1. Create a bot via @BotFather on Telegram → copy the bot token.
  2. Paste the token into the TELEGRAM_BOT_TOKEN secret (App Settings → Secrets).
  3. Click Test Connection in the Telegram Bot Integration panel — confirm the bot username appears.
  4. Set the Webhook URL (this function's public URL) so patient incoming messages reach the system.
  5. Share the bot link / QR with patients and staff; link chat IDs in the Connections panel below.

Telegram Connections

0 connected

No connected staff yet.

Share the bot QR — once a person taps Start and their chat ID is linked here, they appear in this list.

Telegram Integration Workflow Schema

Deployable AI Workflow

BS Derma Clinic · Patient journey from registration to discharge, automated via Telegram bot & charge management.

Flowchart Nodes — Patient Journey

1

Registration

QR → Bot → intake (name, phone, ID, complaint, payment type) → Patient record

2

Task Assignment

Route to Doctor / Nurse / Lab / Imaging / Pharmacy / Admin via Telegram

3

Consultation

Doctor assessment · lab/imaging orders · treatment plan

4

Billing

Auto charge codes · invoice · pharmacy sync · member discounts

5

Follow-up

Scheduled reminders · lab/imaging result delivery

6

Discharge

Discharge summary · transfer/referral · status → discharged

Charge Mapping — Auto Code Generation

Format: [CATEGORY]-[TYPE]-[SEQ] · 11 categories × sub-classifications · sequential auto-coding.

CategorySub-categoryType PrefixSample Code
ConsultationDoctor ConsultationDOCCONS-DOC-001
ProcedureClinical ProceduresCLNPROC-CLN-001
DiagnosticLaboratory TestsLABDIAG-LAB-001
ImageryBasic ImagingBSCIMG-BSC-001
RadiologyAdvanced ImagingADVRAD-ADV-001
Room ChargeInpatient / ObservationINOROOM-INO-001
NursingNursing CareNURNURS-NUR-001
ServiceSupport ServicesSUPSERV-SUP-001
MedicationPrescribed DrugsPREMED-PRE-001
PharmacyDispensing / ConsumablesDISPPHAR-DISP-001
AdministrationAdministrationADMADMIN-ADM-001

Telegram Message Templates

Enter a chat ID, then tap Send on any template to preview it live.
👋

Welcome / Start

Trigger: Patient taps /start

🏥 <b>Welcome to BS Derma Clinic</b>

Hi Patient! I'm your digital assistant. I can help you with:

📝 Register as a patient
📅 Book an appointment
💊 View my prescriptions
💳 Pay my bill

Tap the menu below to begin. To withdraw consent at any time, reply <b>STOP</b>.
📝

Registration Intake

Trigger: Patient chooses Register

📝 <b>Registration — BS Derma</b>

Please reply with:
• Full name
• Age / Date of birth
• Phone number
• National ID or Passport
• Chief complaint
• Payment type (Self-pay / Insurance / CSR)

Example: <i>Samnang, 28, 012345678, ID001234, acne, self-pay</i>
📅

Appointment Confirmed

Trigger: Booking created

✅ <b>Appointment Confirmed</b>

👤 Patient
🆔 BS-2026-001
📅 2026-07-23 · ⏰ 09:00
🔬 Doctor

📍 BS Derma Clinic
Please arrive 15 minutes early. Reply <b>RESCHEDULE</b> to change, or <b>CANCEL</b> to cancel.
🔔

Staff Task Assignment

Trigger: Task routed to dept

🔔 <b>New Task — Doctor</b>

👤 Patient (BS-2026-001)
🏷️ task
⚡ ROUTINE
📝 —

Accept by replying <b>ACCEPT</b>.
🧪

Lab Result Ready

Trigger: Lab result reviewed

🧪 <b>Lab Result Ready</b>

👤 Patient (BS-2026-001)
🔬 CBC, Lipid
📊 Status: <b>Reviewed</b>

Your results are available on the patient portal. Tap below or scan your patient ID QR to view. Reply <b>RESULTS</b> for a summary.
🖼️

Imaging Result Ready

Trigger: Imaging reviewed

🖼️ <b>Imaging Result Ready</b>

👤 Patient (BS-2026-001)
📡 Chest X-Ray
📊 Status: <b>Reviewed</b>

Results are on your patient portal. Scan your ID card QR to open.
💳

Billing Notification

Trigger: Invoice issued

💳 <b>Invoice — BS Derma</b>

👤 Patient (BS-2026-001)
🧾 #INV-001
💰 Total: <b>$50</b>
✅ Paid: $0 · ⏳ Balance: $50

Reply <b>PAY</b> to receive payment instructions.
📅

Follow-up Reminder

Trigger: Day before follow-up

📅 <b>Follow-up Reminder</b>

Hi Patient, this is a reminder for your follow-up visit.

📅 2026-07-23 · ⏰ 09:00
🔬 Doctor

See you at BS Derma Clinic. Reply <b>CONFIRM</b> to confirm or <b>RESCHEDULE</b> to change.
📄

Discharge Summary

Trigger: Patient discharged

📄 <b>Discharge Summary — BS Derma</b>

👤 Patient (BS-2026-001)
📅 Discharged: 2026-07-23
🩺 Acne vulgaris
💊 Tretinoin nightly
🔁 Follow-up: 2 weeks

⚠️ Return immediately if symptoms worsen. Scan your ID QR for the full summary.
🔀

Transfer / Referral

Trigger: Patient transferred

🔀 <b>Patient Transfer</b>

👤 Patient (BS-2026-001)
🏥 From: BS Derma
➡️ To: Referral Hosp
📝 Specialized care

Your records have been shared securely with the receiving facility.
🛡️

Consent Request

Trigger: First notification

🛡️ <b>Consent — Telegram Notifications</b>

Hi Patient, BS Derma Clinic would like to send you appointment reminders, lab results, and billing notifications via this Telegram bot.

Reply <b>AGREE</b> to consent, or <b>STOP</b> to decline. You can withdraw consent at any time.

Integration Summary

Bot Token (TELEGRAM_BOT_TOKEN)

••••• set via App Secrets

Bot Username

Not connected — set token & test

Backend Function

telegramBot (send · broadcast · getMe · setWebhook · webhook)

Webhook URL

https://bsderma.app/functions/telegramBot

Webhook Status

Not registered — use Telegram Bot panel → Set Webhook

Patient Status Flow

Active → Pending → Completed → Discharged → Transferred

Linked Entities:InteractionTaskPatientStaffChargeInvoiceLabTestImagingRecordDispenseRecordAppointment
Webhook receives patient /start + replies → routes to registration intake or task board. Staff notifications use the send/broadcast actions with chat IDs stored on Staff & Patient records.

Patient Registration QR Generator — Telegram Onboarding

Bot token not set — QR uses placeholder
Telegram registration QR

Scanning opens @your_bot and sends /start registration

The tag follows /start so you can track which QR a patient scanned.

https://t.me/your_bot?start=registration
How to use: generate a QR tagged for each placement (reception desk, patient ID card, print poster, social campaign), download the PNG, and print it. New patients scan it on their phone → Telegram opens the bot → they tap Register as Patientand self-register; their record appears in the Patient Intake Approval dashboard for staff to approve.

Patient Intake Approval — Web Self-Registrations

Pending: 0Approved: 0

No web-registered patients in this view.

Staff Task Completion Report — Telegram-Linked

Completed

0

Pending

9

Active

0

Staff w/ tasks

2

StaffCompletedActivePendingTotalNotifiedCompletion %
Puy Reaksmey00110 🔔
0%
Unassigned00880 🔔
0%

Recent Prescriptions

Metformin 500mg

វង្ស រដ្ឋា · BS-2026-651

dispensed

Metformin 500mg

វង្ស រដ្ឋា · BS-2026-651

dispensed

Avarin 300mg

ស៊ីម ឆានុន · BS-2026-749

dispensed

NS 100ML

ស៊ីម ឆានុន · BS-2026-749

dispensed

Ceftriaxone

ស៊ីម ឆានុន · BS-2026-749

dispensed

NS 100ML

ស៊ីម ឆានុន · BS-2026-749

dispensed

Avarin 300mg

ស៊ីម ឆានុន · BS-2026-749

dispensed

NS 100ML

ស៊ីម ឆានុន · BS-2026-749

dispensed

Ceftriaxone

ស៊ីម ឆានុន · BS-2026-749

dispensed

សម្រាក II

ស៊ីម ឆានុន · 6aab5c3e12f9741a28570aeb

dispensed

Ceftriaxone

ស៊ីម ឆានុន · BS-2026-749

dispensed

NS 100ML

ស៊ីម ឆានុន · BS-2026-749

dispensed

Avarin 300mg

ស៊ីម ឆានុន · BS-2026-749

dispensed

Avarin 300mg

ស៊ីម ឆានុន · BS-2026-749

dispensed

ceftriaxone injection

ស៊ីម ឆានុន · BS-2026-749

dispensed

Hyoscine injection 20mg

ស៊ីម ឆានុន · BS-2026-749

dispensed

Smecta

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

NS 100ML

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Smecta

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Smecta

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

NS 100ML

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

NS 100ML

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Konimag Suspension 7ml

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Smecta

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

NS 100ML

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Metrolex infusion

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

ceftriaxone injection

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

ceftriaxone injection

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Metrolex infusion

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

NS 100ML

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Smecta

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Omeprazole 20mg

សុន មួយសៀង · BS-2026-739

dispensed

Omeprazole 20mg

ស៊ុន មួយសៀង · BS-2026-739

dispensed

Multivitamin

ម៉ៅ សុខហេង · BS-2026-671

dispensed

Efferalgan Vit C

ម៉ៅ សុខហេង · BS-2026-671

dispensed

NS 1000ML

ម៉ៅ សុខហេង · BS-2026-671

dispensed

perfagon 250ml

ម៉ៅ សុខហេង · BS-2026-671

dispensed

Avarin 300mg

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Trimebutine maleate 200mg

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Metrolex infusion

លីម​​​ សុខសក្កិមុនី · BS-2026-901

dispensed

Recent Billing

No invoices

Membership & Discounts

B

Bronze · 5% off

B2C / walk-in · referral $5 credit

tier
G

Gold · 10% off

Insurance / Partnership · referral $10 credit

tier
P

Platinum · 15% off

CSR subsidized · referral $20 credit

tier