protofields

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: BSD-3-Clause Imports: 154 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Resources is a map of all resource names to their corresponding field references.
	Resources map[string]*ResourceFieldRefs

	// Elements is a map of all element names to their corresponding field references.
	Elements map[string]*ElementFieldRefs
)

Functions

func AppendList

func AppendList(in proto.Message, fieldName string, values ...proto.Message)

AppendList updates a field of the given name in-place for the specified message.

This function will panic if the field is not a repeated-field.

func DescriptorName

func DescriptorName(value proto.Message) string

DescriptorName gets the type name of a proto Message. If value is nil, this returns an empty string.

func IsCodeField

func IsCodeField(message proto.Message) bool

IsCodeField returns true if the message represents a FHIR code type. Codes with enum values and string values are both considered valid.

func IsValidElementType

func IsValidElementType(name string) bool

IsValidElementType checks that the given name is a valid element name

func IsValidResourceType

func IsValidResourceType(name string) bool

IsValidResourceType checks that the given name is a valid resource name

func Overwrite

func Overwrite(in proto.Message, fieldName string, values ...proto.Message)

Overwrite overwrites a field of the given name for the specified message. If `values` is empty, the field is cleared. If `values` contains more than one entry for a non-repeated field, this panics.

func StringValueFromCodeField

func StringValueFromCodeField(message proto.Message) (string, bool)

StringValueFromCodeField gets the Field Descriptor of a message that represents a FHIR Code type. Returns the string value of the enum or string value of the Code, along with a boolean flag representing whether or not the input is a code type.

func TypeToContainedResourceOneOfFieldName

func TypeToContainedResourceOneOfFieldName(resource string) protoreflect.Name

TypeToContainedResourceOneOfFieldName converts a resource type name into their respective ContainedResource "OneOf" field.

func UnwrapOneofField

func UnwrapOneofField(element proto.Message, fieldName string) proto.Message

UnwrapOneofField obtains the underlying Message for "Oneof" elements contained in fields with the given fieldName. Returns nil if the input message doesn't have the given field, or if the Oneof descriptor is unpopulated.

Types

type ElementFieldRefs

type ElementFieldRefs struct {
	// Extension contains back-references for the Extension to this type
	Extension struct {
		// ValueX is the Extension.ValueX field that corresponds to
		// this resource.
		//
		// This field cannot be nil, as all R4 resources are valid contained-resource
		// types.
		ValueX protoreflect.FieldDescriptor
	}

	// New is a function that will create a new instance of this FHIR element.
	New func() proto.Message
}

ElementFieldRefs is a container of back-references for a specified Element. This enables finding one-ofs that can work with the resource it represents, for easier/faster lookup than waiting on protoreflect APIs.

type Field

type Field struct {
	Value      protoreflect.Value
	Descriptor protoreflect.FieldDescriptor
}

Field is a struct containing both the Value and FieldDescriptor for a proto field.

func GetField

func GetField(message proto.Message, name string) (*Field, bool)

GetField retrieves the proto field of the specified name from the message.

type FieldToValueFunc

FieldToValueFunc is a function converting a protoreflect.Message's field-descriptor into a Value.

This corresponds to either `protoreflect.Message.Mutable` or `protoreflect.Message.NewField`.

This type is an implementation-detail shared through various APIs that support a mix of appending or overwriting sequences.

type ResourceFieldRefs

type ResourceFieldRefs struct {
	// ContainedResource contains back-references for the ContainedResource to
	// this type
	ContainedResource struct {
		// Resource is the ContainedResource.Resource field that corresponds to
		// this resource.
		//
		// This field cannot be nil, as all R4 resources are valid contained-resource
		// types.
		Resource protoreflect.FieldDescriptor
	}

	// New is a function that will create a new instance of this FHIR Resource.
	New func() proto.Message
}

ResourceFieldRefs is a container of back-references for a specified Resource. This enables finding one-ofs that can work with the resource it represents, for easier/faster lookup than waiting on protoreflect APIs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL