11from datetime import datetime
22from functools import cmp_to_key
3+ from pathlib import Path
34
45from sqlalchemy .orm import Session as Database
56
@@ -17,14 +18,14 @@ def insert_dicom_archive(
1718 db : Database ,
1819 dicom_summary : DicomStudySummary ,
1920 dicom_import_log : DicomStudyImportLog ,
20- archive_location : str ,
21+ archive_path : Path ,
2122):
2223 """
2324 Insert a DICOM archive in the database.
2425 """
2526
2627 dicom_archive = DbDicomArchive ()
27- populate_dicom_archive (dicom_archive , dicom_summary , dicom_import_log , archive_location )
28+ populate_dicom_archive (dicom_archive , dicom_summary , dicom_import_log , archive_path )
2829 dicom_archive .date_first_archived = datetime .now ()
2930 db .add (dicom_archive )
3031 db .commit ()
@@ -37,7 +38,7 @@ def update_dicom_archive(
3738 dicom_archive : DbDicomArchive ,
3839 dicom_summary : DicomStudySummary ,
3940 dicom_import_log : DicomStudyImportLog ,
40- archive_location : str ,
41+ archive_path : Path ,
4142):
4243 """
4344 Update a DICOM archive in the database.
@@ -47,7 +48,7 @@ def update_dicom_archive(
4748 delete_dicom_archive_file_series (db , dicom_archive )
4849
4950 # Update the database record with the new DICOM information.
50- populate_dicom_archive (dicom_archive , dicom_summary , dicom_import_log , archive_location )
51+ populate_dicom_archive (dicom_archive , dicom_summary , dicom_import_log , archive_path )
5152 db .commit ()
5253
5354 # Insert the new DICOM files and series.
@@ -58,7 +59,7 @@ def populate_dicom_archive(
5859 dicom_archive : DbDicomArchive ,
5960 dicom_summary : DicomStudySummary ,
6061 dicom_import_log : DicomStudyImportLog ,
61- archive_location : str ,
62+ archive_path : Path ,
6263):
6364 """
6465 Populate a DICOM archive database object with information from its DICOM summary and DICOM
@@ -83,8 +84,8 @@ def populate_dicom_archive(
8384 dicom_archive .creating_user = dicom_import_log .creator_name
8485 dicom_archive .sum_type_version = dicom_import_log .summary_version
8586 dicom_archive .tar_type_version = dicom_import_log .archive_version
86- dicom_archive .source_location = dicom_import_log .source_path
87- dicom_archive .archive_location = archive_location
87+ dicom_archive .source_location = str ( dicom_import_log .source_path )
88+ dicom_archive .archive_location = str ( archive_path )
8889 dicom_archive .scanner_manufacturer = dicom_summary .info .scanner .manufacturer or ''
8990 dicom_archive .scanner_model = dicom_summary .info .scanner .model or ''
9091 dicom_archive .scanner_serial_number = dicom_summary .info .scanner .serial_number or ''
0 commit comments