/// <summary> /// Create a study record from <see cref="DicomDataset"/>. /// </summary> /// <param name="dcmData"><see cref="DicomDataset"/></param> /// <returns>Study record <see cref="{DataModel.StudyRecord}"/></returns> public static StudyRecord CreateStudy(this DicomDataset dcmData) { string studyUID = dcmData.GetString(DicomTag.StudyInstanceUID); var record = new StudyRecord(studyUID); // 1 record.StudyID = dcmData.GetString(DicomTag.StudyID); // 2 record.PatientName = dcmData.GetString(DicomTag.PatientName); // 3 string dcmDate = null; dcmDate = dcmData.GetString(DicomTag.StudyDate); string dcmTime = null; dcmTime = dcmData.GetString(DicomTag.StudyTime); record.DateTime = CombineDateTime(dcmDate, dcmTime); // 4 record.PatientID = dcmData.GetString(DicomTag.PatientID); // 5 string sex = dcmData.GetString(DicomTag.PatientSex); record.PatientSex = (int)DcmConvert.GetPatientSex(sex); // 6 record.PatientAge = dcmData.GetString(DicomTag.PatientAge); // 7 record.Modality = dcmData.GetString(DicomTag.Modality); // 8 record.StudyDescription = dcmData.GetString(DicomTag.StudyDescription); // 9 return(record); }
private static DateTime?CombineDateTime(string dcmDate, string dcmTime) { DateTime?date = DcmConvert.ToDate(dcmDate); DateTime?time = DcmConvert.ToTime(dcmTime); if (date == null) { return(time); } else if (time == null) { return(date); } return(new DateTime(date.Value.Year, date.Value.Month, date.Value.Day, time.Value.Hour, time.Value.Minute, time.Value.Second)); }