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)); }
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)); }
private async Task <FhirTransactionRequestEntry> PrepareRequestAsync(ChangeFeedEntry changeFeedEntry, string patientResourceId) { _fhirTransactionContext = new FhirTransactionContext(changeFeedEntry); _fhirTransactionContext.Request.Patient = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Patient>(new ServerResourceId(ResourceType.Patient, patientResourceId)); return(await _imagingStudyDeleteHandler.BuildAsync(_fhirTransactionContext, CancellationToken.None)); }
public async Task GivenAChangeFeedEntryForDelete_WhenBuilt_ThenDeleteHandlerIsCalled() { const string studyInstanceUid = "1"; const string seriesInstanceUid = "2"; const string sopInstanceUid = "3"; const string patientResourceId = "p1"; ChangeFeedEntry changeFeed = ChangeFeedGenerator.Generate( action: ChangeFeedAction.Delete, studyInstanceUid: studyInstanceUid, seriesInstanceUid: seriesInstanceUid, sopInstanceUid: sopInstanceUid); var fhirTransactionContext = new FhirTransactionContext(changeFeed); fhirTransactionContext.Request.Patient = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Patient>( new ServerResourceId(ResourceType.Patient, patientResourceId)); await _imagingStudyPipeline.PrepareRequestAsync(fhirTransactionContext, DefaultCancellationToken); await _imagingStudyDeleteHandler.Received(1).BuildAsync(fhirTransactionContext, DefaultCancellationToken); }