PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
prefetch_history_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
14#pragma once
15
18
19#ifdef PACS_WITH_DATABASE_SYSTEM
20
21namespace kcenon::pacs::storage {
22
26class prefetch_history_repository
27 : public base_repository<client::prefetch_history, int64_t> {
28public:
29 explicit prefetch_history_repository(
30 std::shared_ptr<pacs_database_adapter> db);
31
32 [[nodiscard]] auto find_by_patient(
33 std::string_view patient_id,
34 size_t limit = 100) -> list_result_type;
35
36 [[nodiscard]] auto find_by_study(std::string_view study_uid)
37 -> list_result_type;
38
39 [[nodiscard]] auto find_by_rule(
40 std::string_view rule_id,
41 size_t limit = 100) -> list_result_type;
42
43 [[nodiscard]] auto find_by_status(
44 std::string_view status,
45 size_t limit = 100) -> list_result_type;
46
47 [[nodiscard]] auto find_recent(size_t limit = 100) -> list_result_type;
48
49 [[nodiscard]] auto is_study_prefetched(std::string_view study_uid)
50 -> Result<bool>;
51
52 [[nodiscard]] auto count_by_status_on_current_date(
53 std::string_view status) -> Result<size_t>;
54
55 [[nodiscard]] auto update_status(
56 int64_t pk,
57 std::string_view status) -> VoidResult;
58
59 [[nodiscard]] auto cleanup_old(std::chrono::hours max_age)
60 -> Result<size_t>;
61
62protected:
63 [[nodiscard]] auto map_row_to_entity(const database_row& row) const
64 -> client::prefetch_history override;
65
66 [[nodiscard]] auto entity_to_row(const client::prefetch_history& entity) const
67 -> std::map<std::string, database_value> override;
68
69 [[nodiscard]] auto get_pk(const client::prefetch_history& entity) const
70 -> int64_t override;
71
72 [[nodiscard]] auto has_pk(const client::prefetch_history& entity) const
73 -> bool override;
74
75 [[nodiscard]] auto select_columns() const
76 -> std::vector<std::string> override;
77
78private:
79 [[nodiscard]] auto parse_timestamp(const std::string& str) const
80 -> std::chrono::system_clock::time_point;
81
82 [[nodiscard]] auto format_timestamp(
83 std::chrono::system_clock::time_point tp) const -> std::string;
84};
85
86} // namespace kcenon::pacs::storage
87
88#endif // PACS_WITH_DATABASE_SYSTEM
Generic base repository for CRUD operations.
Types and structures for prefetch manager.