예제 #1
0
        public GroupMemberExtractorTests()
        {
            var dataClient = Substitute.For <IFhirDataClient>();

            dataClient.SearchAsync(new ResourceIdSearchOptions("Group", _sampleGroupId, null), _noneCancellationToken)
            .ReturnsForAnyArgs(x =>
            {
                var resourceId   = ((ResourceIdSearchOptions)x[0]).ResourceId;
                var testDataFile = _groupIdToTestDataFile.ContainsKey(resourceId)
                        ? Path.Combine(_testDataFolder, _groupIdToTestDataFile[resourceId])
                        : TestDataConstants.EmptyBundleFile;
                var bundle =
                    TestDataProvider.GetBundleFromFile(testDataFile);
                return(bundle);
            });

            var fhirServerConfig = new FhirServerConfiguration
            {
                ServerUrl      = "https://example.com",
                Authentication = AuthenticationType.None,
            };
            var fhirServerOption = Options.Create(fhirServerConfig);

            _dataSource           = new FhirApiDataSource(fhirServerOption);
            _referenceParser      = new R4ReferenceParser(_dataSource, NullLogger <R4ReferenceParser> .Instance);
            _groupMemberExtractor = new GroupMemberExtractor(dataClient, _referenceParser, _nullGroupMemberExtractorLogger);
        }
        public R4ReferenceParserTests()
        {
            var fhirServerConfig = new FhirServerConfiguration
            {
                ServerUrl      = _serverUrl,
                Authentication = AuthenticationType.None,
            };
            var fhirServerOption = Options.Create(fhirServerConfig);

            _dataSource      = new FhirApiDataSource(fhirServerOption);
            _referenceParser = new R4ReferenceParser(_dataSource, _nullR4ReferenceParserLogger);
        }
        public void GivenDataSourceServerUrlEndsWithSlash_WhenParseReference_ParsedReferenceShouldBeReturned()
        {
            var fhirServerConfig = new FhirServerConfiguration
            {
                ServerUrl      = "https://example.com/",
                Authentication = AuthenticationType.None,
            };

            var fhirServerOption = Options.Create(fhirServerConfig);
            var dataSource       = new FhirApiDataSource(fhirServerOption);
            var referenceParser  = new R4ReferenceParser(dataSource, _nullR4ReferenceParserLogger);

            var fhirReference = referenceParser.Parse("https://example.com/Patient/123/_history/2");

            Assert.NotNull(fhirReference);
            Assert.Equal("Patient", fhirReference.ResourceType);
            Assert.Equal("123", fhirReference.ResourceId);
        }