6060
6161from django .conf import settings
6262import os
63+ import time
6364from copy import deepcopy
6465
6566os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'sendit.settings' )
@@ -108,7 +109,6 @@ def replace_identifiers(bid, run_upload_storage=False):
108109 '''
109110
110111 batch .qa ['ProcessStartTime' ] = time .time ()
111-
112112 batch = Batch .objects .get (id = bid )
113113 batch_ids = BatchIdentifiers .objects .get (batch = batch )
114114
@@ -125,12 +125,10 @@ def replace_identifiers(bid, run_upload_storage=False):
125125 cleaned = clean_identifiers (ids = updated ,
126126 default = "KEEP" ,
127127 deid = deid )
128-
129128 # Save progress
130129 batch_ids .cleaned = cleaned
131130 batch_ids .updated = updated
132131 batch_ids .save ()
133-
134132 # Get updated files
135133 dicom_files = batch .get_image_paths ()
136134 output_folder = batch .get_path ()
@@ -142,7 +140,6 @@ def replace_identifiers(bid, run_upload_storage=False):
142140 strip_sequences = True ,
143141 remove_private = True ) # force = True
144142 # save = True,
145-
146143 # Get shared information
147144 aggregate = ["BodyPartExamined" , "Modality" , "StudyDescription" ]
148145 shared_ids = get_shared_identifiers (dicom_files = updated_files ,
@@ -158,24 +155,19 @@ def replace_identifiers(bid, run_upload_storage=False):
158155
159156 # S6M0<MRN-SUID>_<JITTERED-REPORT-DATE>_<ACCESSIONNUMBER-SUID>
160157 # Rename the dicom based on suid
161-
162158 if item_id in updated :
163159 item_suid = updated [item_id ]['item_id' ]
164160 dcm = dcm .rename (item_suid ) # added to [prefix][dcm.name]
165161 dcm .save ()
166-
167162 # If we don't have the id, don't risk uploading
168163 else :
169164 message = "%s for Image Id %s file read error: skipping." % (item_id , dcm .id )
170165 batch = add_batch_error (message ,batch )
171166 dcm .delete ()
172-
173-
174167 except :
175168 message = "%s for Image Id %s not found in lookup: skipping." % (item_id , dcm .id )
176169 batch = add_batch_error (message ,batch )
177170 dcm .delete ()
178-
179171 batch .qa ['ProcessFinishTime' ] = time .time ()
180172
181173 # We don't get here if the call above failed
0 commit comments