示例#1
0
        public static bool IsInstanceTypeFor(FHIRDefinedType superType, FHIRDefinedType instanceType)
        {
            if (superType == instanceType)
            {
                return(true);
            }

            if (IsKnownResource(instanceType))
            {
                if (superType == FHIRDefinedType.Resource)
                {
                    return(true);
                }
                else if (superType == FHIRDefinedType.DomainResource)
                {
                    return(instanceType != FHIRDefinedType.Parameters && instanceType != FHIRDefinedType.Bundle && instanceType != FHIRDefinedType.Binary);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(superType == FHIRDefinedType.Element);
            }
        }
示例#2
0
        public static ElementDefinition OfType(this ElementDefinition ed, FHIRDefinedType type, string profile = null, IEnumerable <ElementDefinition.AggregationMode> aggs = null)
        {
            ed.Type.Clear();
            ed.OrType(type, profile, aggs);

            return(ed);
        }
示例#3
0
        // [WMR 20160421] NEW - Improved & optimized
        // 1. Convert from/to FHIR type names as defined by EnumLiteral attributes on FHIRDefinedType enum members
        // 2. Cache lookup tables, to optimize runtime reflection

        /// <summary>Returns the <see cref="FHIRDefinedType"/> enum value that represents the specified FHIR type name, or <c>null</c>.</summary>
        public static string FhirTypeToFhirTypeName(FHIRDefinedType type)
        {
            string result;

            _fhirTypeToFhirTypeName.Value.TryGetValue(type, out result);
            return(result);
        }
示例#4
0
 /// <summary>
 /// Returns whether the type has subclasses in the core spec
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 /// <remarks>Quantity is not listed here, since its subclasses are
 /// actually profiles on Quantity. Likewise, there is no real inheritance
 /// in the primitives, so string is not a superclass for markdown</remarks>
 public static bool IsCoreSuperType(FHIRDefinedType type)
 {
     return
         (type == FHIRDefinedType.Resource ||
          type == FHIRDefinedType.DomainResource ||
          type == FHIRDefinedType.Element ||
          type == FHIRDefinedType.BackboneElement);
 }
示例#5
0
        public TypeRef(FHIRDefinedType code, string profileUri = null)
        {
            this.Code = code;

            if (profileUri != null)
            {
                this.Profile = new Uri(profileUri);
            }
        }
示例#6
0
 public static bool IsBindeableFhirType(this FHIRDefinedType t)
 {
     return(t == FHIRDefinedType.Code ||
            t == FHIRDefinedType.Coding ||
            t == FHIRDefinedType.CodeableConcept ||
            t == FHIRDefinedType.Quantity ||
            t == FHIRDefinedType.Extension ||
            t == FHIRDefinedType.String ||
            t == FHIRDefinedType.Uri);
 }
示例#7
0
 public static bool IsProfiledQuantity(FHIRDefinedType type)
 {
     return
         (type == FHIRDefinedType.Age ||
          type == FHIRDefinedType.Distance ||
          type == FHIRDefinedType.SimpleQuantity ||
          type == FHIRDefinedType.Duration ||
          type == FHIRDefinedType.Count ||
          type == FHIRDefinedType.Money);
 }
示例#8
0
        public static ElementDefinition OrType(this ElementDefinition ed, FHIRDefinedType type, string profile = null, IEnumerable <ElementDefinition.AggregationMode> aggs = null)
        {
            var newType = new ElementDefinition.TypeRefComponent {
                Code = type
            };

            if (profile != null)
            {
                newType.Profile = new[] { profile }
            }
            ;
            if (aggs != null)
            {
                newType.Aggregation = aggs.Cast <ElementDefinition.AggregationMode?>();
            }

            ed.Type.Add(newType);

            return(ed);
        }
示例#9
0
        /// <summary>
        /// Parses a bindeable type into either a Coding (code, Coding, Quantity, string, uri) or CodeableConcept
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="codedType"></param>
        /// <returns>An object, which is either a Coding or CodeableConcept</returns>
        public static object ParseBindable(this IElementNavigator instance, FHIRDefinedType codedType)
        {
            // 'code','Coding','CodeableConcept','Quantity','Extension', 'string', 'uri'

            if (codedType == FHIRDefinedType.Code)
            {
                return(instance.ParsePrimitiveCode());
            }
            else if (codedType == FHIRDefinedType.Coding)
            {
                return(instance.ParseCoding());
            }
            else if (codedType == FHIRDefinedType.CodeableConcept)
            {
                return(instance.ParseCodeableConcept());
            }
            else if (codedType == FHIRDefinedType.Quantity)
            {
                var newCoding = new Coding();
                var q         = instance.ParseQuantity();
                newCoding.Code   = q.Unit;
                newCoding.System = q.System;
                return(newCoding);
            }
            else if (codedType == FHIRDefinedType.String)
            {
                return(instance.ParsePrimitiveCode());
            }
            else if (codedType == FHIRDefinedType.Uri)
            {
                return(instance.ParsePrimitiveCode());
            }
            else if (codedType == FHIRDefinedType.Extension)
            {
                throw new NotSupportedException($"The validator does not support binding to Extension values");
            }
            else
            {
                throw new NotSupportedException($"FHIR type '{codedType}' is not bindeable");
            }
        }
示例#10
0
 // [WMR 20160421] Slow, based on reflection...
 public static string FhirTypeToFhirTypeName(FHIRDefinedType type)
 {
     return(type.GetLiteral());
 }
示例#11
0
 /// <summary>
 /// Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR conformance resource type,
 /// i.e. if it equals one of the following values:
 /// <list type="bullet">
 /// <item>FHIRDefinedType.Conformance</item>
 /// <item>FHIRDefinedType.StructureDefinition</item>
 /// <item>FHIRDefinedType.ValueSet</item>
 /// <item>FHIRDefinedType.ConceptMap</item>
 /// <item>FHIRDefinedType.DataElement</item>
 /// <item>FHIRDefinedType.OperationDefinition</item>
 /// <item>FHIRDefinedType.SearchParameter</item>
 /// <item>FHIRDefinedType.NamingSystem</item>
 /// <item>FHIRDefinedType.ImplementationGuide</item>
 /// <item>FHIRDefinedType.TestScript</item>
 /// </list>
 /// </summary>
 public static bool IsConformanceResource(FHIRDefinedType type)
 {
     return(ConformanceResources.Contains(type));
 }
示例#12
0
 /// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR Reference type.</summary>
 public static bool IsReference(FHIRDefinedType type)
 {
     return(type == FHIRDefinedType.Reference);
 }
示例#13
0
 /// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR complex data type (NOT including resources and primitives).</summary>
 public static bool IsDataType(FHIRDefinedType type)
 {
     return(IsDataType(FhirTypeToFhirTypeName(type)));
 }
示例#14
0
 public static ResourceIdentity Core(FHIRDefinedType type)
 {
     return(ResourceIdentity.Core(type.GetLiteral()));
 }
示例#15
0
 /// <summary>Returns the <see cref="FHIRDefinedType"/> enum value that represents the specified FHIR type name, or <c>null</c>.</summary>
 public static string FhirTypeToFhirTypeName(FHIRDefinedType type)
 => _fhirTypeToFhirTypeName.TryGetValue(type, out var result) ? result : null;
示例#16
0
 /// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR conformance resource.</summary>
 public static bool IsConformanceResource(FHIRDefinedType type) => ConformanceResources.Contains(type);
示例#17
0
 public void SetInstanceType(FHIRDefinedType instanceType)
 {
     SetInstanceType(ModelInfo.CanonicalUriForFhirCoreType(instanceType));
 }
示例#18
0
 public void SetDeclaredType(FHIRDefinedType declaredType)
 {
     SetDeclaredType(ModelInfo.CanonicalUriForFhirCoreType(declaredType));
 }
示例#19
0
 public static string CanonicalUriForFhirCoreType(FHIRDefinedType type)
 {
     return(CanonicalUriForFhirCoreType(type.GetLiteral()));
 }
示例#20
0
        /// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a known FHIR resource.</summary>
        public static bool IsKnownResource(FHIRDefinedType type)
        {
            var name = FhirTypeToFhirTypeName(type);

            return(name != null && IsKnownResource(name));
        }
示例#21
0
 public static StructureDefinition FindStructureDefinitionForCoreType(this IResourceResolver resolver, FHIRDefinedType type)
 {
     return(resolver.FindStructureDefinitionForCoreType(ModelInfo.FhirTypeToFhirTypeName(type)));
 }
示例#22
0
 /// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR primitive data type.</summary>
 public static bool IsPrimitive(FHIRDefinedType type)
 {
     return(IsPrimitive(FhirTypeToFhirTypeName(type)));
 }
示例#23
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);
        }
示例#24
0
 public StructureDefinition GetStructureDefinitionForCoreType(FHIRDefinedType type)
 {
     return(GetStructureDefinitionForCoreType(ModelInfo.FhirTypeToFhirTypeName(type)));
 }