Documentation
¶
Overview ¶
Package modelinfo provides utilities for working with CQL ModelInfo XML files.
Index ¶
- Variables
- type Convertible
- type Key
- type ModelInfos
- func (m *ModelInfos) BaseTypes(child types.IType) ([]types.IType, error)
- func (m *ModelInfos) DefaultContext() (string, error)
- func (m *ModelInfos) IsImplicitlyConvertible(from, to types.IType) (Convertible, error)
- func (m *ModelInfos) IsSubType(child, base types.IType) (bool, error)
- func (m *ModelInfos) NamedTypeInfo(t *types.Named) (*TypeInfo, error)
- func (m *ModelInfos) PatientBirthDatePropertyName() (string, error)
- func (m *ModelInfos) PropertyTypeSpecifier(parentType types.IType, property string) (types.IType, error)
- func (m *ModelInfos) ResetUsing()
- func (m *ModelInfos) SetUsing(key Key) error
- func (m *ModelInfos) ToNamed(str string) (*types.Named, error)
- func (m *ModelInfos) URL() (string, error)
- type TypeInfo
Constants ¶
This section is empty.
Variables ¶
var ErrTypeNotFound = errors.New("not found in data model")
ErrTypeNotFound is an error that is returned when a type is not found in the modelinfo.
Functions ¶
This section is empty.
Types ¶
type Convertible ¶
type Convertible struct { IsConvertible bool // Library and Function name of the function to call to do the conversion // ex FHIRHelpers.ToString. Library string Function string }
Convertible is the result of the IsImplicitlyConvertible function.
type Key ¶
type Key struct { // Name represents the name of the model info (ex FHIR). Name string // Version represents the version of the model info (ex 4.0.1). Version string }
Key is the name and version of a ModeInfo. This is the same name and version as the CQL using declaration (ex using FHIR version 4.0.1). Implementation note: this struct needs to be usable as a key in a map.
type ModelInfos ¶
type ModelInfos struct {
// contains filtered or unexported fields
}
ModelInfos provides methods for interacting with the underlying ModelInfos such as getting type specifiers for a property or determining implicit conversions. We currently only support the system and one custom ModelInfo. https://cql.hl7.org/03-developersguide.html#multiple-data-models is not supported.
func New ¶
func New(modelInfoBytes [][]byte) (*ModelInfos, error)
New creates a new ModelInfos. The byte array of all the custom ModelInfo should be passed in. System ModelInfo is always loaded by default and does not need to be passed in.
func (*ModelInfos) BaseTypes ¶
BaseTypes returns all of the BaseTypes (aka Parents) of a type excluding Any (or for nested types List<Any>).
func (*ModelInfos) DefaultContext ¶
func (m *ModelInfos) DefaultContext() (string, error)
DefaultContext returns the default context of the custom ModelInfo. To be used if the CQL does not specify one. This is actually not set in the FHIR 4.0.1 ModelInfo.
func (*ModelInfos) IsImplicitlyConvertible ¶
func (m *ModelInfos) IsImplicitlyConvertible(from, to types.IType) (Convertible, error)
IsImplicitlyConvertible uses model info conversionInfo to determine if one type can be converted to another. If the `from` type is convertible to the `to` type, this function will return the library and function name to call to do the conversion.
func (*ModelInfos) IsSubType ¶
func (m *ModelInfos) IsSubType(child, base types.IType) (bool, error)
IsSubType returns true if the child type has the base type (parent) anywhere in it's type hierarchy. Returns errors on nil types.IType, since it cannot be determined what the hierarchy is.
func (*ModelInfos) NamedTypeInfo ¶
func (m *ModelInfos) NamedTypeInfo(t *types.Named) (*TypeInfo, error)
NamedTypeInfo returns the TypeInfo for the given Named type.
func (*ModelInfos) PatientBirthDatePropertyName ¶
func (m *ModelInfos) PatientBirthDatePropertyName() (string, error)
PatientBirthDatePropertyName returns the PatientBirthDatePropertyName field from the custom ModelInfo.
func (*ModelInfos) PropertyTypeSpecifier ¶
func (m *ModelInfos) PropertyTypeSpecifier(parentType types.IType, property string) (types.IType, error)
PropertyTypeSpecifier attempts to return the TypeSpecifier for the property on the parent type passed in. The passed property must be only one level deep (e.g. property1 instead of property1.property2). The input type can be a List, in which case the FHIR Path traversal rules for properties will be applied to determine the type: https://build.fhir.org/ig/HL7/cql/03-developersguide.html#path-traversal. Currently for top level resource types like FHIR.Patient, they need to be built outside of this helper based on knowledge of what resources were retrieved.
func (*ModelInfos) ResetUsing ¶
func (m *ModelInfos) ResetUsing()
ResetUsing resets the using declaration to the system model info key.
func (*ModelInfos) SetUsing ¶
func (m *ModelInfos) SetUsing(key Key) error
SetUsing corresponds to a CQL using declaration.
func (*ModelInfos) ToNamed ¶
func (m *ModelInfos) ToNamed(str string) (*types.Named, error)
ToNamed converts a string into a NamedType. The string may be qualified (FHIR.Patient) or unqualified (Patient) and a Named type with the qualified name will be returned. ToNamed validates that the type is in the custom ModelInfo set by the using declaration. System types should not be passed to this function and will throw an error.
func (*ModelInfos) URL ¶
func (m *ModelInfos) URL() (string, error)
URL returns the URL field from the custom ModelInfo.
type TypeInfo ¶
type TypeInfo struct { // Name is the fully qualified model info type name for this type. Name string // Properties is a map of property (element) name to the type specifier for it. Properties map[string]types.IType // BaseType is the fully qualified model info type name for the base (parent) type. BaseType string // The identifier specifies a unique name for the class that may be independent of the name. In // FHIR, this corresponds to the profile identifier. Identifier string // Retrievable specifies whether the class can be used within a retrieve statement. Retrievable bool // PrimaryCodePath specifies the path that should be used to perform code filtering when a // retrieve does not specify a code path. PrimaryCodePath string }
TypeInfo holds details about a NamedType from a ModelInfo.