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); } }
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); }
// [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); }
/// <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); }
public TypeRef(FHIRDefinedType code, string profileUri = null) { this.Code = code; if (profileUri != null) { this.Profile = new Uri(profileUri); } }
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); }
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); }
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); }
/// <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"); } }
// [WMR 20160421] Slow, based on reflection... public static string FhirTypeToFhirTypeName(FHIRDefinedType type) { return(type.GetLiteral()); }
/// <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)); }
/// <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); }
/// <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))); }
public static ResourceIdentity Core(FHIRDefinedType type) { return(ResourceIdentity.Core(type.GetLiteral())); }
/// <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;
/// <summary>Determines if the specified <see cref="FHIRDefinedType"/> value represents a FHIR conformance resource.</summary> public static bool IsConformanceResource(FHIRDefinedType type) => ConformanceResources.Contains(type);
public void SetInstanceType(FHIRDefinedType instanceType) { SetInstanceType(ModelInfo.CanonicalUriForFhirCoreType(instanceType)); }
public void SetDeclaredType(FHIRDefinedType declaredType) { SetDeclaredType(ModelInfo.CanonicalUriForFhirCoreType(declaredType)); }
public static string CanonicalUriForFhirCoreType(FHIRDefinedType type) { return(CanonicalUriForFhirCoreType(type.GetLiteral())); }
/// <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)); }
public static StructureDefinition FindStructureDefinitionForCoreType(this IResourceResolver resolver, FHIRDefinedType type) { return(resolver.FindStructureDefinitionForCoreType(ModelInfo.FhirTypeToFhirTypeName(type))); }
/// <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))); }
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); }
public StructureDefinition GetStructureDefinitionForCoreType(FHIRDefinedType type) { return(GetStructureDefinitionForCoreType(ModelInfo.FhirTypeToFhirTypeName(type))); }