PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
prefetch_config.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
18#pragma once
19
20#include <chrono>
21#include <cstdint>
22#include <functional>
23#include <optional>
24#include <set>
25#include <string>
26#include <vector>
27
28namespace kcenon::pacs::workflow {
29
38 std::string ae_title;
39
41 std::string host;
42
44 uint16_t port{11112};
45
47 std::string local_ae_title{"PACS_PREFETCH"};
48
50 std::chrono::seconds connection_timeout{30};
51
53 std::chrono::seconds association_timeout{60};
54
56 bool use_tls{false};
57
62 [[nodiscard]] auto is_valid() const noexcept -> bool {
63 return !ae_title.empty() && !host.empty() && port > 0;
64 }
65};
66
75 std::chrono::days lookback_period{365};
76
78 std::size_t max_studies_per_patient{10};
79
81 std::size_t max_series_per_study{0}; // 0 = unlimited
82
84 std::set<std::string> include_modalities;
85
87 std::set<std::string> exclude_modalities;
88
90 std::set<std::string> include_body_parts;
91
94
97};
98
106 std::size_t patients_processed{0};
107
109 std::size_t studies_prefetched{0};
110
112 std::size_t series_prefetched{0};
113
115 std::size_t instances_prefetched{0};
116
118 std::size_t studies_failed{0};
119
122
124 std::size_t bytes_downloaded{0};
125
127 std::chrono::milliseconds duration{0};
128
130 std::chrono::system_clock::time_point timestamp;
131
136 [[nodiscard]] auto is_successful() const noexcept -> bool {
137 return studies_failed == 0;
138 }
139
146 patients_processed += other.patients_processed;
147 studies_prefetched += other.studies_prefetched;
148 series_prefetched += other.series_prefetched;
149 instances_prefetched += other.instances_prefetched;
150 studies_failed += other.studies_failed;
151 studies_already_present += other.studies_already_present;
152 bytes_downloaded += other.bytes_downloaded;
153 duration += other.duration;
154 return *this;
155 }
156};
157
167
169 std::string patient_id;
170
172 std::string patient_name;
173
175 std::string study_date;
176
178 std::string study_description;
179
181 std::set<std::string> modalities;
182
185
187 std::string accession_number;
188
190 std::size_t number_of_series{0};
191
193 std::size_t number_of_instances{0};
194};
195
204 bool enabled{true};
205
207 std::chrono::seconds prefetch_interval{300};
208
211
213 bool auto_start{false};
214
216 std::vector<remote_pacs_config> remote_pacs;
217
220
222 std::size_t rate_limit_per_minute{0};
223
226
228 std::size_t max_retry_attempts{3};
229
231 std::chrono::seconds retry_delay{60};
232
235 std::function<void(const prefetch_result& result)>;
237
240 std::function<void(const std::string& patient_id,
241 const prior_study_info& study,
242 bool success,
243 const std::string& error_message)>;
245
248 std::function<void(const std::string& patient_id,
249 const std::string& study_uid,
250 const std::string& error)>;
252
257 [[nodiscard]] auto is_valid() const noexcept -> bool {
258 if (!enabled) {
259 return true; // Disabled config is always valid
260 }
261 // Must have at least one valid remote PACS
262 for (const auto& pacs : remote_pacs) {
263 if (pacs.is_valid()) {
264 return true;
265 }
266 }
267 return false;
268 }
269};
270
271} // namespace kcenon::pacs::workflow
bool prefer_same_body_part
Prefer same body part as scheduled procedure.
bool prefer_same_modality
Prefer same modality as scheduled procedure.
std::set< std::string > exclude_modalities
Modalities to exclude.
std::chrono::days lookback_period
Lookback period for prior studies (default: 365 days)
std::set< std::string > include_modalities
Modalities to include (empty = all modalities)
std::size_t max_studies_per_patient
Maximum number of prior studies to prefetch per patient.
std::size_t max_series_per_study
Maximum number of prior series to prefetch per study.
std::set< std::string > include_body_parts
Only prefetch studies with specific body parts.
std::size_t studies_prefetched
Number of studies prefetched successfully.
std::size_t studies_already_present
Number of studies already present (skipped)
auto is_successful() const noexcept -> bool
Check if the result indicates success (no failures)
std::size_t bytes_downloaded
Total bytes downloaded.
std::chrono::system_clock::time_point timestamp
Time when this result was recorded.
std::size_t series_prefetched
Number of series prefetched successfully.
std::size_t instances_prefetched
Number of instances (images) prefetched.
auto operator+=(const prefetch_result &other) -> prefetch_result &
Combine results from another prefetch operation.
std::chrono::milliseconds duration
Duration of the prefetch operation.
std::size_t studies_failed
Number of studies that failed to prefetch.
std::size_t patients_processed
Number of patients processed.
Configuration for the auto prefetch service.
prefetch_criteria criteria
Selection criteria for prior studies.
bool auto_start
Whether to start automatically on construction.
std::function< void(const std::string &patient_id, const prior_study_info &study, bool success, const std::string &error_message)> prefetch_complete_callback
Callback for individual prefetch completion.
std::function< void(const prefetch_result &result)> cycle_complete_callback
Callback for prefetch cycle completion.
auto is_valid() const noexcept -> bool
Check if configuration is valid.
std::size_t rate_limit_per_minute
Rate limit: maximum prefetches per minute (0 = unlimited)
std::size_t max_retry_attempts
Maximum retry attempts.
std::size_t max_concurrent_prefetches
Maximum concurrent prefetch operations.
std::function< void(const std::string &patient_id, const std::string &study_uid, const std::string &error)> error_callback
Callback for prefetch errors.
bool enabled
Enable/disable the prefetch service.
std::chrono::seconds retry_delay
Delay between retries.
std::vector< remote_pacs_config > remote_pacs
Remote PACS configurations (can prefetch from multiple sources)
std::chrono::seconds prefetch_interval
Interval between prefetch cycles (default: 5 minutes)
std::string body_part_examined
Body Part Examined.
std::size_t number_of_instances
Number of Instances in Study.
std::string study_description
Study Description.
std::string study_instance_uid
Study Instance UID.
std::set< std::string > modalities
Modalities in Study.
std::size_t number_of_series
Number of Series in Study.
std::string accession_number
Accession Number.
std::string study_date
Study Date (YYYYMMDD format)
Remote PACS connection configuration.
std::chrono::seconds connection_timeout
Connection timeout.
uint16_t port
Remote PACS port (default: 11112)
std::string local_ae_title
Our local AE title for association.
auto is_valid() const noexcept -> bool
Check if configuration is valid.
std::string host
Remote PACS hostname or IP address.
std::chrono::seconds association_timeout
Association timeout.
bool use_tls
Enable TLS for secure connections.
std::string ae_title
Remote PACS AE title.