Documentation
¶
Overview ¶
Package types holds a representation of CQL types and related logic. It is used by both the parser and interpreter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CQLTypeToProto ¶
CQLTypeToProto returns the generic CQLType proto of the CQL type.
Types ¶
type Choice ¶
type Choice struct {
ChoiceTypes []IType
}
Choice defines the type for a choice type.
func ChoiceFromProto ¶
func ChoiceFromProto(pb *ctpb.ChoiceType) (*Choice, error)
ChoiceFromProto converts a proto to a Choice type.
func (*Choice) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (Choice) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the Choice type.
func (*Choice) ModelInfoName ¶
ModelInfoName returns name as the CQL choice type specifier with ChoiceTypes sorted.
type IType ¶
type IType interface { // Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types. Equal(IType) bool // String returns a print friendly representation of the type and implements fmt.Stringer. String() string // ModelInfoName returns the key for this type in the model info. // // For Named and System types this is the fully qualified name like FHIR.EnrollmentResponseStatus // or System.Integer. The name may be split in the XML (namespace="FHIR" // name="EnrollmentResponseStatus"), but we use the qualified name. // // For other types the CQL type specifier syntax is used as the key. For example, // Interval<Integer>, Choice<Integer, String> or Tuple { address String }. For Tuple and Choice types // we alphabetically sort their inner types. ModelInfoName() (string, error) // MarshalJSON implements the json.Marshaler interface for the IType. MarshalJSON() ([]byte, error) }
IType is an interface implemented by all CQL Type structs.
type Interval ¶
type Interval struct {
PointType IType
}
Interval defines the type for an interval.
func IntervalFromProto ¶
func IntervalFromProto(pb *ctpb.IntervalType) (*Interval, error)
IntervalFromProto converts a proto to an Interval type.
func (*Interval) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (Interval) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the Interval type.
func (*Interval) ModelInfoName ¶
ModelInfoName returns name as the CQL interval type specifier.
type List ¶
type List struct { // The type of the elements in the list. ElementType IType }
List defines the type for a list.
func ListFromProto ¶
ListFromProto converts a proto to a List type.
func (*List) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (List) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the List type.
func (*List) ModelInfoName ¶
ModelInfoName returns name as the CQL list type specifier.
type Named ¶
type Named struct { // TypeName is the fully qualified name of the type. TypeName string }
Named defines a single type by name. The name refers to a type defined by ModelInfo.
func NamedFromProto ¶
NamedFromProto converts a proto to a Named type.
func (*Named) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (Named) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the Named type.
func (*Named) ModelInfoName ¶
ModelInfoName returns the fully qualified type name in the model info convention.
type System ¶
type System string
System represents the primitive types defined by CQL (https://cql.hl7.org/09-b-cqlreference.html#types-2).
const ( // Unset indicates that the parser did not set this Result Type. Unset System = "System.UnsetType" // Any is a CQL Any Type. It means that the type could be anything including list, interval, // named type from ModelInfo or null. Any System = "System.Any" // String is a CQL String type. String System = "System.String" // Integer is a CQL Integer type. Integer System = "System.Integer" // Decimal is a CQL Decimal type. Decimal System = "System.Decimal" // Long is a CQL Long type. Long System = "System.Long" // Quantity is a CQL decimal value and unit pair. Quantity System = "System.Quantity" // Ratio is the type for ratio - two CQL quantities. Ratio System = "System.Ratio" // Boolean is a CQL Boolean type. Boolean System = "System.Boolean" // DateTime is the CQL DateTime type. DateTime System = "System.DateTime" // Date is the CQL Date type. Date System = "System.Date" // Time is the CQL Time type. Time System = "System.Time" // ValueSet is the CQL Valueset type. ValueSet System = "System.ValueSet" // CodeSystem is a CQL CodeSystem which contains external Code definitions. CodeSystem System = "System.CodeSystem" // Vocabulary is the CQL Vocabulary type which is the parent type of ValueSet and CodeSystem. Vocabulary System = "System.Vocabulary" // Code is the CQL System Code type (which is distinct from a FHIR code type). Code System = "System.Code" // Concept is the CQL System Concept type. Concept System = "System.Concept" )
func SystemFromProto ¶
func SystemFromProto(pb *ctpb.SystemType) System
SystemFromProto converts a proto to a System type.
func ToSystem ¶
ToSystem converts a string to a System type returning System.Unsupported if the string cannot be converted to a system type.
func (System) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (System) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the System type.
func (System) ModelInfoName ¶
ModelInfoName returns the fully qualified type name in the model info convention.
func (System) Proto ¶
func (s System) Proto() *ctpb.SystemType
Proto returns the proto representation of the system type.
type Tuple ¶
type Tuple struct { // ElementTypes is a map from element name to its type. ElementTypes map[string]IType }
Tuple defines the type for a tuple (aka Structured Value).
func TupleFromProto ¶
TupleFromProto converts a proto to a Tuple type.
func (*Tuple) Equal ¶
Equal is a strict equal. X.Equal(Y) is true when X and Y are the exact same types.
func (Tuple) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the Tuple type.
func (*Tuple) ModelInfoName ¶
ModelInfoName returns name as the CQL tuple type specifier with ElementTypes sorted by name.