HIS Middleware Connector

Buktor Middleware User Documentation

1. Introduction

Buktor Middleware enables seamless integration between Buktor and Hospital Information Systems (HIS). It acts as an intermediary to:

  • Receive events from Buktor
  • Store them locally in SQLite
  • Sync data into HIS databases (MySQL, SQL Server, Oracle)

2. Downloading and Installing

2.1 System Requirements

  • Windows 10/11 or Linux Server
  • HIS Database: MySQL / SQL Server / Oracle
  • Buktor Middleware EXE (Download from Buktor Portal)

2.2 Download Buktor Middleware

  1. Visit the Buktor Portal and download:
    • buktor-middleware.exe (Windows) / buktor-middleware (Linux)
    • his-config.json (Configuration file)
  2. Place both files in the desired folder on the HIS server.

2.3 Extract & Install

Windows

buktor-middleware.exe

Linux

chmod +x buktor-middleware
./buktor-middleware

Middleware is now running on http://127.0.0.1:5000


3. Configuring Database and Mapping Fields

Instead of modifying Python code, all configurations are stored in his-config.json.

3.1 Database Configuration

Example his-config.json for MySQL:

{
  "database": {
    "type": "mysql",
    "host": "your-mysql-host",
    "user": "your-user",
    "password": "your-password",
    "database": "his_database"
  }
}

Example his-config.json for SQL Server:

{
  "database": {
    "type": "sqlserver",
    "host": "your-sqlserver-host",
    "user": "your-user",
    "password": "your-password",
    "database": "his_database"
  }
}

Example his-config.json for Oracle:

{
  "database": {
    "type": "oracle",
    "host": "your-oracle-host",
    "user": "your-user",
    "password": "your-password",
    "database": "his_database"
  }
}

3.2 Mapping Events, Fields, and Tables

The his-config.json file defines how incoming Buktor events map to HIS tables and fields.

Example Event Mapping Configuration

{
  "mapping": {
    "appointment": {
      "table": "HIS_appointments",
      "fields": {
        "appointment_id": "HIS_appointment_id",
        "status": "HIS_status",
        "received_at": "HIS_created_at"
      }
    },
    "schedule_change": {
      "table": "HIS_schedules",
      "fields": {
        "schedule_id": "HIS_schedule_id",
        "new_time": "HIS_new_time",
        "updated_at": "HIS_updated_at"
      }
    },
    "payment": {
      "table": "HIS_payments",
      "fields": {
        "payment_id": "HIS_payment_id",
        "amount": "HIS_amount",
        "status": "HIS_payment_status",
        "paid_at": "HIS_paid_at"
      }
    }
  }
}

Ensure that this mapping aligns correctly with the HIS database schema.


4. Testing with Sample cURL Commands

4.1 Sending an Appointment Event

curl -X POST "http://127.0.0.1:5000/receive-event" \
     -H "Content-Type: application/json" \
     -d '{"event_type": "appointment", "appointment_id": 123, "status": "confirmed"}'

4.2 Sending a Schedule Change Event

curl -X POST "http://127.0.0.1:5000/receive-event" \
     -H "Content-Type: application/json" \
     -d '{"event_type": "schedule_change", "schedule_id": 456, "new_time": "2025-03-03T09:00:00"}'

4.3 Sending a Payment Event

curl -X POST "http://127.0.0.1:5000/receive-event" \
     -H "Content-Type: application/json" \
     -d '{"event_type": "payment", "payment_id": 789, "amount": "1500", "status": "paid", "paid_at": "2025-03-02T11:00:00"}'

5. Loading Middleware on System Startup

Windows (Task Scheduler)

schtasks /create /tn "Buktor Middleware" /tr "C:\path\to\buktor-middleware.exe" /sc onstart /ru SYSTEM

Linux (Systemd Service)

sudo nano /etc/systemd/system/buktor-middleware.service

Paste the following:

[Unit]
Description=Buktor Middleware Service
After=network.target
 
[Service]
ExecStart=/path/to/buktor-middleware
Restart=always
User=root
 
[Install]
WantedBy=multi-user.target

Save and exit, then enable and start the service:

sudo systemctl enable buktor-middleware
sudo systemctl start buktor-middleware

Middleware will now start automatically on boot.


6. Exposing Middleware to Public URL

6.1 Using Ngrok

ngrok http 5000

Copy the public URL and use it as the webhook endpoint in Buktor.

6.2 Using Nginx as a Reverse Proxy

sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/buktor

Paste the following:

server {
    listen 80;
    server_name your-public-domain.com;
    location / {
        proxy_pass http://127.0.0.1:5000;
    }
}

Save and exit, then enable and restart Nginx:

sudo ln -s /etc/nginx/sites-available/buktor /etc/nginx/sites-enabled/
sudo systemctl restart nginx

6.3 Using Dynamic DNS (DynDNS)

Step 1: Register a DynDNS Account

  1. Go to https://www.dynu.com/ (opens in a new tab) or another Dynamic DNS provider.
  2. Create an account and add a new hostname (e.g., your-buktor.dynu.net).
  3. Point the hostname to your public IP.

Step 2: Install DynDNS Updater

sudo apt install ddclient
sudo nano /etc/ddclient.conf

Add:

protocol=dyndns2
server=api.dynu.com
login=your-dyn-dns-username
password=your-dyn-dns-password
your-buktor.dynu.net

Save and restart:

sudo systemctl restart ddclient

Your middleware is now accessible via http://your-buktor.dynu.net.


7. Support & Contact

For support, contact Buktor Technical Team: 📧 support@buktor.com
🌐 www.buktor.com/support (opens in a new tab)