@@ -60,6 +60,10 @@ def __init__(
6060 device_serial_number : str | None = None ,
6161 institution_name : str | None = None ,
6262 institutional_department_name : str | None = None ,
63+ content_date : str | datetime .date | None = None ,
64+ content_time : str | datetime .time | None = None ,
65+ series_date : str | datetime .date | None = None ,
66+ series_time : str | datetime .time | None = None ,
6367 ):
6468 """
6569 Parameters
@@ -121,6 +125,18 @@ def __init__(
121125 institutional_department_name: Union[str, None], optional
122126 Name of the department of the person or device that creates the
123127 SR document instance.
128+ content_date: str | datetime.date | None, optional
129+ Date the content of this instance was created. If not specified,
130+ the current date will be used.
131+ content_time: str | datetime.time | None, optional
132+ Time the content of this instance was created. If not specified,
133+ the current time will be used.
134+ series_date: str | datetime.date | None, optional
135+ Date the series was started. This should be the same for all
136+ instances in a series.
137+ series_time: str | datetime.time | None, optional
138+ Time the series was started. This should be the same for all
139+ instances in a series.
124140
125141 Note
126142 ----
@@ -207,7 +223,11 @@ def __init__(
207223 _check_long_string (device_serial_number )
208224 self .DeviceSerialNumber = device_serial_number
209225 if software_versions is not None :
210- _check_long_string (software_versions )
226+ if not isinstance (software_versions , str ):
227+ for v in software_versions :
228+ _check_long_string (v )
229+ else :
230+ _check_long_string (software_versions )
211231 self .SoftwareVersions = software_versions
212232 if institution_name is not None :
213233 _check_long_string (institution_name )
@@ -227,11 +247,59 @@ def __init__(
227247 )
228248 self .InstanceNumber = instance_number
229249
250+ now = datetime .datetime .now ()
251+ self .InstanceCreationDate = DA (now .date ())
252+ self .InstanceCreationTime = TM (now .time ())
253+
230254 # Content Date and Content Time are not present in all IODs
231255 if is_attribute_in_iod ('ContentDate' , sop_class_uid ):
232- self .ContentDate = DA (datetime .datetime .now ().date ())
256+ if content_date is None :
257+ if content_time is not None :
258+ raise TypeError (
259+ "'content_time' may not be specified without "
260+ "'content_date'."
261+ )
262+ content_date = now .date ()
263+ content_date = DA (content_date )
264+ self .ContentDate = content_date
265+ elif content_date is not None :
266+ raise TypeError (
267+ f"'content_date' should not be specified for SOP Class UID: "
268+ f"{ sop_class_uid } "
269+ )
233270 if is_attribute_in_iod ('ContentTime' , sop_class_uid ):
234- self .ContentTime = TM (datetime .datetime .now ().time ())
271+ if content_time is None :
272+ content_time = now .time ()
273+ content_time = TM (content_time )
274+ self .ContentTime = content_time
275+ elif content_time is not None :
276+ raise TypeError (
277+ f"'content_time' should not be specified for SOP Class UID: "
278+ f"{ sop_class_uid } "
279+ )
280+
281+ if series_date is not None :
282+ series_date = DA (series_date )
283+ if content_date is not None :
284+ if series_date > content_date :
285+ raise ValueError (
286+ "'series_date' must not be later than 'content_date'."
287+ )
288+ self .SeriesDate = series_date
289+ if series_time is not None :
290+ series_time = TM (series_time )
291+ if series_date is None :
292+ raise TypeError (
293+ "'series_time' may not be specified without "
294+ "'series_date'."
295+ )
296+ if content_time is not None :
297+ if series_time > content_time :
298+ raise ValueError (
299+ "'series_time' must not be later than content time."
300+ )
301+ self .SeriesTime = series_time
302+
235303 if content_qualification is not None :
236304 content_qualification = ContentQualificationValues (
237305 content_qualification
0 commit comments