57 using namespace network::dimse;
60 if (request.
command() != command_field::c_find_rq) {
63 "Expected C-FIND-RQ but received " +
71 "No UPS query handler configured");
81 status_refused_sop_class_not_supported);
88 status_error_cannot_understand);
92 const auto& query_keys = request.
dataset().value().get();
97 logger_->debug(
"Processing UPS C-FIND query from " + calling_ae);
100 auto results =
handler_(query_keys, calling_ae);
108 for (
const auto& result : results) {
123 if (send_result.is_err()) {
133 logger_->info(
"UPS C-FIND completed: " + std::to_string(results.size()) +
134 " workitems matched");
143 return "UPS Query SCP";
173 using namespace network::dimse;
175 auto response = make_c_find_rsp(
181 response.set_dataset(result);
183 return assoc.
send_dimse(context_id, response);
192 using namespace network::dimse;
194 auto response = make_c_find_rsp(
200 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.
std::shared_ptr< di::ILogger > logger_
Logger instance for service logging.
std::string_view service_name() const noexcept override
Get the service name for logging/debugging.
network::Result< std::monostate > send_pending_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const core::dicom_dataset &result)
network::Result< std::monostate > send_final_response(network::association &assoc, uint8_t context_id, uint16_t message_id, network::dimse::status_code status)
std::atomic< size_t > items_returned_
void set_max_results(size_t max) noexcept
void set_cancel_check(ups_query_cancel_check check)
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.
void set_handler(ups_query_handler handler)
size_t queries_processed() const noexcept
ups_query_handler handler_
std::vector< std::string > supported_sop_classes() const override
Get the list of SOP Class UIDs supported by this service.
size_t items_returned() const noexcept
ups_query_cancel_check cancel_check_
size_t max_results() const noexcept
ups_query_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct UPS Query SCP with optional logger.
void reset_statistics() noexcept
std::atomic< size_t > queries_processed_
DIMSE command field enumeration.
Compile-time constants for commonly used DICOM tags.
constexpr int ups_unexpected_command
constexpr int ups_handler_not_set
uint16_t status_code
DIMSE status code type alias.
std::function< bool()> ups_query_cancel_check
Cancel check function type for UPS queries.
std::function< std::vector< core::dicom_dataset >( const core::dicom_dataset &query_keys, const std::string &calling_ae)> ups_query_handler
UPS query handler function type.
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
constexpr std::string_view ups_query_find_sop_class_uid
UPS Query Information Model - FIND SOP Class UID (PS3.4 Table CC.2-1)
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 UPS Query SCP service (C-FIND handler for UPS workitems)