|
PACS System 0.1.0
PACS DICOM system library
|
#include <routing_manager.h>

Public Member Functions | |
| routing_manager (std::shared_ptr< storage::routing_repository > repo, std::shared_ptr< job_manager > job_manager, std::shared_ptr< di::ILogger > logger=nullptr) | |
| Construct a routing manager with default configuration. | |
| routing_manager (const routing_manager_config &config, std::shared_ptr< storage::routing_repository > repo, std::shared_ptr< job_manager > job_manager, std::shared_ptr< di::ILogger > logger=nullptr) | |
| Construct a routing manager with custom configuration. | |
| ~routing_manager () | |
| Destructor. | |
| routing_manager (const routing_manager &)=delete | |
| auto | operator= (const routing_manager &) -> routing_manager &=delete |
| routing_manager (routing_manager &&)=delete | |
| auto | operator= (routing_manager &&) -> routing_manager &=delete |
| auto | add_rule (const routing_rule &rule) -> kcenon::pacs::VoidResult |
| Add a new routing rule. | |
| auto | update_rule (const routing_rule &rule) -> kcenon::pacs::VoidResult |
| Update an existing routing rule. | |
| auto | remove_rule (std::string_view rule_id) -> kcenon::pacs::VoidResult |
| Remove a routing rule. | |
| auto | get_rule (std::string_view rule_id) const -> std::optional< routing_rule > |
| Get a routing rule by ID. | |
| auto | list_rules () const -> std::vector< routing_rule > |
| List all routing rules. | |
| auto | list_enabled_rules () const -> std::vector< routing_rule > |
| List only enabled routing rules. | |
| auto | set_rule_priority (std::string_view rule_id, int priority) -> kcenon::pacs::VoidResult |
| Set the priority of a rule. | |
| auto | reorder_rules (const std::vector< std::string > &rule_ids) -> kcenon::pacs::VoidResult |
| Reorder rules by specifying the desired order. | |
| auto | evaluate (const core::dicom_dataset &dataset) -> std::vector< routing_action > |
| Evaluate rules against a dataset. | |
| auto | evaluate_with_rule_ids (const core::dicom_dataset &dataset) -> std::vector< std::pair< std::string, std::vector< routing_action > > > |
| Evaluate rules and return with matched rule IDs. | |
| void | route (const core::dicom_dataset &dataset) |
| Route a DICOM dataset based on matching rules. | |
| void | route (std::string_view sop_instance_uid) |
| Route a stored instance by SOP Instance UID. | |
| void | enable () |
| Enable routing globally. | |
| void | disable () |
| Disable routing globally. | |
| auto | is_enabled () const noexcept -> bool |
| Check if routing is enabled. | |
| void | attach_to_storage_scp (services::storage_scp &scp) |
| Attach to a Storage SCP for automatic routing. | |
| void | detach_from_storage_scp () |
| Detach from the currently attached Storage SCP. | |
| void | set_routing_callback (routing_event_callback callback) |
| Set callback for routing events. | |
| auto | test_rules (const core::dicom_dataset &dataset) const -> routing_test_result |
| Test rules against a dataset without executing actions. | |
| auto | get_statistics () const -> routing_statistics |
| Get overall routing statistics. | |
| auto | get_rule_statistics (std::string_view rule_id) const -> routing_statistics |
| Get statistics for a specific rule. | |
| void | reset_statistics () |
| Reset all statistics. | |
| auto | config () const noexcept -> const routing_manager_config & |
| Get current configuration. | |
Private Member Functions | |
| auto | match_condition (const routing_condition &condition, const core::dicom_dataset &dataset) const -> bool |
| Check if a condition matches a dataset. | |
| auto | match_pattern (std::string_view pattern, std::string_view value, bool case_sensitive) const -> bool |
| Match a wildcard pattern against a value. | |
| auto | get_field_value (routing_field field, const core::dicom_dataset &dataset) const -> std::string |
| Get DICOM field value from dataset. | |
| void | execute_actions (const std::string &sop_instance_uid, const std::vector< routing_action > &actions) |
| Execute routing actions. | |
| void | load_rules () |
| Load rules from repository into cache. | |
Private Attributes | |
| routing_manager_config | config_ |
| std::shared_ptr< storage::routing_repository > | repo_ |
| std::shared_ptr< job_manager > | job_manager_ |
| std::shared_ptr< di::ILogger > | logger_ |
| std::vector< routing_rule > | rules_ |
| std::shared_mutex | rules_mutex_ |
| std::atomic< bool > | enabled_ {true} |
| routing_event_callback | routing_callback_ |
| std::atomic< size_t > | total_evaluated_ {0} |
| std::atomic< size_t > | total_matched_ {0} |
| std::atomic< size_t > | total_forwarded_ {0} |
| std::atomic< size_t > | total_failed_ {0} |
| services::storage_scp * | attached_scp_ {nullptr} |
Definition at line 93 of file routing_manager.h.
|
explicit |
Construct a routing manager with default configuration.
| repo | Routing repository for persistence (required) |
| job_manager | Job manager for executing forward jobs (required) |
| logger | Logger instance (optional, defaults to NullLogger) |
Definition at line 58 of file routing_manager.cpp.
References load_rules(), logger_, and rules_.

|
explicit |
Construct a routing manager with custom configuration.
| config | Manager configuration |
| repo | Routing repository for persistence (required) |
| job_manager | Job manager for executing forward jobs (required) |
| logger | Logger instance (optional, defaults to NullLogger) |
Definition at line 74 of file routing_manager.cpp.
References config_, kcenon::pacs::client::routing_manager_config::enabled, enabled_, load_rules(), logger_, and rules_.

| kcenon::pacs::client::routing_manager::~routing_manager | ( | ) |
Destructor.
Definition at line 93 of file routing_manager.cpp.
References detach_from_storage_scp().

|
delete |
|
delete |
|
nodiscard |
Add a new routing rule.
| rule | The rule to add |
Definition at line 101 of file routing_manager.cpp.
References config_, logger_, kcenon::pacs::client::routing_manager_config::max_rules, kcenon::pacs::client::routing_rule::name, kcenon::pacs::pacs_void_error(), repo_, kcenon::pacs::client::routing_rule::rule_id, rules_, and rules_mutex_.

| void kcenon::pacs::client::routing_manager::attach_to_storage_scp | ( | services::storage_scp & | scp | ) |
Attach to a Storage SCP for automatic routing.
Registers a post-store handler to automatically route received images.
| scp | The Storage SCP to attach to |
Definition at line 443 of file routing_manager.cpp.
References attached_scp_, detach_from_storage_scp(), logger_, route(), and kcenon::pacs::services::storage_scp::set_post_store_handler().

|
nodiscardnoexcept |
Get current configuration.
Definition at line 574 of file routing_manager.cpp.
References config_.
| void kcenon::pacs::client::routing_manager::detach_from_storage_scp | ( | ) |
Detach from the currently attached Storage SCP.
Definition at line 463 of file routing_manager.cpp.
References attached_scp_, logger_, and kcenon::pacs::services::storage_scp::set_post_store_handler().
Referenced by attach_to_storage_scp(), and ~routing_manager().


| void kcenon::pacs::client::routing_manager::disable | ( | ) |
| void kcenon::pacs::client::routing_manager::enable | ( | ) |
|
nodiscard |
Evaluate rules against a dataset.
Returns all actions that should be executed based on matching rules.
| dataset | The DICOM dataset to evaluate |
Definition at line 291 of file routing_manager.cpp.
References enabled_, match_condition(), rules_, rules_mutex_, total_evaluated_, and total_matched_.

|
nodiscard |
Evaluate rules and return with matched rule IDs.
| dataset | The DICOM dataset to evaluate |
Definition at line 334 of file routing_manager.cpp.
References enabled_, match_condition(), rules_, rules_mutex_, total_evaluated_, and total_matched_.
Referenced by route().


|
private |
Execute routing actions.
Definition at line 672 of file routing_manager.cpp.
References job_manager_, logger_, and total_forwarded_.
Referenced by route().

|
nodiscardprivate |
Get DICOM field value from dataset.
Definition at line 634 of file routing_manager.cpp.
References kcenon::pacs::client::body_part, kcenon::pacs::client::department, kcenon::pacs::core::dicom_dataset::get_string(), kcenon::pacs::client::institution, kcenon::pacs::core::tags::institution_name, kcenon::pacs::client::modality, kcenon::pacs::core::tags::modality, kcenon::pacs::core::tags::patient_id, kcenon::pacs::client::patient_id_pattern, kcenon::pacs::client::referring_physician, kcenon::pacs::core::tags::referring_physician_name, kcenon::pacs::client::series_description, kcenon::pacs::core::tags::series_description, kcenon::pacs::client::sop_class_uid, kcenon::pacs::core::tags::sop_class_uid, kcenon::pacs::client::station_ae, kcenon::pacs::core::tags::station_name, kcenon::pacs::client::study_description, and kcenon::pacs::core::tags::study_description.
Referenced by match_condition().


|
nodiscard |
Get a routing rule by ID.
| rule_id | The rule ID to retrieve |
Definition at line 202 of file routing_manager.cpp.
References rules_, and rules_mutex_.
|
nodiscard |
Get statistics for a specific rule.
| rule_id | The rule ID |
Definition at line 528 of file routing_manager.cpp.
References repo_.
|
nodiscard |
Get overall routing statistics.
Definition at line 519 of file routing_manager.cpp.
References total_evaluated_, total_failed_, total_forwarded_, and total_matched_.
|
nodiscardnoexcept |
Check if routing is enabled.
Definition at line 435 of file routing_manager.cpp.
References enabled_.
|
nodiscard |
List only enabled routing rules.
Definition at line 219 of file routing_manager.cpp.
References rules_, and rules_mutex_.
|
nodiscard |
List all routing rules.
Definition at line 214 of file routing_manager.cpp.
References rules_, and rules_mutex_.
|
private |
Load rules from repository into cache.
Definition at line 707 of file routing_manager.cpp.
References logger_, repo_, rules_, and rules_mutex_.
Referenced by routing_manager(), and routing_manager().

|
nodiscardprivate |
Check if a condition matches a dataset.
Definition at line 582 of file routing_manager.cpp.
References kcenon::pacs::client::routing_condition::case_sensitive, get_field_value(), kcenon::pacs::client::routing_condition::match_field, match_pattern(), kcenon::pacs::client::routing_condition::negate, and kcenon::pacs::client::routing_condition::pattern.
Referenced by evaluate(), evaluate_with_rule_ids(), and test_rules().


|
nodiscardprivate |
Match a wildcard pattern against a value.
Definition at line 595 of file routing_manager.cpp.
Referenced by match_condition().

|
delete |
|
delete |
|
nodiscard |
Remove a routing rule.
| rule_id | The ID of the rule to remove |
Definition at line 177 of file routing_manager.cpp.
References logger_, repo_, rules_, and rules_mutex_.
|
nodiscard |
Reorder rules by specifying the desired order.
| rule_ids | Vector of rule IDs in desired order (first = highest priority) |
Definition at line 257 of file routing_manager.cpp.
References repo_, rules_, and rules_mutex_.
| void kcenon::pacs::client::routing_manager::reset_statistics | ( | ) |
Reset all statistics.
Definition at line 553 of file routing_manager.cpp.
References logger_, repo_, rules_, rules_mutex_, total_evaluated_, total_failed_, total_forwarded_, and total_matched_.
| void kcenon::pacs::client::routing_manager::route | ( | const core::dicom_dataset & | dataset | ) |
Route a DICOM dataset based on matching rules.
Evaluates rules and creates forward jobs for matching actions.
| dataset | The DICOM dataset to route |
Definition at line 371 of file routing_manager.cpp.
References enabled_, evaluate_with_rule_ids(), execute_actions(), kcenon::pacs::core::dicom_dataset::get_string(), logger_, repo_, routing_callback_, and kcenon::pacs::core::tags::sop_instance_uid.
Referenced by attach_to_storage_scp().


| void kcenon::pacs::client::routing_manager::route | ( | std::string_view | sop_instance_uid | ) |
Route a stored instance by SOP Instance UID.
| sop_instance_uid | The SOP Instance UID to route |
Definition at line 404 of file routing_manager.cpp.
| void kcenon::pacs::client::routing_manager::set_routing_callback | ( | routing_event_callback | callback | ) |
Set callback for routing events.
Called when a rule matches and actions are triggered.
| callback | The callback function |
Definition at line 478 of file routing_manager.cpp.
References routing_callback_.
|
nodiscard |
Set the priority of a rule.
| rule_id | The rule ID to update |
| priority | The new priority (higher = evaluated first) |
Definition at line 231 of file routing_manager.cpp.
References repo_, rules_, and rules_mutex_.
|
nodiscard |
Test rules against a dataset without executing actions.
| dataset | The DICOM dataset to test |
Definition at line 486 of file routing_manager.cpp.
References kcenon::pacs::client::routing_test_result::actions, match_condition(), kcenon::pacs::client::routing_test_result::matched, kcenon::pacs::client::routing_test_result::matched_rule_id, rules_, and rules_mutex_.

|
nodiscard |
Update an existing routing rule.
| rule | The rule to update (identified by rule_id) |
Definition at line 141 of file routing_manager.cpp.
References logger_, kcenon::pacs::client::routing_rule::name, kcenon::pacs::pacs_void_error(), repo_, kcenon::pacs::client::routing_rule::rule_id, rules_, and rules_mutex_.

|
private |
Definition at line 414 of file routing_manager.h.
Referenced by attach_to_storage_scp(), and detach_from_storage_scp().
|
private |
Definition at line 396 of file routing_manager.h.
Referenced by add_rule(), config(), and routing_manager().
|
private |
Definition at line 404 of file routing_manager.h.
Referenced by disable(), enable(), evaluate(), evaluate_with_rule_ids(), is_enabled(), route(), route(), and routing_manager().
|
private |
Definition at line 398 of file routing_manager.h.
Referenced by execute_actions().
|
private |
Definition at line 399 of file routing_manager.h.
Referenced by add_rule(), attach_to_storage_scp(), detach_from_storage_scp(), disable(), enable(), execute_actions(), load_rules(), remove_rule(), reset_statistics(), route(), route(), routing_manager(), routing_manager(), and update_rule().
|
private |
Definition at line 397 of file routing_manager.h.
Referenced by add_rule(), get_rule_statistics(), load_rules(), remove_rule(), reorder_rules(), reset_statistics(), route(), set_rule_priority(), and update_rule().
|
private |
Definition at line 405 of file routing_manager.h.
Referenced by route(), and set_routing_callback().
|
private |
Definition at line 401 of file routing_manager.h.
Referenced by add_rule(), evaluate(), evaluate_with_rule_ids(), get_rule(), list_enabled_rules(), list_rules(), load_rules(), remove_rule(), reorder_rules(), reset_statistics(), routing_manager(), routing_manager(), set_rule_priority(), test_rules(), and update_rule().
|
mutableprivate |
Definition at line 402 of file routing_manager.h.
Referenced by add_rule(), evaluate(), evaluate_with_rule_ids(), get_rule(), list_enabled_rules(), list_rules(), load_rules(), remove_rule(), reorder_rules(), reset_statistics(), set_rule_priority(), test_rules(), and update_rule().
|
private |
Definition at line 408 of file routing_manager.h.
Referenced by evaluate(), evaluate_with_rule_ids(), get_statistics(), and reset_statistics().
|
private |
Definition at line 411 of file routing_manager.h.
Referenced by get_statistics(), and reset_statistics().
|
private |
Definition at line 410 of file routing_manager.h.
Referenced by execute_actions(), get_statistics(), and reset_statistics().
|
private |
Definition at line 409 of file routing_manager.h.
Referenced by evaluate(), evaluate_with_rule_ids(), get_statistics(), and reset_statistics().