A comprehensive medical imaging management system built with .NET 8, providing DICOM image storage, AI-powered report generation, and user management for medical professionals.
This system serves as a backend for a medical imaging platform that integrates with Orthanc PACS server for DICOM storage and an AI service for automated radiology report generation. It's designed for hospitals, clinics, and medical imaging centers to streamline their radiology workflow.
- JWT-based authentication with role-based access control
- Multi-role support: SuperAdmin, Admin, Doctor, Technician roles
- Secure user management with profile picture uploads
- Password-based authentication with Identity framework
- Orthanc PACS integration for medical image storage
- Complete DICOM hierarchy support: Patients β Studies β Series β Instances
- DICOM file upload (single and bulk upload)
- Image preview generation (PNG, JPEG formats)
- DICOM metadata extraction and tag viewing
- Study viewer data for DICOM viewing applications
- Automated report generation using external AI service
- Background processing with queue-based report generation
- DICOM Structured Reports (SR) creation and storage
- Report status tracking: Pending β InProgress β Generated β Failed
- Findings and impressions extraction from AI responses
- Study assignment to doctors for review
- User CRUD operations with role assignment
- Profile management with picture uploads
- Role management with custom role creation
- User filtering and pagination support
- System statistics and reporting
- Study status monitoring
- Health checks for Orthanc server connectivity
- Comprehensive logging with structured logging
The project follows Clean Architecture principles with clear separation of concerns:
βββ GP_Server.Api/ # API Layer (Controllers, Middleware)
βββ GP_Server.Application/ # Application Layer (Services, DTOs, Interfaces)
βββ GP_Server.Domain/ # Domain Layer (Entities, Business Logic)
βββ GP_Server.Infrastructure/ # Infrastructure Layer (Data Access, External Services)
- OrthancService: Handles all DICOM operations with Orthanc PACS server
- ReportGenerationWorker: Background service for AI report generation
- AuthService: JWT token generation and user authentication
- UserService: User management and role assignment
- StudyService: Study lifecycle and status management
- .NET 8 - Modern C# development platform
- ASP.NET Core - Web API framework
- Entity Framework Core - ORM with PostgreSQL
- PostgreSQL - Primary database
- Orthanc - DICOM PACS server
- JWT Authentication - Secure token-based auth
- Docker - Containerization
- AutoMapper - Object mapping
- FellowOak DICOM - DICOM file processing
- Docker & Docker Compose
- .NET 8 SDK (for local development)
- PostgreSQL (handled by Docker)
- Orthanc PACS Server (handled by Docker)
- AI Report Generation Service (external)
git clone <repository-url>
cd GP/Back-End
Update configuration in Server/src/GP_Server.Api/appsettings.json
:
{
"ConnectionStrings": {
"DefaultConnection": "Host=postgres;Database=GP_Database;Username=postgres;Password=mysecretpassword;Port=5432;"
},
"Jwt": {
"SecretKey": "your-secret-key-here",
"Issuer": "http://localhost:7150",
"ExpirationInHours": 24
},
"Orthanc": {
"BaseUrl": "http://orthanc:8042",
"Username": "orthanc",
"Password": "orthanc"
},
"AI": {
"Endpoint": "http://host.docker.internal:8000/generate_report_dicom"
}
}
# Start all services
docker-compose up --build
# Or run in detached mode
docker-compose up -d --build
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger
- Orthanc Web UI: http://localhost:8042
- PostgreSQL: localhost:5432
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password"
}
# Upload DICOM file
POST /api/orthanc/upload
Content-Type: multipart/form-data
Authorization: Bearer <jwt-token>
# Get all patients
GET /api/orthanc/patients?pageNumber=1&pageSize=20
Authorization: Bearer <jwt-token>
# Get patient studies
GET /api/orthanc/patients/{patientId}/studies
Authorization: Bearer <jwt-token>
# Get study viewer data
GET /api/orthanc/studies/{studyId}/viewer-data
Authorization: Bearer <jwt-token>
# Queue study for report generation
POST /api/orthanc/studies/{studyId}/queue-report
Authorization: Bearer <jwt-token>
# Get all users
GET /api/users?pageNumber=1&pageSize=20
Authorization: Bearer <jwt-token>
# Create user
POST /api/users
Content-Type: application/json
Authorization: Bearer <jwt-token>
{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"password": "SecurePassword123",
"roles": ["doctor-role-id"]
}
- Start PostgreSQL and Orthanc (keep these in Docker):
docker-compose up postgres orthanc -d
-
Update connection strings for local development in
appsettings.Development.json
-
Run the API:
cd Server/src/GP_Server.Api
dotnet run
# Add new migration
cd Server/src/GP_Server.Infrastructure
dotnet ef migrations add MigrationName --startup-project ../GP_Server.Api
# Update database
dotnet ef database update --startup-project ../GP_Server.Api
- DICOM Upload: Medical images uploaded to Orthanc PACS server
- Queue Generation: Study queued for report generation
- Background Processing:
ReportGenerationWorker
processes the queue - AI Analysis: DICOM sent to AI service for analysis
- Report Creation: AI response formatted into medical report
- SR Generation: DICOM Structured Report created and stored
- Status Update: Study status updated to "Generated" or "Failed"
The system expects an AI service at the configured endpoint that accepts:
- Input: DICOM file via multipart/form-data
- Output: JSON response with findings and impressions
Expected AI response format:
{
"generated_report": {
"findings": "Clinical findings text...",
"impression": "Clinical impression text..."
},
"dicom_metadata": {
"patient_id": "12345",
"study_date": "20231201",
"modality": "CT",
"body_part": "CHEST"
}
}
The docker-compose.yml
includes:
- api: Main .NET application (Port 8080)
- postgres: PostgreSQL database (Port 5432)
- orthanc: DICOM PACS server (Ports 8042, 4242)
The system seeds default data on startup:
- SuperAdmin: Full system access
- Admin: Administrative tasks
- Doctor: Medical professional access
- Technician: Technical operations
Check the UserSeeder.cs
for default user accounts.
- JWT token authentication with configurable expiration
- Role-based authorization on all endpoints
- Secure password hashing with Identity framework
- HTTPS support (configurable)
- CORS policy for frontend integration
- File upload validation for DICOM files
Server/
βββ src/
β βββ GP_Server.Api/ # Controllers, Program.cs, appsettings
β βββ GP_Server.Application/ # Services, DTOs, Interfaces, Background Services
β βββ GP_Server.Domain/ # Entities, Domain Logic
β βββ GP_Server.Infrastructure/ # Data Access, Repositories, External Services
βββ docker-compose.yml # Docker services configuration
βββ Dockerfile # Application container
βββ README.md # This file
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This is a medical imaging system. Ensure compliance with healthcare regulations (HIPAA, GDPR, etc.) in your jurisdiction before deploying in production.