PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
prefetch_types.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 <cstddef>
22#include <string>
23#include <vector>
24
25namespace kcenon::pacs::client {
26
27// =============================================================================
28// Prefetch Trigger
29// =============================================================================
30
40
46[[nodiscard]] constexpr const char* to_string(prefetch_trigger trigger) noexcept {
47 switch (trigger) {
48 case prefetch_trigger::worklist_match: return "worklist_match";
49 case prefetch_trigger::prior_studies: return "prior_studies";
50 case prefetch_trigger::scheduled_exam: return "scheduled_exam";
51 case prefetch_trigger::manual: return "manual";
52 default: return "unknown";
53 }
54}
55
62 std::string_view str) noexcept {
63 if (str == "worklist_match") return prefetch_trigger::worklist_match;
64 if (str == "prior_studies") return prefetch_trigger::prior_studies;
65 if (str == "scheduled_exam") return prefetch_trigger::scheduled_exam;
66 if (str == "manual") return prefetch_trigger::manual;
68}
69
70// =============================================================================
71// Prefetch Rule
72// =============================================================================
73
81 // =========================================================================
82 // Identification
83 // =========================================================================
84
85 std::string rule_id;
86 std::string name;
87 bool enabled{true};
88
90
91 // =========================================================================
92 // Filters
93 // =========================================================================
94
95 std::string modality_filter;
96 std::string body_part_filter;
97 std::string station_ae_filter;
98
99 // =========================================================================
100 // Prior Study Settings
101 // =========================================================================
102
103 std::chrono::hours prior_lookback{8760};
105 std::vector<std::string> prior_modalities;
106
107 // =========================================================================
108 // Source Nodes
109 // =========================================================================
110
111 std::vector<std::string> source_node_ids;
112
113 // =========================================================================
114 // Schedule Settings
115 // =========================================================================
116
117 std::string schedule_cron;
118 std::chrono::minutes advance_time{60};
119
120 // =========================================================================
121 // Statistics
122 // =========================================================================
123
124 size_t triggered_count{0};
126 std::chrono::system_clock::time_point last_triggered;
127
128 // =========================================================================
129 // Database Fields
130 // =========================================================================
131
132 int64_t pk{0};
133};
134
135// =============================================================================
136// Prefetch Result
137// =============================================================================
138
145 std::string patient_id;
146 std::string patient_name;
147 size_t studies_found{0};
150 std::vector<std::string> job_ids;
151 std::chrono::milliseconds elapsed{0};
152
156 [[nodiscard]] bool is_success() const noexcept {
158 }
159};
160
161// =============================================================================
162// Prefetch History
163// =============================================================================
164
169 std::string patient_id;
170 std::string study_uid;
171 std::string rule_id;
172 std::string source_node_id;
173 std::string job_id;
174 std::string status;
175 std::chrono::system_clock::time_point prefetched_at;
176
177 int64_t pk{0};
178};
179
180// =============================================================================
181// Prefetch Manager Configuration
182// =============================================================================
183
188 bool enabled{true};
189 std::chrono::seconds worklist_check_interval{300};
192};
193
194// =============================================================================
195// Rule Statistics
196// =============================================================================
197
206
207} // namespace kcenon::pacs::client
prefetch_trigger prefetch_trigger_from_string(std::string_view str) noexcept
Parse prefetch_trigger from string.
constexpr const char * to_string(job_type type) noexcept
Convert job_type to string representation.
Definition job_types.h:54
prefetch_trigger
Trigger type for prefetch operations.
@ worklist_match
Triggered by worklist entry.
@ scheduled_exam
Based on scheduled procedure.
@ prior_studies
Fetch prior studies for patient.
History record for a single prefetch operation.
std::string source_node_id
Source node ID.
std::chrono::system_clock::time_point prefetched_at
Timestamp.
std::string job_id
Associated job ID.
std::string study_uid
Study Instance UID.
std::string status
Status (pending, completed, failed)
std::string rule_id
Rule that triggered this (if any)
Configuration for the prefetch manager.
bool deduplicate_requests
Deduplicate pending requests.
std::chrono::seconds worklist_check_interval
Worklist polling interval.
size_t max_concurrent_prefetch
Max concurrent prefetch jobs.
bool enabled
Enable prefetch functionality.
Result of a prefetch operation.
std::vector< std::string > job_ids
Created job IDs.
size_t studies_already_local
Studies already local.
std::string patient_name
Patient name.
std::chrono::milliseconds elapsed
Operation duration.
size_t studies_found
Studies found on remote.
size_t studies_prefetched
Studies actually prefetched.
bool is_success() const noexcept
Check if prefetch was successful.
size_t studies_prefetched
Total studies prefetched.
size_t triggered_count
Times rule was triggered.
size_t bytes_prefetched
Total bytes prefetched.
Rule defining when and how to prefetch DICOM data.
std::string name
Human-readable name.
std::string station_ae_filter
Station AE title filter.
std::string modality_filter
Modality filter (e.g., "CT,MR")
std::vector< std::string > prior_modalities
Modalities to fetch (empty = same)
size_t triggered_count
Times rule was triggered.
size_t studies_prefetched
Total studies prefetched.
int64_t pk
Primary key (0 if not persisted)
std::chrono::hours prior_lookback
Lookback period (default: 1 year)
std::string body_part_filter
Body part filter (e.g., "CHEST,ABDOMEN")
std::chrono::system_clock::time_point last_triggered
Last trigger time.
std::string schedule_cron
Cron expression (e.g., "0 6 * * *")
std::chrono::minutes advance_time
Prefetch N minutes before scheduled.
size_t max_prior_studies
Maximum prior studies to fetch.
prefetch_trigger trigger
What triggers this rule.
std::vector< std::string > source_node_ids
Nodes to search for data.
std::string rule_id
Unique rule identifier (UUID)
bool enabled
Whether the rule is active.