From 7d87ea98d33f42307a0e205a64a7807eca0bd99e Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Wed, 13 Nov 2024 13:41:18 -0500 Subject: [PATCH] Add file, file_parameter and scanner SQLAlchemy models (#1207) * add tables * rename file model * rename parameter_file --- python/lib/db/model/file.py | 34 +++++++++++++++++++++++++++ python/lib/db/model/mri_scanner.py | 16 +++++++++++++ python/lib/db/model/parameter_file.py | 15 ++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 python/lib/db/model/file.py create mode 100644 python/lib/db/model/mri_scanner.py create mode 100644 python/lib/db/model/parameter_file.py diff --git a/python/lib/db/model/file.py b/python/lib/db/model/file.py new file mode 100644 index 000000000..56f221c2b --- /dev/null +++ b/python/lib/db/model/file.py @@ -0,0 +1,34 @@ +from datetime import date +from typing import Optional + +from sqlalchemy.orm import Mapped, mapped_column + +from lib.db.base import Base + + +class DbFile(Base): + __tablename__ = 'files' + + id : Mapped[int] = mapped_column('FileID', primary_key=True) + session_id : Mapped[int] = mapped_column('SessionID') + file_name : Mapped[str] = mapped_column('File') + series_uid : Mapped[Optional[str]] = mapped_column('SeriesUID') + echo_time : Mapped[Optional[float]] = mapped_column('EchoTime') + phase_encoding_direction : Mapped[Optional[str]] = mapped_column('PhaseEncodingDirection') + echo_number : Mapped[Optional[str]] = mapped_column('EchoNumber') + coordinate_space : Mapped[Optional[str]] = mapped_column('CoordinateSpace') + output_type : Mapped[str] = mapped_column('OutputType') + acquisition_protocol_id : Mapped[Optional[int]] = mapped_column('AcquisitionProtocolID') + file_type : Mapped[Optional[str]] = mapped_column('FileType') + inserted_by_user_id : Mapped[str] = mapped_column('InsertedByUserID') + insert_time : Mapped[int] = mapped_column('InsertTime') + source_pipeline : Mapped[Optional[str]] = mapped_column('SourcePipeline') + pipeline_date : Mapped[Optional[date]] = mapped_column('PipelineDate') + source_file_id : Mapped[Optional[int]] = mapped_column('SourceFileID') + process_protocol_id : Mapped[Optional[int]] = mapped_column('ProcessProtocolID') + caveat : Mapped[Optional[bool]] = mapped_column('Caveat') + dicom_archive_id : Mapped[Optional[int]] = mapped_column('TarchiveSource') + hrrt_archive_id : Mapped[Optional[int]] = mapped_column('HrrtArchiveID') + scanner_id : Mapped[Optional[int]] = mapped_column('ScannerID') + acquisition_order_per_modality : Mapped[Optional[int]] = mapped_column('AcqOrderPerModality') + acquisition_date : Mapped[Optional[date]] = mapped_column('AcquisitionDate') diff --git a/python/lib/db/model/mri_scanner.py b/python/lib/db/model/mri_scanner.py new file mode 100644 index 000000000..cff78124b --- /dev/null +++ b/python/lib/db/model/mri_scanner.py @@ -0,0 +1,16 @@ +from typing import Optional + +from sqlalchemy.orm import Mapped, mapped_column + +from lib.db.base import Base + + +class DbMriScanner(Base): + __tablename__ = 'mri_scanner' + + id : Mapped[int] = mapped_column('ID', primary_key=True) + manufacturer : Mapped[Optional[str]] = mapped_column('Manufacturer') + model : Mapped[Optional[str]] = mapped_column('Model') + serial_number : Mapped[Optional[str]] = mapped_column('Serial_number') + software_version : Mapped[Optional[str]] = mapped_column('Software') + cand_id : Mapped[Optional[int]] = mapped_column('CandID') diff --git a/python/lib/db/model/parameter_file.py b/python/lib/db/model/parameter_file.py new file mode 100644 index 000000000..a0a7e8b8f --- /dev/null +++ b/python/lib/db/model/parameter_file.py @@ -0,0 +1,15 @@ +from typing import Optional + +from sqlalchemy.orm import Mapped, mapped_column + +from lib.db.base import Base + + +class DbParameterFile(Base): + __tablename__ = 'parameter_file' + + id : Mapped[int] = mapped_column('ParameterFileID', primary_key=True) + file_id : Mapped[int] = mapped_column('FileID') + parameter_type_id : Mapped[int] = mapped_column('ParameterTypeID') + value : Mapped[Optional[str]] = mapped_column('Value') + insert_time : Mapped[int] = mapped_column('InsertTime')