PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
recent_study_repository.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#pragma once
19
22
23#ifdef PACS_WITH_DATABASE_SYSTEM
24
25namespace kcenon::pacs::storage {
26
51class recent_study_repository
52 : public base_repository<recent_study_record, int64_t> {
53public:
59 explicit recent_study_repository(std::shared_ptr<pacs_database_adapter> db);
60
61 // =========================================================================
62 // Domain-Specific Queries
63 // =========================================================================
64
75 [[nodiscard]] auto record_access(
76 std::string_view user_id,
77 std::string_view study_uid) -> VoidResult;
78
86 [[nodiscard]] auto find_by_user(
87 std::string_view user_id,
88 size_t limit = 20) -> list_result_type;
89
96 [[nodiscard]] auto clear_for_user(std::string_view user_id) -> VoidResult;
97
104 [[nodiscard]] auto count_for_user(std::string_view user_id)
105 -> Result<size_t>;
106
114 [[nodiscard]] auto was_recently_accessed(
115 std::string_view user_id,
116 std::string_view study_uid) -> Result<bool>;
117
118protected:
119 // =========================================================================
120 // base_repository Overrides
121 // =========================================================================
122
123 [[nodiscard]] auto map_row_to_entity(const database_row& row) const
124 -> recent_study_record override;
125
126 [[nodiscard]] auto entity_to_row(const recent_study_record& entity) const
127 -> std::map<std::string, database_value> override;
128
129 [[nodiscard]] auto get_pk(const recent_study_record& entity) const
130 -> int64_t override;
131
132 [[nodiscard]] auto has_pk(const recent_study_record& entity) const
133 -> bool override;
134
135 [[nodiscard]] auto select_columns() const
136 -> std::vector<std::string> override;
137
138private:
139 [[nodiscard]] auto parse_timestamp(const std::string& str) const
140 -> std::chrono::system_clock::time_point;
141
142 [[nodiscard]] auto format_timestamp(
143 std::chrono::system_clock::time_point tp) const -> std::string;
144};
145
146} // namespace kcenon::pacs::storage
147
148#endif // PACS_WITH_DATABASE_SYSTEM
Generic base repository for CRUD operations.
Viewer state record data structures for database operations.