コード例 #1
0
        public void GivenExtendedQueryPrivateTag_WithUrl_ParseSucceeds()
        {
            DicomTag tag      = new DicomTag(0x0405, 0x1001, "PrivateCreator1");
            QueryTag queryTag = new QueryTag(tag.BuildExtendedQueryTagStoreEntry(vr: DicomVRCode.CS, level: QueryTagLevel.Study));

            QueryExpression queryExpression = _queryParser.Parse(CreateParameters(GetSingleton(tag.GetPath(), "Test"), QueryResource.AllStudies), new[] { queryTag });

            Assert.Equal(queryTag, queryExpression.FilterConditions.First().QueryTag);
        }
コード例 #2
0
        public async Task GivenValidTagPath_WhenDeleteExtendedQueryTagIsInvoked_ThenShouldSucceed()
        {
            DicomTag tag     = DicomTag.DeviceSerialNumber;
            string   tagPath = tag.GetPath();
            var      entry   = new ExtendedQueryTagStoreJoinEntry(tag.BuildExtendedQueryTagStoreEntry());

            _extendedQueryTagStore.GetExtendedQueryTagAsync(tagPath, default).Returns(entry);
            await _extendedQueryTagService.DeleteExtendedQueryTagAsync(tagPath);

            await _extendedQueryTagStore.Received(1).DeleteExtendedQueryTagAsync(tagPath, entry.VR);
        }
コード例 #3
0
        public void GivenExtendedQueryPrivateTag_WithUrl_ParseSucceeds()
        {
            DicomTag tag         = new DicomTag(0x0405, 0x1001, "PrivateCreator1");
            string   value       = "Test";
            var      queryString = $"{tag.GetPath()}={value}";
            QueryTag queryTag    = new QueryTag(tag.BuildExtendedQueryTagStoreEntry(vr: DicomVRCode.CS, level: QueryTagLevel.Study));

            QueryExpression queryExpression = _queryParser.Parse(CreateRequest(GetQueryCollection(queryString), QueryResource.AllStudies), new[] { queryTag });

            Assert.Equal(queryTag, queryExpression.FilterConditions.First().QueryTag);
        }
コード例 #4
0
        public async Task GivenExtendedQueryTags_WhenValidating_ThenExtendedQueryTagsShouldBeValidated()
        {
            DicomTag standardTag = DicomTag.DestinationAE;

            // AE > 16 characters is not allowed
            _dicomDataset.Add(standardTag, "01234567890123456");

            QueryTag indextag = new QueryTag(standardTag.BuildExtendedQueryTagStoreEntry());

            _queryTags.Add(indextag);
            await ExecuteAndValidateException <ElementValidationException>(ValidationFailedFailureCode);
        }
コード例 #5
0
        public void GivenStandardExtendedQueryTag_WhenInitialize_ThenShouldCreatedSuccessfully()
        {
            DicomTag      tag        = DicomTag.AcquisitionDate;
            QueryTagLevel level      = QueryTagLevel.Series;
            var           storeEntry = tag.BuildExtendedQueryTagStoreEntry(level: level);
            QueryTag      queryTag   = new QueryTag(storeEntry);

            Assert.Equal(tag, queryTag.Tag);
            Assert.Equal(DicomVR.DA, queryTag.VR);
            Assert.Equal(storeEntry, queryTag.ExtendedQueryTagStoreEntry);
            Assert.True(queryTag.IsExtendedQueryTag);
            Assert.Equal(level, queryTag.Level);
        }
コード例 #6
0
        public void GivenPrivateExtendedQueryTag_WhenInitialize_ThenShouldCreatedSuccessfully()
        {
            DicomTag      tag        = new DicomTag(0x1205, 0x1003, "PrivateCreator1");
            DicomVR       vr         = DicomVR.CS;
            QueryTagLevel level      = QueryTagLevel.Study;
            var           storeEntry = tag.BuildExtendedQueryTagStoreEntry(vr: vr.ToString(), privateCreator: tag.PrivateCreator.Creator, level: level);
            QueryTag      queryTag   = new QueryTag(storeEntry);

            Assert.Equal(tag, queryTag.Tag);
            Assert.Equal(vr, queryTag.VR);
            Assert.Equal(storeEntry, queryTag.ExtendedQueryTagStoreEntry);
            Assert.True(queryTag.IsExtendedQueryTag);
            Assert.Equal(level, queryTag.Level);
        }
コード例 #7
0
        public async Task GivenPrivateExtendedQueryTags_WhenValidating_ThenExtendedQueryTagsShouldBeValidated()
        {
            DicomTag tag = DicomTag.Parse("04050001");

            DicomIntegerString element = new DicomIntegerString(tag, "0123456789123"); // exceed max length 12

            // AE > 16 characters is not allowed
            _dicomDataset.Add(element);

            QueryTag indextag = new QueryTag(tag.BuildExtendedQueryTagStoreEntry(vr: element.ValueRepresentation.Code));

            _queryTags.Clear();
            _queryTags.Add(indextag);

            await ExecuteAndValidateException <ElementValidationException>(ValidationFailedFailureCode);
        }
コード例 #8
0
        public async Task GivenExtendedQueryTags_WhenValidating_ThenExtendedQueryTagsShouldBeValidated()
        {
            DicomTag standardTag = DicomTag.DestinationAE;

#pragma warning disable CS0618 // Type or member is obsolete
            DicomValidation.AutoValidation = false;
#pragma warning restore CS0618 // Type or member is obsolete

            // AE > 16 characters is not allowed
            _dicomDataset.Add(standardTag, "01234567890123456");

#pragma warning disable CS0618 // Type or member is obsolete
            DicomValidation.AutoValidation = true;
#pragma warning restore CS0618 // Type or member is obsolete

            QueryTag indextag = new QueryTag(standardTag.BuildExtendedQueryTagStoreEntry());
            _queryTags.Add(indextag);
            await ExecuteAndValidateException <DicomElementValidationException>(ValidationFailedFailureCode);
        }
コード例 #9
0
        public async Task GivenDicomTagWithDifferentVR_WhenValidated_ThenShouldSkip()
        {
            var featureConfiguration = Options.Create(new FeatureConfiguration()
            {
                EnableFullDicomItemValidation = false
            });
            DicomTag     tag     = DicomTag.Date;
            DicomElement element = new DicomDateTime(tag, DateTime.Now);

            _dicomDataset.AddOrUpdate(element);

            _queryTags.Clear();
            _queryTags.Add(new QueryTag(tag.BuildExtendedQueryTagStoreEntry()));
            IDicomElementMinimumValidator validator = Substitute.For <IDicomElementMinimumValidator>();

            _dicomDatasetValidator = new DicomDatasetValidator(featureConfiguration, validator, _queryTagService);
            await _dicomDatasetValidator.ValidateAsync(_dicomDataset, requiredStudyInstanceUid : null);

            validator.DidNotReceive().Validate(Arg.Any <DicomElement>());
        }
コード例 #10
0
        public async Task GivenDicomTagWithDifferentVR_WhenValidated_ThenShouldThrowException()
        {
            var featureConfiguration = Options.Create(new FeatureConfiguration()
            {
                EnableFullDicomItemValidation = false
            });
            DicomTag     tag     = DicomTag.Date;
            DicomElement element = new DicomDateTime(tag, DateTime.Now);

            _dicomDataset.AddOrUpdate(element);

            _queryTags.Clear();
            _queryTags.Add(new QueryTag(tag.BuildExtendedQueryTagStoreEntry()));
            IDicomElementMinimumValidator validator = Substitute.For <IDicomElementMinimumValidator>();

            _dicomDatasetValidator = new DicomDatasetValidator(featureConfiguration, validator, _queryTagService);
            await AssertThrowsAsyncWithMessage <DatasetValidationException>(
                () => _dicomDatasetValidator.ValidateAsync(_dicomDataset, requiredStudyInstanceUid: null),
                expectedMessage : $"The extended query tag '{tag}' is expected to have VR 'DA' but has 'DT' in file.");

            validator.DidNotReceive().Validate(Arg.Any <DicomElement>());
        }
コード例 #11
0
        public async Task GivenPrivateExtendedQueryTags_WhenValidating_ThenExtendedQueryTagsShouldBeValidated()
        {
            DicomTag tag = DicomTag.Parse("04050001");

            DicomIntegerString element = new DicomIntegerString(tag, "0123456789123"); // exceed max length 12

#pragma warning disable CS0618                                                         // Type or member is obsolete
            DicomValidation.AutoValidation = false;
#pragma warning restore CS0618                                                         // Type or member is obsolete

            // AE > 16 characters is not allowed
            _dicomDataset.Add(element);

#pragma warning disable CS0618 // Type or member is obsolete
            DicomValidation.AutoValidation = true;
#pragma warning restore CS0618 // Type or member is obsolete

            QueryTag indextag = new QueryTag(tag.BuildExtendedQueryTagStoreEntry(vr: element.ValueRepresentation.Code));
            _queryTags.Clear();
            _queryTags.Add(indextag);

            await ExecuteAndValidateException <DicomElementValidationException>(ValidationFailedFailureCode);
        }