52 if (!
pacs_->start()) {
53 std::cerr <<
"Failed to start Mini PACS\n";
65 }
catch (
const std::exception& e) {
66 std::cerr <<
"Failed to start Production PACS: " << e.what() <<
"\n";
139 auto hours = std::chrono::duration_cast<std::chrono::hours>(uptime);
140 auto minutes = std::chrono::duration_cast<std::chrono::minutes>(uptime) % 60;
141 auto seconds = uptime.count() % 60;
143 std::ostringstream uptime_str;
144 uptime_str << hours.count() <<
"h " << minutes.count() <<
"m " << seconds <<
"s";
147 std::cout <<
"╔══════════════════════════════════════════════════════════════════╗\n";
148 std::cout <<
"║ Production PACS Server Status ║\n";
149 std::cout <<
"╠══════════════════════════════════════════════════════════════════╣\n";
150 std::cout <<
"║ Server: ║\n";
151 std::cout <<
"║ AE Title: " << std::setw(48) << std::left
153 std::cout <<
"║ DICOM Port: " << std::setw(48) << std::left
155 std::cout <<
"║ TLS: " << std::setw(48) << std::left
157 std::cout <<
"╠══════════════════════════════════════════════════════════════════╣\n";
158 std::cout <<
"║ REST API: ║\n";
159 std::cout <<
"║ Status: " << std::setw(48) << std::left
162 std::cout <<
"║ Port: " << std::setw(48) << std::left
165 std::cout <<
"╠══════════════════════════════════════════════════════════════════╣\n";
166 std::cout <<
"║ Security: ║\n";
167 std::cout <<
"║ RBAC: " << std::setw(48) << std::left
169 std::cout <<
"║ Auto-Anon: " << std::setw(48) << std::left
172 std::cout <<
"╠══════════════════════════════════════════════════════════════════╣\n";
173 std::cout <<
"║ Statistics: ║\n";
174 std::cout <<
"║ Uptime: " << std::setw(48) << std::left
175 << uptime_str.str() <<
"║\n";
176 std::cout <<
"║ Images: " << std::setw(48) << std::left
178 std::cout <<
"║ Queries: " << std::setw(48) << std::left
180 std::cout <<
"║ Associations:" << std::setw(48) << std::left
182 std::cout <<
"╚══════════════════════════════════════════════════════════════════╝\n\n";
197 std::ofstream file(path);
198 if (!file.is_open()) {
199 std::cerr <<
"Failed to open statistics file: " << path <<
"\n";
206 file <<
" \"uptime_seconds\": " << uptime.count() <<
",\n";
213 file <<
" \"server\": {\n";
218 file <<
" \"rest_api\": {\n";
243 pacs_ = std::make_unique<mini_pacs>(pacs_config);
251 access_control_ = std::make_shared<security::access_control_manager>();
265 anonymizer_ = std::make_unique<security::anonymizer>(
279 rest_server_ = std::make_unique<web::rest_server>(rest_config);
301 health_checker_ = std::make_shared<monitoring::health_checker>(health_config);
306 metrics_ = std::make_shared<monitoring::pacs_metrics>();
325 }
catch (
const std::exception& e) {
326 std::cerr <<
"Error in image received handler: " << e.what() <<
"\n";
336 }
catch (
const std::exception& e) {
337 std::cerr <<
"Error in query executed handler: " << e.what() <<
"\n";
347 }
catch (
const std::exception& e) {
348 std::cerr <<
"Error in association event handler: " << e.what() <<
"\n";
359 }
catch (
const std::exception& e) {
360 std::cerr <<
"Error in access denied handler: " << e.what() <<
"\n";
bool is_running() const noexcept
Check if server is running.
void setup_anonymization()
void dispatch_image_received(const events::image_received_event &event)
void dispatch_query_executed(const events::query_executed_event &event)
std::atomic< bool > running_
void setup_event_handlers()
production_statistics stats_
std::mutex handlers_mutex_
void on_access_denied(std::function< void(const events::access_denied_event &)> handler)
Register handler for access denied events.
production_pacs(const production_config &config)
Construct Production PACS with configuration.
std::unique_ptr< web::rest_server > rest_server_
std::shared_ptr< monitoring::pacs_metrics > metrics_
void print_status() const
Print server status to stdout.
~production_pacs()
Destructor - ensures clean shutdown.
void dispatch_access_denied(const events::access_denied_event &event)
std::shared_ptr< monitoring::health_checker > health_checker_
void on_query_executed(std::function< void(const events::query_executed_event &)> handler)
Register handler for query executed events.
void dispatch_association_event(const events::association_event &event)
void wait()
Block until server shutdown.
std::condition_variable shutdown_cv_
const production_statistics & statistics() const noexcept
Get current statistics.
std::vector< std::function< void(const events::query_executed_event &)> > query_handlers_
std::vector< std::function< void(const events::association_event &)> > association_handlers_
void on_association_event(std::function< void(const events::association_event &)> handler)
Register handler for association events.
std::unique_ptr< mini_pacs > pacs_
production_config config_
const production_config & config() const noexcept
Get the configuration.
bool start()
Start the production PACS server.
void on_image_received(std::function< void(const events::image_received_event &)> handler)
Register handler for image received events.
std::mutex shutdown_mutex_
std::vector< std::function< void(const events::image_received_event &)> > image_handlers_
std::vector< std::function< void(const events::access_denied_event &)> > access_denied_handlers_
void stop()
Stop the production PACS server.
std::unique_ptr< security::anonymizer > anonymizer_
monitoring::health_status get_health() const
Get health status.
void export_statistics(const std::filesystem::path &path) const
Export statistics to JSON file.
std::shared_ptr< security::access_control_manager > access_control_
Console output utilities for developer samples.
Production-grade PACS with enterprise features.
Configuration for REST API server.
Configuration options for the health checker.
std::chrono::seconds cache_duration
Cache health check results for this duration.
std::chrono::seconds check_interval
Interval between automatic health checks.
double storage_critical_threshold
Storage usage threshold for unhealthy status (percentage)
double storage_warning_threshold
Storage usage threshold for degraded status (percentage)
Comprehensive health status of the PACS system.
bool enabled
Enable access control enforcement.
security::anonymization_profile profile
Anonymization profile to use.
bool auto_anonymize
Automatically anonymize incoming images.
Event fired when access is denied.
Event fired for association lifecycle events.
Event fired when an image is received and stored.
Event fired when a query is executed.
std::string level
Log level: "debug", "info", "warn", "error".
Configuration options for Mini PACS.
uint16_t port
TCP port to listen on.
std::string ae_title
Application Entity title (max 16 characters)
bool verbose_logging
Enable verbose logging.
bool enable_mpps
Enable MPPS service.
std::filesystem::path storage_path
Root path for DICOM file storage.
size_t max_associations
Maximum concurrent associations.
bool enable_worklist
Enable Modality Worklist service.
std::chrono::seconds health_check_interval
Interval between health checks (seconds)
bool metrics_enabled
Enable Prometheus-style metrics endpoint.
Complete production PACS configuration.
monitoring_config monitoring
Monitoring settings.
logging_config logging
Logging settings.
storage_config storage
Storage settings.
rest_api_config rest_api
REST API settings.
security_config security
Security settings.
server_config server
DICOM server settings.
Extended statistics for production PACS.
std::atomic< std::uint64_t > images_stored
Total images stored.
std::atomic< std::uint64_t > images_anonymized
Total images anonymized.
std::atomic< std::uint64_t > rest_requests
Total REST API requests.
std::chrono::system_clock::time_point start_time
Server uptime start.
std::atomic< std::uint64_t > queries_executed
Total queries executed.
std::atomic< std::uint64_t > access_denied_count
Total access denied events.
auto uptime() const -> std::chrono::seconds
Get uptime duration.
std::atomic< std::uint32_t > active_associations
Current active DICOM associations.
std::uint16_t port
HTTP port for REST API.
bool cors_enabled
Enable CORS for web clients.
bool enabled
Enable REST API server.
std::vector< std::string > allowed_ae_titles
Allowed AE titles (supports wildcards with *)
access_control_config access_control
Access control settings.
anonymization_config anonymization
Anonymization settings.
std::uint16_t port
TCP port for DICOM connections.
tls_config tls
TLS configuration.
std::size_t max_associations
Maximum concurrent associations.
std::string ae_title
Application Entity title (max 16 characters)
std::filesystem::path root_path
Root path for DICOM file storage.
bool enabled
Enable TLS for DICOM connections.
Configuration options for the REST server.
bool enable_cors
Enable CORS (Cross-Origin Resource Sharing) headers.
std::uint16_t port
Port to listen on.
std::size_t concurrency
Number of worker threads for handling requests.