61 using namespace network::dimse;
64 if (request.
command() != command_field::c_find_rq) {
67 "Expected C-FIND-RQ but received " +
75 "No worklist handler configured");
85 status_refused_sop_class_not_supported);
92 status_error_cannot_understand);
96 const auto& query_keys = request.
dataset().value().get();
102 auto results =
handler_(query_keys, calling_ae);
110 for (
const auto& result : results) {
127 if (send_result.is_err()) {
145 return "Worklist SCP";
175 using namespace network::dimse;
178 auto response = make_c_find_rsp(
185 response.set_dataset(result);
188 return assoc.
send_dimse(context_id, response);
197 using namespace network::dimse;
200 auto response = make_c_find_rsp(
207 return assoc.
send_dimse(context_id, response);
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.
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 command() const noexcept -> command_field
Get the command field.
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.
worklist_handler handler_
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.
DIMSE command field enumeration.
Compile-time constants for commonly used DICOM tags.
constexpr int worklist_handler_not_set
constexpr int worklist_unexpected_command
uint16_t status_code
DIMSE status code type alias.
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.
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
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 Modality Worklist SCP service (MWL C-FIND handler)