PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
status_codes.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
18#ifndef PACS_NETWORK_DIMSE_STATUS_CODES_HPP
19#define PACS_NETWORK_DIMSE_STATUS_CODES_HPP
20
21#include <cstdint>
22#include <string_view>
23
25
32using status_code = uint16_t;
33
36
38constexpr status_code status_success = 0x0000;
39
41constexpr status_code status_pending = 0xFF00;
42
44constexpr status_code status_pending_warning = 0xFF01;
45
47constexpr status_code status_cancel = 0xFE00;
48
50
53
55constexpr status_code status_refused_out_of_resources = 0xA700;
56
58constexpr status_code status_refused_out_of_resources_matches = 0xA701;
59
61constexpr status_code status_refused_out_of_resources_subops = 0xA702;
62
64constexpr status_code status_refused_move_destination_unknown = 0xA801;
65
67constexpr status_code status_refused_sop_class_not_supported = 0x0122;
68
70constexpr status_code status_error_dataset_mismatch = 0xA900;
71
73constexpr status_code status_error_cannot_understand = 0xC000;
74
76constexpr status_code status_error_unable_to_process = 0xC001;
77
79constexpr status_code status_error_duplicate_sop_instance = 0x0111;
80
82constexpr status_code status_error_missing_attribute = 0x0120;
83
85constexpr status_code status_error_missing_attribute_value = 0x0121;
86
88
91
94
97
100
103
106
109
112
115
118
121
124
127
130
132
135
137constexpr status_code status_warning_coercion = 0xB000;
138
140constexpr status_code status_warning_dataset_mismatch = 0xB007;
141
143constexpr status_code status_warning_elements_discarded = 0xB006;
144
147
149
152
158[[nodiscard]] constexpr bool is_success(status_code status) noexcept {
159 return status == status_success;
160}
161
167[[nodiscard]] constexpr bool is_pending(status_code status) noexcept {
168 return status == status_pending || status == status_pending_warning;
169}
170
176[[nodiscard]] constexpr bool is_cancel(status_code status) noexcept {
177 return status == status_cancel;
178}
179
185[[nodiscard]] constexpr bool is_warning(status_code status) noexcept {
186 return (status & 0xF000) == 0xB000;
187}
188
197[[nodiscard]] constexpr bool is_failure(status_code status) noexcept {
198 const auto high_nibble = (status & 0xF000) >> 12;
199 return high_nibble == 0xA || high_nibble == 0xC ||
200 (status >= 0x0100 && status <= 0x02FF);
201}
202
208[[nodiscard]] constexpr bool is_final(status_code status) noexcept {
209 return !is_pending(status);
210}
211
213
216
222[[nodiscard]] constexpr std::string_view status_description(
223 status_code status) noexcept {
224 switch (status) {
225 case status_success: return "Success";
226 case status_pending: return "Pending";
227 case status_pending_warning: return "Pending (Warning)";
228 case status_cancel: return "Canceled";
229 case status_refused_out_of_resources: return "Refused: Out of resources";
231 return "Refused: Unable to calculate number of matches";
233 return "Refused: Unable to perform sub-operations";
235 return "Refused: Move destination unknown";
237 return "Refused: SOP class not supported";
239 return "Error: Data set does not match SOP class";
240 case status_error_cannot_understand: return "Error: Cannot understand";
241 case status_error_unable_to_process: return "Error: Unable to process";
243 return "Error: Duplicate SOP instance";
244 case status_error_missing_attribute: return "Error: Missing attribute";
246 return "Error: Missing attribute value";
248 return "Error: Attribute list error";
250 return "Error: Attribute value out of range";
252 return "Error: Invalid object instance";
254 return "Error: No such SOP class";
256 return "Error: Class-instance conflict";
258 return "Error: Not authorized";
260 return "Error: Duplicate invocation";
262 return "Error: Unrecognized operation";
264 return "Error: Mistyped argument";
266 return "Error: Resource limitation";
268 return "Error: No such action type";
270 return "Error: No such event type";
272 return "Error: Processing failure";
273 case status_warning_coercion: return "Warning: Coercion of data elements";
275 return "Warning: Data set does not match SOP class";
277 return "Warning: Elements discarded";
278 default:
279 if (is_success(status)) return "Success";
280 if (is_pending(status)) return "Pending";
281 if (is_warning(status)) return "Warning";
282 if (is_failure(status)) return "Failure";
283 return "Unknown status";
284 }
285}
286
292[[nodiscard]] constexpr std::string_view status_category(
293 status_code status) noexcept {
294 if (is_success(status)) return "Success";
295 if (is_pending(status)) return "Pending";
296 if (is_cancel(status)) return "Cancel";
297 if (is_warning(status)) return "Warning";
298 if (is_failure(status)) return "Failure";
299 return "Unknown";
300}
301
303
304} // namespace kcenon::pacs::network::dimse
305
306#endif // PACS_NETWORK_DIMSE_STATUS_CODES_HPP
constexpr status_code status_refused_sop_class_not_supported
Refused: SOP class not supported.
constexpr status_code status_error_duplicate_sop_instance
Error: Duplicate SOP instance.
constexpr status_code status_pending
Operation pending (more results available)
constexpr status_code status_refused_out_of_resources_matches
Refused: Out of resources - Unable to calculate number of matches.
constexpr status_code status_error_attribute_value_out_of_range
Error: Attribute value out of range (N-SET)
constexpr status_code status_warning_elements_discarded
Warning: Elements discarded.
constexpr status_code status_error_no_such_action_type
Error: No such action type (N-ACTION)
constexpr status_code status_refused_out_of_resources_subops
Refused: Out of resources - Unable to perform sub-operations.
constexpr status_code status_error_attribute_list_error
Error: Attribute list error (N-CREATE)
constexpr bool is_warning(status_code status) noexcept
Check if status indicates a warning.
constexpr status_code status_error_dataset_mismatch
Error: Data set does not match SOP class.
constexpr status_code status_error_no_such_event_type
Error: No such event type (N-EVENT-REPORT)
constexpr status_code status_warning_dataset_mismatch
Warning: Data set does not match SOP class (non-fatal)
constexpr std::string_view status_description(status_code status) noexcept
Get a human-readable description of a status code.
constexpr bool is_cancel(status_code status) noexcept
Check if status indicates cancellation.
constexpr status_code status_warning_coercion
Warning: Coercion of data elements.
constexpr status_code status_warning_subops_complete_failures
Warning: Sub-operations complete with failures.
constexpr status_code status_error_unable_to_process
Error: Unable to process.
constexpr status_code status_refused_out_of_resources
Refused: Out of resources.
constexpr bool is_final(status_code status) noexcept
Check if this is a final status (operation complete)
constexpr status_code status_error_mistyped_argument
Error: Mistyped argument (All DIMSE-N)
constexpr status_code status_error_invalid_object_instance
Error: Invalid object instance (N-SET, N-GET, N-ACTION, N-DELETE)
constexpr status_code status_error_missing_attribute
Error: Missing attribute.
constexpr status_code status_error_missing_attribute_value
Error: Missing attribute value.
constexpr status_code status_success
Operation completed successfully.
constexpr status_code status_error_class_instance_conflict
Error: Class-instance conflict (All DIMSE-N)
constexpr bool is_success(status_code status) noexcept
Check if status indicates success.
constexpr status_code status_error_no_such_sop_class
Error: No such SOP class (All DIMSE-N)
constexpr status_code status_pending_warning
Pending with optional keys not supported.
constexpr bool is_pending(status_code status) noexcept
Check if status indicates pending (more results)
constexpr bool is_failure(status_code status) noexcept
Check if status indicates a failure.
constexpr status_code status_error_not_authorized
Error: Not authorized (All DIMSE-N)
constexpr status_code status_error_unrecognized_operation
Error: Unrecognized operation (All DIMSE-N)
constexpr status_code status_error_cannot_understand
Error: Cannot understand.
constexpr std::string_view status_category(status_code status) noexcept
Get the category name for a status code.
constexpr status_code status_error_resource_limitation
Error: Resource limitation (All DIMSE-N)
constexpr status_code status_cancel
Operation was canceled.
uint16_t status_code
DIMSE status code type alias.
constexpr status_code status_error_duplicate_invocation
Error: Duplicate invocation (All DIMSE-N)
constexpr status_code status_refused_move_destination_unknown
Refused: Move destination unknown.
constexpr status_code status_error_processing_failure
Error: Processing failure (All DIMSE-N)