Exemple #1
0
        public void GivenATransactionContexAndImagingStudy_WhenProcessedForStudy_ThenDicomPropertiesAreCorrectlyMappedtoImagingStudy()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Endpoint,
                reference => string.Equals(reference.Reference, context.Request.Endpoint.Resource.ToString(), StringComparison.Ordinal));

            Assert.Collection(
                imagingStudy.Modality,
                modality => string.Equals(modality.Code, "MODALITY", StringComparison.Ordinal));

            Assert.Collection(
                imagingStudy.Note,
                note => string.Equals(note.Text.ToString(), "Study Description", StringComparison.Ordinal));

            Assert.Equal(new FhirDateTime(1974, 7, 10, 7, 10, 24, TimeSpan.Zero), imagingStudy.StartedElement);
        }
        public void GivenATransactionContextWithUpdatedInstanceNumber_WhenprocessedForInstance_ThenDicomPropertyValuesAreUpdatedCorrectly()
        {
            DicomDataset dataset = FhirTransactionContextBuilder.CreateDicomDataset();

            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(dataset);

            ImagingStudy.SeriesComponent   series   = imagingStudy.Series.First();
            ImagingStudy.InstanceComponent instance = series.Instance.First();

            _imagingStudyInstancePropertySynchronizer.Synchronize(context, instance);

            Assert.Equal(1, instance.Number);

            FhirTransactionContext newContext = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(instanceNumber: "2"));

            _imagingStudyInstancePropertySynchronizer.Synchronize(newContext, instance);
            Assert.Equal(2, instance.Number);
        }
Exemple #3
0
        public void GivenATransactionContexAndImagingStudyWithNewModality_WhenProcessedForStudy_ThenNewModalityIsAdded()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Modality,
                modality => string.Equals(modality.Code, "MODALITY", StringComparison.Ordinal));

            FhirTransactionContext newConText = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(modalityInStudy: "NEWMODALITY", modalityInSeries: "NEWMODALITY"));

            _imagingStudyPropertySynchronizer.Synchronize(newConText, imagingStudy);

            Assert.Collection(
                imagingStudy.Modality,
                modality => string.Equals(modality.Code, "MODALITY", StringComparison.Ordinal),
                modality => string.Equals(modality.Code, "NEWMODALITY", StringComparison.Ordinal));
        }
Exemple #4
0
        public void GivenATransactionContextAndImagingStudyWithNewEndpointReference_WhenProcessedForStudyWithEndpoint_ThenEndpointIsAdded()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);

            // Simulate the imaging study with an existing endpoint.
            Endpoint existingEndpoint           = FhirResourceBuilder.CreateEndpointResource(id: "2345", name: "new wado-rs");
            var      existingEndpointResourceId = new ServerResourceId(ResourceType.Endpoint, existingEndpoint.Id);
            var      existingEndpointReference  = existingEndpointResourceId.ToResourceReference();

            imagingStudy.Endpoint.Add(existingEndpointReference);

            Endpoint endpoint           = FhirResourceBuilder.CreateEndpointResource();
            var      endpointResourceId = new ServerResourceId(ResourceType.Endpoint, endpoint.Id);
            var      endpointReference  = endpointResourceId.ToResourceReference();

            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            context.Request.Endpoint = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Endpoint>(endpointResourceId);

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Endpoint,
                endPoint => Assert.Equal(existingEndpointReference, endPoint),
                endPoint => Assert.Equal(endpointReference, endPoint));
        }
Exemple #5
0
        public void GivenATransactionContexAndImagingStudyWithNewStudyDescription_WhenProcessedForStudy_ThenNewNoteIsAdded()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Note,
                note => string.Equals(note.Text.ToString(), "Study Description", StringComparison.Ordinal));

            // When studyDescription is same, note is not added twice

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Note,
                note => string.Equals(note.Text.ToString(), "Study Description", StringComparison.Ordinal));

            // When study description is new, new note is added
            FhirTransactionContext newConText = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(studyDescription: "New Study Description"));

            _imagingStudyPropertySynchronizer.Synchronize(newConText, imagingStudy);

            Assert.Collection(
                imagingStudy.Note,
                note => string.Equals(note.Text.ToString(), "Study Description", StringComparison.Ordinal),
                note => string.Equals(note.Text.ToString(), "New Study Description", StringComparison.Ordinal));
        }
        public void GivenATransactionContextAndImagingStudyWithExitsingAccessionNumber_WhenProcessedForStudy_ThenAccessionNumberIsNotAdded()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Identifier,
                identifier => ValidationUtility.ValidateIdentifier("urn:dicom:uid", $"urn:oid:{DefaultStudyInstanceUid}", identifier),
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier));

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Identifier,
                identifier => ValidationUtility.ValidateIdentifier("urn:dicom:uid", $"urn:oid:{DefaultStudyInstanceUid}", identifier),
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier));
        }
        public async Task GivenATransactionContextWithNoDicomPropertyValueChange_WhenprocessedForInstancee_ThenDicomPropertyValuesUpdateIsSkippedAsync()
        {
            DicomDataset dataset = FhirTransactionContextBuilder.CreateDicomDataset();

            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(StudyInstanceUid, new List <string>()
            {
                SeriesInstanceUid
            }, new List <string>()
            {
                SopInstanceUid
            }, PatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(dataset);

            ImagingStudy.SeriesComponent   series   = imagingStudy.Series.First();
            ImagingStudy.InstanceComponent instance = series.Instance.First();

            await _imagingStudyInstancePropertySynchronizer.SynchronizeAsync(context, instance, DefaultCancellationToken);

            Assert.Equal(1, instance.Number);

            FhirTransactionContext newContext = FhirTransactionContextBuilder.DefaultFhirTransactionContext(dataset);

            await _imagingStudyInstancePropertySynchronizer.SynchronizeAsync(newContext, instance, DefaultCancellationToken);

            Assert.Equal(1, instance.Number);
        }
Exemple #8
0
        public async Task GivenATransactionContextAndImagingStudyWithExistingEndpointReference_WhenProcessedForStudy_ThenEndpointResourceIsNotAddedAsync()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            Endpoint endpoint           = FhirResourceBuilder.CreateEndpointResource();
            var      endpointResourceId = new ServerResourceId(ResourceType.Endpoint, endpoint.Id);
            var      endpointReference  = endpointResourceId.ToResourceReference();

            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            context.Request.Endpoint = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Endpoint>(endpointResourceId);

            imagingStudy.Endpoint.Add(endpointReference);

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Endpoint,
                endPoint => Assert.Equal(endpointReference, endPoint));
        }
        public async Task GivenAChangeFeedEntryToDeleteAnInstanceWithinAStudyContainingMoreThanOneSeries_WhenBuilt_ThenCorrectEntryComponentShouldBeCreated()
        {
            const string studyInstanceUid   = "1";
            const string seriesInstanceUid  = "2";
            const string seriesInstanceUid1 = "3";
            const string sopInstanceUid     = "3";
            const string patientResourceId  = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid, seriesInstanceUid1
            }, new List <string>()
            {
                sopInstanceUid,
            }, patientResourceId);

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // delete an existing instance within a study
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, seriesInstanceUid, sopInstanceUid, patientResourceId);

            ImagingStudy updatedImagingStudy = ValidationUtility.ValidateImagingStudyUpdate(studyInstanceUid, patientResourceId, entry);

            Assert.Equal(ImagingStudy.ImagingStudyStatus.Available, updatedImagingStudy.Status);

            Assert.Collection(
                updatedImagingStudy.Series,
                series =>
            {
                ValidationUtility.ValidateSeries(series, seriesInstanceUid1, sopInstanceUid);
            });
        }
Exemple #10
0
        public async Task GivenATransactionContexAndImagingStudyWithNewAccessionNumber_WhenProcessedForStudy_ThenNewAccessionNumberIsAddedAsync()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Identifier,
                identifier => ValidationUtility.ValidateIdentifier("urn:dicom:uid", $"urn:oid:{DefaultStudyInstanceUid}", identifier),            // studyinstanceUid
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier)); // accession number

            FhirTransactionContext newConText = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(accessionNumber: NewAccessionNumber));

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(newConText, imagingStudy);

            Assert.Collection(
                imagingStudy.Identifier,
                identifier => ValidationUtility.ValidateIdentifier("urn:dicom:uid", $"urn:oid:{DefaultStudyInstanceUid}", identifier),           // studyinstanceUid
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier), // accession number
                identifier => ValidationUtility.ValidateAccessionNumber(null, NewAccessionNumber, identifier));                                  // new accession number
        }
        public async Task GivenAChangeFeedWithExistingInstanceForAnExistingSeriesAndImagingStudy_WhenBuilt_ThenNoEntryComponentShouldBeReturned()
        {
            const string studyInstanceUid  = "1";
            const string seriesInstanceUid = "2";
            const string sopInstanceUid    = "3";
            const string patientResourceId = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, $"Patient/{patientResourceId}");

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // try update an existing ImagingStudy
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, seriesInstanceUid, sopInstanceUid, patientResourceId, addMetadata : false);

            // Validate no entry component is created as there is no update
            Assert.NotNull(entry);
            Assert.Equal(FhirTransactionRequestMode.None, entry.RequestMode);
            Assert.Null(entry.Request);
            Assert.IsType <ServerResourceId>(entry.ResourceId);
            Assert.True(imagingStudy.IsExactly(entry.Resource));
        }
        public async Task GivenAChangeFeedWithNewInstanceAndNewSeiresForAnExistingImagingStudy_WhenBuilt_ThenCorrectEtagIsGeneratedd()
        {
            const string studyInstanceUid     = "1";
            const string seriesInstanceUid    = "2";
            const string sopInstanceUid       = "3";
            const string newSeriesInstanceUid = "3";
            const string newSopInstanceUid    = "3";
            const string patientResourceId    = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // update an existing ImagingStudy
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, newSeriesInstanceUid, newSopInstanceUid, patientResourceId);

            string expectedIfMatchCondition = $"W/\"1\"";

            Assert.Equal(expectedIfMatchCondition, entry.Request.IfMatch);
        }
        public async Task GivenATransactionContexAndImagingStudy_WhenprocessedForInstance_ThenDicomPropertiesAreCorrectlyMappedtoInstanceWithinImagingStudyAsync()
        {
            DicomDataset dataset = FhirTransactionContextBuilder.CreateDicomDataset();

            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(StudyInstanceUid, new List <string>()
            {
                SeriesInstanceUid
            }, new List <string>()
            {
                SopInstanceUid
            }, PatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(dataset);

            if (imagingStudy.Series.Count() > 0)
            {
                System.Console.WriteLine("");
            }
            ImagingStudy.SeriesComponent   series   = imagingStudy.Series.First();
            ImagingStudy.InstanceComponent instance = series.Instance.First();

            await _imagingStudyInstancePropertySynchronizer.SynchronizeAsync(context, instance, DefaultCancellationToken);

            Assert.Equal(SopClassUid, instance.SopClass.Code);
            Assert.Equal(1, instance.Number);
        }
        public async Task GivenAChangeFeedWithNewSeriesAndInstanceForAnExistingImagingStudy_WhenBuilt_ThenCorrectEntryComponentShouldBeCreated()
        {
            const string studyInstanceUid     = "1";
            const string seriesInstanceUid    = "2";
            const string sopInstanceUid       = "3";
            const string patientResourceId    = "p1";
            const string newSeriesInstanceUid = "3";
            const string newSopInstanceUid    = "4";

            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // Update an existing ImagingStudy
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, newSeriesInstanceUid, newSopInstanceUid, patientResourceId);

            ImagingStudy updatedImagingStudy = ValidationUtility.ValidateImagingStudyUpdate(studyInstanceUid, patientResourceId, entry);

            Assert.Collection(
                updatedImagingStudy.Series,
                series =>
            {
                ValidationUtility.ValidateSeries(series, seriesInstanceUid, sopInstanceUid);
            },
                series =>
            {
                ValidationUtility.ValidateSeries(series, newSeriesInstanceUid, newSopInstanceUid);
            });
        }
Exemple #15
0
        public async Task GivenAnExistingEndpointWithDifferentAddress_WhenRequestIsPrepared_ThenFhirResourceValidationExceptionShouldBeThrown()
        {
            var context = new FhirTransactionContext(ChangeFeedGenerator.Generate());

            Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(address: "https://dicom2");

            _fhirService.RetrieveEndpointAsync(Arg.Any <string>(), DefaultCancellationToken).Returns(endpoint);

            await Assert.ThrowsAsync <FhirResourceValidationException>(() => _endpointPipeline.PrepareRequestAsync(context, DefaultCancellationToken));
        }
Exemple #16
0
        public async Task GivenAnExistingEndpointWithMatchingAddress_WhenRequestIsPrepared_ThenCorrectRequestEntryShouldBeCreated()
        {
            var context = new FhirTransactionContext(ChangeFeedGenerator.Generate());

            Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(address: DefaultDicomWebEndpoint);

            _fhirService.RetrieveEndpointAsync(Arg.Any <string>(), DefaultCancellationToken).Returns(endpoint);

            await _endpointPipeline.PrepareRequestAsync(context, DefaultCancellationToken);

            FhirTransactionRequestEntry actualEndPointEntry = context.Request.Endpoint;

            ValidationUtility.ValidateRequestEntryMinimumRequirementForNoChange(endpoint.ToServerResourceId(), actualEndPointEntry);
        }
Exemple #17
0
        public void GivenATransactionContextAndImagingStudyWithNoEndpoint_WhenProcessedForStudy_ThenNewEndpointIsAdded()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Endpoint,
                endPoint => Assert.Equal(context.Request.Endpoint.ResourceId.ToResourceReference(), endPoint));
        }
Exemple #18
0
        public async Task SyncPropertiesAsync_PartialValidationEnabledAndPropertyRequired_ThrowsError()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            Action <ImagingStudy, FhirTransactionContext> actionSubstitute = Substitute.For <Action <ImagingStudy, FhirTransactionContext> >();

            actionSubstitute.When(x => x.Invoke(imagingStudy, context)).Do(x => throw new InvalidDicomTagValueException("invalid tag", "invalid tag"));

            await Assert.ThrowsAsync <InvalidDicomTagValueException>(() => ImagingStudyPipelineHelper.SynchronizePropertiesAsync(imagingStudy, context, actionSubstitute, true, true, _exceptionStore));
        }
        public async Task GivenATransactionContexAndImagingStudy_WhenprocessedForSeries_ThenDicomPropertiesAreCorrectlyMappedtoSeriesWithinImagingStudyAsync()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(StudyInstanceUid, new List <string>()
            {
                SeriesInstanceUid
            }, new List <string>()
            {
                SopInstanceUid
            }, PatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            ImagingStudy.SeriesComponent series = imagingStudy.Series.First();

            await _imagingStudySeriesPropertySynchronizer.SynchronizeAsync(context, series, DefaultCancellationToken);

            Assert.Equal("Series Description", series.Description);
            Assert.Equal("MODALITY", series.Modality.Code);
            Assert.Equal(1, series.Number);
            Assert.Equal(new FhirDateTime(1974, 8, 10, 8, 10, 24, TimeSpan.Zero), series.StartedElement);
        }
        public void GivenATransactionContexAndImagingStudy_WhenprocessedForInstance_ThenDicomPropertiesAreCorrectlyMappedtoInstanceWithinImagingStudy()
        {
            DicomDataset dataset = FhirTransactionContextBuilder.CreateDicomDataset();

            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(dataset);

            ImagingStudy.SeriesComponent   series   = imagingStudy.Series.First();
            ImagingStudy.InstanceComponent instance = series.Instance.First();

            _imagingStudyInstancePropertySynchronizer.Synchronize(context, instance);

            Assert.Equal(sopClassUid, instance.SopClass.Code);
            Assert.Equal(1, instance.Number);
        }
Exemple #21
0
        public void GivenATransactionContextWithNoPropertyValueChange_WhenprocessedForSeries_ThenDicomPropertyValuesUpdateIsSkipped()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext();

            ImagingStudy.SeriesComponent series = imagingStudy.Series.First();

            _imagingStudySeriesPropertySynchronizer.Synchronize(context, series);

            Assert.Equal(1, series.Number);

            FhirTransactionContext newContext = FhirTransactionContextBuilder.DefaultFhirTransactionContext();

            _imagingStudySeriesPropertySynchronizer.Synchronize(newContext, series);
            Assert.Equal(1, series.Number);
        }
Exemple #22
0
        public void GivenATransactionContextWithUpdatedSeriesModality_WhenprocessedForSeries_ThenDicomPropertyValuesAreUpdatedAreCorrectly()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            ImagingStudy.SeriesComponent series = imagingStudy.Series.First();

            _imagingStudySeriesPropertySynchronizer.Synchronize(context, series);

            Assert.Equal("MODALITY", series.Modality.Code);

            FhirTransactionContext newContext = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(modalityInSeries: "NEWMODALITY"));

            _imagingStudySeriesPropertySynchronizer.Synchronize(newContext, series);
            Assert.Equal("NEWMODALITY", series.Modality.Code);
        }
        public async Task GivenATransactionContextWithUpdatedSeriesDescription_WhenprocessedForSeries_ThenDicomPropertyValuesAreUpdatedAreCorrectlyAsync()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(StudyInstanceUid, new List <string>()
            {
                SeriesInstanceUid
            }, new List <string>()
            {
                SopInstanceUid
            }, PatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            ImagingStudy.SeriesComponent series = imagingStudy.Series.First();

            await _imagingStudySeriesPropertySynchronizer.SynchronizeAsync(context, series, DefaultCancellationToken);

            Assert.Equal("Series Description", series.Description);

            FhirTransactionContext newContext = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset(seriesDescrition: "New Series Description"));

            await _imagingStudySeriesPropertySynchronizer.SynchronizeAsync(newContext, series, DefaultCancellationToken);

            Assert.Equal("New Series Description", series.Description);
        }
        public async Task GivenAChangeFeedEntryToDeleteAnInstanceWithinASeriesContainingOneInstanceDifferentSouce_WhenBuilt_ShouldUpdateNotDelete()
        {
            const string studyInstanceUid  = "1";
            const string seriesInstanceUid = "2";
            const string sopInstanceUid    = "3";
            const string patientResourceId = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // delete an existing instance within a study
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, seriesInstanceUid, sopInstanceUid, patientResourceId);

            Assert.Equal(FhirTransactionRequestMode.Update, entry.RequestMode);
        }
Exemple #25
0
        public async Task GivenATransactionContextAndImagingStudyWithExitsingModality_WhenProcessedForStudy_ThenModalityIsNotAddedAsync()
        {
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>()
            {
                DefaultSeriesInstanceUid
            }, new List <string>()
            {
                DefaultSopInstanceUid
            }, DefaultPatientResourceId);
            FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset());

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Modality,
                modality => string.Equals(modality.Code, "MODALITY", StringComparison.Ordinal));

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Modality,
                modality => string.Equals(modality.Code, "MODALITY", StringComparison.Ordinal));
        }
        public async Task GivenAChangeFeedEntryForDeleteInstanceThatDoesNotExistsWithinGivenStudy_WhenBuilt_ThenNoEntryComponentShouldBeCreated()
        {
            const string studyInstanceUid  = "1";
            const string seriesInstanceUid = "2";
            const string sopInstanceUid    = "3";
            const string sopInstanceUid1   = "4";
            const string patientResourceId = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid
            }, patientResourceId);

            _fhirService.RetrieveImagingStudyAsync(Arg.Any <Identifier>(), Arg.Any <CancellationToken>()).Returns(imagingStudy);

            // try delete non-existing instance within a study
            FhirTransactionRequestEntry entry = await BuildImagingStudyEntryComponent(studyInstanceUid, seriesInstanceUid, sopInstanceUid1, patientResourceId);

            Assert.Null(entry);
        }