Skip to content

Commit

Permalink
Add file, file_parameter and scanner SQLAlchemy models (#1207)
Browse files Browse the repository at this point in the history
* add tables

* rename file model

* rename parameter_file
  • Loading branch information
maximemulder authored Nov 13, 2024
1 parent 9810e93 commit 7d87ea9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
34 changes: 34 additions & 0 deletions python/lib/db/model/file.py
Original file line number Diff line number Diff line change
@@ -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')
16 changes: 16 additions & 0 deletions python/lib/db/model/mri_scanner.py
Original file line number Diff line number Diff line change
@@ -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')
15 changes: 15 additions & 0 deletions python/lib/db/model/parameter_file.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 7d87ea9

Please sign in to comment.