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.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Running the Application
- Project Structure
- Technologies Used
- Troubleshooting
- Contributing
- Contact
- 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
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
- Fork and then clone the repository:
git clone https://github.com/[your-username]/Token-Management-System
cd Token-Management-System-
Option A: Running Server with Docker (Recommended)
Build the Docker image:
docker build -t token-server .-
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-
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 ..-
Server Configuration
Edit
server/config.iniwith 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-
Counter Configuration
Each counter can be configured using
Config.jsonin%APPDATA%(the application will guide you through this on first run).
The Token Management System consists of two main components:
- Server: Backend that manages token queue, database, and API
- Counter Applications: Frontend Electron apps for receptionists, nurses, and doctors
- Start the server (backend)
- Launch counter applications as needed
- Receptionist generates tokens for patients
- Tokens appear on appropriate screens based on priority
- Staff can call next patient using the counter interface
Using Docker (Recommended):
docker run -p 8032:8032 token-serverOr run locally:
cd server
python server5.pyThe server will be available at http://localhost:8032
Open a new terminal for each counter you want to run:
Counter 1 (Reception):
cd Counter1
npm startNursing Counter:
cd Nursing
npm startThe counter applications will automatically connect to the server at localhost:8032.
Open your browser and navigate to:
http://localhost:8032/static/index.html
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
-
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
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
- 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
Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name) - Make your changes
- Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature-name) - Open a Pull Request
Project Link: https://github.com/areeb234/Token-Management-System
For issues or questions, please open an issue on GitHub.