PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
ups_push_scu.h
Go to the documentation of this file.
1
16#ifndef PACS_SERVICES_UPS_PUSH_SCU_HPP
17#define PACS_SERVICES_UPS_PUSH_SCU_HPP
18
19#include "ups_push_scp.h"
20
25
26#include <atomic>
27#include <chrono>
28#include <memory>
29#include <string>
30#include <vector>
31
32namespace kcenon::pacs::services {
33
34// =============================================================================
35// UPS SCU Data Structures
36// =============================================================================
37
46 std::string workitem_uid;
47
50
52 std::string worklist_label;
53
55 std::string priority{"MEDIUM"};
56
59
62
65
67 std::string input_information;
68};
69
82
88 std::string workitem_uid;
89
91 std::vector<core::dicom_tag> attribute_tags;
92};
93
99 std::string workitem_uid;
100
102 std::string requested_state;
103
105 std::string transaction_uid;
106};
107
113 std::string workitem_uid;
114
116 std::string reason;
117};
118
126 std::string workitem_uid;
127
129 uint16_t status{0};
130
132 std::string error_comment;
133
136
138 std::chrono::milliseconds elapsed{0};
139
141 [[nodiscard]] bool is_success() const noexcept {
142 return status == 0x0000;
143 }
144
146 [[nodiscard]] bool is_warning() const noexcept {
147 return (status & 0xF000) == 0xB000;
148 }
149
151 [[nodiscard]] bool is_error() const noexcept {
152 return !is_success() && !is_warning();
153 }
154};
155
161 std::chrono::milliseconds timeout{30000};
162
165};
166
167// =============================================================================
168// UPS Push SCU Class
169// =============================================================================
170
230public:
231 // =========================================================================
232 // Construction
233 // =========================================================================
234
240 explicit ups_push_scu(std::shared_ptr<di::ILogger> logger = nullptr);
241
248 explicit ups_push_scu(const ups_push_scu_config& config,
249 std::shared_ptr<di::ILogger> logger = nullptr);
250
251 ~ups_push_scu() = default;
252
253 // Non-copyable, non-movable (due to atomic members)
254 ups_push_scu(const ups_push_scu&) = delete;
258
259 // =========================================================================
260 // N-CREATE Operation
261 // =========================================================================
262
275 const ups_create_data& data);
276
277 // =========================================================================
278 // N-SET Operation
279 // =========================================================================
280
288 [[nodiscard]] network::Result<ups_result> set(
290 const ups_set_data& data);
291
292 // =========================================================================
293 // N-GET Operation
294 // =========================================================================
295
303 [[nodiscard]] network::Result<ups_result> get(
305 const ups_get_data& data);
306
307 // =========================================================================
308 // N-ACTION Operations
309 // =========================================================================
310
324 const ups_change_state_data& data);
325
335 const ups_request_cancel_data& data);
336
337 // =========================================================================
338 // Statistics
339 // =========================================================================
340
341 [[nodiscard]] size_t creates_performed() const noexcept;
342 [[nodiscard]] size_t sets_performed() const noexcept;
343 [[nodiscard]] size_t gets_performed() const noexcept;
344 [[nodiscard]] size_t actions_performed() const noexcept;
345
346 void reset_statistics() noexcept;
347
348private:
349 // =========================================================================
350 // Private Implementation
351 // =========================================================================
352
353 [[nodiscard]] core::dicom_dataset build_create_dataset(
354 const ups_create_data& data) const;
355
356 [[nodiscard]] core::dicom_dataset build_change_state_dataset(
357 const ups_change_state_data& data) const;
358
359 [[nodiscard]] core::dicom_dataset build_request_cancel_dataset(
360 const ups_request_cancel_data& data) const;
361
362 [[nodiscard]] std::string generate_workitem_uid() const;
363
364 [[nodiscard]] uint16_t next_message_id() noexcept;
365
366 // =========================================================================
367 // Private Members
368 // =========================================================================
369
370 std::shared_ptr<di::ILogger> logger_;
372 std::atomic<uint16_t> message_id_counter_{1};
373 std::atomic<size_t> creates_performed_{0};
374 std::atomic<size_t> sets_performed_{0};
375 std::atomic<size_t> gets_performed_{0};
376 std::atomic<size_t> actions_performed_{0};
377};
378
379} // namespace kcenon::pacs::services
380
381#endif // PACS_SERVICES_UPS_PUSH_SCU_HPP
DICOM Association management per PS3.8.
ups_push_scu(ups_push_scu &&)=delete
size_t creates_performed() const noexcept
network::Result< ups_result > request_cancel(network::association &assoc, const ups_request_cancel_data &data)
Request cancellation of a UPS workitem (N-ACTION Type 3)
std::atomic< size_t > gets_performed_
std::atomic< size_t > sets_performed_
ups_push_scu & operator=(ups_push_scu &&)=delete
core::dicom_dataset build_request_cancel_dataset(const ups_request_cancel_data &data) const
ups_push_scu(const ups_push_scu &)=delete
network::Result< ups_result > set(network::association &assoc, const ups_set_data &data)
Modify an existing UPS workitem (N-SET)
size_t sets_performed() const noexcept
size_t gets_performed() const noexcept
network::Result< ups_result > change_state(network::association &assoc, const ups_change_state_data &data)
Change UPS workitem state (N-ACTION Type 1)
std::atomic< size_t > actions_performed_
size_t actions_performed() const noexcept
ups_push_scu & operator=(const ups_push_scu &)=delete
ups_push_scu(std::shared_ptr< di::ILogger > logger=nullptr)
Construct UPS Push SCU with default configuration.
std::shared_ptr< di::ILogger > logger_
network::Result< ups_result > get(network::association &assoc, const ups_get_data &data)
Retrieve UPS workitem attributes from remote SCP (N-GET)
core::dicom_dataset build_create_dataset(const ups_create_data &data) const
core::dicom_dataset build_change_state_dataset(const ups_change_state_data &data) const
std::atomic< size_t > creates_performed_
std::atomic< uint16_t > message_id_counter_
network::Result< ups_result > create(network::association &assoc, const ups_create_data &data)
Create a new UPS workitem on the remote SCP (N-CREATE)
DICOM Dataset - ordered collection of Data Elements.
DIMSE message encoding and decoding.
Logger interface for dependency injection.
Data for N-ACTION Type 1 (change UPS state)
std::string requested_state
Requested new state: "IN PROGRESS", "COMPLETED", "CANCELED".
std::string workitem_uid
Workitem SOP Instance UID (required)
std::string transaction_uid
Transaction UID (required for claiming/completing/canceling)
Data for N-CREATE operation (create new workitem)
std::string priority
Priority: LOW, MEDIUM, HIGH.
std::string procedure_step_label
Procedure Step Label (required)
std::string input_information
Input Information (JSON serialized sequence data)
std::string scheduled_station_name
Scheduled Station Name AE.
std::string expected_completion_datetime
Expected completion date/time (DICOM DT format)
std::string workitem_uid
Workitem SOP Instance UID (generated if empty)
std::string worklist_label
Worklist Label.
std::string scheduled_start_datetime
Scheduled start date/time (DICOM DT format)
Data for N-GET operation (retrieve workitem)
std::string workitem_uid
Workitem SOP Instance UID (required)
std::vector< core::dicom_tag > attribute_tags
Specific attribute tags to retrieve (empty = all)
Configuration for UPS Push SCU service.
std::chrono::milliseconds timeout
Timeout for receiving DIMSE response.
bool auto_generate_uid
Auto-generate workitem UID if not provided.
Data for N-ACTION Type 3 (request cancellation)
std::string reason
Reason for cancellation request (optional)
std::string workitem_uid
Workitem SOP Instance UID (required)
Result of a UPS SCU operation.
std::chrono::milliseconds elapsed
Time taken for the operation.
bool is_success() const noexcept
Check if the operation was successful.
bool is_error() const noexcept
Check if this was an error status.
std::string workitem_uid
Workitem SOP Instance UID.
uint16_t status
DIMSE status code (0x0000 = success)
bool is_warning() const noexcept
Check if this was a warning status.
core::dicom_dataset attributes
Response dataset (for N-GET operations)
std::string error_comment
Error comment from the SCP (if any)
Data for N-SET operation (modify workitem attributes)
core::dicom_dataset modifications
Modification dataset.
std::string workitem_uid
Workitem SOP Instance UID (required)
DICOM UPS (Unified Procedure Step) Push SCP service.