53 using namespace network::dimse;
56 if (request.
command() != command_field::n_get_rq) {
59 "Unexpected command for N-GET SCP: " +
67 "No N-GET handler configured");
72 if (sop_class_uid.empty()) {
75 "",
"", status_error_missing_attribute);
82 sop_class_uid,
"", status_refused_sop_class_not_supported);
87 if (sop_instance_uid.empty()) {
90 sop_class_uid,
"", status_error_missing_attribute);
96 logger_->debug(
"N-GET request for instance: " + sop_instance_uid +
97 " (attributes requested: " +
98 (attribute_tags.empty() ?
"all" :
99 std::to_string(attribute_tags.size())) +
")");
102 auto result =
handler_(sop_class_uid, sop_instance_uid, attribute_tags);
103 if (result.is_err()) {
104 logger_->warn(
"N-GET handler failed for instance: " + sop_instance_uid +
105 " - " + result.error().message);
108 sop_class_uid, sop_instance_uid,
109 status_error_invalid_object_instance);
116 auto dataset = std::move(result.value());
119 sop_class_uid, sop_instance_uid,
120 status_success, &dataset);
147 const std::string& sop_class_uid,
148 const std::string& sop_instance_uid,
152 using namespace network::dimse;
155 auto response = make_n_get_rsp(
156 message_id, sop_class_uid, sop_instance_uid, status);
159 if (dataset !=
nullptr) {
160 response.set_dataset(std::move(*dataset));
164 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.
auto message_id() const noexcept -> uint16_t
Get the message ID.
auto attribute_identifier_list() const -> std::vector< core::dicom_tag >
Get the Attribute Identifier List (for N-GET)
auto requested_sop_class_uid() const -> std::string
Get the Requested SOP Class UID (for N-SET, N-GET, N-ACTION, N-DELETE)
auto requested_sop_instance_uid() const -> std::string
Get the Requested SOP Instance UID (for N-SET, N-GET, N-ACTION, N-DELETE)
auto command() const noexcept -> command_field
Get the command field.
std::vector< std::string > supported_sop_classes_
network::Result< std::monostate > send_n_get_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const std::string &sop_class_uid, const std::string &sop_instance_uid, network::dimse::status_code status, core::dicom_dataset *dataset=nullptr)
Send N-GET response.
void set_handler(n_get_handler handler)
Set the N-GET handler function.
std::atomic< size_t > gets_processed_
std::vector< std::string > supported_sop_classes() const override
Get supported SOP Class UIDs.
n_get_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct N-GET SCP with optional logger.
void reset_statistics() noexcept
Reset statistics counters.
size_t gets_processed() const noexcept
Get total number of N-GET requests processed.
network::Result< std::monostate > handle_message(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request) override
Handle an incoming N-GET-RQ message.
void add_supported_sop_class(std::string sop_class_uid)
Add a SOP Class UID that this SCP supports.
std::string_view service_name() const noexcept override
Get the service name.
bool supports_sop_class(std::string_view sop_class_uid) const
Check if this service supports a specific SOP Class.
std::shared_ptr< di::ILogger > logger_
Logger instance for service logging.
DIMSE command field enumeration.
DICOM N-GET SCP service for attribute retrieval.
constexpr int n_get_handler_not_set
constexpr int n_get_unexpected_command
uint16_t status_code
DIMSE status code type alias.
std::function< network::Result< core::dicom_dataset >( const std::string &sop_class_uid, const std::string &sop_instance_uid, const std::vector< core::dicom_tag > &attribute_tags)> n_get_handler
N-GET handler function type.
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.