PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
worklist_scp.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
20#ifndef PACS_SERVICES_WORKLIST_SCP_HPP
21#define PACS_SERVICES_WORKLIST_SCP_HPP
22
23#include "scp_service.h"
24
25#include <atomic>
26#include <functional>
27
28namespace kcenon::pacs::services {
29
30// =============================================================================
31// SOP Class UIDs (re-exported for convenience)
32// =============================================================================
33
35inline constexpr std::string_view worklist_find_sop_class_uid =
36 "1.2.840.10008.5.1.4.31";
37
38// =============================================================================
39// Worklist Handler Type
40// =============================================================================
41
85using worklist_handler = std::function<std::vector<core::dicom_dataset>(
86 const core::dicom_dataset& query_keys,
87 const std::string& calling_ae)>;
88
97using worklist_cancel_check = std::function<bool()>;
98
99// =============================================================================
100// Worklist SCP Class
101// =============================================================================
102
192class worklist_scp final : public scp_service {
193public:
194 // =========================================================================
195 // Construction
196 // =========================================================================
197
203 explicit worklist_scp(std::shared_ptr<di::ILogger> logger = nullptr);
204
205 ~worklist_scp() override = default;
206
207 // =========================================================================
208 // Configuration
209 // =========================================================================
210
219 void set_handler(worklist_handler handler);
220
226 void set_max_results(size_t max) noexcept;
227
233 [[nodiscard]] size_t max_results() const noexcept;
234
244
245 // =========================================================================
246 // scp_service Interface Implementation
247 // =========================================================================
248
254 [[nodiscard]] std::vector<std::string> supported_sop_classes() const override;
255
268 [[nodiscard]] network::Result<std::monostate> handle_message(
269 network::association& assoc,
270 uint8_t context_id,
271 const network::dimse::dimse_message& request) override;
272
278 [[nodiscard]] std::string_view service_name() const noexcept override;
279
280 // =========================================================================
281 // Statistics
282 // =========================================================================
283
289 [[nodiscard]] size_t queries_processed() const noexcept;
290
296 [[nodiscard]] size_t items_returned() const noexcept;
297
301 void reset_statistics() noexcept;
302
303private:
304 // =========================================================================
305 // Private Implementation
306 // =========================================================================
307
317 [[nodiscard]] network::Result<std::monostate> send_pending_response(
318 network::association& assoc,
319 uint8_t context_id,
320 uint16_t message_id,
321 const core::dicom_dataset& result);
322
332 [[nodiscard]] network::Result<std::monostate> send_final_response(
333 network::association& assoc,
334 uint8_t context_id,
335 uint16_t message_id,
336 network::dimse::status_code status);
337
338 // =========================================================================
339 // Member Variables
340 // =========================================================================
341
344 size_t max_results_{0}; // 0 = unlimited
345 std::atomic<size_t> queries_processed_{0};
346 std::atomic<size_t> items_returned_{0};
347};
348
349} // namespace kcenon::pacs::services
350
351#endif // PACS_SERVICES_WORKLIST_SCP_HPP
const std::shared_ptr< di::ILogger > & logger() const noexcept
Get the current logger instance.
Definition scp_service.h:93
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 (MWL C-FIND-RQ)
size_t items_returned() const noexcept
Get total number of worklist items returned.
void set_max_results(size_t max) noexcept
Set maximum number of results to return.
network::Result< std::monostate > send_final_response(network::association &assoc, uint8_t context_id, uint16_t message_id, network::dimse::status_code status)
Send the final C-FIND response (success or cancel)
void reset_statistics() noexcept
Reset statistics counters.
std::string_view service_name() const noexcept override
Get the service name.
std::atomic< size_t > items_returned_
network::Result< std::monostate > send_pending_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const core::dicom_dataset &result)
Send a pending C-FIND response with matching worklist item.
size_t max_results() const noexcept
Get maximum number of results.
worklist_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct Worklist SCP with optional logger.
std::atomic< size_t > queries_processed_
worklist_cancel_check cancel_check_
size_t queries_processed() const noexcept
Get total number of worklist queries processed.
void set_handler(worklist_handler handler)
Set the worklist handler function.
void set_cancel_check(worklist_cancel_check check)
Set the cancel check function.
std::vector< std::string > supported_sop_classes() const override
Get supported SOP Class UIDs.
std::function< bool()> worklist_cancel_check
Cancel check function type.
std::function< std::vector< core::dicom_dataset >( const core::dicom_dataset &query_keys, const std::string &calling_ae)> worklist_handler
constexpr std::string_view worklist_find_sop_class_uid
Modality Worklist Information Model - FIND SOP Class UID.
Base class for DICOM SCP (Service Class Provider) services.