PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
audit_record.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
17#pragma once
18
19#include <chrono>
20#include <optional>
21#include <string>
22
23namespace kcenon::pacs::storage {
24
45
49[[nodiscard]] inline auto to_string(audit_event_type type) -> std::string {
50 switch (type) {
52 return "ASSOCIATION_ESTABLISHED";
54 return "ASSOCIATION_RELEASED";
56 return "C_STORE";
58 return "C_FIND";
60 return "C_MOVE";
62 return "C_GET";
64 return "SECURITY_EVENT";
66 return "CONFIGURATION_CHANGE";
68 return "SYSTEM_STARTUP";
70 return "SYSTEM_SHUTDOWN";
72 return "USER_LOGIN";
74 return "USER_LOGOUT";
76 return "DATA_ACCESS";
78 return "DATA_EXPORT";
80 return "ERROR";
81 default:
82 return "UNKNOWN";
83 }
84}
85
89[[nodiscard]] inline auto parse_audit_event_type(std::string_view str)
90 -> std::optional<audit_event_type> {
91 if (str == "ASSOCIATION_ESTABLISHED") {
93 }
94 if (str == "ASSOCIATION_RELEASED") {
96 }
97 if (str == "C_STORE") {
99 }
100 if (str == "C_FIND") {
102 }
103 if (str == "C_MOVE") {
105 }
106 if (str == "C_GET") {
108 }
109 if (str == "SECURITY_EVENT") {
111 }
112 if (str == "CONFIGURATION_CHANGE") {
114 }
115 if (str == "SYSTEM_STARTUP") {
117 }
118 if (str == "SYSTEM_SHUTDOWN") {
120 }
121 if (str == "USER_LOGIN") {
123 }
124 if (str == "USER_LOGOUT") {
126 }
127 if (str == "DATA_ACCESS") {
129 }
130 if (str == "DATA_EXPORT") {
132 }
133 if (str == "ERROR") {
135 }
136 return std::nullopt;
137}
138
142enum class audit_outcome {
143 success,
144 failure,
145 warning
146};
147
151[[nodiscard]] inline auto to_string(audit_outcome outcome) -> std::string {
152 switch (outcome) {
154 return "SUCCESS";
156 return "FAILURE";
158 return "WARNING";
159 default:
160 return "UNKNOWN";
161 }
162}
163
172 int64_t pk{0};
173
175 std::string event_type;
176
178 std::string outcome;
179
181 std::chrono::system_clock::time_point timestamp;
182
184 std::string user_id;
185
187 std::string source_ae;
188
190 std::string target_ae;
191
193 std::string source_ip;
194
196 std::string patient_id;
197
199 std::string study_uid;
200
202 std::string message;
203
205 std::string details;
206
210 [[nodiscard]] auto is_valid() const noexcept -> bool {
211 return !event_type.empty();
212 }
213};
214
220 std::optional<std::string> event_type;
221
223 std::optional<std::string> outcome;
224
226 std::optional<std::string> user_id;
227
229 std::optional<std::string> source_ae;
230
232 std::optional<std::string> patient_id;
233
235 std::optional<std::string> study_uid;
236
238 std::optional<std::string> date_from;
239
241 std::optional<std::string> date_to;
242
244 size_t limit{0};
245
247 size_t offset{0};
248
252 [[nodiscard]] auto has_criteria() const noexcept -> bool {
253 return event_type.has_value() || outcome.has_value() ||
254 user_id.has_value() || source_ae.has_value() ||
255 patient_id.has_value() || study_uid.has_value() ||
256 date_from.has_value() || date_to.has_value();
257 }
258};
259
260} // namespace kcenon::pacs::storage
auto parse_audit_event_type(std::string_view str) -> std::optional< audit_event_type >
Parse string to audit_event_type enum.
audit_outcome
Audit log outcome/status.
auto to_string(annotation_type type) -> std::string
Convert annotation_type to string.
audit_event_type
Audit event type enumeration.
Query parameters for audit log search.
std::optional< std::string > user_id
User ID filter (supports wildcards with '*')
size_t limit
Maximum number of results to return (0 = unlimited)
std::optional< std::string > study_uid
Study UID filter (exact match)
std::optional< std::string > date_from
Date range begin (inclusive, format: YYYY-MM-DD or YYYYMMDD)
std::optional< std::string > event_type
Event type filter (exact match)
std::optional< std::string > source_ae
Source AE filter (exact match)
size_t offset
Offset for pagination.
std::optional< std::string > date_to
Date range end (inclusive, format: YYYY-MM-DD or YYYYMMDD)
std::optional< std::string > outcome
Outcome filter (exact match)
auto has_criteria() const noexcept -> bool
Check if any filter criteria is set.
std::optional< std::string > patient_id
Patient ID filter (exact match)
Audit log record from the database.
std::string outcome
Outcome/status of the event.
std::string event_type
Event type.
std::string user_id
User ID or AE Title that initiated the action.
std::string patient_id
Patient ID (if applicable)
std::string details
Additional details in JSON format.
std::string message
Human-readable message.
auto is_valid() const noexcept -> bool
Check if this record has valid data.
std::chrono::system_clock::time_point timestamp
Timestamp of the event.
std::string source_ae
Source AE Title (for DICOM operations)
std::string study_uid
Study Instance UID (if applicable)
std::string target_ae
Target/Called AE Title (for DICOM operations)
std::string source_ip
Source IP address.
int64_t pk
Primary key (auto-generated)