|
PACS System 0.1.0
PACS DICOM system library
|
#include <index_database.h>

Classes | |
| struct | storage_stats |
| Storage statistics structure. More... | |
Public Member Functions | |
| ~index_database () | |
| Destructor - closes database connection. | |
| index_database (const index_database &)=delete | |
| auto | operator= (const index_database &) -> index_database &=delete |
| index_database (index_database &&) noexcept | |
| auto | operator= (index_database &&) noexcept -> index_database & |
| auto | upsert_patient (std::string_view patient_id, std::string_view patient_name="", std::string_view birth_date="", std::string_view sex="") -> Result< int64_t > |
| Insert or update a patient record. | |
| auto | upsert_patient (const patient_record &record) -> Result< int64_t > |
| Insert or update a patient record with full details. | |
| auto | find_patient (std::string_view patient_id) const -> std::optional< patient_record > |
| Find a patient by patient ID. | |
| auto | find_patient_by_pk (int64_t pk) const -> std::optional< patient_record > |
| Find a patient by primary key. | |
| auto | search_patients (const patient_query &query) const -> Result< std::vector< patient_record > > |
| Search patients with query criteria. | |
| auto | delete_patient (std::string_view patient_id) -> VoidResult |
| Delete a patient by patient ID. | |
| auto | patient_count () const -> Result< size_t > |
| Get total patient count. | |
| auto | upsert_study (int64_t patient_pk, std::string_view study_uid, std::string_view study_id="", std::string_view study_date="", std::string_view study_time="", std::string_view accession_number="", std::string_view referring_physician="", std::string_view study_description="") -> Result< int64_t > |
| Insert or update a study record. | |
| auto | upsert_study (const study_record &record) -> Result< int64_t > |
| Insert or update a study record with full details. | |
| auto | find_study (std::string_view study_uid) const -> std::optional< study_record > |
| Find a study by Study Instance UID. | |
| auto | find_study_by_pk (int64_t pk) const -> std::optional< study_record > |
| Find a study by primary key. | |
| auto | list_studies (std::string_view patient_id) const -> Result< std::vector< study_record > > |
| List all studies for a patient. | |
| auto | search_studies (const study_query &query) const -> Result< std::vector< study_record > > |
| Search studies with query criteria. | |
| auto | delete_study (std::string_view study_uid) -> VoidResult |
| Delete a study by Study Instance UID. | |
| auto | study_count () const -> Result< size_t > |
| Get total study count. | |
| auto | study_count (std::string_view patient_id) const -> Result< size_t > |
| Get study count for a specific patient. | |
| auto | update_modalities_in_study (int64_t study_pk) -> VoidResult |
| Update modalities in study (denormalized field) | |
| auto | upsert_series (int64_t study_pk, std::string_view series_uid, std::string_view modality="", std::optional< int > series_number=std::nullopt, std::string_view series_description="", std::string_view body_part_examined="", std::string_view station_name="") -> Result< int64_t > |
| Insert or update a series record. | |
| auto | upsert_series (const series_record &record) -> Result< int64_t > |
| Insert or update a series record with full details. | |
| auto | find_series (std::string_view series_uid) const -> std::optional< series_record > |
| Find a series by Series Instance UID. | |
| auto | find_series_by_pk (int64_t pk) const -> std::optional< series_record > |
| Find a series by primary key. | |
| auto | list_series (std::string_view study_uid) const -> Result< std::vector< series_record > > |
| List all series for a study. | |
| auto | search_series (const series_query &query) const -> Result< std::vector< series_record > > |
| Search series with query criteria. | |
| auto | delete_series (std::string_view series_uid) -> VoidResult |
| Delete a series by Series Instance UID. | |
| auto | series_count () const -> Result< size_t > |
| Get total series count. | |
| auto | series_count (std::string_view study_uid) const -> Result< size_t > |
| Get series count for a specific study. | |
| auto | upsert_instance (int64_t series_pk, std::string_view sop_uid, std::string_view sop_class_uid, std::string_view file_path, int64_t file_size, std::string_view transfer_syntax="", std::optional< int > instance_number=std::nullopt) -> Result< int64_t > |
| Insert or update an instance record. | |
| auto | upsert_instance (const instance_record &record) -> Result< int64_t > |
| Insert or update an instance record with full details. | |
| auto | find_instance (std::string_view sop_uid) const -> std::optional< instance_record > |
| Find an instance by SOP Instance UID. | |
| auto | find_instance_by_pk (int64_t pk) const -> std::optional< instance_record > |
| Find an instance by primary key. | |
| auto | list_instances (std::string_view series_uid) const -> Result< std::vector< instance_record > > |
| List all instances for a series. | |
| auto | search_instances (const instance_query &query) const -> Result< std::vector< instance_record > > |
| Search instances with query criteria. | |
| auto | delete_instance (std::string_view sop_uid) -> VoidResult |
| Delete an instance by SOP Instance UID. | |
| auto | instance_count () const -> Result< size_t > |
| Get total instance count. | |
| auto | instance_count (std::string_view series_uid) const -> Result< size_t > |
| Get instance count for a specific series. | |
| auto | create_mpps (std::string_view mpps_uid, std::string_view station_ae="", std::string_view modality="", std::string_view study_uid="", std::string_view accession_no="", std::string_view start_datetime="") -> Result< int64_t > |
| Create a new MPPS record (N-CREATE) | |
| auto | create_mpps (const mpps_record &record) -> Result< int64_t > |
| Create a new MPPS record with full details. | |
| auto | update_mpps (std::string_view mpps_uid, std::string_view new_status, std::string_view end_datetime="", std::string_view performed_series="") -> VoidResult |
| Update an existing MPPS record (N-SET) | |
| auto | update_mpps (const mpps_record &record) -> VoidResult |
| Update an existing MPPS record with partial data. | |
| auto | find_mpps (std::string_view mpps_uid) const -> std::optional< mpps_record > |
| Find an MPPS by SOP Instance UID. | |
| auto | find_mpps_by_pk (int64_t pk) const -> std::optional< mpps_record > |
| Find an MPPS by primary key. | |
| auto | list_active_mpps (std::string_view station_ae) const -> Result< std::vector< mpps_record > > |
| List active (IN PROGRESS) MPPS records for a station. | |
| auto | find_mpps_by_study (std::string_view study_uid) const -> Result< std::vector< mpps_record > > |
| Find MPPS records by Study Instance UID. | |
| auto | search_mpps (const mpps_query &query) const -> Result< std::vector< mpps_record > > |
| Search MPPS records with query criteria. | |
| auto | delete_mpps (std::string_view mpps_uid) -> VoidResult |
| Delete an MPPS record. | |
| auto | mpps_count () const -> Result< size_t > |
| Get total MPPS count. | |
| auto | mpps_count (std::string_view status) const -> Result< size_t > |
| Get MPPS count by status. | |
| auto | add_worklist_item (const worklist_item &item) -> Result< int64_t > |
| Add a new worklist item. | |
| auto | update_worklist_status (std::string_view step_id, std::string_view accession_no, std::string_view new_status) -> VoidResult |
| Update worklist item status. | |
| auto | query_worklist (const worklist_query &query) const -> Result< std::vector< worklist_item > > |
| Query worklist items. | |
| auto | find_worklist_item (std::string_view step_id, std::string_view accession_no) const -> std::optional< worklist_item > |
| Find a worklist item by step ID and accession number. | |
| auto | find_worklist_by_pk (int64_t pk) const -> std::optional< worklist_item > |
| Find a worklist item by primary key. | |
| auto | delete_worklist_item (std::string_view step_id, std::string_view accession_no) -> VoidResult |
| Delete a worklist item. | |
| auto | cleanup_old_worklist_items (std::chrono::hours age) -> Result< size_t > |
| Cleanup old worklist items. | |
| auto | cleanup_worklist_items_before (std::chrono::system_clock::time_point before) -> Result< size_t > |
| auto | worklist_count () const -> Result< size_t > |
| Get total worklist count. | |
| auto | worklist_count (std::string_view status) const -> Result< size_t > |
| Get worklist count by status. | |
| auto | create_ups_workitem (const ups_workitem &workitem) -> Result< int64_t > |
| Create a new UPS workitem (N-CREATE) | |
| auto | update_ups_workitem (const ups_workitem &workitem) -> VoidResult |
| Update an existing UPS workitem. | |
| auto | change_ups_state (std::string_view workitem_uid, std::string_view new_state, std::string_view transaction_uid="") -> VoidResult |
| Change UPS workitem state. | |
| auto | find_ups_workitem (std::string_view workitem_uid) const -> std::optional< ups_workitem > |
| Find a UPS workitem by SOP Instance UID. | |
| auto | search_ups_workitems (const ups_workitem_query &query) const -> Result< std::vector< ups_workitem > > |
| Search UPS workitems with query criteria. | |
| auto | delete_ups_workitem (std::string_view workitem_uid) -> VoidResult |
| Delete a UPS workitem. | |
| auto | ups_workitem_count () const -> Result< size_t > |
| Get total UPS workitem count. | |
| auto | ups_workitem_count (std::string_view state) const -> Result< size_t > |
| Get UPS workitem count by state. | |
| auto | subscribe_ups (const ups_subscription &subscription) -> Result< int64_t > |
| Subscribe to UPS workitem events. | |
| auto | unsubscribe_ups (std::string_view subscriber_ae, std::string_view workitem_uid="") -> VoidResult |
| Unsubscribe from UPS workitem events. | |
| auto | get_ups_subscriptions (std::string_view subscriber_ae) const -> Result< std::vector< ups_subscription > > |
| Get all subscriptions for a subscriber. | |
| auto | get_ups_subscribers (std::string_view workitem_uid) const -> Result< std::vector< std::string > > |
| Get all subscribers for a workitem. | |
| auto | add_audit_log (const audit_record &record) -> Result< int64_t > |
| Add a new audit log entry. | |
| auto | query_audit_log (const audit_query &query) const -> Result< std::vector< audit_record > > |
| Query audit log entries. | |
| auto | find_audit_by_pk (int64_t pk) const -> std::optional< audit_record > |
| Find an audit log entry by primary key. | |
| auto | audit_count () const -> Result< size_t > |
| Get total audit log count. | |
| auto | cleanup_old_audit_logs (std::chrono::hours age) -> Result< size_t > |
| Cleanup old audit log entries. | |
| auto | path () const -> std::string_view |
| Get the database file path. | |
| auto | schema_version () const -> int |
| Get the current schema version. | |
| auto | is_open () const noexcept -> bool |
| Check if the database is open. | |
| auto | get_file_path (std::string_view sop_instance_uid) const -> Result< std::optional< std::string > > |
| Get file path for a SOP Instance UID. | |
| auto | get_study_files (std::string_view study_instance_uid) const -> Result< std::vector< std::string > > |
| Get all file paths for a study. | |
| auto | get_series_files (std::string_view series_instance_uid) const -> Result< std::vector< std::string > > |
| Get all file paths for a series. | |
| auto | vacuum () -> VoidResult |
| Reclaim unused space in the database. | |
| auto | analyze () -> VoidResult |
| Update database statistics for query optimization. | |
| auto | verify_integrity () const -> VoidResult |
| Verify database integrity. | |
| auto | native_handle () const noexcept -> sqlite3 * |
| Get the raw SQLite database handle. | |
| auto | checkpoint (bool truncate=false) -> VoidResult |
| Checkpoint WAL file. | |
| auto | get_storage_stats () const -> Result< storage_stats > |
| Get storage statistics. | |
Static Public Member Functions | |
| static auto | open (std::string_view db_path) -> Result< std::unique_ptr< index_database > > |
| Open or create a database with default configuration. | |
| static auto | open (std::string_view db_path, const index_config &config) -> Result< std::unique_ptr< index_database > > |
| Open or create a database with custom configuration. | |
Private Member Functions | |
| index_database (sqlite3 *db, std::string path) | |
| Private constructor - use open() factory method. | |
| auto | parse_patient_row (void *stmt) const -> patient_record |
| Parse a patient record from a prepared statement. | |
| auto | parse_study_row (void *stmt) const -> study_record |
| Parse a study record from a prepared statement. | |
| auto | parse_series_row (void *stmt) const -> series_record |
| Parse a series record from a prepared statement. | |
| auto | parse_instance_row (void *stmt) const -> instance_record |
| Parse an instance record from a prepared statement. | |
| auto | parse_mpps_row (void *stmt) const -> mpps_record |
| Parse an MPPS record from a prepared statement. | |
| auto | parse_worklist_row (void *stmt) const -> worklist_item |
| Parse a worklist record from a prepared statement. | |
| auto | parse_ups_workitem_row (void *stmt) const -> ups_workitem |
| Parse a UPS workitem record from a prepared statement. | |
| auto | parse_audit_row (void *stmt) const -> audit_record |
| Parse an audit record from a prepared statement. | |
| auto | initialize_repositories () -> VoidResult |
| Initialize extracted repositories for facade delegation. | |
Static Private Member Functions | |
| static auto | to_like_pattern (std::string_view pattern) -> std::string |
| Convert wildcard pattern to SQL LIKE pattern. | |
Private Attributes | |
| sqlite3 * | db_ {nullptr} |
| SQLite database handle (used for migrations and fallback) | |
| std::string | path_ |
| Database file path. | |
| bool | remove_on_close_ {false} |
| Remove the backing file on destruction for adapter-compatible memory DBs. | |
| std::shared_ptr< patient_repository > | patient_repository_ |
| Extracted repositories used by the facade API. | |
| std::shared_ptr< study_repository > | study_repository_ |
| std::shared_ptr< series_repository > | series_repository_ |
| std::shared_ptr< instance_repository > | instance_repository_ |
| std::shared_ptr< mpps_repository > | mpps_repository_ |
| std::shared_ptr< worklist_repository > | worklist_repository_ |
| std::shared_ptr< ups_repository > | ups_repository_ |
| std::shared_ptr< audit_repository > | audit_repository_ |
| migration_runner | migration_runner_ |
| Migration runner for schema management. | |
Definition at line 123 of file index_database.h.
| kcenon::pacs::storage::index_database::~index_database | ( | ) |
Destructor - closes database connection.
Definition at line 282 of file index_database.cpp.
References audit_repository_, db_, instance_repository_, mpps_repository_, path_, patient_repository_, remove_on_close_, series_repository_, study_repository_, ups_repository_, and worklist_repository_.
|
delete |
|
noexcept |
Definition at line 683 of file index_database.cpp.
|
explicitprivate |
Private constructor - use open() factory method.
Definition at line 279 of file index_database.cpp.
|
nodiscard |
Add a new audit log entry.
Creates a new audit log record for HIPAA compliance and system monitoring.
| record | Audit record data (pk field is ignored) |
Definition at line 1720 of file index_database.cpp.
|
nodiscard |
Add a new worklist item.
Creates a new scheduled procedure step entry for Modality Worklist. The step_status is set to 'SCHEDULED' by default.
| item | Worklist item data (pk field is ignored) |
Definition at line 1528 of file index_database.cpp.
|
nodiscard |
Update database statistics for query optimization.
ANALYZE collects statistics about tables and indexes, which helps the query planner choose better execution plans. Should be run periodically, especially after bulk insertions.
Definition at line 1181 of file index_database.cpp.
|
nodiscard |
Get total audit log count.
Definition at line 1735 of file index_database.cpp.
References audit_repository_.
|
nodiscard |
Change UPS workitem state.
Performs a state transition with validation per PS3.4 Table CC.1.1-2.
| workitem_uid | The workitem SOP Instance UID |
| new_state | The target state |
| transaction_uid | Transaction UID (required for IN PROGRESS transition) |
Definition at line 1627 of file index_database.cpp.
|
nodiscard |
Checkpoint WAL file.
Forces a WAL checkpoint, writing all WAL content to the main database file. Useful for ensuring durability before backup.
| truncate | If true, truncate the WAL file after checkpoint |
Definition at line 1247 of file index_database.cpp.
|
nodiscard |
Cleanup old audit log entries.
Removes audit log entries older than the specified age.
| age | Maximum age of entries to keep |
Definition at line 1739 of file index_database.cpp.
|
nodiscard |
Cleanup old worklist items.
Removes worklist items older than the specified age. Only deletes items that are not in SCHEDULED status.
| age | Maximum age of items to keep |
Definition at line 1563 of file index_database.cpp.
|
nodiscard |
Definition at line 1568 of file index_database.cpp.
|
nodiscard |
Create a new MPPS record with full details.
| record | Complete MPPS record (pk field is ignored) |
Definition at line 1356 of file index_database.cpp.
|
nodiscard |
Create a new MPPS record (N-CREATE)
Creates a new MPPS with status "IN PROGRESS". This corresponds to the DICOM N-CREATE operation received from modalities.
| mpps_uid | SOP Instance UID for the MPPS (required, must be unique) |
| station_ae | Performing station AE Title |
| modality | Modality type (CT, MR, etc.) |
| study_uid | Related Study Instance UID |
| accession_no | Accession number |
| start_datetime | Procedure step start date/time (YYYYMMDDHHMMSS) |
Definition at line 1344 of file index_database.cpp.
|
nodiscard |
Create a new UPS workitem (N-CREATE)
Creates a new UPS workitem with state "SCHEDULED". This corresponds to the DICOM N-CREATE operation.
| workitem | The workitem data (pk field is ignored) |
Definition at line 1617 of file index_database.cpp.
|
nodiscard |
Delete an instance by SOP Instance UID.
| sop_uid | The SOP Instance UID to delete |
Definition at line 1082 of file index_database.cpp.
|
nodiscard |
Delete an MPPS record.
| mpps_uid | The MPPS SOP Instance UID to delete |
Definition at line 1398 of file index_database.cpp.
|
nodiscard |
Delete a patient by patient ID.
This operation cascades to delete all related studies, series, and instances.
| patient_id | The patient ID to delete |
Definition at line 774 of file index_database.cpp.
|
nodiscard |
Delete a series by Series Instance UID.
This operation cascades to delete all related instances.
| series_uid | The Series Instance UID to delete |
Definition at line 995 of file index_database.cpp.
|
nodiscard |
Delete a study by Study Instance UID.
This operation cascades to delete all related series and instances.
| study_uid | The Study Instance UID to delete |
Definition at line 886 of file index_database.cpp.
|
nodiscard |
Delete a UPS workitem.
Only COMPLETED or CANCELED workitems can be deleted unless no subscribers have a deletion lock.
| workitem_uid | The workitem SOP Instance UID |
Definition at line 1645 of file index_database.cpp.
|
nodiscard |
Delete a worklist item.
| step_id | Scheduled Procedure Step ID |
| accession_no | Accession Number |
Definition at line 1557 of file index_database.cpp.
|
nodiscard |
Find an audit log entry by primary key.
| pk | The audit log primary key |
Definition at line 1730 of file index_database.cpp.
|
nodiscard |
Find an instance by SOP Instance UID.
| sop_uid | The SOP Instance UID to search for |
Definition at line 1062 of file index_database.cpp.
|
nodiscard |
Find an instance by primary key.
| pk | The instance's primary key |
Definition at line 1067 of file index_database.cpp.
|
nodiscard |
Find an MPPS by SOP Instance UID.
| mpps_uid | The MPPS SOP Instance UID to search for |
Definition at line 1373 of file index_database.cpp.
|
nodiscard |
Find an MPPS by primary key.
| pk | The MPPS primary key |
Definition at line 1378 of file index_database.cpp.
|
nodiscard |
Find MPPS records by Study Instance UID.
| study_uid | The Study Instance UID to search for |
Definition at line 1388 of file index_database.cpp.
|
nodiscard |
Find a patient by patient ID.
| patient_id | The patient ID to search for |
Definition at line 759 of file index_database.cpp.
|
nodiscard |
Find a patient by primary key.
| pk | The patient's primary key |
Definition at line 764 of file index_database.cpp.
|
nodiscard |
Find a series by Series Instance UID.
| series_uid | The Series Instance UID to search for |
Definition at line 975 of file index_database.cpp.
|
nodiscard |
Find a series by primary key.
| pk | The series's primary key |
Definition at line 980 of file index_database.cpp.
|
nodiscard |
Find a study by Study Instance UID.
| study_uid | The Study Instance UID to search for |
Definition at line 864 of file index_database.cpp.
|
nodiscard |
Find a study by primary key.
| pk | The study's primary key |
Definition at line 869 of file index_database.cpp.
|
nodiscard |
Find a UPS workitem by SOP Instance UID.
| workitem_uid | The workitem SOP Instance UID |
Definition at line 1635 of file index_database.cpp.
|
nodiscard |
Find a worklist item by primary key.
| pk | The worklist primary key |
Definition at line 1552 of file index_database.cpp.
|
nodiscard |
Find a worklist item by step ID and accession number.
| step_id | Scheduled Procedure Step ID |
| accession_no | Accession Number |
Definition at line 1546 of file index_database.cpp.
|
nodiscard |
Get file path for a SOP Instance UID.
Convenience method to quickly look up the file path for a specific DICOM instance without loading the full record.
| sop_instance_uid | The SOP Instance UID to look up |
Definition at line 1145 of file index_database.cpp.
|
nodiscard |
Get all file paths for a series.
Returns all DICOM file paths associated with a series.
| series_instance_uid | The Series Instance UID |
Definition at line 1155 of file index_database.cpp.
|
nodiscard |
Get storage statistics.
Returns aggregate statistics about the database contents.
Definition at line 1283 of file index_database.cpp.
References kcenon::pacs::error_codes::database_query_error, db_, instance_count(), kcenon::pacs::pacs_error(), path_, patient_count(), series_count(), and study_count().

|
nodiscard |
Get all file paths for a study.
Returns all DICOM file paths associated with a study. Useful for bulk operations like C-MOVE or study export.
| study_instance_uid | The Study Instance UID |
Definition at line 1150 of file index_database.cpp.
|
nodiscard |
Get all subscribers for a workitem.
Returns subscribers that would receive notifications for the specified workitem (workitem-specific + global subscriptions).
| workitem_uid | The workitem SOP Instance UID |
Definition at line 1679 of file index_database.cpp.
|
nodiscard |
Get all subscriptions for a subscriber.
| subscriber_ae | The subscriber AE Title |
Definition at line 1674 of file index_database.cpp.
|
nodiscardprivate |
Initialize extracted repositories for facade delegation.
Definition at line 645 of file index_database.cpp.
References kcenon::pacs::error_codes::database_connection_error.
|
nodiscard |
Get total instance count.
Definition at line 1086 of file index_database.cpp.
References instance_repository_.
Referenced by get_storage_stats().

|
nodiscard |
Get instance count for a specific series.
| series_uid | The Series Instance UID |
Definition at line 1090 of file index_database.cpp.
|
nodiscardnoexcept |
Check if the database is open.
Definition at line 792 of file index_database.cpp.
References db_.
|
nodiscard |
List active (IN PROGRESS) MPPS records for a station.
| station_ae | The station AE Title to filter by |
Definition at line 1383 of file index_database.cpp.
|
nodiscard |
List all instances for a series.
| series_uid | The Series Instance UID to list instances for |
Definition at line 1072 of file index_database.cpp.
|
nodiscard |
List all series for a study.
| study_uid | The Study Instance UID to list series for |
Definition at line 985 of file index_database.cpp.
|
nodiscard |
List all studies for a patient.
| patient_id | The patient ID to list studies for |
Definition at line 874 of file index_database.cpp.
|
nodiscard |
Get total MPPS count.
Definition at line 1402 of file index_database.cpp.
References mpps_repository_.
|
nodiscard |
Get MPPS count by status.
| status | The status to count (IN PROGRESS, COMPLETED, DISCONTINUED) |
Definition at line 1406 of file index_database.cpp.
|
nodiscardnoexcept |
Get the raw SQLite database handle.
Returns the underlying SQLite database handle for advanced operations such as creating cursors for streaming queries. The returned handle should not be closed or modified directly.
Definition at line 1268 of file index_database.cpp.
References db_.
|
staticnodiscard |
Open or create a database with default configuration.
Opens an existing database or creates a new one at the specified path. Automatically runs pending migrations. Uses default configuration with WAL mode enabled.
| db_path | Path to the database file, or ":memory:" for in-memory DB |
Definition at line 156 of file index_database.cpp.
Referenced by kcenon::pacs::example::pacs_server_app::setup_database().

|
staticnodiscard |
Open or create a database with custom configuration.
Opens an existing database or creates a new one at the specified path. Automatically runs pending migrations.
| db_path | Path to the database file, or ":memory:" for in-memory DB |
| config | Configuration options for database behavior |
Definition at line 161 of file index_database.cpp.
References code.
|
delete |
|
noexcept |
Definition at line 702 of file index_database.cpp.
|
nodiscardprivate |
Parse an audit record from a prepared statement.
Definition at line 1744 of file index_database.cpp.
|
nodiscardprivate |
Parse an instance record from a prepared statement.
Definition at line 1095 of file index_database.cpp.
|
nodiscardprivate |
Parse an MPPS record from a prepared statement.
Definition at line 1410 of file index_database.cpp.
|
nodiscardprivate |
Parse a patient record from a prepared statement.
Definition at line 798 of file index_database.cpp.
|
nodiscardprivate |
Parse a series record from a prepared statement.
Definition at line 1012 of file index_database.cpp.
|
nodiscardprivate |
Parse a study record from a prepared statement.
Definition at line 907 of file index_database.cpp.
|
nodiscardprivate |
Parse a UPS workitem record from a prepared statement.
Definition at line 1684 of file index_database.cpp.
|
nodiscardprivate |
Parse a worklist record from a prepared statement.
Definition at line 1581 of file index_database.cpp.
|
nodiscard |
Get the database file path.
Definition at line 786 of file index_database.cpp.
References path_.
|
nodiscard |
Get total patient count.
Definition at line 778 of file index_database.cpp.
References patient_repository_.
Referenced by get_storage_stats().

|
nodiscard |
Query audit log entries.
Returns audit log entries matching the query criteria.
| query | Query parameters with optional filters |
Definition at line 1725 of file index_database.cpp.
|
nodiscard |
Query worklist items.
Returns worklist items matching the query criteria. By default, only returns items with status 'SCHEDULED'. Used for MWL C-FIND operations.
| query | Query parameters with optional filters |
Definition at line 1541 of file index_database.cpp.
|
nodiscard |
Get the current schema version.
Definition at line 788 of file index_database.cpp.
References db_, kcenon::pacs::storage::migration_runner::get_current_version(), and migration_runner_.

|
nodiscard |
Search instances with query criteria.
Can filter by series UID, SOP class, and other attributes.
| query | Query parameters with optional filters |
Definition at line 1077 of file index_database.cpp.
|
nodiscard |
Search MPPS records with query criteria.
| query | Query parameters with optional filters |
Definition at line 1393 of file index_database.cpp.
|
nodiscard |
Search patients with query criteria.
Supports wildcard matching using '' character.
| query | Query parameters with optional filters |
Definition at line 769 of file index_database.cpp.
|
nodiscard |
Search series with query criteria.
Supports wildcard matching using '*' character. Can filter by study UID, modality, and other attributes.
| query | Query parameters with optional filters |
Definition at line 990 of file index_database.cpp.
|
nodiscard |
Search studies with query criteria.
Supports wildcard matching using '*' character. Can filter by patient attributes, study attributes, and date ranges.
| query | Query parameters with optional filters |
Definition at line 881 of file index_database.cpp.
|
nodiscard |
Search UPS workitems with query criteria.
Used for UPS C-FIND operations.
| query | Query parameters with optional filters |
Definition at line 1640 of file index_database.cpp.
|
nodiscard |
Get total series count.
Definition at line 1004 of file index_database.cpp.
References series_repository_.
Referenced by get_storage_stats().

|
nodiscard |
Get series count for a specific study.
| study_uid | The Study Instance UID |
Definition at line 1008 of file index_database.cpp.
|
nodiscard |
Get total study count.
Definition at line 890 of file index_database.cpp.
References study_repository_.
Referenced by get_storage_stats().

|
nodiscard |
Get study count for a specific patient.
| patient_id | The patient ID |
Definition at line 894 of file index_database.cpp.
|
nodiscard |
Subscribe to UPS workitem events.
| subscription | The subscription data (pk field is ignored) |
Definition at line 1663 of file index_database.cpp.
|
staticnodiscardprivate |
Convert wildcard pattern to SQL LIKE pattern.
Converts '*' to '' for SQL LIKE matching
Definition at line 820 of file index_database.cpp.
|
nodiscard |
Unsubscribe from UPS workitem events.
| subscriber_ae | The subscriber AE Title |
| workitem_uid | The workitem UID (empty for global unsubscribe) |
Definition at line 1668 of file index_database.cpp.
|
nodiscard |
Update modalities in study (denormalized field)
Called after series insert/delete to update the modalities_in_study field.
| study_pk | The study's primary key |
Definition at line 902 of file index_database.cpp.
|
nodiscard |
Update an existing MPPS record with partial data.
Only non-empty fields in the record will be updated.
| record | MPPS record with fields to update (mpps_uid required) |
Definition at line 1369 of file index_database.cpp.
|
nodiscard |
Update an existing MPPS record (N-SET)
Updates the MPPS status and attributes. This corresponds to the DICOM N-SET operation. Status transitions are validated:
| mpps_uid | SOP Instance UID of the MPPS to update |
| new_status | New status (COMPLETED or DISCONTINUED) |
| end_datetime | Procedure step end date/time |
| performed_series | JSON string of performed series information |
Definition at line 1360 of file index_database.cpp.
|
nodiscard |
Update an existing UPS workitem.
Updates the workitem attributes. State transitions are validated:
| workitem | Updated workitem data (workitem_uid required) |
Definition at line 1622 of file index_database.cpp.
|
nodiscard |
Update worklist item status.
Called when MPPS is received to update the corresponding worklist item status from SCHEDULED to STARTED or COMPLETED.
| step_id | Scheduled Procedure Step ID |
| accession_no | Accession Number |
| new_status | New status (STARTED or COMPLETED) |
Definition at line 1533 of file index_database.cpp.
|
nodiscard |
Get total UPS workitem count.
Definition at line 1650 of file index_database.cpp.
References ups_repository_.
|
nodiscard |
Get UPS workitem count by state.
| state | The state to count |
Definition at line 1654 of file index_database.cpp.
|
nodiscard |
Insert or update an instance record with full details.
| record | Complete instance record (pk field is ignored for insert) |
Definition at line 1057 of file index_database.cpp.
|
nodiscard |
Insert or update an instance record.
If an instance with the same sop_uid exists, updates the record. Otherwise, inserts a new record.
| series_pk | Foreign key to the series (required) |
| sop_uid | SOP Instance UID (required, max 64 chars) |
| sop_class_uid | SOP Class UID (required) |
| file_path | Path to the stored DICOM file (required) |
| file_size | Size of the file in bytes (required, >= 0) |
| transfer_syntax | Transfer Syntax UID |
| instance_number | Instance number |
Definition at line 1044 of file index_database.cpp.
|
nodiscard |
Insert or update a patient record with full details.
| record | Complete patient record (pk field is ignored for insert) |
Definition at line 754 of file index_database.cpp.
|
nodiscard |
Insert or update a patient record.
If a patient with the same patient_id exists, updates the record. Otherwise, inserts a new record.
| patient_id | Patient ID (required, max 64 chars) |
| patient_name | Patient's name in DICOM PN format |
| birth_date | Birth date in YYYYMMDD format |
| sex | Sex code (M, F, O) |
Definition at line 746 of file index_database.cpp.
|
nodiscard |
Insert or update a series record with full details.
| record | Complete series record (pk field is ignored for insert) |
Definition at line 956 of file index_database.cpp.
|
nodiscard |
Insert or update a series record.
If a series with the same series_uid exists, updates the record. Otherwise, inserts a new record.
| study_pk | Foreign key to the study (required) |
| series_uid | Series Instance UID (required, max 64 chars) |
| modality | Modality (e.g., CT, MR) |
| series_number | Series number |
| series_description | Series description |
| body_part_examined | Body part examined |
| station_name | Station name |
Definition at line 937 of file index_database.cpp.
|
nodiscard |
Insert or update a study record with full details.
| record | Complete study record (pk field is ignored for insert) |
Definition at line 859 of file index_database.cpp.
|
nodiscard |
Insert or update a study record.
If a study with the same study_uid exists, updates the record. Otherwise, inserts a new record.
| patient_pk | Foreign key to the patient (required) |
| study_uid | Study Instance UID (required, max 64 chars) |
| study_id | Study ID |
| study_date | Study date in YYYYMMDD format |
| study_time | Study time in HHMMSS format |
| accession_number | Accession number |
| referring_physician | Referring physician's name |
| study_description | Study description |
Definition at line 845 of file index_database.cpp.
|
nodiscard |
Reclaim unused space in the database.
VACUUM rebuilds the database file, repacking it into a minimal amount of disk space. This can reduce file size after large deletions but may take time for large databases.
Note: This operation requires exclusive access and may take significant time for large databases.
Definition at line 1164 of file index_database.cpp.
|
nodiscard |
Verify database integrity.
Runs SQLite's integrity check to verify the database structure and detect any corruption issues.
Definition at line 1198 of file index_database.cpp.
References db_.
|
nodiscard |
Get total worklist count.
Definition at line 1573 of file index_database.cpp.
References worklist_repository_.
|
nodiscard |
Get worklist count by status.
| status | The status to count (SCHEDULED, STARTED, COMPLETED) |
Definition at line 1577 of file index_database.cpp.
|
mutableprivate |
Definition at line 1353 of file index_database.h.
Referenced by audit_count(), and ~index_database().
|
private |
SQLite database handle (used for migrations and fallback)
Definition at line 1337 of file index_database.h.
Referenced by get_storage_stats(), is_open(), native_handle(), schema_version(), verify_integrity(), and ~index_database().
|
mutableprivate |
Definition at line 1349 of file index_database.h.
Referenced by instance_count(), and ~index_database().
|
private |
Migration runner for schema management.
Definition at line 1356 of file index_database.h.
Referenced by schema_version().
|
mutableprivate |
Definition at line 1350 of file index_database.h.
Referenced by mpps_count(), and ~index_database().
|
private |
Database file path.
Definition at line 1340 of file index_database.h.
Referenced by get_storage_stats(), path(), and ~index_database().
|
mutableprivate |
Extracted repositories used by the facade API.
Definition at line 1346 of file index_database.h.
Referenced by patient_count(), and ~index_database().
|
private |
Remove the backing file on destruction for adapter-compatible memory DBs.
Definition at line 1343 of file index_database.h.
Referenced by ~index_database().
|
mutableprivate |
Definition at line 1348 of file index_database.h.
Referenced by series_count(), and ~index_database().
|
mutableprivate |
Definition at line 1347 of file index_database.h.
Referenced by study_count(), and ~index_database().
|
mutableprivate |
Definition at line 1352 of file index_database.h.
Referenced by ups_workitem_count(), and ~index_database().
|
mutableprivate |
Definition at line 1351 of file index_database.h.
Referenced by worklist_count(), and ~index_database().