24 std::shared_ptr<storage::storage_interface>
storage,
25 std::shared_ptr<di::ILogger> logger)
27 , storage_(std::move(
storage)) {}
42 using namespace network::dimse;
45 case command_field::n_action_rq:
51 "Unexpected command for Storage Commitment SCP: " +
57 return "Storage Commitment SCP";
91 using namespace network::dimse;
94 auto sop_class_uid = request.
command_set().get_string(
95 tag_requested_sop_class_uid);
96 if (sop_class_uid.empty()) {
103 status_refused_sop_class_not_supported);
108 if (!action_type.has_value() ||
112 status_error_no_such_action_type);
119 status_error_missing_attribute);
122 const auto& dataset = request.
dataset().value().get();
126 if (transaction_uid.empty()) {
129 status_error_missing_attribute);
134 if (references.empty()) {
137 status_error_missing_attribute);
144 if (rsp_result.is_err()) {
167 const std::string& transaction_uid,
168 const std::vector<sop_reference>& references) {
172 result.
timestamp = std::chrono::system_clock::now();
174 for (
const auto& ref : references) {
195 using namespace network::dimse;
203 auto event_rq = make_n_event_report_rq(
211 event_rq.set_dataset(std::move(event_dataset));
214 return assoc.
send_dimse(context_id, event_rq);
227 using namespace network::dimse;
229 auto response = make_n_action_rsp(
236 return assoc.
send_dimse(context_id, response);
246 std::vector<sop_reference> references;
249 if (seq ==
nullptr) {
253 for (
const auto& item : *seq) {
259 references.push_back(std::move(ref));
286 success_seq.push_back(std::move(item));
303 static_cast<uint16_t
>(reason));
304 failed_seq.push_back(std::move(item));
auto get_sequence(dicom_tag tag) const noexcept -> const std::vector< dicom_dataset > *
void set_string(dicom_tag tag, encoding::vr_type vr, std::string_view value)
Set a string value for the given tag.
auto get_or_create_sequence(dicom_tag tag) -> std::vector< dicom_dataset > &
Insert or create a sequence element with the given tag.
Result< std::monostate > send_dimse(uint8_t context_id, const dimse::dimse_message &msg)
Send a DIMSE message.
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 command_set() noexcept -> core::dicom_dataset &
Get mutable reference to the command set.
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 action_type_id() const -> std::optional< uint16_t >
Get the Action Type ID (for N-ACTION)
auto command() const noexcept -> command_field
Get the command field.
std::atomic< size_t > instances_failed_
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.
storage_commitment_scp(std::shared_ptr< storage::storage_interface > storage, std::shared_ptr< di::ILogger > logger=nullptr)
Construct Storage Commitment SCP with storage backend.
commitment_result verify_instances(const std::string &transaction_uid, const std::vector< sop_reference > &references)
std::atomic< size_t > actions_processed_
network::Result< std::monostate > handle_n_action(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request)
static std::vector< sop_reference > parse_referenced_sop_sequence(const core::dicom_dataset &dataset)
std::shared_ptr< storage::storage_interface > storage_
size_t instances_failed() const noexcept
network::Result< std::monostate > send_n_action_response(network::association &assoc, uint8_t context_id, uint16_t message_id, network::dimse::status_code status)
static core::dicom_dataset build_event_report_dataset(const commitment_result &result)
std::string_view service_name() const noexcept override
Get the service name for logging/debugging.
size_t instances_committed() const noexcept
size_t actions_processed() const noexcept
void reset_statistics() noexcept
std::vector< std::string > supported_sop_classes() const override
Get the list of SOP Class UIDs supported by this service.
std::atomic< size_t > instances_committed_
network::Result< std::monostate > send_event_report(network::association &assoc, uint8_t context_id, const commitment_result &result)
DIMSE command field enumeration.
Compile-time constants for commonly used DICOM tags.
@ UI
Unique Identifier (64 chars max)
@ US
Unsigned Short (2 bytes)
constexpr int storage_commitment_unexpected_command
uint16_t status_code
DIMSE status code type alias.
constexpr std::string_view storage_commitment_push_model_sop_instance_uid
Storage Commitment Push Model SOP Instance UID (Well-Known)
constexpr uint16_t storage_commitment_event_type_success
N-EVENT-REPORT: Storage Commitment Request Successful (Event Type ID = 1)
constexpr std::string_view storage_commitment_push_model_sop_class_uid
Storage Commitment Push Model SOP Class UID (PS3.4 Table J.3-1)
@ no_such_object_instance
Referenced SOP Instance not found in storage.
constexpr uint16_t storage_commitment_event_type_failure
N-EVENT-REPORT: Storage Commitment Request Complete - Failures Exist (Event Type ID = 2)
constexpr uint16_t storage_commitment_action_type_request
N-ACTION: Request Storage Commitment (Action Type ID = 1)
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
@ storage
Storage Service Class.
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 Commitment Push Model SCP service.
Result of a Storage Commitment verification.
std::chrono::system_clock::time_point timestamp
Timestamp when verification was completed.
std::vector< std::pair< sop_reference, commitment_failure_reason > > failed_references
Failed SOP Instance references with failure reasons.
std::vector< sop_reference > success_references
Successfully committed SOP Instance references.
std::string transaction_uid
Transaction UID identifying this commitment request.
Reference to a SOP Instance in a commitment request.
std::string sop_class_uid
Referenced SOP Class UID (0008,1150)
std::string sop_instance_uid
Referenced SOP Instance UID (0008,1155)