25#include <kcenon/common/patterns/result.h>
268 [[nodiscard]]
static auto create(
269 std::shared_ptr<storage::storage_interface> storage,
270 std::shared_ptr<storage::index_database> database)
271 -> std::unique_ptr<ai_result_handler>;
429 std::string_view result_uid,
430 std::string_view source_study_uid) ->
VoidResult;
440 std::string_view result_uid,
473 std::string_view study_instance_uid,
491 [[nodiscard]] auto
exists(std::string_view sop_instance_uid) const ->
bool;
519 std::shared_ptr<storage::storage_interface> storage,
520 std::shared_ptr<storage::index_database> database);
Simple result type for error handling.
auto operator=(const ai_result_handler &) -> ai_result_handler &=delete
void set_pre_store_validator(pre_store_validator validator)
Set custom pre-storage validator.
auto receive_presentation_state(const core::dicom_dataset &pr) -> VoidResult
Receive and store an AI-generated Presentation State.
ai_result_handler(ai_result_handler &&) noexcept
auto get_source_reference(std::string_view result_uid) -> Result< source_reference >
Get source references for an AI result.
auto remove(std::string_view sop_instance_uid) -> VoidResult
Remove an AI result and its source links.
auto receive_structured_report(const core::dicom_dataset &sr) -> VoidResult
Receive and store an AI-generated Structured Report.
auto exists(std::string_view sop_instance_uid) const -> bool
Check if an AI result exists.
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 receive_segmentation(const core::dicom_dataset &seg) -> VoidResult
Receive and store an AI-generated Segmentation object.
ai_result_handler(const ai_result_handler &)=delete
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 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.
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 get_ai_result_info(std::string_view sop_instance_uid) -> std::optional< ai_result_info >
Get AI result information by SOP Instance UID.
void set_received_callback(ai_result_received_callback callback)
Set callback for AI result reception notifications.
auto validate_segmentation(const core::dicom_dataset &seg) -> validation_result
Validate segmentation data integrity.
auto get_cad_findings(std::string_view sr_sop_instance_uid) -> Result< std::vector< cad_finding > >
Extract CAD findings from a Structured Report.
void configure(const ai_handler_config &config)
Configure handler behavior.
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 validate_presentation_state(const core::dicom_dataset &pr) -> validation_result
Validate Presentation State.
auto get_segment_info(std::string_view seg_sop_instance_uid) -> Result< std::vector< segment_info > >
Get segment information from a stored Segmentation.
virtual ~ai_result_handler()
Destructor.
auto get_config() const -> ai_handler_config
Get current configuration.
std::unique_ptr< impl > pimpl_
auto validate_sr_template(const core::dicom_dataset &sr) -> validation_result
Validate SR template conformance.
DICOM Dataset - ordered collection of Data Elements.
PACS index database for metadata storage and retrieval.
ai_result_type
Types of AI-generated DICOM objects.
@ structured_report
DICOM SR (Structured Report)
@ segmentation
DICOM SEG (Segmentation)
@ presentation_state
DICOM PR (Presentation State)
validation_status
Validation status for AI results.
@ invalid_template
SR template conformance failed.
@ unknown_error
Unexpected validation error.
@ invalid_segment_data
Segmentation data is malformed.
@ valid
All validations passed.
@ invalid_reference
Referenced source images not found.
@ missing_required_tags
Required DICOM tags are missing.
kcenon::common::VoidResult VoidResult
Result type alias for void operations.
std::function< void(const ai_result_info &info)> ai_result_received_callback
Callback for notification when AI result is received.
std::function< bool( const core::dicom_dataset &dataset, ai_result_type type)> pre_store_validator
Callback for pre-storage validation.
Abstract storage interface for DICOM persistent storage backends.
Configuration for AI result handler.
bool validate_sr_templates
Whether to validate SR template conformance.
std::vector< std::string > accepted_sr_templates
Accepted SR template identifiers (empty = accept all)
bool auto_link_to_source
Whether to auto-link results to source studies.
uint16_t max_segments
Maximum segment count for SEG objects (0 = unlimited)
bool validate_source_references
Whether to validate source references exist in storage.
Information about an AI result stored in the system.
std::string series_instance_uid
Series Instance UID.
ai_result_type type
Type of AI result.
std::string algorithm_name
AI model/algorithm identifier.
std::string algorithm_version
Algorithm version.
std::string sop_class_uid
SOP Class UID.
std::string source_study_uid
Study Instance UID of the source study.
std::string sop_instance_uid
SOP Instance UID of the AI result.
std::optional< std::string > description
Optional description.
std::chrono::system_clock::time_point received_at
Timestamp when the result was received.
CAD finding extracted from Structured Report.
std::optional< double > confidence
Confidence score (0.0 to 1.0)
std::string location
Location/site description.
std::optional< std::string > measurement
Additional measurement or annotation data.
std::optional< std::string > referenced_sop_instance_uid
Reference to specific image where finding was detected.
std::string finding_type
Finding type/category.
Segment information from Segmentation object.
std::string algorithm_type
Algorithm type that created this segment.
std::string segment_label
Segment label.
std::optional< std::tuple< uint8_t, uint8_t, uint8_t > > recommended_display_color
RGB color for visualization (optional)
uint16_t segment_number
Segment number (1-based)
std::optional< std::string > description
Segment description.
Source reference linking AI result to original images.
std::vector< std::string > sop_instance_uids
SOP Instance UIDs (optional, for instance-level reference)
std::string study_instance_uid
Study Instance UID.
std::optional< std::string > series_instance_uid
Series Instance UID (optional, for series-level reference)
Validation result containing status and details.
std::vector< std::string > missing_tags
List of missing required tags (if applicable)
validation_status status
Overall validation status.
std::optional< std::string > error_message
Detailed error message if validation failed.
std::vector< std::string > invalid_references
List of invalid references (if applicable)