Пример #1
0
        public async Task GivenExistingPatientAndNoChange_WhenRequestIsPrepared_ThenCorrectEntryComponentShouldBeCreated()
        {
            FhirTransactionContext context = CreateFhirTransactionContext();

            var patient = new Patient()
            {
                Id   = "patient1",
                Meta = new Meta()
                {
                    VersionId = "v1",
                },
            };

            _fhirService.RetrievePatientAsync(Arg.Is(TestUtility.BuildIdentifierPredicate(string.Empty, DefaultPatientId)), DefaultCancellationToken)
            .Returns(patient);

            await _patientPipeline.PrepareRequestAsync(context, DefaultCancellationToken);

            FhirTransactionRequestEntry actualPatientEntry = context.Request.Patient;

            ValidationUtility.ValidateRequestEntryMinimumRequirementForNoChange(patient.ToServerResourceId(), actualPatientEntry);
        }
Пример #2
0
        public async Task GivenEndpointDoesNotAlreadyExist_WhenRequestIsPrepared_ThenCorrentRequestEntryShouldBeCreated()
        {
            var context = new FhirTransactionContext(ChangeFeedGenerator.Generate());

            await _endpointPipeline.PrepareRequestAsync(context, DefaultCancellationToken);

            FhirTransactionRequestEntry actualEndpointEntry = context.Request.Endpoint;

            ValidationUtility.ValidateRequestEntryMinimumRequirementForWithChange(FhirTransactionRequestMode.Create, "Endpoint", Bundle.HTTPVerb.POST, actualEndpointEntry);

            Assert.Equal($"name={EndpointName}&connection-type={EndpointConnectionTypeSystem}|{EndpointConnectionTypeCode}", actualEndpointEntry.Request.IfNoneExist);

            Endpoint endpoint = Assert.IsType <Endpoint>(actualEndpointEntry.Resource);

            Assert.Equal(EndpointName, endpoint.Name);
            Assert.Equal(Endpoint.EndpointStatus.Active, endpoint.Status);
            Assert.NotNull(endpoint.ConnectionType);
            Assert.Equal(EndpointConnectionTypeSystem, endpoint.ConnectionType.System);
            Assert.Equal(EndpointConnectionTypeCode, endpoint.ConnectionType.Code);
            Assert.Equal(_configuration.Endpoint.ToString(), endpoint.Address);
            Assert.Equal(EndpointPayloadTypeText, endpoint.PayloadType.First().Text);
            Assert.Equal(new[] { DicomMimeType }, endpoint.PayloadMimeType);
        }
        public async Task GivenAChangeFeedEntryToDeleteAnInstanceWithinASeriesContainingMoreThanOneInstance_WhenBuilt_ThenCorrectEntryComponentShouldBeCreated()
        {
            const string studyInstanceUid  = "1";
            const string seriesInstanceUid = "2";
            const string sopInstanceUid    = "3";
            const string sopInstanceUid1   = "3";
            const string patientResourceId = "p1";

            // create a new ImagingStudy
            ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(studyInstanceUid, new List <string>()
            {
                seriesInstanceUid
            }, new List <string>()
            {
                sopInstanceUid, sopInstanceUid1
            }, 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 =>
            {
                Assert.Equal(seriesInstanceUid, series.Uid);

                Assert.Collection(
                    series.Instance,
                    instance => Assert.Equal(sopInstanceUid1, instance.Uid));
            });
        }