18#include <kcenon/common/patterns/event_bus.h>
30 std::shared_ptr<di::ILogger> logger)
31 :
scp_service(std::move(logger)), config_(config) {}
50 std::shared_ptr<kcenon::pacs::security::atna_service_auditor> auditor) {
70 using namespace network::dimse;
73 if (request.
command() != command_field::c_store_rq) {
76 "Expected C-STORE-RQ but received " +
86 auto response = make_c_store_rsp(
96 const auto& dataset = request.
dataset().value().get();
100 auto response = make_c_store_rsp(
106 return assoc.
send_dimse(context_id, response);
128 dataset.size() *
sizeof(uint32_t),
129 std::memory_order_relaxed
148 kcenon::common::get_event_bus().publish(
163 kcenon::common::get_event_bus().publish(
168 static_cast<int>(status),
169 "C-STORE operation failed"
183 !is_failure(status));
187 auto response = make_c_store_rsp(
191 static_cast<status_code
>(status)
194 return assoc.
send_dimse(context_id, response);
198 return "Storage SCP";
250 "1.2.840.10008.5.1.4.1.1.20",
251 "1.2.840.10008.5.1.4.1.1.128",
252 "1.2.840.10008.5.1.4.1.1.130",
255 "1.2.840.10008.5.1.4.1.1.12.1",
256 "1.2.840.10008.5.1.4.1.1.12.2",
259 "1.2.840.10008.5.1.4.1.1.1.2",
260 "1.2.840.10008.5.1.4.1.1.1.2.1",
263 "1.2.840.10008.5.1.4.1.1.7.1",
264 "1.2.840.10008.5.1.4.1.1.7.2",
265 "1.2.840.10008.5.1.4.1.1.7.3",
266 "1.2.840.10008.5.1.4.1.1.7.4",
269 "1.2.840.10008.5.1.4.1.1.88.11",
270 "1.2.840.10008.5.1.4.1.1.88.22",
271 "1.2.840.10008.5.1.4.1.1.88.33",
272 "1.2.840.10008.5.1.4.1.1.88.34",
275 "1.2.840.10008.5.1.4.1.1.104.1",
276 "1.2.840.10008.5.1.4.1.1.104.2",
High-level facade for ATNA audit logging in DICOM services.
Result< std::monostate > send_dimse(uint8_t context_id, const dimse::dimse_message &msg)
Send a DIMSE message.
std::string_view calling_ae() const noexcept
Get calling AE title.
std::string_view called_ae() const noexcept
Get called AE title.
auto message_id() const noexcept -> uint16_t
Get the message ID.
auto affected_sop_class_uid() const -> std::string
Get the Affected SOP Class UID.
auto has_dataset() const noexcept -> bool
Check if the message has an associated data set.
auto dataset() -> kcenon::pacs::Result< std::reference_wrapper< core::dicom_dataset > >
Get mutable reference to the data set.
auto affected_sop_instance_uid() const -> std::string
Get the Affected SOP Instance UID.
auto command() const noexcept -> command_field
Get the command field.
void audit_instance_stored(const std::string &source_ae, const std::string &dest_ae, const std::string &study_uid, const std::string &patient_id, bool success)
Audit a C-STORE (DICOM Instances Transferred) event.
void set_audit_handler(std::shared_ptr< kcenon::pacs::security::atna_service_auditor > auditor)
Set the ATNA audit handler for C-STORE operations.
storage_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct a Storage SCP with default configuration.
size_t bytes_received() const noexcept
Get the total bytes received since construction.
void reset_statistics() noexcept
Reset statistics counters to zero.
void set_handler(storage_handler handler)
Set the storage handler callback.
size_t images_received() const noexcept
Get the number of images received since construction.
std::vector< std::string > supported_sop_classes() const override
Get supported SOP Class UIDs.
std::shared_ptr< kcenon::pacs::security::atna_service_auditor > auditor_
ATNA audit handler.
storage_handler handler_
Main storage handler.
network::Result< std::monostate > handle_message(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request) override
Handle an incoming DIMSE message (C-STORE-RQ)
storage_scp_config config_
Configuration.
std::atomic< size_t > images_received_
Statistics: number of images received.
void set_post_store_handler(post_store_handler handler)
std::string_view service_name() const noexcept override
Get the service name.
void set_pre_store_handler(pre_store_handler handler)
Set the pre-store validation handler.
pre_store_handler pre_store_handler_
Pre-store validation handler.
post_store_handler post_store_handler_
Post-store notification handler.
std::atomic< size_t > bytes_received_
Statistics: total bytes received.
DIMSE command field enumeration.
Compile-time constants for commonly used DICOM tags.
DICOM event definitions for event-based communication.
constexpr int store_unexpected_command
constexpr bool is_failure(storage_status status) noexcept
Check if the status indicates a failure.
std::vector< std::string > get_standard_storage_sop_classes()
Get a list of all standard Storage SOP Class UIDs.
constexpr std::string_view mr_image_storage_uid
MR Image Storage.
constexpr std::string_view cr_image_storage_uid
CR Image Storage.
constexpr std::string_view us_image_storage_uid
US Image Storage.
std::function< bool(const core::dicom_dataset &dataset)> pre_store_handler
Callback type for pre-store validation.
storage_status
Storage operation status codes.
@ success
Success - image stored successfully (0x0000)
@ cannot_understand
Failure: Cannot understand - processing failure (0xC000)
std::function< storage_status( const core::dicom_dataset &dataset, const std::string &calling_ae, const std::string &sop_class_uid, const std::string &sop_instance_uid)> storage_handler
Callback type for handling received DICOM images.
constexpr std::string_view secondary_capture_image_storage_uid
Secondary Capture Image Storage.
constexpr std::string_view rt_image_storage_uid
RT Image Storage.
std::function< void( const core::dicom_dataset &dataset, const std::string &patient_id, const std::string &study_uid, const std::string &series_uid, const std::string &sop_instance_uid)> post_store_handler
Callback type for post-store notification.
constexpr std::string_view dx_image_storage_presentation_uid
Digital X-Ray Image Storage - For Presentation.
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
constexpr std::string_view ct_image_storage_uid
CT Image Storage.
constexpr std::string_view rt_plan_storage_uid
RT Plan Storage.
constexpr std::string_view rt_dose_storage_uid
RT Dose Storage.
constexpr std::string_view enhanced_ct_image_storage_uid
Enhanced CT Image Storage.
constexpr std::string_view rt_structure_set_storage_uid
RT Structure Set Storage.
constexpr std::string_view enhanced_mr_image_storage_uid
Enhanced MR Image Storage.
constexpr std::string_view dx_image_storage_processing_uid
Digital X-Ray Image Storage - For Processing.
VoidResult pacs_void_error(int code, const std::string &message, const std::string &details="")
Create a PACS void error result.
Result<T> type aliases and helpers for PACS system.
DICOM Storage SCP service (C-STORE handler)
Event published when an image is successfully received via C-STORE.
Event published when a C-STORE operation fails.
Configuration for Storage SCP service.
std::vector< std::string > accepted_sop_classes
List of accepted SOP Class UIDs (empty = accept all standard storage classes)