27#include <condition_variable>
32#include <shared_mutex>
36#include <unordered_set>
41class prefetch_repository;
42class prefetch_rule_repository;
43class prefetch_history_repository;
57class remote_node_manager;
61 std::shared_ptr<storage::prefetch_rule_repository>
rules;
62 std::shared_ptr<storage::prefetch_history_repository>
history;
128 std::shared_ptr<remote_node_manager> node_manager,
130 std::shared_ptr<services::worklist_scu> worklist_scu =
nullptr,
131 std::shared_ptr<di::ILogger> logger =
nullptr);
146 std::shared_ptr<remote_node_manager> node_manager,
148 std::shared_ptr<services::worklist_scu> worklist_scu =
nullptr,
149 std::shared_ptr<di::ILogger> logger =
nullptr);
163 std::shared_ptr<storage::prefetch_repository> repo,
164 std::shared_ptr<remote_node_manager> node_manager,
166 std::shared_ptr<services::worklist_scu> worklist_scu =
nullptr,
167 std::shared_ptr<di::ILogger> logger =
nullptr);
183 std::shared_ptr<storage::prefetch_repository> repo,
184 std::shared_ptr<remote_node_manager> node_manager,
186 std::shared_ptr<services::worklist_scu> worklist_scu =
nullptr,
187 std::shared_ptr<di::ILogger> logger =
nullptr);
226 [[nodiscard]]
auto remove_rule(std::string_view rule_id) -> kcenon::pacs::VoidResult;
234 [[nodiscard]]
auto get_rule(std::string_view rule_id)
const
235 -> std::optional<prefetch_rule>;
256 void process_worklist(const std::vector<core::dicom_dataset>& worklist_items);
265 const std::vector<core::dicom_dataset>& worklist_items) -> std::future<
void>;
283 std::string_view patient_id,
284 std::string_view current_modality,
296 std::string_view patient_id,
297 std::string_view current_modality,
298 std::optional<std::string_view>
body_part = std::nullopt)
313 std::string_view source_node_id,
314 std::string_view study_uid) -> std::
string;
325 std::string_view source_node_id,
326 std::string_view patient_id,
327 std::chrono::hours lookback = std::chrono::hours{8760}) -> std::string;
void stop_worklist_monitor()
Stop the worklist monitor.
prefetch_manager(prefetch_manager &&)=delete
auto config() const noexcept -> const prefetch_manager_config &
Get current configuration.
auto prefetch_study(std::string_view source_node_id, std::string_view study_uid) -> std::string
Prefetch a specific study.
auto prefetch_patient(std::string_view source_node_id, std::string_view patient_id, std::chrono::hours lookback=std::chrono::hours{8760}) -> std::string
Prefetch all studies for a patient.
auto is_scheduler_running() const noexcept -> bool
Check if scheduler is running.
auto get_rule(std::string_view rule_id) const -> std::optional< prefetch_rule >
Get a rule by ID.
auto pending_prefetches() const -> size_t
Get number of pending prefetch operations.
auto completed_today() const -> size_t
Get number of prefetches completed today.
void process_worklist(const std::vector< core::dicom_dataset > &worklist_items)
Process worklist items and trigger prefetch.
prefetch_manager(prefetch_repositories repositories, std::shared_ptr< remote_node_manager > node_manager, std::shared_ptr< job_manager > job_manager, std::shared_ptr< services::worklist_scu > worklist_scu=nullptr, std::shared_ptr< di::ILogger > logger=nullptr)
Construct a prefetch manager from split repositories.
auto failed_today() const -> size_t
Get number of prefetches failed today.
auto remove_rule(std::string_view rule_id) -> kcenon::pacs::VoidResult
Remove a prefetch rule.
void set_config(prefetch_manager_config new_config)
Update configuration.
auto prefetch_priors_async(std::string_view patient_id, std::string_view current_modality, std::optional< std::string_view > body_part=std::nullopt) -> std::future< prefetch_result >
Prefetch prior studies asynchronously.
void start_worklist_monitor(std::string_view worklist_node_id)
Start the worklist monitor.
auto list_rules() const -> std::vector< prefetch_rule >
List all prefetch rules.
auto prefetch_priors(std::string_view patient_id, std::string_view current_modality, std::optional< std::string_view > body_part=std::nullopt) -> prefetch_result
Prefetch prior studies for a patient.
auto operator=(const prefetch_manager &) -> prefetch_manager &=delete
auto is_worklist_monitor_running() const noexcept -> bool
Check if worklist monitor is running.
~prefetch_manager()
Destructor - stops scheduler and monitor if running.
auto get_rule_statistics(std::string_view rule_id) const -> prefetch_rule_statistics
Get statistics for a specific rule.
auto add_rule(const prefetch_rule &rule) -> kcenon::pacs::VoidResult
Add a new prefetch rule.
auto operator=(prefetch_manager &&) -> prefetch_manager &=delete
void stop_scheduler()
Stop the scheduler.
auto update_rule(const prefetch_rule &rule) -> kcenon::pacs::VoidResult
Update an existing prefetch rule.
auto process_worklist_async(const std::vector< core::dicom_dataset > &worklist_items) -> std::future< void >
Process worklist items asynchronously.
std::unique_ptr< impl > impl_
prefetch_manager(const prefetch_manager &)=delete
void start_scheduler()
Start the scheduler for cron-based rules.
Logger interface for dependency injection.
@ body_part
(0018,0015) Body Part Examined
Types and structures for prefetch manager.
Result<T> type aliases and helpers for PACS system.
Configuration for the prefetch manager.
std::shared_ptr< storage::prefetch_history_repository > history
std::shared_ptr< storage::prefetch_rule_repository > rules
Result of a prefetch operation.
Statistics for a prefetch rule.
Rule defining when and how to prefetch DICOM data.