예제 #1
0
        public async Task GivenATransactionContexAndImagingStudyWithNewStudyDescription_WhenProcessedForStudy_ThenNewNoteIsAddedAsync()
        {
            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.Note,
                note => string.Equals(note.Text.ToString(), "Study Description", StringComparison.Ordinal));

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

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(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"));

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(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));
        }
예제 #2
0
        public async Task GivenATransactionContextAndImagingStudyWithNewEndpointReference_WhenProcessedForStudyWithEndpoint_ThenEndpointIsAddedAsync()
        {
            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);

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Endpoint,
                endPoint => Assert.Equal(existingEndpointReference, endPoint),
                endPoint => Assert.Equal(endpointReference, endPoint));
        }
예제 #3
0
        public async Task GivenATransactionContextAndImagingStudyWithNoEndpoint_WhenProcessedForStudy_ThenNewEndpointIsAddedAsync()
        {
            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.Endpoint,
                endPoint => Assert.Equal(context.Request.Endpoint.ResourceId.ToResourceReference(), endPoint));
        }
예제 #4
0
        public async Task GivenATransactionContextAndImagingStudyWithExitsingAccessionNumber_WhenProcessedForStudy_ThenAccessionNumberIsNotAddedAsync()
        {
            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),
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier));

            await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy);

            Assert.Collection(
                imagingStudy.Identifier,
                identifier => ValidationUtility.ValidateIdentifier("urn:dicom:uid", $"urn:oid:{DefaultStudyInstanceUid}", identifier),
                identifier => ValidationUtility.ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier));
        }
예제 #5
0
        public void GivenATransactionContextWithUpdatedSeriesNumber_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(1, series.Number);

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

            _imagingStudySeriesPropertySynchronizer.Synchronize(newContext, series);
            Assert.Equal(2, series.Number);
        }
예제 #6
0
        public void GivenATransactionContexAndImagingStudy_WhenprocessedForSeries_ThenDicomPropertiesAreCorrectlyMappedtoSeriesWithinImagingStudy()
        {
            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("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);
        }