4.6 KiB
Project Setup Guide
This guide provides step-by-step instructions to set up, configure, and run the Hospital Management System.
Prerequisites
- PHP: Version 8.0 or higher.
- Database: MariaDB 10.x or MySQL 5.7+.
- Web Server: Apache 2.4+ (with
mod_rewriteenabled). - Composer: (Optional) For dependency management if using third-party packages in the future.
Installation Steps
-
Clone the Repository
git clone <repository_url> cd <project_directory> -
Configure Web Server
- Point your Apache VirtualHost
DocumentRootto the project directory. - Ensure the directory has appropriate permissions (e.g.,
www-datauser). - Enable
.htaccessoverrides if applicable.
- Point your Apache VirtualHost
-
Database Setup
- Create a new MySQL/MariaDB database (e.g.,
hospital_db). - Import the database schema and seed data. You can do this by running the initialization script or importing SQL files:
- Option A (Script): Run
php init_db.phpfrom the command line (ensuredb/config.phpis configured first). - Option B (Manual): Import files from
db/migrations/in chronological order using a tool like phpMyAdmin or CLI.
- Option A (Script): Run
- Create a new MySQL/MariaDB database (e.g.,
-
Configuration Files
- Database: Edit
db/config.phpto match your database credentials:define('DB_HOST', '127.0.0.1'); define('DB_NAME', 'your_db_name'); define('DB_USER', 'your_db_user'); define('DB_PASS', 'your_db_password');
- Database: Edit
Configuration & Environment Variables
The application uses a mix of PHP constants and environment variables for configuration.
Email Configuration (mail/config.php)
The application uses PHPMailer. Configure the following environment variables (in your server config or .env file):
MAIL_TRANSPORT:smtp(default)SMTP_HOST: e.g.,smtp.gmail.comSMTP_PORT: e.g.,587SMTP_SECURE:tlsorsslSMTP_USER: Your email addressSMTP_PASS: Your email password or App PasswordMAIL_FROM: Sender email addressMAIL_FROM_NAME: Sender name (e.g., "Hospital Admin")
AI Integration (ai/config.php)
The system uses an AI proxy for features like "AI Suggestion" in visit forms and the Telegram bot.
- Config File:
ai/config.php - Key Settings:
base_url,project_uuid. - Usage: See
ai/LocalAIApi.php.
Telegram Integration
The system includes a Telegram bot for answering FAQs (api/telegram_webhook.php).
- Create a Bot: Talk to
@BotFatheron Telegram to create a bot and get a Token. - Save Token: Insert the token into the
settingstable in your database:INSERT INTO settings (setting_key, setting_value) VALUES ('telegram_token', 'YOUR_TELEGRAM_BOT_TOKEN'); - Set Webhook: Configure the webhook URL for your bot:
https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook?url=https://<YOUR_DOMAIN>/api/telegram_webhook.php
Integrations & Libraries
Frontend (CDN)
The project relies on the following CDN-hosted libraries. Ensure you have an active internet connection.
- Framework: Bootstrap 5.3.0
- Icons: Bootstrap Icons 1.10.5
- Fonts: Google Fonts (Inter, Tajawal)
- Forms:
- Select2 4.1.0 (with Bootstrap 5 theme)
- Summernote Lite 0.8.18 (Rich Text Editor)
- Flatpickr (Date/Time picker)
- Inputmask 5.0.7 (Input formatting)
- Utilities:
- jQuery 3.6.0
- Ui-Avatars (User avatars)
- JsBarcode 3.11.5 (Patient labels)
Backend Services
- Email:
mail/MailService.php(Wraps PHPMailer). - AI:
ai/LocalAIApi.php(Handles OpenAI requests via proxy). - Reporting:
includes/SimpleXLSX.php(Excel export support).
Default Credentials
If you used the provided migration scripts (20260321_create_auth_system.sql), the default administrator account is:
- Email:
admin@hospital.com - Password:
admin123 - Role: Administrator
Note: Change this password immediately after logging in.
Troubleshooting
- Database Connection Error: Check
db/config.phpcredentials. Ensure the database server is running. - Email Not Sending: Verify SMTP settings in
mail/config.phpor environment variables. Check server logs for connection timeouts. - AI Features Not Working: Ensure the server can reach the AI proxy endpoint defined in
ai/config.php. - Telegram Bot Not Responding: Verify the
telegram_tokenin thesettingstable and ensure the webhook URL is accessible from the public internet (HTTPS required).