PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::ai::ai_result_handler Class Reference

#include <ai_result_handler.h>

Collaboration diagram for kcenon::pacs::ai::ai_result_handler:
Collaboration graph

Classes

class  impl
 

Public Member Functions

virtual ~ai_result_handler ()
 Destructor.
 
 ai_result_handler (const ai_result_handler &)=delete
 
auto operator= (const ai_result_handler &) -> ai_result_handler &=delete
 
 ai_result_handler (ai_result_handler &&) noexcept
 
auto operator= (ai_result_handler &&) noexcept -> ai_result_handler &
 
void configure (const ai_handler_config &config)
 Configure handler behavior.
 
auto get_config () const -> ai_handler_config
 Get current configuration.
 
void set_received_callback (ai_result_received_callback callback)
 Set callback for AI result reception notifications.
 
void set_pre_store_validator (pre_store_validator validator)
 Set custom pre-storage validator.
 
auto receive_structured_report (const core::dicom_dataset &sr) -> VoidResult
 Receive and store an AI-generated Structured Report.
 
auto validate_sr_template (const core::dicom_dataset &sr) -> validation_result
 Validate SR template conformance.
 
auto get_cad_findings (std::string_view sr_sop_instance_uid) -> Result< std::vector< cad_finding > >
 Extract CAD findings from a Structured Report.
 
auto receive_segmentation (const core::dicom_dataset &seg) -> VoidResult
 Receive and store an AI-generated Segmentation object.
 
auto validate_segmentation (const core::dicom_dataset &seg) -> validation_result
 Validate segmentation data integrity.
 
auto get_segment_info (std::string_view seg_sop_instance_uid) -> Result< std::vector< segment_info > >
 Get segment information from a stored Segmentation.
 
auto receive_presentation_state (const core::dicom_dataset &pr) -> VoidResult
 Receive and store an AI-generated Presentation State.
 
auto validate_presentation_state (const core::dicom_dataset &pr) -> validation_result
 Validate Presentation State.
 
auto link_to_source (std::string_view result_uid, std::string_view source_study_uid) -> VoidResult
 Link an AI result to its source study.
 
auto link_to_source (std::string_view result_uid, const source_reference &references) -> VoidResult
 Link an AI result with detailed source references.
 
auto get_source_reference (std::string_view result_uid) -> Result< source_reference >
 Get source references for an AI result.
 
auto find_ai_results_for_study (std::string_view study_instance_uid) -> Result< std::vector< ai_result_info > >
 Find all AI results linked to a study.
 
auto find_ai_results_by_type (std::string_view study_instance_uid, ai_result_type type) -> Result< std::vector< ai_result_info > >
 Find AI results by type.
 
auto get_ai_result_info (std::string_view sop_instance_uid) -> std::optional< ai_result_info >
 Get AI result information by SOP Instance UID.
 
auto exists (std::string_view sop_instance_uid) const -> bool
 Check if an AI result exists.
 
auto remove (std::string_view sop_instance_uid) -> VoidResult
 Remove an AI result and its source links.
 
auto remove_ai_results_for_study (std::string_view study_instance_uid) -> Result< std::size_t >
 Remove all AI results linked to a study.
 

Static Public Member Functions

static auto create (std::shared_ptr< storage::storage_interface > storage, std::shared_ptr< storage::index_database > database) -> std::unique_ptr< ai_result_handler >
 Create an AI result handler.
 

Protected Member Functions

 ai_result_handler (std::shared_ptr< storage::storage_interface > storage, std::shared_ptr< storage::index_database > database)
 Protected constructor - use create() factory method.
 

Private Attributes

std::unique_ptr< implpimpl_
 

Detailed Description

Definition at line 259 of file ai_result_handler.h.

Constructor & Destructor Documentation

◆ ~ai_result_handler()

kcenon::pacs::ai::ai_result_handler::~ai_result_handler ( )
virtualdefault

◆ ai_result_handler() [1/3]

kcenon::pacs::ai::ai_result_handler::ai_result_handler ( const ai_result_handler & )
delete

◆ ai_result_handler() [2/3]

kcenon::pacs::ai::ai_result_handler::ai_result_handler ( ai_result_handler && )
defaultnoexcept

◆ ai_result_handler() [3/3]

kcenon::pacs::ai::ai_result_handler::ai_result_handler ( std::shared_ptr< storage::storage_interface > storage,
std::shared_ptr< storage::index_database > database )
protected

Protected constructor - use create() factory method.

Definition at line 246 of file ai_result_handler.cpp.

249 : pimpl_(std::make_unique<impl>(std::move(storage), std::move(database))) {}

Member Function Documentation

◆ configure()

void kcenon::pacs::ai::ai_result_handler::configure ( const ai_handler_config & config)

Configure handler behavior.

Parameters
configConfiguration options
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 262 of file ai_result_handler.cpp.

262 {
263 pimpl_->config_ = config;
264}

◆ create()

auto kcenon::pacs::ai::ai_result_handler::create ( std::shared_ptr< storage::storage_interface > storage,
std::shared_ptr< storage::index_database > database ) -> std::unique_ptr<ai_result_handler>
staticnodiscard

Create an AI result handler.

Parameters
storageStorage backend for persisting DICOM objects
databaseIndex database for metadata queries
Returns
Unique pointer to the handler instance

Definition at line 238 of file ai_result_handler.cpp.

241 {
242 return std::unique_ptr<ai_result_handler>(
243 new ai_result_handler(std::move(storage), std::move(database)));
244}
ai_result_handler(const ai_result_handler &)=delete

◆ exists()

auto kcenon::pacs::ai::ai_result_handler::exists ( std::string_view sop_instance_uid) const -> bool
nodiscard

Check if an AI result exists.

Parameters
sop_instance_uidSOP Instance UID to check
Returns
true if the AI result exists, false otherwise
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 701 of file ai_result_handler.cpp.

701 {
702 // Check cache first
703 if (pimpl_->ai_results_cache_.find(std::string(sop_instance_uid)) !=
704 pimpl_->ai_results_cache_.end()) {
705 return true;
706 }
707
708 // Check storage
709 return pimpl_->storage_->exists(sop_instance_uid);
710}
std::map< std::string, ai_result_info > ai_results_cache_
std::shared_ptr< storage::storage_interface > storage_

◆ find_ai_results_by_type()

auto kcenon::pacs::ai::ai_result_handler::find_ai_results_by_type ( std::string_view study_instance_uid,
ai_result_type type ) -> Result<std::vector<ai_result_info>>
nodiscard

Find AI results by type.

Parameters
study_instance_uidStudy Instance UID
typeType of AI result to search for
Returns
Result containing list of AI result info or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 678 of file ai_result_handler.cpp.

680 {
681 std::vector<ai_result_info> results;
682
683 for (const auto& [uid, info] : pimpl_->ai_results_cache_) {
684 if (info.source_study_uid == study_instance_uid && info.type == type) {
685 results.push_back(info);
686 }
687 }
688
689 return results;
690}
std::string_view uid

References uid.

◆ find_ai_results_for_study()

auto kcenon::pacs::ai::ai_result_handler::find_ai_results_for_study ( std::string_view study_instance_uid) -> Result<std::vector<ai_result_info>>
nodiscard

Find all AI results linked to a study.

Parameters
study_instance_uidStudy Instance UID
Returns
Result containing list of AI result info or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 653 of file ai_result_handler.cpp.

654 {
655 std::vector<ai_result_info> results;
656
657 for (const auto& [uid, info] : pimpl_->ai_results_cache_) {
658 if (info.source_study_uid == study_instance_uid) {
659 results.push_back(info);
660 }
661 }
662
663 // Also check source links
664 for (const auto& [uid, ref] : pimpl_->source_links_) {
665 if (ref.study_instance_uid == study_instance_uid) {
666 auto it = pimpl_->ai_results_cache_.find(uid);
667 if (it != pimpl_->ai_results_cache_.end()) {
668 // Already included from cache
669 continue;
670 }
671 // Would need to retrieve from storage for complete info
672 }
673 }
674
675 return results;
676}
std::map< std::string, source_reference > source_links_

References uid.

◆ get_ai_result_info()

auto kcenon::pacs::ai::ai_result_handler::get_ai_result_info ( std::string_view sop_instance_uid) -> std::optional<ai_result_info>
nodiscard

Get AI result information by SOP Instance UID.

Parameters
sop_instance_uidSOP Instance UID of the AI result
Returns
Optional containing AI result info if found
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 692 of file ai_result_handler.cpp.

693 {
694 auto it = pimpl_->ai_results_cache_.find(std::string(sop_instance_uid));
695 if (it != pimpl_->ai_results_cache_.end()) {
696 return it->second;
697 }
698 return std::nullopt;
699}

◆ get_cad_findings()

auto kcenon::pacs::ai::ai_result_handler::get_cad_findings ( std::string_view sr_sop_instance_uid) -> Result<std::vector<cad_finding>>
nodiscard

Extract CAD findings from a Structured Report.

Parameters
sr_sop_instance_uidSOP Instance UID of the SR
Returns
Result containing list of CAD findings or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 375 of file ai_result_handler.cpp.

376 {
377 // Retrieve the SR dataset
378 auto retrieve_result = pimpl_->storage_->retrieve(sr_sop_instance_uid);
379 if (retrieve_result.is_err()) {
380#if KCENON_HAS_COMMON_SYSTEM
381 return kcenon::common::error_info("Failed to retrieve SR: " +
382 std::string(sr_sop_instance_uid));
383#else
384 return std::string("Failed to retrieve SR: ") + std::string(sr_sop_instance_uid);
385#endif
386 }
387
388 // Parse CAD findings from Content Sequence
389 // This is a simplified implementation - full parsing would handle
390 // the complete SR tree structure
391 std::vector<cad_finding> findings;
392
393 // Note: Actual implementation would parse the Content Sequence
394 // recursively to extract CAD findings based on the SR template
395
396 return findings;
397}

◆ get_config()

auto kcenon::pacs::ai::ai_result_handler::get_config ( ) const -> ai_handler_config
nodiscard

Get current configuration.

Returns
Current configuration
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 266 of file ai_result_handler.cpp.

266 {
267 return pimpl_->config_;
268}

References kcenon::pacs::ai::ai_result_handler::impl::config_, and pimpl_.

◆ get_segment_info()

auto kcenon::pacs::ai::ai_result_handler::get_segment_info ( std::string_view seg_sop_instance_uid) -> Result<std::vector<segment_info>>
nodiscard

Get segment information from a stored Segmentation.

Parameters
seg_sop_instance_uidSOP Instance UID of the SEG
Returns
Result containing list of segment information or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 491 of file ai_result_handler.cpp.

492 {
493 // Retrieve the SEG dataset
494 auto retrieve_result = pimpl_->storage_->retrieve(seg_sop_instance_uid);
495 if (retrieve_result.is_err()) {
496#if KCENON_HAS_COMMON_SYSTEM
497 return kcenon::common::error_info("Failed to retrieve SEG: " +
498 std::string(seg_sop_instance_uid));
499#else
500 return std::string("Failed to retrieve SEG: ") + std::string(seg_sop_instance_uid);
501#endif
502 }
503
504 // Parse segment information from Segment Sequence
505 std::vector<segment_info> segments;
506
507 // Note: Actual implementation would parse the Segment Sequence
508 // to extract segment information
509
510 return segments;
511}

◆ get_source_reference()

auto kcenon::pacs::ai::ai_result_handler::get_source_reference ( std::string_view result_uid) -> Result<source_reference>
nodiscard

Get source references for an AI result.

Parameters
result_uidSOP Instance UID of the AI result
Returns
Result containing source reference or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 635 of file ai_result_handler.cpp.

636 {
637 auto it = pimpl_->source_links_.find(std::string(result_uid));
638 if (it == pimpl_->source_links_.end()) {
639#if KCENON_HAS_COMMON_SYSTEM
640 return kcenon::common::error_info("No source reference found for: " +
641 std::string(result_uid));
642#else
643 return std::string("No source reference found for: ") + std::string(result_uid);
644#endif
645 }
646 return it->second;
647}

◆ link_to_source() [1/2]

auto kcenon::pacs::ai::ai_result_handler::link_to_source ( std::string_view result_uid,
const source_reference & references ) -> VoidResult
nodiscard

Link an AI result with detailed source references.

Parameters
result_uidSOP Instance UID of the AI result
referencesSource references (study, series, instances)
Returns
VoidResult Success or error information

Definition at line 607 of file ai_result_handler.cpp.

609 {
610 // Verify the AI result exists
611 auto it = pimpl_->ai_results_cache_.find(std::string(result_uid));
612 if (it == pimpl_->ai_results_cache_.end()) {
613 // Try to check storage
614 if (!pimpl_->storage_->exists(result_uid)) {
615#if KCENON_HAS_COMMON_SYSTEM
616 return kcenon::common::error_info("AI result not found: " +
617 std::string(result_uid));
618#else
619 return std::string("AI result not found: ") + std::string(result_uid);
620#endif
621 }
622 }
623
624 // Store the source link
625 pimpl_->source_links_[std::string(result_uid)] = references;
626
627 // Update cached info if present
628 if (it != pimpl_->ai_results_cache_.end()) {
629 it->second.source_study_uid = references.study_instance_uid;
630 }
631
632 return ok();
633}

◆ link_to_source() [2/2]

auto kcenon::pacs::ai::ai_result_handler::link_to_source ( std::string_view result_uid,
std::string_view source_study_uid ) -> VoidResult
nodiscard

Link an AI result to its source study.

Creates a reference association between the AI result and the original study/series/instances it was derived from.

Parameters
result_uidSOP Instance UID of the AI result
source_study_uidStudy Instance UID of the source
Returns
VoidResult Success or error information
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 599 of file ai_result_handler.cpp.

601 {
602 source_reference ref;
603 ref.study_instance_uid = std::string(source_study_uid);
604 return link_to_source(result_uid, ref);
605}
auto link_to_source(std::string_view result_uid, std::string_view source_study_uid) -> VoidResult
Link an AI result to its source study.

References kcenon::pacs::ai::source_reference::study_instance_uid.

◆ operator=() [1/2]

auto kcenon::pacs::ai::ai_result_handler::operator= ( ai_result_handler && ) -> ai_result_handler &
defaultnoexcept

◆ operator=() [2/2]

auto kcenon::pacs::ai::ai_result_handler::operator= ( const ai_result_handler & ) -> ai_result_handler &=delete
delete

◆ receive_presentation_state()

auto kcenon::pacs::ai::ai_result_handler::receive_presentation_state ( const core::dicom_dataset & pr) -> VoidResult
nodiscard

Receive and store an AI-generated Presentation State.

Validates the PR dataset and stores it linked to source images.

Parameters
prThe Presentation State dataset
Returns
VoidResult Success or error information
Note
Handles annotations and measurements from AI analysis
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 517 of file ai_result_handler.cpp.

518 {
519 // Validate SOP Class
520 auto sop_class = pr.get_string(core::tags::sop_class_uid);
521 auto type = determine_result_type(sop_class);
522 if (!type || *type != ai_result_type::presentation_state) {
523#if KCENON_HAS_COMMON_SYSTEM
524 return kcenon::common::error_info("Invalid SOP Class for Presentation State");
525#else
526 return std::string("Invalid SOP Class for Presentation State");
527#endif
528 }
529
530 // Run common validation
531 auto common_validation = pimpl_->validate_common_tags(pr);
532 if (common_validation.status != validation_status::valid) {
533#if KCENON_HAS_COMMON_SYSTEM
534 return kcenon::common::error_info(
535 common_validation.error_message.value_or("Validation failed"));
536#else
537 return common_validation.error_message.value_or("Validation failed");
538#endif
539 }
540
541 // Validate presentation state
542 auto pr_validation = validate_presentation_state(pr);
543 if (pr_validation.status != validation_status::valid) {
544#if KCENON_HAS_COMMON_SYSTEM
545 return kcenon::common::error_info(
546 pr_validation.error_message.value_or("Presentation state validation failed"));
547#else
548 return pr_validation.error_message.value_or("Presentation state validation failed");
549#endif
550 }
551
552 // Validate source references if configured
553 auto ref_validation = pimpl_->validate_source_references_exist(pr);
554 if (ref_validation.status != validation_status::valid) {
555#if KCENON_HAS_COMMON_SYSTEM
556 return kcenon::common::error_info(
557 ref_validation.error_message.value_or("Source reference validation failed"));
558#else
559 return ref_validation.error_message.value_or("Source reference validation failed");
560#endif
561 }
562
563 // Call pre-store validator if set
566#if KCENON_HAS_COMMON_SYSTEM
567 return kcenon::common::error_info("Pre-store validation rejected the presentation state");
568#else
569 return std::string("Pre-store validation rejected the presentation state");
570#endif
571 }
572
573 // Store the PR
575}
auto validate_source_references_exist(const core::dicom_dataset &dataset) -> validation_result
auto store_ai_result(const core::dicom_dataset &dataset, ai_result_type type) -> VoidResult
auto validate_common_tags(const core::dicom_dataset &dataset) -> validation_result
auto validate_presentation_state(const core::dicom_dataset &pr) -> validation_result
Validate Presentation State.
@ presentation_state
DICOM PR (Presentation State)
@ valid
All validations passed.
constexpr dicom_tag sop_class_uid
SOP Class UID.

References kcenon::pacs::ai::presentation_state, kcenon::pacs::core::tags::sop_class_uid, and kcenon::pacs::ai::valid.

◆ receive_segmentation()

auto kcenon::pacs::ai::ai_result_handler::receive_segmentation ( const core::dicom_dataset & seg) -> VoidResult
nodiscard

Receive and store an AI-generated Segmentation object.

Validates the SEG dataset for required tags and segment sequence, then stores it and links it to the source images.

Parameters
segThe Segmentation dataset
Returns
VoidResult Success or error information
Note
Supports both BINARY and FRACTIONAL segment types
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 403 of file ai_result_handler.cpp.

404 {
405 // Validate SOP Class
406 auto sop_class = seg.get_string(core::tags::sop_class_uid);
407 auto type = determine_result_type(sop_class);
408 if (!type || *type != ai_result_type::segmentation) {
409#if KCENON_HAS_COMMON_SYSTEM
410 return kcenon::common::error_info("Invalid SOP Class for Segmentation");
411#else
412 return std::string("Invalid SOP Class for Segmentation");
413#endif
414 }
415
416 // Run common validation
417 auto common_validation = pimpl_->validate_common_tags(seg);
418 if (common_validation.status != validation_status::valid) {
419#if KCENON_HAS_COMMON_SYSTEM
420 return kcenon::common::error_info(
421 common_validation.error_message.value_or("Validation failed"));
422#else
423 return common_validation.error_message.value_or("Validation failed");
424#endif
425 }
426
427 // Validate segmentation data
428 auto seg_validation = validate_segmentation(seg);
429 if (seg_validation.status != validation_status::valid) {
430#if KCENON_HAS_COMMON_SYSTEM
431 return kcenon::common::error_info(
432 seg_validation.error_message.value_or("Segmentation validation failed"));
433#else
434 return seg_validation.error_message.value_or("Segmentation validation failed");
435#endif
436 }
437
438 // Validate source references if configured
439 auto ref_validation = pimpl_->validate_source_references_exist(seg);
440 if (ref_validation.status != validation_status::valid) {
441#if KCENON_HAS_COMMON_SYSTEM
442 return kcenon::common::error_info(
443 ref_validation.error_message.value_or("Source reference validation failed"));
444#else
445 return ref_validation.error_message.value_or("Source reference validation failed");
446#endif
447 }
448
449 // Call pre-store validator if set
452#if KCENON_HAS_COMMON_SYSTEM
453 return kcenon::common::error_info("Pre-store validation rejected the segmentation");
454#else
455 return std::string("Pre-store validation rejected the segmentation");
456#endif
457 }
458
459 // Store the SEG
461}
auto validate_segmentation(const core::dicom_dataset &seg) -> validation_result
Validate segmentation data integrity.
@ segmentation
DICOM SEG (Segmentation)

References kcenon::pacs::ai::segmentation, kcenon::pacs::core::tags::sop_class_uid, and kcenon::pacs::ai::valid.

◆ receive_structured_report()

auto kcenon::pacs::ai::ai_result_handler::receive_structured_report ( const core::dicom_dataset & sr) -> VoidResult
nodiscard

Receive and store an AI-generated Structured Report.

Validates the SR dataset for required tags and template conformance, then stores it and links it to the source study.

Parameters
srThe Structured Report dataset
Returns
VoidResult Success or error information
Note
The dataset must contain valid Content Sequence with CAD findings
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 282 of file ai_result_handler.cpp.

283 {
284 // Validate SOP Class
285 auto sop_class = sr.get_string(core::tags::sop_class_uid);
286 auto type = determine_result_type(sop_class);
287 if (!type || *type != ai_result_type::structured_report) {
288#if KCENON_HAS_COMMON_SYSTEM
289 return kcenon::common::error_info("Invalid SOP Class for Structured Report");
290#else
291 return std::string("Invalid SOP Class for Structured Report");
292#endif
293 }
294
295 // Run common validation
296 auto common_validation = pimpl_->validate_common_tags(sr);
297 if (common_validation.status != validation_status::valid) {
298#if KCENON_HAS_COMMON_SYSTEM
299 return kcenon::common::error_info(
300 common_validation.error_message.value_or("Validation failed"));
301#else
302 return common_validation.error_message.value_or("Validation failed");
303#endif
304 }
305
306 // Validate SR template if configured
308 auto template_validation = validate_sr_template(sr);
309 if (template_validation.status != validation_status::valid) {
310#if KCENON_HAS_COMMON_SYSTEM
311 return kcenon::common::error_info(
312 template_validation.error_message.value_or("SR template validation failed"));
313#else
314 return template_validation.error_message.value_or("SR template validation failed");
315#endif
316 }
317 }
318
319 // Validate source references if configured
320 auto ref_validation = pimpl_->validate_source_references_exist(sr);
321 if (ref_validation.status != validation_status::valid) {
322#if KCENON_HAS_COMMON_SYSTEM
323 return kcenon::common::error_info(
324 ref_validation.error_message.value_or("Source reference validation failed"));
325#else
326 return ref_validation.error_message.value_or("Source reference validation failed");
327#endif
328 }
329
330 // Call pre-store validator if set
333#if KCENON_HAS_COMMON_SYSTEM
334 return kcenon::common::error_info("Pre-store validation rejected the SR");
335#else
336 return std::string("Pre-store validation rejected the SR");
337#endif
338 }
339
340 // Store the SR
342}
auto validate_sr_template(const core::dicom_dataset &sr) -> validation_result
Validate SR template conformance.
@ structured_report
DICOM SR (Structured Report)
bool validate_sr_templates
Whether to validate SR template conformance.

References kcenon::pacs::core::tags::sop_class_uid, kcenon::pacs::ai::structured_report, and kcenon::pacs::ai::valid.

◆ remove()

auto kcenon::pacs::ai::ai_result_handler::remove ( std::string_view sop_instance_uid) -> VoidResult
nodiscard

Remove an AI result and its source links.

Parameters
sop_instance_uidSOP Instance UID of the AI result to remove
Returns
VoidResult Success or error information
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 716 of file ai_result_handler.cpp.

716 {
717 std::string uid_str(sop_instance_uid);
718
719 // Remove from storage
720 auto remove_result = pimpl_->storage_->remove(sop_instance_uid);
721 if (remove_result.is_err()) {
722 return remove_result;
723 }
724
725 // Remove from cache
726 pimpl_->ai_results_cache_.erase(uid_str);
727
728 // Remove source links
729 pimpl_->source_links_.erase(uid_str);
730
731 return ok();
732}

◆ remove_ai_results_for_study()

auto kcenon::pacs::ai::ai_result_handler::remove_ai_results_for_study ( std::string_view study_instance_uid) -> Result<std::size_t>
nodiscard

Remove all AI results linked to a study.

Parameters
study_instance_uidStudy Instance UID
Returns
Result containing count of removed results or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 734 of file ai_result_handler.cpp.

735 {
736 std::size_t removed_count = 0;
737
738 // Find all AI results for this study
739 std::vector<std::string> to_remove;
740 for (const auto& [uid, info] : pimpl_->ai_results_cache_) {
741 if (info.source_study_uid == study_instance_uid) {
742 to_remove.push_back(uid);
743 }
744 }
745
746 // Remove each one
747 for (const auto& uid : to_remove) {
748 auto result = remove(uid);
749 if (result.is_ok()) {
750 ++removed_count;
751 }
752 }
753
754 return removed_count;
755}
auto remove(std::string_view sop_instance_uid) -> VoidResult
Remove an AI result and its source links.

References uid.

◆ set_pre_store_validator()

void kcenon::pacs::ai::ai_result_handler::set_pre_store_validator ( pre_store_validator validator)

Set custom pre-storage validator.

Parameters
validatorFunction to validate before storage
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 274 of file ai_result_handler.cpp.

274 {
275 pimpl_->pre_store_validator_ = std::move(validator);
276}

References pimpl_, and kcenon::pacs::ai::ai_result_handler::impl::pre_store_validator_.

◆ set_received_callback()

void kcenon::pacs::ai::ai_result_handler::set_received_callback ( ai_result_received_callback callback)

Set callback for AI result reception notifications.

Parameters
callbackFunction to call when AI result is received
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 270 of file ai_result_handler.cpp.

270 {
271 pimpl_->received_callback_ = std::move(callback);
272}

References pimpl_, and kcenon::pacs::ai::ai_result_handler::impl::received_callback_.

◆ validate_presentation_state()

auto kcenon::pacs::ai::ai_result_handler::validate_presentation_state ( const core::dicom_dataset & pr) -> validation_result
nodiscard

Validate Presentation State.

Parameters
prThe Presentation State dataset to validate
Returns
Validation result with status and details
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 577 of file ai_result_handler.cpp.

578 {
579 validation_result result;
580 result.status = validation_status::valid;
581
582 // Note: Referenced Series Sequence (0008,1115) validation would be done here
583 // for full presentation state conformance checking
584
585 // Basic validation - ensure presentation state has valid SOP Class UID
586 auto sop_class = pr.get_string(core::tags::sop_class_uid);
587 if (sop_class.empty()) {
589 result.missing_tags.push_back("SOP Class UID");
590 }
591
592 return result;
593}
@ missing_required_tags
Required DICOM tags are missing.

References kcenon::pacs::ai::missing_required_tags, kcenon::pacs::ai::validation_result::missing_tags, kcenon::pacs::core::tags::sop_class_uid, kcenon::pacs::ai::validation_result::status, and kcenon::pacs::ai::valid.

◆ validate_segmentation()

auto kcenon::pacs::ai::ai_result_handler::validate_segmentation ( const core::dicom_dataset & seg) -> validation_result
nodiscard

Validate segmentation data integrity.

Parameters
segThe Segmentation dataset to validate
Returns
Validation result with status and details
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 463 of file ai_result_handler.cpp.

464 {
465 validation_result result;
466 result.status = validation_status::valid;
467
468 // Note: Segment Sequence (0062,0002) validation would be done here
469 // for full segmentation conformance checking
470
471 // Check Segmentation Type
472 // Tag (0062,0001) Segmentation Type
473 const core::dicom_tag seg_type_tag(0x0062, 0x0001);
474 auto seg_type = seg.get_string(seg_type_tag);
475
476 if (seg_type != "BINARY" && seg_type != "FRACTIONAL" && !seg_type.empty()) {
478 result.error_message = "Invalid segmentation type: " + seg_type;
479 return result;
480 }
481
482 // Check segment count if max_segments is configured
483 if (pimpl_->config_.max_segments > 0) {
484 // Tag (0062,0004) Number of Segments
485 // This would need proper implementation based on actual tag
486 }
487
488 return result;
489}
@ invalid_segment_data
Segmentation data is malformed.
uint16_t max_segments
Maximum segment count for SEG objects (0 = unlimited)

References kcenon::pacs::ai::validation_result::error_message, kcenon::pacs::ai::invalid_segment_data, kcenon::pacs::ai::validation_result::status, and kcenon::pacs::ai::valid.

◆ validate_sr_template()

auto kcenon::pacs::ai::ai_result_handler::validate_sr_template ( const core::dicom_dataset & sr) -> validation_result
nodiscard

Validate SR template conformance.

Parameters
srThe Structured Report dataset to validate
Returns
Validation result with status and details
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/ai/ai_result_handler.h.

Definition at line 344 of file ai_result_handler.cpp.

345 {
346 validation_result result;
347 result.status = validation_status::valid;
348
349 // Note: Content Sequence (0040,A730) validation would be done here
350 // for full SR template conformance checking
351
352 // Check for Template Identifier if configured
353 if (!pimpl_->config_.accepted_sr_templates.empty()) {
354 // Tag (0040,DB00) Template Identifier
355 const core::dicom_tag template_id_tag(0x0040, 0xDB00);
356 auto template_id = sr.get_string(template_id_tag);
357
358 bool template_found = false;
359 for (const auto& accepted : pimpl_->config_.accepted_sr_templates) {
360 if (template_id == accepted) {
361 template_found = true;
362 break;
363 }
364 }
365
366 if (!template_found && !template_id.empty()) {
368 result.error_message = "SR template not in accepted list: " + template_id;
369 }
370 }
371
372 return result;
373}
@ invalid_template
SR template conformance failed.
std::vector< std::string > accepted_sr_templates
Accepted SR template identifiers (empty = accept all)

References kcenon::pacs::ai::validation_result::error_message, kcenon::pacs::ai::invalid_template, kcenon::pacs::ai::validation_result::status, and kcenon::pacs::ai::valid.

Member Data Documentation

◆ pimpl_

std::unique_ptr<impl> kcenon::pacs::ai::ai_result_handler::pimpl_
private

The documentation for this class was generated from the following files: