public static ListedCapabilityStatement BuildRestResourceComponent(this ListedCapabilityStatement statement, ResourceType resourceType, Action <ListedResourceComponent> componentBuilder)
        {
            EnsureArg.IsNotNull(statement, nameof(statement));
            EnsureArg.IsNotNull(componentBuilder, nameof(componentBuilder));

            var restComponent = statement.GetListedRestComponent();

            var restNode = restComponent
                           .Resource
                           .FirstOrDefault(x => x.Type == resourceType);

            if (restNode == null)
            {
                restNode = new ListedResourceComponent
                {
                    Type    = resourceType,
                    Profile = new ResourceReference(ResourceIdentity.Core(resourceType.ToString()).AbsoluteUri),
                };
                restComponent.Resource.Add(restNode);
            }

            componentBuilder(restNode);

            return(statement);
        }
Ejemplo n.º 2
0
        public async Task GivenASystemConformanceProvider_WhenRequestingACapabilitiesDocument_ThenGetsAValidCapabilityStatement()
        {
            SystemConformanceProvider systemCapabilities = CreateSystemConformanceProvider();

            var capabilityStatement = await systemCapabilities.GetSystemListedCapabilitiesStatementAsync();

            Assert.NotNull(capabilityStatement.Software);
            Assert.Equal("Microsoft FHIR Server", capabilityStatement.Software.Name);
            Assert.Equal("Microsoft Corporation", capabilityStatement.Publisher);
            Assert.NotNull(capabilityStatement.Rest.Single().Resource.Single().Interaction.FirstOrDefault(x => x.Code == CapabilityStatement.TypeRestfulInteraction.Create));
            Assert.Equal(ResourceIdentity.Core(FHIRAllTypes.Account).AbsoluteUri, capabilityStatement.Rest.Single().Resource.Single().Profile.Url.ToString());
        }
Ejemplo n.º 3
0
        public void TestCoreIdentifiers()
        {
            var patientId = ResourceIdentity.Core(FHIRDefinedType.Patient);

            Assert.AreEqual("http://hl7.org/fhir/StructureDefinition/Patient", patientId.ToString());

            var oidId = ResourceIdentity.Core(FHIRDefinedType.Oid);

            Assert.AreEqual("http://hl7.org/fhir/StructureDefinition/oid", oidId.ToString());

            var observationId = ResourceIdentity.Core("Observation");

            Assert.AreEqual("http://hl7.org/fhir/StructureDefinition/Observation", observationId.ToString());
        }
Ejemplo n.º 4
0
        private static StructureDefinition createTestSD(string url, string name, string description, FHIRDefinedType constrainedType, string baseUri = null)
        {
            var result = new StructureDefinition();

            result.Url         = url;
            result.Name        = name;
            result.Status      = ConformanceResourceStatus.Draft;
            result.Description = description;
            result.FhirVersion = ModelInfo.Version;

            if (ModelInfo.IsKnownResource(constrainedType))
            {
                result.Kind = StructureDefinition.StructureDefinitionKind.Resource;
            }
            else if (ModelInfo.IsDataType(constrainedType) || ModelInfo.IsPrimitive(constrainedType))
            {
                result.Kind = StructureDefinition.StructureDefinitionKind.Datatype;
            }
            else
            {
                result.Kind = StructureDefinition.StructureDefinitionKind.Logical;
            }

            result.ConstrainedType = constrainedType;
            result.Abstract        = false;

            if (baseUri == null)
            {
                baseUri = ResourceIdentity.Core(constrainedType).ToString();
            }

            result.Base = baseUri;

            result.Differential = new StructureDefinition.DifferentialComponent();

            return(result);
        }