- Introduced the GNU General Public License v3.0 to ensure the software remains free and open source. - Updated README.md to reflect the new licensing terms and added a section explaining the implications of the GPL-3.0 license. - Included a brief description of the project's purpose as a test for AI-assisted software development.
96 lines
2.9 KiB
Markdown
96 lines
2.9 KiB
Markdown
# Hospital API
|
|
|
|
A Rust-based API service that manages and provides information about hospitals on duty in Luxembourg City.
|
|
|
|
## Overview
|
|
|
|
This API service tracks which hospital is currently on duty in Luxembourg City and provides endpoints to access this information. The system automatically manages hospital shifts and ensures there's always a hospital assigned for emergency services.
|
|
|
|
This project was developed as a test project for exploring AI-assisted software development. It demonstrates how AI can be used to create, modify, and maintain a real-world application.
|
|
|
|
## Features
|
|
|
|
- **Automatic Shift Management**: Creates and manages hospital shifts automatically
|
|
- **Real-time Hospital Information**: Provides current on-duty hospital information via API
|
|
- **Periodic Checks**: Regularly verifies and updates future shifts
|
|
- **Timestamped Logging**: All system events are logged with timestamps for better tracking
|
|
|
|
## API Endpoints
|
|
|
|
### Root Endpoint
|
|
- **URL**: `/`
|
|
- **Method**: `GET`
|
|
- **Description**: Returns basic API information
|
|
- **Response Example**:
|
|
```json
|
|
{
|
|
"name": "HospitalAPI",
|
|
"version": "0.1",
|
|
"description": "This API provides you with the current hospital on duty in luxembourg city. Call the /getHospital endpoint."
|
|
}
|
|
```
|
|
|
|
### Current Hospital Endpoint
|
|
- **URL**: `/current-hospital`
|
|
- **Method**: `GET`
|
|
- **Description**: Returns information about the hospital currently on duty
|
|
- **Response Example**:
|
|
```json
|
|
{
|
|
"success": true,
|
|
"hospital": {
|
|
"id": 1,
|
|
"name": "Centre Hospitalier",
|
|
"start_time": "2023-04-15T08:00:00Z",
|
|
"end_time": "2023-04-16T08:00:00Z"
|
|
},
|
|
"message": "Current hospital retrieved successfully"
|
|
}
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The application uses environment variables for configuration. Create a `.env` file in the project root with the following variables:
|
|
|
|
```
|
|
DATABASE_URL=postgres://username:password@localhost/hospitaldb
|
|
HOST=127.0.0.1
|
|
PORT=3000
|
|
```
|
|
|
|
## Database Schema
|
|
|
|
The application uses a PostgreSQL database with the following main tables:
|
|
|
|
- **hospitals**: Stores information about hospitals
|
|
- **shifts**: Stores hospital shift information
|
|
|
|
## Background Tasks
|
|
|
|
The application runs two background tasks:
|
|
|
|
1. **Future Shifts Check**: Runs every 48 hours to ensure future shifts are created
|
|
2. **Current Hospital Monitor**: Runs every minute to log the current on-duty hospital
|
|
|
|
## Logging
|
|
|
|
All system events are logged with timestamps in the format:
|
|
```
|
|
[YYYY-MM-DD HH:MM:SS] Message
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). This license ensures that:
|
|
|
|
- The software remains free and open source
|
|
- Any modifications or improvements must be shared back with the community
|
|
- The source code must be made available to users
|
|
- The license terms must be preserved in any derivative works
|
|
|
|
For the full license text, see the [LICENSE](LICENSE) file.
|
|
|
|
## Contributing
|
|
|
|
Contributions are welcome! Please feel free to submit a Pull Request.
|