Exemplo n.º 1
0
        public void Return_Hour_And_Minute_When_Time_Is_Passed_In_As_String()
        {
            // Arrange
            var timeAsString = "01:00";

            // Act
            var(hour, minute) = _timeParser.Parse(timeAsString);

            // Assert
            Assert.Equal(1, hour);
            Assert.Equal(00, minute);
        }
Exemplo n.º 2
0
        protected override string GetRenderedDateTimeText()
        {
            if (String.IsNullOrEmpty(Value))
            {
                return(EmptyValueText);
            }

            DateTime?dt = TimeParser.Parse(Value);

            if (dt != null)
            {
                if (String.IsNullOrEmpty(Format))
                {
                    return(DateTimeFormatter.Format(dt.Value, DateTimeFormatter.Style.Time));
                }
                else
                {
                    return(dt.Value.ToString(Format));
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        private void TraceAcquisitionTime(IEnumerable <IPresentationImage> images)
        {
            foreach (IPresentationImage image in images)
            {
                if (image is DicomGrayscalePresentationImage)
                {
                    DicomGrayscalePresentationImage dicomImage = (DicomGrayscalePresentationImage)image;

                    DateTime?acqDate = DateParser.Parse(dicomImage.ImageSop.Frames[1].AcquisitionDate);
                    DateTime?acqTime = TimeParser.Parse(dicomImage.ImageSop.Frames[1].AcquisitionTime);
                    if (acqDate != null)
                    {
                        acqDate = acqDate.Value.AddTicks(acqTime.Value.Ticks);
                    }
                    else
                    {
                        acqDate = DateTimeParser.Parse(dicomImage.ImageSop.Frames[1].AcquisitionDateTime);
                    }

                    string line = string.Format("StudyUID: {0}, Series: {1}, Acq.Date/Time: {2}, Instance: {3}, Frame: {4}",
                                                dicomImage.ImageSop.StudyInstanceUid,
                                                dicomImage.ImageSop.SeriesInstanceUid,
                                                acqDate.Value.ToString(DateTimeParser.DicomFullDateTimeFormat),
                                                dicomImage.ImageSop.InstanceNumber,
                                                dicomImage.Frame.FrameNumber);
                    Debug.WriteLine(line);
                }
                else
                {
                    Debug.WriteLine("** Non-Dicom Image **");
                }
            }
        }
Exemplo n.º 4
0
        public void TimeParser_ParsesCorrectlySecs(string input, int expected)
        {
            int?result = TimeParser.Parse(input);

            result.Should().HaveValue();
            result.Should().Be(expected);
        }
Exemplo n.º 5
0
        public async Task <string> UpdateUnverifyAsync(SocketGuildUser user, SocketGuild guild, string time, SocketUser fromUser)
        {
            var task = Queue.Get <UnverifyBackgroundTask>(o => o.GuildId == guild.Id && o.UserId == user.Id);

            if (task == null)
            {
                throw new NotFoundException("Aktualizace času nelze pro hledaného uživatele provést. Unverify nenalezeno.");
            }

            if (task.CanProcess() || (task.At - DateTime.Now).TotalSeconds < 30.0D)
            {
                throw new ValidationException("Aktualizace data a času již není možná. Vypršel čas, nebo zbývá méně, než půl minuty.");
            }

            var endDateTime = TimeParser.Parse(time, minimumMinutes: 10);
            await UnverifyLogger.LogUpdateAsync(DateTime.Now, endDateTime, guild, fromUser, user);

            var userEntity = await GrillBotRepository.UsersRepository.GetUserAsync(guild.Id, user.Id, UsersIncludes.Unverify);

            userEntity.Unverify.EndDateTime   = endDateTime;
            userEntity.Unverify.StartDateTime = DateTime.Now;
            await GrillBotRepository.CommitAsync();

            task.At = endDateTime;

            var pmMessage = MessageGenerator.CreateUpdatePMMessage(guild, endDateTime);
            await user.SendPrivateMessageAsync(pmMessage);

            return(MessageGenerator.CreateUpdateChannelMessage(user, endDateTime));
        }
Exemplo n.º 6
0
        public async Task <UnverifyUserProfile> CreateProfileAsync(SocketGuildUser user, SocketGuild guild, string time, string data, bool isSelfunverify, List <string> toKeep,
                                                                   SocketRole mutedRole)
        {
            var result = new UnverifyUserProfile()
            {
                StartDateTime   = DateTime.Now,
                Reason          = ReasonParser.Parse(data),
                EndDateTime     = TimeParser.Parse(time),
                DestinationUser = user,
                IsSelfUnverify  = isSelfunverify
            };

            var selfUnverifyConfig = await GetSelfunverifyConfigAsync(guild);

            if (isSelfunverify && selfUnverifyConfig == null)
            {
                throw new InvalidOperationException("Neplatná konfigurace pro selfunverify");
            }

            if (toKeep != null && selfUnverifyConfig != null)
            {
                toKeep = toKeep.Select(o => o.ToLower()).Distinct().ToList();
                if (toKeep.Count > selfUnverifyConfig.MaxRolesToKeep)
                {
                    throw new ValidationException($"Lze si ponechat maximálně následující počet přístupů: {selfUnverifyConfig.MaxRolesToKeep}");
                }
            }

            await SetRolesAsync(result, user, guild, isSelfunverify, toKeep, selfUnverifyConfig, mutedRole);

            SetChannels(result, user, toKeep, selfUnverifyConfig);

            return(result);
        }
Exemplo n.º 7
0
        private IEnumerable <IComparable> GetCompareValues(IStudyData studyData)
        {
            yield return(DateParser.Parse(studyData.StudyDate));

            yield return(TimeParser.Parse(studyData.StudyTime));

            yield return(studyData.StudyDescription);
        }
Exemplo n.º 8
0
        public void TestTimeParser(string input, int hour, int min, int sec)
        {
            var result = TimeParser.Parse(input, new DateTime(1, 1, 1, 12, 0, 0)) ?? new TimeSpan(9, 9, 9, 9, 9);

            Assert.Equal(hour, result.Hours);
            Assert.Equal(min, result.Minutes);
            Assert.Equal(sec, result.Seconds);
        }
        private string timeformatHMS(string input)
        {
            DateTime time;

            if (!TimeParser.Parse(input, out time))
            {
                return(input);
            }

            return(time.ToString("HH:mm:ss.FFFFFF"));
        }
Exemplo n.º 10
0
        private static IEnumerable <IComparable> GetCompareValues(Frame frame)
        {
            //Group be common study level attributes
            yield return(frame.StudyInstanceUid);

            //Group by common series level attributes
            //This sorts "FOR PRESENTATION" images to the beginning (except in reverse, of course).
            yield return(frame.ParentImageSop.PresentationIntentType == "FOR PRESENTATION" ? 0 : 1);

            yield return(frame.ParentImageSop.SeriesNumber);

            yield return(frame.ParentImageSop.SeriesDescription);

            yield return(frame.SeriesInstanceUid);

            DateTime?datePart = null;
            TimeSpan?timePart = null;

            //then sort by acquisition datetime.
            DateTime?acquisitionDateTime = DateTimeParser.Parse(frame.AcquisitionDateTime);

            if (acquisitionDateTime != null)
            {
                datePart = acquisitionDateTime.Value.Date;
                timePart = acquisitionDateTime.Value.TimeOfDay;
            }
            else
            {
                datePart = DateParser.Parse(frame.AcquisitionDate);
                if (datePart != null)
                {
                    //only set the time part if there is a valid date part.
                    DateTime?acquisitionTime = TimeParser.Parse(frame.AcquisitionTime);
                    if (acquisitionTime != null)
                    {
                        timePart = acquisitionTime.Value.TimeOfDay;
                    }
                }
            }

            yield return(datePart);

            yield return(timePart);

            //as a last resort.
            yield return(frame.ParentImageSop.InstanceNumber);

            yield return(frame.FrameNumber);

            yield return(frame.AcquisitionNumber);
        }
Exemplo n.º 11
0
 private int?GetTicksFromTime(string value)
 {
     if (value == TIME_FORMATTER.NullTime || value == "" || value == null)
     {
         return(null);
     }
     else
     {
         TimeSpan timeSpan          = TimeParser.Parse(value);
         int      ticksFromSeconds  = (int)((int)timeSpan.TotalSeconds * Run.Category.TicksPerSecond);
         int      ticksFromMantissa = (int)Math.Round(timeSpan.Milliseconds * Run.Category.TicksPerSecond / 1000);
         return(ticksFromSeconds + ticksFromMantissa);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Returns the input value formatted according to <see cref="Format.TimeFormat"/>.
        /// </summary>
        /// <param name="input">A time value taken from a Dicom Header.</param>
        public static string TimeFormat(string input)
        {
            if (String.IsNullOrEmpty(input))
            {
                return(String.Empty);
            }

            DateTime time;

            if (!TimeParser.Parse(input, out time))
            {
                return(input);
            }

            return(time.ToString(Format.TimeFormat));
        }
Exemplo n.º 13
0
        public static void ValidateString(DicomTag tag, string stringValue)
        {
            if (string.IsNullOrEmpty(stringValue))
            {
                return;
            }

            string[] temp = stringValue.Split(new[] { '\\' });
            foreach (string value in temp)
            {
                string   s = value.Trim();
                DateTime dt;
                if (!string.IsNullOrEmpty(s) && !TimeParser.Parse(s, out dt))
                {
                    throw new DicomDataException(string.Format("Invalid TM value '{0}' for {1}", value, tag));
                }
            }
        }
            public SegmentationActionContainer(SegmentationTool ownerTool, SegmentationMenuInfo info, int index)
            {
                _ownerTool = ownerTool;
                _info      = info;

                StringBuilder pathStringBuilder = new StringBuilder();

                pathStringBuilder.AppendFormat("{0}/", ImageViewerComponent.ContextMenuSite);
                // Multiple patients
                if (_ownerTool.Context.Viewer.StudyTree.Studies.Any(study => study.ParentPatient.PatientId != info.PatientId))
                {
                    pathStringBuilder.AppendFormat("{0} · {1}/", info.PatientsName, info.PatientId);
                }
                // Multiple Studies
                if (_ownerTool.Context.Viewer.StudyTree.Studies.Any(study => study.StudyInstanceUid != info.StudyInstanceUid))
                {
                    // We are trying to replicate what ImageSetDescriptior.GetName() does here:
                    string modalitiesInStudy = StringUtilities.Combine(CollectionUtils.Sort(
                                                                           _ownerTool.Context.Viewer.StudyTree.Studies.First(
                                                                               study => study.StudyInstanceUid == info.StudyInstanceUid).ModalitiesInStudy), ", ");

                    DateTime studyDate;
                    DateParser.Parse(info.StudyDate, out studyDate);
                    DateTime studyTime;
                    TimeParser.Parse(info.StudyTime, out studyTime);

                    pathStringBuilder.AppendFormat("{0} {1}", studyDate.ToString(Format.DateFormat), studyTime.ToString(Format.TimeFormat));
                    if (!string.IsNullOrEmpty(info.StudyAccessionNumber))
                    {
                        pathStringBuilder.AppendFormat(", A#: {0}", info.StudyAccessionNumber);
                    }
                    pathStringBuilder.AppendFormat(", [{0}] {1}/", modalitiesInStudy ?? "", info.StudyDescription);
                }
                pathStringBuilder.AppendFormat("SEG{0}", index);

                string actionId   = String.Format("{0}:apply{1}", typeof(SegmentationTool).FullName, index);
                var    actionPath = new ActionPath(pathStringBuilder.ToString(), _ownerTool._resolver);

                _action           = new MenuAction(actionId, actionPath, ClickActionFlags.None, _ownerTool._resolver);
                _action.GroupHint = new GroupHint("DisplaySets");

                _action.Label = String.Format("{0} SEG: {1}", _info.SeriesNumber, _info.DisplayLabel);
                _action.SetClickHandler(Apply);
            }
Exemplo n.º 15
0
        public override void ValidateString(DicomTag tag, string stringValue)
        {
            lock (_mutex)
            {
                if (stringValue == null || stringValue == "")
                {
                    return;
                }

                DateTime dt;
                string[] temp = stringValue.Split(new char[] { '\\' });
                foreach (string value in temp)
                {
                    string s = value.Trim();
                    if (s != null && s != "" && !TimeParser.Parse(s, out dt))
                    {
                        throw new DicomDataException(string.Format("Invalid TM value '{0}' for {1}", value, tag.ToString()));
                    }
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Compares two <see cref="StudyIdentifier"/>s.
        /// </summary>
        public int Compare(StudyIdentifier x, StudyIdentifier y)
        {
            DateTime?studyDateX = DateParser.Parse(x.StudyDate);
            DateTime?studyTimeX = TimeParser.Parse(x.StudyTime);

            DateTime?studyDateY = DateParser.Parse(y.StudyDate);
            DateTime?studyTimeY = TimeParser.Parse(y.StudyTime);

            DateTime?studyDateTimeX = studyDateX;

            if (studyDateTimeX != null && studyTimeX != null)
            {
                studyDateTimeX = studyDateTimeX.Value.Add(studyTimeX.Value.TimeOfDay);
            }

            DateTime?studyDateTimeY = studyDateY;

            if (studyDateTimeY != null && studyTimeY != null)
            {
                studyDateTimeY = studyDateTimeY.Value.Add(studyTimeY.Value.TimeOfDay);
            }

            if (studyDateTimeX == null)
            {
                if (studyDateTimeY == null)
                {
                    return(Math.Sign(x.StudyInstanceUid.CompareTo(y.StudyInstanceUid)));
                }
                else
                {
                    return(1);                    // > because we want x at the end.
                }
            }
            else if (studyDateY == null)
            {
                return(-1);                // < because we want x at the beginning.
            }
            //Return negative of x compared to y because we want most recent first.
            return(-Math.Sign(studyDateTimeX.Value.CompareTo(studyDateTimeY)));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the descriptive name of the <see cref="IImageSet"/>.
        /// </summary>
        protected virtual string GetName()
        {
            DateTime studyDate;

            DateParser.Parse(SourceStudy.StudyDate, out studyDate);
            DateTime studyTime;

            TimeParser.Parse(SourceStudy.StudyTime, out studyTime);

            string modalitiesInStudy = StringUtilities.Combine(SourceStudy.ModalitiesInStudy, ", ");

            var nameBuilder = new StringBuilder();

            nameBuilder.AppendFormat("{0} {1}", studyDate.ToString(Format.DateFormat),
                                     studyTime.ToString(Format.TimeFormat));

            if (!String.IsNullOrEmpty(SourceStudy.AccessionNumber))
            {
                nameBuilder.AppendFormat(", A#: {0}", SourceStudy.AccessionNumber);
            }

            nameBuilder.AppendFormat(", [{0}] {1}", modalitiesInStudy ?? "", SourceStudy.StudyDescription);

            if (LoadStudyError != null)
            {
                string serverName;
                if (Server == null)
                {
                    serverName = SR.LabelUnknownServer;
                }
                else
                {
                    serverName = Server.Name;
                }

                nameBuilder.Insert(0, String.Format("({0}) ", serverName));
            }

            return(nameBuilder.ToString());
        }
Exemplo n.º 18
0
        private IEnumerable <IComparable> GetCompareValues(IImageSet imageSet)
        {
            DateTime?studyDate = null;
            DateTime?studyTime = null;

            IDicomImageSetDescriptor descriptor = imageSet.Descriptor as IDicomImageSetDescriptor;

            if (descriptor == null)
            {
                if (imageSet.DisplaySets.Count == 0)
                {
                    Debug.Assert(false, "All image sets being sorted must have at least one display set with at least one image in order for them to be sorted properly.");
                }
                else if (imageSet.DisplaySets[0].PresentationImages.Count == 0)
                {
                    Debug.Assert(false, "All image sets being sorted must have at least one display set with at least one image in order for them to be sorted properly.");
                }
                else
                {
                    ISopProvider provider = imageSet.DisplaySets[0].PresentationImages[0] as ISopProvider;
                    if (provider != null)
                    {
                        studyDate = DateParser.Parse(provider.Sop.StudyDate);
                        studyTime = TimeParser.Parse(provider.Sop.StudyTime);
                    }
                }
            }
            else
            {
                studyDate = DateParser.Parse(descriptor.SourceStudy.StudyDate);
                studyTime = TimeParser.Parse(descriptor.SourceStudy.StudyTime);
            }

            yield return(studyDate);

            yield return(studyTime);

            yield return(imageSet.Name);
        }
Exemplo n.º 19
0
        public void Apply(InstrumentalArrangement arrangement, Action <string> Log)
        {
            var phrasesToMove = arrangement.Phrases
                                .Where(p => p.Name.StartsWith("moveto", StringComparison.OrdinalIgnoreCase) ||
                                       p.Name.StartsWith("moveR", StringComparison.OrdinalIgnoreCase))
                                .ToList();

            if (phrasesToMove.Count > 0)
            {
                Log("Processing 'move' phrases:");
            }
            else
            {
                return;
            }

            foreach (var phraseToMove in phrasesToMove)
            {
                // Find phrase iterations by matching phrase index
                int phraseId = arrangement.Phrases.IndexOf(phraseToMove);
                foreach (var phraseIterationToMove in arrangement.PhraseIterations.Where(pi => pi.PhraseId == phraseId))
                {
                    int    phraseTime = phraseIterationToMove.Time;
                    int    movetoTime;
                    string phraseToMoveName = phraseToMove.Name;

                    // Relative phrase moving right
                    if (phraseToMoveName.StartsWith("moveR", StringComparison.OrdinalIgnoreCase))
                    {
                        if (int.TryParse(phraseToMoveName.Substring("moveR".Length), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out int moveRightBy))
                        {
                            var level = arrangement.Levels[phraseToMove.MaxDifficulty];
                            movetoTime = TimeParser.FindTimeOfNthNoteFrom(level, phraseTime, moveRightBy);
                        }
                        else
                        {
                            string errorMessage = $"Unable to read value for 'moveR' phrase at {phraseTime.TimeToString()}. (Usage example: moveR2)";
                            _statusMessages.Add(new ImproverMessage(errorMessage, MessageType.Warning));
                            Log(errorMessage);

                            continue;
                        }
                    }
                    else // Parse the absolute time to move to from the phrase name
                    {
                        int?parsedTime = TimeParser.Parse(phraseToMoveName);
                        if (parsedTime.HasValue)
                        {
                            movetoTime = parsedTime.Value;
                        }
                        else
                        {
                            MoveToParseFailure(phraseTime, Log);
                            continue;
                        }
                    }

                    // Check if anchor(s) should be moved
                    foreach (var level in arrangement.Levels)
                    {
                        if (level.Difficulty > phraseToMove.MaxDifficulty)
                        {
                            break;
                        }

                        var anchors             = level.Anchors;
                        int originalAnchorIndex = anchors.FindIndexByTime(phraseTime);
                        int movetoAnchorIndex   = anchors.FindIndexByTime(movetoTime);

                        // If there is an anchor at the original position, but not at the new position, move it
                        if (originalAnchorIndex != -1 && movetoAnchorIndex == -1)
                        {
                            var originalAnchor = anchors[originalAnchorIndex];
                            anchors.Insert(originalAnchorIndex + 1, new Anchor(originalAnchor.Fret, movetoTime, originalAnchor.Width));

                            // Remove anchor at original phrase position if no note or chord present
                            if (level.Notes.FindIndexByTime(phraseTime) == -1 &&
                                level.Chords.FindIndexByTime(phraseTime) == -1)
                            {
                                anchors.RemoveAt(originalAnchorIndex);
                                Log($"--Moved anchor from {phraseTime.TimeToString()} to {movetoTime.TimeToString()}");
                            }
                            else
                            {
                                Log($"--Added anchor at {movetoTime.TimeToString()}");
                            }
                        }
                    }

                    // Move phraseIteration
                    phraseIterationToMove.Time = movetoTime;

                    // Move section (if present)
                    var sectionToMove = arrangement.Sections.FindByTime(phraseTime);
                    if (sectionToMove is not null)
                    {
                        sectionToMove.Time = movetoTime;
                        Log($"--Moved phrase and section from {phraseTime.TimeToString()} to {movetoTime.TimeToString()}");
                    }
                    else
                    {
                        Log($"--Moved phrase from {phraseTime.TimeToString()} to {movetoTime.TimeToString()}");
                    }

                    // Add new temporary beat
                    var beatToAdd = new Ebeat(movetoTime, XMLProcessor.TempMeasureNumber);

                    var insertIndex = arrangement.Ebeats.FindIndex(b => b.Time > movetoTime);
                    arrangement.Ebeats.Insert(insertIndex, beatToAdd);

                    // Set the beat for later removal
                    _addedBeats.Add(beatToAdd);
                }
            }
        }
        /// <summary>
        /// Load data from the specified reader.
        /// </summary>
        /// <param name="reader">CSV reader.</param>
        /// <param name="date">Date.</param>
        /// <returns>Data.</returns>
        protected override ExecutionMessage Read(FastCsvReader reader, DateTime date)
        {
            var msg = new ExecutionMessage
            {
                SecurityId            = SecurityId,
                ExecutionType         = ExecutionTypes.Transaction,
                ServerTime            = ReadTime(reader, date),
                TransactionId         = reader.ReadLong(),
                OriginalTransactionId = reader.ReadLong(),
                OrderId              = reader.ReadNullableLong(),
                OrderStringId        = reader.ReadString(),
                OrderBoardId         = reader.ReadString(),
                UserOrderId          = reader.ReadString(),
                OrderPrice           = reader.ReadDecimal(),
                OrderVolume          = reader.ReadNullableDecimal(),
                Balance              = reader.ReadNullableDecimal(),
                VisibleVolume        = reader.ReadNullableDecimal(),
                Side                 = reader.ReadEnum <Sides>(),
                OriginSide           = reader.ReadNullableEnum <Sides>(),
                OrderState           = reader.ReadNullableEnum <OrderStates>(),
                OrderType            = reader.ReadNullableEnum <OrderTypes>(),
                TimeInForce          = reader.ReadNullableEnum <TimeInForce>(),
                TradeId              = reader.ReadNullableLong(),
                TradeStringId        = reader.ReadString(),
                TradePrice           = reader.ReadNullableDecimal(),
                TradeVolume          = reader.ReadNullableDecimal(),
                PortfolioName        = reader.ReadString(),
                ClientCode           = reader.ReadString(),
                BrokerCode           = reader.ReadString(),
                DepoName             = reader.ReadString(),
                IsSystem             = reader.ReadNullableBool(),
                HasOrderInfo         = reader.ReadBool(),
                HasTradeInfo         = reader.ReadBool(),
                Commission           = reader.ReadNullableDecimal(),
                Currency             = reader.ReadNullableEnum <CurrencyTypes>(),
                Comment              = reader.ReadString(),
                SystemComment        = reader.ReadString(),
                DerivedOrderId       = reader.ReadNullableLong(),
                DerivedOrderStringId = reader.ReadString(),
                IsUpTick             = reader.ReadNullableBool(),
                IsCancelled          = reader.ReadBool(),
                OpenInterest         = reader.ReadNullableDecimal(),
                PnL         = reader.ReadNullableDecimal(),
                Position    = reader.ReadNullableDecimal(),
                Slippage    = reader.ReadNullableDecimal(),
                TradeStatus = reader.ReadNullableInt(),
                OrderStatus = reader.ReadNullableLong(),
                Latency     = reader.ReadNullableLong().To <TimeSpan?>(),
            };

            var error = reader.ReadString();

            if (!error.IsEmpty())
            {
                msg.Error = new InvalidOperationException(error);
            }

            var dtStr = reader.ReadString();

            if (dtStr != null)
            {
                msg.ExpiryDate = (DateParser.Parse(dtStr) + TimeParser.Parse(reader.ReadString())).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Replace("+", string.Empty)));
            }
            else
            {
                reader.Skip(2);
            }

            return(msg);
        }
        public GeneralImageAnnotationItemProvider()
            : base("AnnotationItemProviders.Dicom.GeneralImage", new AnnotationResourceResolver(typeof(GeneralImageAnnotationItemProvider).Assembly))
        {
            _annotationItems = new List <IAnnotationItem>();

            AnnotationResourceResolver resolver = new AnnotationResourceResolver(this);

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.AcquisitionDate",
                    resolver,
                    delegate(Frame frame) { return(frame.AcquisitionDate); },
                    DicomDataFormatHelper.DateFormat
                )
            );


            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.AcquisitionTime",
                    resolver,
                    delegate(Frame frame) { return(frame.AcquisitionTime); },
                    delegate(string input)
            {
                if (String.IsNullOrEmpty(input))
                {
                    return(String.Empty);
                }

                DateTime time;
                if (!TimeParser.Parse(input, out time))
                {
                    return(input);
                }

                return(time.ToString("HH:mm:ss.FFFFFF"));
            }
                )
            );


            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.AcquisitionDateTime",
                    resolver,
                    delegate(Frame frame) { return(frame.AcquisitionDateTime); },
                    delegate(string input)
            {
                if (String.IsNullOrEmpty(input))
                {
                    return(String.Empty);
                }

                DateTime dateTime;
                if (!DateTimeParser.Parse(input, out dateTime))
                {
                    return(input);
                }

                return(String.Format("{0} {1}",
                                     dateTime.Date.ToString(Format.DateFormat),
                                     dateTime.ToString("HH:mm:ss.FFFFFF")));
            }
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.AcquisitionNumber",
                    resolver,
                    delegate(Frame frame) { return(frame.AcquisitionNumber.ToString()); },
                    DicomDataFormatHelper.RawStringFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.ContentDate",
                    resolver,
                    FrameDataRetrieverFactory.GetStringRetriever(DicomTags.ContentDate),
                    DicomDataFormatHelper.DateFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.ContentTime",
                    resolver,
                    FrameDataRetrieverFactory.GetStringRetriever(DicomTags.ContentTime),
                    DicomDataFormatHelper.TimeFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.DerivationDescription",
                    resolver,
                    FrameDataRetrieverFactory.GetStringRetriever(DicomTags.DerivationDescription),
                    DicomDataFormatHelper.RawStringFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.ImageComments",
                    resolver,
                    delegate(Frame frame) { return(frame.ImageComments); },
                    DicomDataFormatHelper.RawStringFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.ImagesInAcquisition",
                    resolver,
                    delegate(Frame frame) { return(frame.ImagesInAcquisition.ToString()); },
                    DicomDataFormatHelper.RawStringFormat
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.ImageType",
                    resolver,
                    delegate(Frame frame) { return(frame.ImageType); },
                    DicomDataFormatHelper.RawStringFormat
                )
            );

            _annotationItems.Add(new InstanceNumberAnnotationItem());

            _annotationItems.Add
            (
                new LossyImagePresentationAnnotationItem
                (
                    "Dicom.GeneralImage.LossyImageCompression",
                    resolver
                )
            );

            _annotationItems.Add
            (
                new DicomAnnotationItem <string>
                (
                    "Dicom.GeneralImage.QualityControlImage",
                    resolver,
                    FrameDataRetrieverFactory.GetStringRetriever(DicomTags.QualityControlImage),
                    DicomDataFormatHelper.BooleanFormatter
                )
            );

            _annotationItems.Add
            (
                new LateralityViewPositionAnnotationItem
                (
                    "Dicom.GeneralImage.ViewPosition",
                    false, true
                )
            );

            _annotationItems.Add
            (
                new LateralityViewPositionAnnotationItem
                (
                    "Dicom.GeneralImage.ImageLaterality",
                    true, false
                )
            );

            _annotationItems.Add
            (
                new LateralityViewPositionAnnotationItem
                (
                    "Dicom.GeneralImage.Composite.LateralityViewPosition",
                    true, true
                )
            );
        }
Exemplo n.º 22
0
        public void TestTimeParser()
        {
            //According to Dicom, any part of the time that is omitted is zero.
            //These are all valid time formats.
            DateTime time;
            DateTime testTime;
            bool     returnValue = TimeParser.Parse("000000", out time);

            Assert.IsTrue(returnValue);
            testTime = new DateTime(1, 1, 1, 0, 0, 0);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("22", out time);
            Assert.IsTrue(returnValue);
            testTime = new DateTime(1, 1, 1, 22, 0, 0);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("2217", out time);
            Assert.IsTrue(returnValue);
            testTime = new DateTime(1, 1, 1, 22, 17, 0);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721", out time);
            Assert.IsTrue(returnValue);
            testTime = new DateTime(1, 1, 1, 22, 17, 21);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            //zero fraction
            returnValue = TimeParser.Parse("221721.000000", out time);
            Assert.IsTrue(returnValue);
            testTime = new DateTime(1, 1, 1, 22, 17, 21);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            //maximum fraction defined by Dicom
            returnValue = TimeParser.Parse("221721.999999", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(9999990);          //ticks are in units of 100 nano-seconds (1e9 * 100 = 1e7)
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            //arbitrary length fractions
            returnValue = TimeParser.Parse("221721.1", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1000000);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721.12", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1200000);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721.123", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1230000);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721.1234", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1234000);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721.12345", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1234500);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("221721.123456", out time);
            testTime    = new DateTime(1, 1, 1, 22, 17, 21);
            testTime    = testTime.AddTicks(1234560);
            Assert.IsTrue(returnValue);
            Assert.AreEqual(time.TimeOfDay, testTime.TimeOfDay);

            returnValue = TimeParser.Parse("240000", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("236000", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("230060", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("a21721.12345", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("22a721.12345", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("2217a1.12345", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse("221721.a2345", out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse(String.Empty, out time);
            Assert.IsFalse(returnValue);

            returnValue = TimeParser.Parse(null, out time);
            Assert.IsFalse(returnValue);
        }
Exemplo n.º 23
0
 public void Parse(string input, string output)
 {
     var parser = new TimeParser();
      NUF.Assert.That(parser.Parse(input), NUF.Is.EqualTo(output));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Read data from the specified reader.
        /// </summary>
        /// <param name="reader">CSV reader.</param>
        /// <param name="date">Date.</param>
        /// <returns>Data.</returns>
        protected override Level1ChangeMessage Read(FastCsvReader reader, DateTime date)
        {
            var level1 = new Level1ChangeMessage
            {
                SecurityId = SecurityId,
                ServerTime = ReadTime(reader, date),
            };

            foreach (var field in _level1Fields)
            {
                switch (field)
                {
                case Level1Fields.BestAskTime:
                case Level1Fields.BestBidTime:
                case Level1Fields.LastTradeTime:
                    var dtStr = reader.ReadString();

                    if (dtStr != null)
                    {
                        level1.Changes.Add(field, (DateParser.Parse(dtStr) + TimeParser.Parse(reader.ReadString())).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+"))));
                    }
                    else
                    {
                        reader.Skip(2);
                    }

                    break;

                case Level1Fields.LastTradeId:
                    var id = reader.ReadNullableLong();

                    if (id != null)
                    {
                        level1.Changes.Add(field, id);
                    }

                    break;

                case Level1Fields.AsksCount:
                case Level1Fields.BidsCount:
                case Level1Fields.TradesCount:
                    var count = reader.ReadNullableLong();

                    if (count != null)
                    {
                        level1.Changes.Add(field, count);
                    }

                    break;

                case Level1Fields.LastTradeUpDown:
                case Level1Fields.IsSystem:
                    var flag = reader.ReadNullableBool();

                    if (flag != null)
                    {
                        level1.Changes.Add(field, flag);
                    }

                    break;

                default:
                    var value = reader.ReadNullableDecimal();

                    if (value != null)
                    {
                        level1.Changes.Add(field, value);
                    }

                    break;
                }
            }

            return(level1);
        }
Exemplo n.º 25
0
        private void UpdateFields()
        {
            if (Study == null)
            {
                return;
            }

            var patientName   = new PersonName(Study.PatientsName);
            var physicianName = new PersonName(Study.ReferringPhysiciansName);

            PatientNamePanel.PersonName            = patientName;
            ReferringPhysicianNamePanel.PersonName = physicianName;

            // Patient Information
            if (!string.IsNullOrEmpty(Study.PatientsSex))
            {
                switch (Study.PatientsSex)
                {
                case "M":
                    PatientGender.SelectedIndex = 1;
                    break;

                case "F":
                    PatientGender.SelectedIndex = 2;
                    break;

                case "O":
                    PatientGender.SelectedIndex = 3;
                    break;

                default:
                    PatientGender.SelectedIndex = 0;
                    break;
                }
            }
            else
            {
                PatientGender.SelectedIndex = 0;
            }

            PatientID.Text = Study.PatientId;
            DateTime?birthDate = String.IsNullOrEmpty(Study.PatientsBirthDate)? null:DateParser.Parse(Study.PatientsBirthDate);

            if (birthDate == null)
            {
                PatientBirthDate.Text = String.Empty; // calendar fills in the default date if it's null, we don't want that to happen.
            }
            if (!String.IsNullOrEmpty(Study.PatientsAge))
            {
                PatientAge.Text = Study.PatientsAge.Substring(0, 3).TrimStart('0');
                switch (Study.PatientsAge.Substring(3))
                {
                case "Y":
                    PatientAgePeriod.SelectedIndex = 0;
                    break;

                case "M":
                    PatientAgePeriod.SelectedIndex = 1;
                    break;

                case "W":
                    PatientAgePeriod.SelectedIndex = 2;
                    break;

                default:
                    PatientAgePeriod.SelectedIndex = 3;
                    break;
                }
            }
            else
            {
                PatientAge.Text = string.Empty;
                PatientAgePeriod.SelectedIndex = 0;
            }

            // Study Information
            StudyDescription.Text = Study.StudyDescription;
            StudyID.Text          = Study.StudyId;
            AccessionNumber.Text  = Study.AccessionNumber;

            if (!string.IsNullOrEmpty(Study.StudyDate))
            {
                DateTime?studyDate = DateParser.Parse(Study.StudyDate);
                StudyDateCalendarExtender.SelectedDate = studyDate;
            }
            else
            {
                StudyDateCalendarExtender.SelectedDate = null;
            }


            if (!string.IsNullOrEmpty(Study.StudyTime))
            {
                DateTime?studyTime = TimeParser.Parse(Study.StudyTime);
                if (studyTime != null)
                {
                    StudyTimeHours.Text = String.Format("{0:00}", studyTime.Value.Hour);

                    StudyTimeMinutes.Text = String.Format("{0:00}", studyTime.Value.Minute);
                    StudyTimeSeconds.Text = String.Format("{0:00}", studyTime.Value.Second);
                }
                else
                {
                    // The time is invalid, display it in the boxes
                    StudyTimeHours.Text   = "";
                    StudyTimeMinutes.Text = "";
                    StudyTimeSeconds.Text = "";
                }
            }
            else
            {
                StudyTimeHours.Text   = "00";
                StudyTimeMinutes.Text = "00";
                StudyTimeSeconds.Text = "00";
            }

            ReasonListBox.SelectedIndex = 0;
            if (string.IsNullOrEmpty(ReasonListBox.SelectedValue))
            {
                Comment.Text = string.Empty;
            }
            else
            {
                Comment.Text = SR.CustomReasonComment;
            }
            SaveReasonAsName.Text = string.Empty;

            AttachmentExistWarning.Visible = this.Study.HasAttachment;

            DataBind();
        }
 public void WillThrow_OnGarbageInput()
 {
     _sut.Parse("hello world");
 }
Exemplo n.º 27
0
        public static ImageProperty Create(DicomAttribute attribute, string category, string name, string description, string separator)
        {
            // always use the hex value as the identifier, so that private and unknown tags aren't all mapped to the same identifier
            string identifier = attribute.Tag.HexString;

            if (category == null)
            {
                category = string.Empty;
            }

            if (string.IsNullOrEmpty(name))
            {
                name = GetTagName(attribute.Tag);
            }

            if (string.IsNullOrEmpty(description))
            {
                description = GetTagDescription(attribute.Tag);
            }

            if (attribute.IsNull || attribute.IsEmpty)
            {
                return(new ImageProperty(identifier, category, name, description, string.Empty));
            }

            if (String.IsNullOrEmpty(separator))
            {
                separator = ", ";
            }

            object value;

            if (attribute.Tag.VR.Name == DicomVr.DAvr.Name)
            {
                value = StringUtilities.Combine(attribute.Values as string[], separator,
                                                delegate(string dateString)
                {
                    DateTime?date = DateParser.Parse(dateString);
                    if (!date.HasValue)
                    {
                        return(null);
                    }
                    else
                    {
                        return(Format.Date(date.Value));
                    }
                }, true);
            }
            else if (attribute.Tag.VR.Name == DicomVr.TMvr.Name)
            {
                value = StringUtilities.Combine(attribute.Values as string[], separator,
                                                delegate(string timeString)
                {
                    DateTime?time = TimeParser.Parse(timeString);
                    if (!time.HasValue)
                    {
                        return(null);
                    }
                    else
                    {
                        return(Format.Time(time.Value));
                    }
                }, true);
            }
            else if (attribute.Tag.VR.Name == DicomVr.DTvr.Name)
            {
                value = StringUtilities.Combine(attribute.Values as string[], separator,
                                                delegate(string dateTimeString)
                {
                    DateTime?dateTime = DateTimeParser.Parse(dateTimeString);
                    if (!dateTime.HasValue)
                    {
                        return(null);
                    }
                    else
                    {
                        return(Format.Time(dateTime.Value));
                    }
                }, true);
            }
            else if (attribute.Tag.VR.Name == DicomVr.PNvr.Name)
            {
                value = StringUtilities.Combine(attribute.Values as string[], separator,
                                                delegate(string nameString)
                {
                    PersonName personName = new PersonName(nameString ?? "");
                    return(personName.FormattedName);
                }, true);
            }
            else if (attribute.Tag.VR == DicomVr.SQvr)
            {
                value = string.Empty;

                var values = attribute.Values as DicomSequenceItem[];
                if (values != null && values.Length > 0)
                {
                    // handle simple use case by listing only the attributes of the first sequence item
                    // since user can always use DICOM editor for more complex use cases
                    var subproperties = new List <IImageProperty>();
                    foreach (var subattribute in values[0])
                    {
                        subproperties.Add(Create(subattribute, string.Empty, null, null, null));
                    }
                    subproperties.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase));
                    value = subproperties.ToArray();
                }
            }
            else if (attribute.Tag.VR.IsTextVR && attribute.GetValueType() == typeof(string[]))
            {
                value = StringUtilities.Combine(attribute.Values as string[], separator, true);
            }
            else
            {
                value = attribute.ToString();
            }

            return(new ImageProperty(identifier, category, name, description, value));
        }
 public void Parse_ShouldThrowException_WhenGivenValueIsNull()
 {
     Assert.Throws <Exception>(() => _sut.Parse(null));
 }
Exemplo n.º 29
0
        public static void Main(string[] args)
        {
            var options = new Options();
             CommandLine.ICommandLineParser cmdParser =
               new CommandLine.CommandLineParser(new CommandLine.CommandLineParserSettings(System.Console.Error));

             if (cmdParser.ParseArguments(args, options)) {
            string connectionString = string.Format("URI=file:{0}", options.Database);

            #if (NET)
            var connection = new System.Data.SQLite.SQLiteConnection(connectionString);
            #else
            var connection = new Mono.Data.Sqlite.SqliteConnection(connectionString);
            #endif

            connection.Open();
            var command = connection.CreateCommand();
            command.CommandText =
              "CREATE TABLE IF NOT EXISTS at (id INTEGER PRIMARY KEY  NOT NULL,name VARCHAR,surname VARCHAR,year INTEGER,gender CHAR,time VARCHAR)";
            command.ExecuteNonQuery();
            var repo = new AthleteRepository(command);
            switch (options.Action) {
               case Action.Module: {
                  // 10mm d=> 28pt
                  // 15mm => 42pt
                  //float marginLeft, float marginRight, float marginTop, float marginBottom
                  var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 36, 36);
                  iTextSharp.text.pdf.PdfWriter.GetInstance(document,
                                                            new System.IO.FileStream("./module.pdf", System.IO.FileMode.Create));
                  document.Open();
                  var builder = new ModuleBuilder(document, options.YearEdition, 10);
                  for (int page = 0; page < 10; page++) {
                     builder.AddPage();
                  }
                  document.Close();
                  break;
               }
               case Action.Insert: {
                  System.Console.WriteLine("Drop all results?[y/N]?");
                  string yes  = System.Console.ReadLine();
                  if (yes == "y") {
                     FileHelpers.FileHelperEngine<Athlete> engine = new FileHelpers.FileHelperEngine<Athlete>();
                     Athlete[] athletes = engine.ReadFile(options.Input);

                     repo.DeleteAll();
                     foreach (var a in athletes) {
                        System.Console.WriteLine(a.Name);
                        repo.Insert(a);
                     }
                  }
                  break;
               }
               case Action.CreateList:
               case Action.CreateResult: {
                  string catFileName = GetCatFileName(options);
                  string reportFileName = GetReportFileName(options);
                  var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 36, 36);
                  iTextSharp.text.pdf.PdfWriter.GetInstance(document,
                                                            new System.IO.FileStream(reportFileName, System.IO.FileMode.Create));
                  document.Open();
                  IBuilder builder = null;

                  if (options.Action == Action.CreateList) {
                     builder = new ListBuilder(document);
                  } else {
                     builder = new PdfBuilder(document);
                  }

                  Category[] cats = GetCategories(catFileName);
                  foreach (Category cat in cats) {
                     if (log.IsDebugEnabled) log.Debug("parse" + cat.Id);
                     builder.BeginReport(cat.Title, options.YearEdition);
                     var athletes = repo.Query(string.Format (cat.Sql, options.YearEdition));
                     foreach (Athlete athlete in athletes) {
                        builder.Add(athlete);
                     }
                     builder.EndReport();
                  }
                  document.Close();
                  break;
               }
               case Action.Interactive: {
                  Category[] cats = GetCategories(GetCatFileName(options));
                  var parser = new TimeParser();
                  foreach (Category cat in cats) {
                     System.Console.WriteLine("========{0}=========", cat.Id);
                     var athletes = repo.Query(string.Format (cat.Sql, options.YearEdition));
                     foreach (Athlete athlete in athletes) {
                        System.Console.Write("{0:00} {1}\t{2}({3}):", athlete.Id, athlete.Surname, athlete.Name, athlete.Gender);
                        string time = string.Empty;
                        string fmt = string.Empty;
                        do {
                           time = System.Console.ReadLine();
                           fmt = parser.Parse(time);
                           if (!string.IsNullOrEmpty(fmt) ) {
                              System.Console.WriteLine(fmt);
                              repo.UpdateTime(athlete.Id, fmt);
                           } else {
                              if (time != "s") {
                                 System.Console.WriteLine("invalid..");
                              }
                           }
                        } while (string.IsNullOrEmpty(fmt) && time != "s");
                     }
                  }
                  break;
               }
            }
            connection.Close();
             }
        }
Exemplo n.º 30
0
        public void Update(StudyXml studyXml)
        {
            Platform.CheckForNullReference(studyXml, "studyXml");

            var dataSet = studyXml.First().First().Collection;

            DicomAttribute attribute       = dataSet[DicomTags.StudyInstanceUid];
            string         datasetStudyUid = attribute.ToString();

            if (!String.IsNullOrEmpty(StudyInstanceUid) && StudyInstanceUid != datasetStudyUid)
            {
                string message = String.Format("The study uid in the data set does not match this study's uid ({0} != {1}).",
                                               datasetStudyUid, StudyInstanceUid);

                throw new InvalidOperationException(message);
            }

            StudyInstanceUid = attribute.ToString();

            Platform.CheckForEmptyString(StudyInstanceUid, "StudyInstanceUid");

            _studyXml = studyXml;

            attribute = dataSet[DicomTags.PatientId];
            PatientId = attribute.ToString();

            attribute    = dataSet[DicomTags.PatientsName];
            PatientsName = new PersonName(attribute.ToString());

            attribute = dataSet[DicomTags.ReferringPhysiciansName];
            ReferringPhysiciansName = new PersonName(attribute.ToString());

            attribute   = dataSet[DicomTags.PatientsSex];
            PatientsSex = attribute.ToString();

            attribute            = dataSet[DicomTags.PatientsBirthDate];
            PatientsBirthDateRaw = attribute.ToString();
            PatientsBirthDate    = DateParser.Parse(PatientsBirthDateRaw);

            attribute            = dataSet[DicomTags.PatientsBirthTime];
            PatientsBirthTimeRaw = attribute.ToString();
            var time = TimeParser.Parse(PatientsBirthTimeRaw);

            if (time.HasValue)
            {
                PatientsBirthTimeTicks = time.Value.TimeOfDay.Ticks;
            }
            else
            {
                PatientsBirthTimeTicks = null;
            }

            attribute = dataSet[DicomTags.StudyId];
            StudyId   = attribute.ToString();

            attribute       = dataSet[DicomTags.AccessionNumber];
            AccessionNumber = attribute.ToString();

            attribute        = dataSet[DicomTags.StudyDescription];
            StudyDescription = attribute.ToString();

            attribute    = dataSet[DicomTags.StudyDate];
            StudyDateRaw = attribute.ToString();
            StudyDate    = DateParser.Parse(StudyDateRaw);

            attribute    = dataSet[DicomTags.StudyTime];
            StudyTimeRaw = attribute.ToString();
            time         = TimeParser.Parse(StudyTimeRaw);
            if (time.HasValue)
            {
                StudyTimeTicks = time.Value.TimeOfDay.Ticks;
            }
            else
            {
                StudyTimeTicks = null;
            }

            if (dataSet.Contains(DicomTags.ProcedureCodeSequence))
            {
                attribute = dataSet[DicomTags.ProcedureCodeSequence];
                if (!attribute.IsEmpty && !attribute.IsNull)
                {
                    DicomSequenceItem sequence = ((DicomSequenceItem[])attribute.Values)[0];
                    ProcedureCodeSequenceCodeValue = sequence[DicomTags.CodeValue].ToString();
                    ProcedureCodeSequenceCodingSchemeDesignator = sequence[DicomTags.CodingSchemeDesignator].ToString();
                }
            }

            attribute = dataSet[DicomTags.PatientSpeciesDescription];
            PatientSpeciesDescription = attribute.ToString();

            if (dataSet.Contains(DicomTags.PatientSpeciesCodeSequence))
            {
                attribute = dataSet[DicomTags.PatientSpeciesCodeSequence];
                if (!attribute.IsEmpty && !attribute.IsNull)
                {
                    DicomSequenceItem sequence = ((DicomSequenceItem[])attribute.Values)[0];
                    PatientSpeciesCodeSequenceCodingSchemeDesignator = sequence[DicomTags.CodingSchemeDesignator].ToString();
                    PatientSpeciesCodeSequenceCodeValue   = sequence[DicomTags.CodeValue].ToString();
                    PatientSpeciesCodeSequenceCodeMeaning = sequence[DicomTags.CodeMeaning].ToString();
                }
            }

            attribute = dataSet[DicomTags.PatientBreedDescription];
            PatientBreedDescription = attribute.ToString();

            if (dataSet.Contains(DicomTags.PatientBreedCodeSequence))
            {
                attribute = dataSet[DicomTags.PatientBreedCodeSequence];
                if (!attribute.IsEmpty && !attribute.IsNull)
                {
                    DicomSequenceItem sequence = ((DicomSequenceItem[])attribute.Values)[0];
                    PatientBreedCodeSequenceCodingSchemeDesignator = sequence[DicomTags.CodingSchemeDesignator].ToString();
                    PatientBreedCodeSequenceCodeValue   = sequence[DicomTags.CodeValue].ToString();
                    PatientBreedCodeSequenceCodeMeaning = sequence[DicomTags.CodeMeaning].ToString();
                }
            }

            attribute         = dataSet[DicomTags.ResponsiblePerson];
            ResponsiblePerson = new PersonName(attribute.ToString());

            attribute             = dataSet[DicomTags.ResponsiblePersonRole];
            ResponsiblePersonRole = attribute.ToString();

            attribute = dataSet[DicomTags.ResponsibleOrganization];
            ResponsibleOrganization = attribute.ToString();

            attribute            = dataSet[DicomTags.SpecificCharacterSet];
            SpecificCharacterSet = attribute.ToString();

            var modalities = _studyXml
                             .Select(s => s.First()[DicomTags.Modality].GetString(0, null))
                             .Where(value => !String.IsNullOrEmpty(value)).Distinct();

            ModalitiesInStudy = DicomStringHelper.GetDicomStringArray(modalities);

            var stationNames = _studyXml
                               .Select(s => s.First()[DicomTags.StationName].GetString(0, null))
                               .Where(value => !String.IsNullOrEmpty(value)).Distinct();

            StationNamesInStudy = DicomStringHelper.GetDicomStringArray(stationNames);

            var institutionNames = _studyXml
                                   .Select(s => s.First()[DicomTags.InstitutionName].GetString(0, null))
                                   .Where(value => !String.IsNullOrEmpty(value)).Distinct();

            InstitutionNamesInStudy = DicomStringHelper.GetDicomStringArray(institutionNames);

            var sopClasses = (from series in _studyXml
                              from instance in series
                              where instance.SopClass != null
                              select instance.SopClass.Uid).Distinct();

            SopClassesInStudy = DicomStringHelper.GetDicomStringArray(sopClasses);

            #region Meta Info

            var sourceAEs = (from series in _studyXml
                             from instance in series
                             where !String.IsNullOrEmpty(instance.SourceAETitle)
                             select instance.SourceAETitle).Distinct();
            SourceAETitlesInStudy = DicomStringHelper.GetDicomStringArray(sourceAEs);

            #endregion

            //these have to be here, rather than in Initialize b/c they are
            // computed from the series, which are parsed from the xml.
            NumberOfStudyRelatedSeries    = _studyXml.NumberOfStudyRelatedSeries;
            NumberOfStudyRelatedInstances = _studyXml.NumberOfStudyRelatedInstances;
        }