public TestsForDicomFilePatternApplier() { var dicomTagParser = new DicomTagParser(); var folderNameCleaner = new FolderNameCleaner(); _patternApplier = new PatternApplier(dicomTagParser, folderNameCleaner); }
/// <summary> /// Normalize custom tag entry before saving to CustomTagStore. /// </summary> /// <param name="customTagEntry">The custom tag entry.</param> /// <returns>Normalize custom tag entry.</returns> public static CustomTagEntry Normalize(this CustomTagEntry customTagEntry) { DicomTagParser dicomTagParser = new DicomTagParser(); DicomTag[] tags; if (!dicomTagParser.TryParse(customTagEntry.Path, out tags, supportMultiple: false)) { // not a valid dicom tag path throw new CustomTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.InvalidCustomTag, customTagEntry)); } DicomTag tag = tags[0]; string path = tag.GetPath(); string vr = customTagEntry.VR; // when VR is not specified for standard tag, if (!tag.IsPrivate && tag.DictionaryEntry != DicomDictionary.UnknownTag) { if (string.IsNullOrWhiteSpace(vr)) { vr = tag.GetDefaultVR()?.Code; } } vr = vr.ToUpperInvariant(); return(new CustomTagEntry(path, vr, customTagEntry.Level, customTagEntry.Status)); }
/// <summary> /// Normalize extended query tag entry before saving to ExtendedQueryTagStore. /// </summary> /// <param name="extendedQueryTagEntry">The extended query tag entry.</param> /// <returns>Normalize extended query tag entry.</returns> public static AddExtendedQueryTagEntry Normalize(this AddExtendedQueryTagEntry extendedQueryTagEntry) { DicomTagParser dicomTagParser = new DicomTagParser(); DicomTag[] tags; if (!dicomTagParser.TryParse(extendedQueryTagEntry.Path, out tags, supportMultiple: false)) { // not a valid dicom tag path throw new ExtendedQueryTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.InvalidExtendedQueryTag, extendedQueryTagEntry)); } DicomTag tag = tags[0]; string path = tag.GetPath(); string vr = extendedQueryTagEntry.VR; string privateCreator = string.IsNullOrWhiteSpace(extendedQueryTagEntry.PrivateCreator) ? null : extendedQueryTagEntry.PrivateCreator; // when VR is not specified for known tags if (tag.DictionaryEntry != DicomDictionary.UnknownTag) { if (string.IsNullOrWhiteSpace(vr)) { vr = tag.GetDefaultVR()?.Code; } } vr = vr?.ToUpperInvariant(); return(new AddExtendedQueryTagEntry() { Path = path, VR = vr, PrivateCreator = privateCreator, Level = extendedQueryTagEntry.Level, }); }
public void ShouldParseTagByGroupAndElement() { DicomTagParser.TryParse("(0008,0050)", out var dicomTag).Should().BeTrue(); dicomTag.Should().Be(DicomTag.AccessionNumber); }
public void ShouldNotParseUnknownTag() { DicomTagParser.TryParse("Banana", out _).Should().BeFalse(); }
public void ShouldParseTagByName() { DicomTagParser.TryParse("AccessionNumber", out var dicomTag).Should().BeTrue(); dicomTag.Should().Be(DicomTag.AccessionNumber); }
public TestsForDicomTagParser() { _dicomTagParser = new DicomTagParser(); }