Skip to content

Commit fd36abe

Browse files
First Commit
0 parents  commit fd36abe

36 files changed

+2803
-0
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SECRET_KEY=your-secret-key
2+
SMTP_SERVER=your-smtp-server
3+
SMTP_PORT=587
4+
SMTP_USERNAME=your-smtp-username
5+
SMTP_PASSWORD=your-smtp-password
6+
EMAIL_FROM=noreply@yourdomain.com

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
client/
2+
.env
3+

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1 \
7+
PYTHONPATH=/app
8+
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends gcc \
11+
&& apt-get clean \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY requirements.txt .
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
17+
COPY . .
18+
19+
CMD ["uvicorn", "app.main:app","--reload" ,"--host", "0.0.0.0", "--port", "8000"]

Dockerfile.notification

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
COPY requirements.notification.txt .
9+
RUN pip install --no-cache-dir -r requirements.notification.txt
10+
11+
COPY notification_service.py .
12+
13+
CMD ["python", "notification_service.py"]

README.md

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# Healthcare Appointment Scheduling System
2+
3+
A robust, secure backend service that efficiently manages patient data and enables seamless appointment scheduling with healthcare providers.
4+
5+
## Features
6+
7+
- **Patient Management**: Register and manage patient profiles, store basic patient information and contact details, track patient identification and insurance information.
8+
- **Doctor Management**: Maintain doctor profiles with specializations and manage doctor availability schedules.
9+
- **Appointment Scheduling**: Create appointments between patients and doctors, check doctor availability when scheduling, prevent scheduling conflicts and double-bookings, and manage appointment status changes.
10+
- **Medical Records**: Store medical records for patients, link records to specific appointments, and implement appropriate access controls for sensitive information.
11+
12+
## Technical Stack
13+
14+
- **Backend**: FastAPI (Python)
15+
- **Database**: PostgreSQL
16+
- **Documentation**: Swagger/OpenAPI
17+
- **Message Queue**: RabbitMQ
18+
- **Caching & Rate Limiting**: Redis
19+
20+
## Architecture
21+
22+
The system follows a microservices architecture with the following components:
23+
24+
1. **API Gateway**: Main FastAPI application that handles HTTP requests
25+
2. **Authentication Service**: Handles user authentication and authorization
26+
3. **Patient Service**: Manages patient data
27+
4. **Doctor Service**: Manages doctor data and availability
28+
5. **Appointment Service**: Handles appointment scheduling and conflict prevention
29+
6. **Notification Service**: Sends notifications about appointments
30+
31+
## Project Structure
32+
33+
\`\`\`
34+
healthcare-appointment-system/
35+
├── app/ # Main application package
36+
│ ├── api/ # API endpoints
37+
│ │ ├── deps.py # Dependency injection
38+
│ │ └── routes/ # API route handlers
39+
│ ├── core/ # Core functionality
40+
│ │ ├── config.py # Configuration settings
41+
│ │ ├── security.py # Security utilities
42+
│ │ ├── notifications.py # Notification handling
43+
│ │ ├── rate_limiter.py # Rate limiting middleware
44+
│ │ └── cache.py # Caching middleware
45+
│ ├── crud/ # Database CRUD operations
46+
│ ├── db/ # Database models and session
47+
│ │ ├── models.py # SQLAlchemy models
48+
│ │ └── session.py # Database session
49+
│ ├── schemas/ # Pydantic schemas
50+
│ ├── tests/ # Unit and integration tests
51+
│ └── main.py # Application entry point
52+
├── Dockerfile # Main service Dockerfile
53+
├── Dockerfile.notification # Notification service Dockerfile
54+
├── docker-compose.yml # Docker Compose configuration
55+
├── requirements.txt # Main service dependencies
56+
├── requirements.notification.txt # Notification service dependencies
57+
├── notification_service.py # Standalone notification service
58+
└── README.md # Project documentation
59+
\`\`\`
60+
61+
## Getting Started
62+
63+
### Prerequisites
64+
65+
- Docker and Docker Compose
66+
- Python 3.11+
67+
68+
### Installation
69+
70+
1. Clone the repository:
71+
\`\`\`
72+
git clone https://github.com/yourusername/healthcare-appointment-system.git
73+
cd healthcare-appointment-system
74+
\`\`\`
75+
76+
2. Create a `.env` file with the following variables:
77+
\`\`\`
78+
SECRET_KEY=your-secret-key
79+
SMTP_SERVER=your-smtp-server
80+
SMTP_PORT=587
81+
SMTP_USERNAME=your-smtp-username
82+
SMTP_PASSWORD=your-smtp-password
83+
EMAIL_FROM=noreply@yourdomain.com
84+
\`\`\`
85+
86+
3. Start the services using Docker Compose:
87+
\`\`\`
88+
docker-compose up -d
89+
\`\`\`
90+
91+
4. The API will be available at http://localhost:8000
92+
93+
### Running Tests
94+
95+
\`\`\`
96+
pytest
97+
\`\`\`
98+
99+
## API Documentation
100+
101+
Once the application is running, you can access the API documentation at:
102+
103+
- Swagger UI: http://localhost:8000/docs
104+
- ReDoc: http://localhost:8000/redoc
105+
106+
## API Endpoints
107+
108+
### Authentication
109+
- `POST /api/auth/login` - Obtain JWT token
110+
- `POST /api/auth/register` - Register a new user
111+
- `GET /api/auth/me` - Get current user information
112+
113+
### Patients
114+
- `GET /api/patients/` - List all patients
115+
- `POST /api/patients/` - Create a new patient
116+
- `GET /api/patients/{id}` - Get patient details
117+
- `PUT /api/patients/{id}` - Update patient information
118+
- `DELETE /api/patients/{id}` - Delete a patient
119+
- `GET /api/patients/search/` - Search for patients
120+
121+
### Doctors
122+
- `GET /api/doctors/` - List all doctors
123+
- `POST /api/doctors/` - Create a new doctor
124+
- `GET /api/doctors/{id}` - Get doctor details with availability
125+
- `PUT /api/doctors/{id}` - Update doctor information
126+
- `DELETE /api/doctors/{id}` - Delete a doctor
127+
- `POST /api/doctors/{id}/availability` - Add availability for a doctor
128+
- `GET /api/doctors/specialization/{specialization}` - Get doctors by specialization
129+
130+
### Appointments
131+
- `GET /api/appointments/` - List appointments (filtered by user role)
132+
- `POST /api/appointments/` - Create a new appointment
133+
- `GET /api/appointments/{id}` - Get appointment details
134+
- `PUT /api/appointments/{id}` - Update an appointment
135+
- `DELETE /api/appointments/{id}` - Delete an appointment
136+
- `PUT /api/appointments/{id}/status` - Update appointment status
137+
- `GET /api/appointments/doctor/{doctor_id}/available-slots` - Get available slots for a doctor
138+
139+
## Database Schema
140+
141+
The system uses the following database schema:
142+
143+
- **patients**: Stores patient information
144+
- **doctors**: Stores doctor information
145+
- **availabilities**: Stores doctor availability schedules
146+
- **appointments**: Stores appointment information
147+
- **medical_records**: Stores patient medical records
148+
- **users**: Stores user authentication information
149+
150+
## Security
151+
152+
The system implements the following security measures:
153+
154+
- JWT-based authentication
155+
- Role-based access control
156+
- Password hashing
157+
- HTTPS support
158+
- Rate limiting
159+
- Input validation
160+
161+
## Performance Optimizations
162+
163+
- Redis caching for frequently accessed data
164+
- Asynchronous processing with RabbitMQ
165+
- Database query optimization
166+
- Connection pooling
167+
168+
## Deployment
169+
170+
### Local Development
171+
Follow the installation instructions above to deploy the system locally using Docker Compose.
172+
173+
### Production Deployment
174+
175+
For production deployment, consider the following additional steps:
176+
177+
1. Use a production-grade PostgreSQL setup with proper backups
178+
2. Configure HTTPS with a valid SSL certificate
179+
3. Set up monitoring and logging (e.g., Prometheus, Grafana, ELK stack)
180+
4. Use a reverse proxy like Nginx in front of the application
181+
5. Implement proper secrets management
182+
183+
Example production docker-compose.yml adjustments:
184+
185+
\`\`\`yaml
186+
version: '3.8'
187+
188+
services:
189+
app:
190+
build: .
191+
restart: always
192+
environment:
193+
- DATABASE_URL=postgresql://user:password@db:5432/healthcare
194+
- REDIS_URL=redis://redis:6379/0
195+
- RABBITMQ_URL=amqp://user:password@rabbitmq:5672/
196+
- SECRET_KEY=${SECRET_KEY}
197+
deploy:
198+
replicas: 3
199+
resources:
200+
limits:
201+
cpus: '0.5'
202+
memory: 512M
203+
204+
db:
205+
image: postgres:15
206+
volumes:
207+
- postgres_data:/var/lib/postgresql/data/
208+
environment:
209+
- POSTGRES_USER=${DB_USER}
210+
- POSTGRES_PASSWORD=${DB_PASSWORD}
211+
- POSTGRES_DB=healthcare
212+
deploy:
213+
resources:
214+
limits:
215+
cpus: '1'
216+
memory: 1G
217+
218+
# Other services with similar production configurations
219+
\`\`\`
220+
221+
## Troubleshooting
222+
223+
### Common Issues
224+
225+
1. **Database Connection Errors**
226+
- Check if PostgreSQL is running: `docker-compose ps`
227+
- Verify database credentials in environment variables
228+
- Check network connectivity between services
229+
230+
2. **Authentication Issues**
231+
- Ensure SECRET_KEY is properly set
232+
- Check token expiration time
233+
- Verify user credentials
234+
235+
3. **Performance Issues**
236+
- Check Redis connection for caching
237+
- Monitor database query performance
238+
- Check RabbitMQ queue sizes
239+
240+
### Logs
241+
242+
To view logs for troubleshooting:
243+
244+
\`\`\`bash
245+
# View logs for all services
246+
docker-compose logs
247+
248+
# View logs for a specific service
249+
docker-compose logs app
250+
251+
# Follow logs in real-time
252+
docker-compose logs -f app
253+
\`\`\`
254+
255+
## Contributing
256+
257+
We welcome contributions to improve the Healthcare Appointment Scheduling System!
258+
259+
### Development Workflow
260+
261+
1. Fork the repository
262+
2. Create a feature branch: `git checkout -b feature/your-feature-name`
263+
3. Make your changes
264+
4. Run tests: `pytest`
265+
5. Commit your changes: `git commit -m "Add some feature"`
266+
6. Push to the branch: `git push origin feature/your-feature-name`
267+
7. Submit a pull request
268+
269+
### Coding Standards
270+
271+
- Follow PEP 8 style guide for Python code
272+
- Write docstrings for all functions, classes, and modules
273+
- Include unit tests for new features
274+
- Update documentation as needed
275+
276+
## Future Enhancements
277+
278+
- **Mobile Application**: Develop a mobile app for patients to schedule appointments
279+
- **Telemedicine Integration**: Add support for virtual appointments
280+
- **Analytics Dashboard**: Implement reporting and analytics features
281+
- **Multi-language Support**: Add internationalization for multiple languages
282+
- **Payment Processing**: Integrate payment gateway for online payments
283+
- **AI-based Scheduling**: Implement intelligent scheduling recommendations
284+
285+
## License
286+
287+
This project is licensed under the MIT License - see the LICENSE file for details.
288+

0 commit comments

Comments
 (0)