public async Task <GetCustomTagResponse> GetCustomTagAsync(string tagPath, CancellationToken cancellationToken) { string internalTagPath = _dicomTagParser.ParseFormattedTagPath(tagPath); CustomTagEntry customTag = await _customTagStore.GetCustomTagAsync(internalTagPath, cancellationToken); return(new GetCustomTagResponse(customTag)); }
/// <summary> /// Validate custom tag entry. /// </summary> /// <param name="tagEntry">the tag entry.</param> private void ValidateCustomTagEntry(CustomTagEntry tagEntry) { DicomTag tag = ParseTag(tagEntry.Path); // cannot be any tag we already support if (QueryLimit.AllInstancesTags.Contains(tag)) { throw new CustomTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.CustomTagAlreadyExists, tag.DictionaryEntry.Name)); } if (tag.IsPrivate) { // this is private tag, VR is required ParseVRCode(tagEntry.VR); EnsureVRIsSupported(tagEntry.VR); } else { // stardard tag must have name - should not be "Unknown". if (tag.DictionaryEntry.Equals(DicomDictionary.UnknownTag)) { // not a valid dicom tag throw new CustomTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.InvalidCustomTag, tag)); } if (string.IsNullOrWhiteSpace(tagEntry.VR)) { // When VR is missing for standard tag, still need to verify VRCode string vrCode = tag.GetDefaultVR()?.Code; EnsureVRIsSupported(vrCode); } else { // when VR is specified, verify it's correct // parse VR DicomVR vr = ParseVRCode(tagEntry.VR); EnsureVRIsSupported(vr.Code); if (!tag.DictionaryEntry.ValueRepresentations.Contains(vr)) { // not a valid VR throw new CustomTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.UnsupportedVRCodeOnTag, vr.Code, tag)); } } } }
public async Task <AddCustomTagResponse> AddCustomTagAsync(IEnumerable <CustomTagEntry> customTags, CancellationToken cancellationToken) { _customTagEntryValidator.ValidateCustomTags(customTags); IEnumerable <CustomTagEntry> result = customTags.Select(item => { CustomTagEntry normalized = item.Normalize(); normalized.Status = CustomTagStatus.Added; return(normalized); }); await _customTagStore.AddCustomTagsAsync(result, cancellationToken); // Current solution is synchronouse, no job uri is generated, so always return emtpy. return(new AddCustomTagResponse(job: string.Empty)); }