Skip to content

areeb234/Token-Management-System

Repository files navigation

Token Management System

Description

This application is used to track/direct patients coming into PMC. It generates tokens for each patient and depending on if they have an appointment or are walk-ins, their token will come up on the reception's screen based on the patient's priority. Appointment patients are prioritized, whilst walk-in patients can be called if the receptionist wishes to do so. The interface looks different for the receptionists, nurses, and doctors.

Table of Contents

Features

  • Token Generation: Automatically generates tokens for patients (starting from 1001)
  • Priority Queue Management: Prioritizes appointment patients over walk-ins
  • Multi-Interface Support: Separate views for receptionists, nurses, and doctors
  • Audio Announcements: Text-to-speech support for calling patients
  • Counter Management: Multiple counter stations for different service areas
  • Real-time Updates: Live token status updates across all interfaces
  • QR Code Integration: Generates QR codes for patient tokens

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js v16.0 or higher (for Counter applications)
  • Python 3.11 or higher (for server)
  • Docker Desktop (for containerized server deployment)
  • PostgreSQL database access (or running instance)
  • Network Access: Must be on clinic network to access database at 172.16.0.99:5432

Installation

  1. Fork and then clone the repository:
   git clone https://github.com/[your-username]/Token-Management-System
   cd Token-Management-System
  1. Option A: Running Server with Docker (Recommended)

    Build the Docker image:

   docker build -t token-server .
  1. Option B: Running Server Locally

    Create a virtual environment and install Python dependencies:

   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
   pip install -r requirements.txt
  1. Install Counter Application Dependencies

    For each counter you want to run:

   cd Counter1
   npm install
   cd ..

Repeat for Nursing counter if needed:

   cd Nursing
   npm install
   cd ..

Configuration

  1. Server Configuration

    Edit server/config.ini with your database connection details:

   [postgres]
   host = 172.16.0.99  # Your database host
   port = 5432
   
   [qms]
   token_start = 1001
   
   [printer]
   name =  # Your printer name (Windows only)
   
   [audio]
   use_tts = true  # Enable/disable text-to-speech
  1. Counter Configuration

    Each counter can be configured using Config.json in %APPDATA% (the application will guide you through this on first run).

Usage

The Token Management System consists of two main components:

  1. Server: Backend that manages token queue, database, and API
  2. Counter Applications: Frontend Electron apps for receptionists, nurses, and doctors

Workflow

  1. Start the server (backend)
  2. Launch counter applications as needed
  3. Receptionist generates tokens for patients
  4. Tokens appear on appropriate screens based on priority
  5. Staff can call next patient using the counter interface

Running the Application

Step 1: Start the Server

Using Docker (Recommended):

docker run -p 8032:8032 token-server

Or run locally:

cd server
python server5.py

The server will be available at http://localhost:8032

Step 2: Launch Counter Applications

Open a new terminal for each counter you want to run:

Counter 1 (Reception):

cd Counter1
npm start

Nursing Counter:

cd Nursing
npm start

The counter applications will automatically connect to the server at localhost:8032.

Step 3: Access Web Interface

Open your browser and navigate to:

http://localhost:8032/static/index.html

Project Structure

Token-Management-System/
├── app/                    # Main application GUI components
│   ├── app.py             # Main application entry point
│   ├── audio.py           # Audio/TTS handling
│   ├── printing.py        # Token printing functionality
│   └── audios/            # Audio files for counter announcements
├── Counter1/              # Reception counter Electron app
│   ├── main.js           # Electron main process
│   ├── preload.js        # Preload script
│   └── renderer/         # Frontend HTML/CSS/JS
├── Nursing/               # Nursing counter Electron app
│   └── [similar structure to Counter1]
├── server/                # Backend server
│   ├── server5.py        # FastAPI server
│   ├── db.py             # Database operations
│   ├── config.ini        # Server configuration
│   ├── discovery.py      # Network discovery
│   ├── static/           # Static web files
│   └── web/              # Web interface templates
├── Dockerfile             # Docker configuration for server
├── .dockerignore          # Docker ignore file
├── requirements.txt       # All Python dependencies
├── requirements-server.txt # Server-only Python dependencies (for Docker)
└── README.md

Technologies Used

  • Frontend (Counter Apps):

    • Electron - Desktop application framework
    • HTML/CSS/JavaScript - UI implementation
  • Backend (Server):

    • Python 3.11 - Core language
    • FastAPI - Modern web framework for APIs
    • Uvicorn - ASGI server
    • psycopg - PostgreSQL adapter
  • Database:

    • PostgreSQL - Patient and token data storage
  • Additional Libraries:

    • Pillow - Image processing for QR codes
    • qrcode - QR code generation
    • PyQt5 - GUI framework (for local app components)
  • DevOps:

    • Docker - Containerization for cross-platform deployment

Troubleshooting

Common Issues

Issue 1: Docker build fails with PyQt5 errors

Solution: Use requirements-server.txt which excludes GUI dependencies:
docker build -t token-server .
(The Dockerfile is already configured to use requirements-server.txt)

Issue 2: Server can't connect to database

Error: psycopg.OperationalError: connection failed

Solution: 
1. Ensure you're on the clinic network
2. Verify database credentials in server/config.ini
3. Check that PostgreSQL is running at the configured host
4. Ping the database host: ping 172.16.0.99

Issue 3: Counter app won't start

Error: npm ERR! Missing script

Solution:
Use 'npm start' instead of 'npm run dev'
Check available scripts with: npm run

Issue 4: "Directory 'static' does not exist" error

Solution: The Dockerfile sets the working directory correctly.
If you see this error, rebuild the image:
docker build -t token-server .

Issue 5: Port 8032 already in use

Solution:
1. Stop the existing Docker container: docker ps, then docker stop [container-id]
2. Or use a different port: docker run -p 8033:8032 token-server

Issue 6: Changes to config.ini not reflected

Solution: Rebuild the Docker image after changing config.ini:
docker build -t token-server .
docker run -p 8032:8032 token-server

Cross-Platform Notes

  • Windows: All components work natively
  • macOS:
    • Server runs best in Docker (avoids Windows-specific dependencies)
    • Counter apps run natively with Node.js/npm
    • pywin32 dependency is excluded in Docker setup
  • Linux: Similar to macOS setup

Contributing

Please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature-name)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some feature')
  5. Push to the branch (git push origin feature/your-feature-name)
  6. Open a Pull Request

Contact

Project Link: https://github.com/areeb234/Token-Management-System

For issues or questions, please open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •