Documentation ¶
Overview ¶
Package identifier provides utilities for constructing and working with FHIR R4 Identifier elements.
Index ¶
- func Equivalent(lhs, rhs *dtpb.Identifier) bool
- func FindBySystem(identifiers []*dtpb.Identifier, system string) *dtpb.Identifier
- func GenerateIfNoneExist(identifier *dtpb.Identifier) string
- func New(value, system string, opts ...Option) *dtpb.Identifier
- func Official(value, system string, opts ...Option) *dtpb.Identifier
- func Old(value, system string, opts ...Option) *dtpb.Identifier
- func QueryIdentifier(id *dtpb.Identifier) string
- func QueryString(system string, value string) string
- func Secondary(value, system string, opts ...Option) *dtpb.Identifier
- func Temp(value, system string, opts ...Option) *dtpb.Identifier
- func Update(identifier *dtpb.Identifier, opts ...Option) *dtpb.Identifier
- func Usual(value, system string, opts ...Option) *dtpb.Identifier
- type Option
- func IncludeExtensions(ext ...*dtpb.Extension) Option
- func WithAssigner(assigner *dtpb.Reference) Option
- func WithExtensions(ext ...*dtpb.Extension) Option
- func WithID(id string) Option
- func WithPeriod(period *dtpb.Period) Option
- func WithSystem(system *dtpb.Uri) Option
- func WithSystemString(system string) Option
- func WithType(ty *dtpb.CodeableConcept) Option
- func WithUse(use Use) Option
- func WithValue(value string) Option
- type Use
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equivalent ¶
func Equivalent(lhs, rhs *dtpb.Identifier) bool
Equivalent checks if two identifiers are equivalent by comparing the system and values of the identifier.
func FindBySystem ¶
func FindBySystem(identifiers []*dtpb.Identifier, system string) *dtpb.Identifier
FindBySystem searches a slice of identifiers for the first identifier that contains the specified system.
func GenerateIfNoneExist ¶
func GenerateIfNoneExist(identifier *dtpb.Identifier) string
GenerateIfNoneExist takes an Identifier and generates a query appropriate for use in an If-None-Exist header. This is used for FHIR conditional create or other conditional methods.
Untrusted data in Identifiers is escaped both for FHIR and for URL safety.
Returns an empty string if identifier is nil.
This function only accepts a single identifier due to limitations of the GCP FHIR store. Important note: The GCP FHIR store only supports conditional queries on a single identifier, with no modifiers (so identifier=foo is OK, while identifier:exact=foo is invalid). Deviating from this in API v1 will result in an HTTP 400 invalid query error. NB: Deviating from this in API v1beta1 results in silent fallback to non-transactional search, meaning the conditional queries will have race conditions.
Example ¶
package main import ( "fmt" "github.com/fhir-fli/fhirpath-go/internal/element/identifier" dtpb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/datatypes_go_proto" ) func main() { id := &dtpb.Identifier{ System: &dtpb.Uri{Value: "http://fake.com"}, Value: &dtpb.String{Value: "9efbf82d-7a58-4d14-bec1-63f8fda148a8"}, } header := identifier.GenerateIfNoneExist(id) fmt.Printf("If-None-Exist: %v", header) }
Output: If-None-Exist: identifier=http%3A%2F%2Ffake.com%7C9efbf82d-7a58-4d14-bec1-63f8fda148a8
func New ¶
func New(value, system string, opts ...Option) *dtpb.Identifier
New constructs a new Identifier object from the given options.
func Official ¶
func Official(value, system string, opts ...Option) *dtpb.Identifier
Official is a convenience constructor for forming an identifier with an "Official" Use-code assigned.
func Old ¶
func Old(value, system string, opts ...Option) *dtpb.Identifier
Old is a convenience constructor for forming an identifier with an "Old" Use-code assigned.
func QueryIdentifier ¶
func QueryIdentifier(id *dtpb.Identifier) string
QueryIdentifier formats an Identifier proto for use in a Search query, escaping FHIR special characters `,|$\` in the input. Use this in a query param as the value with key `identifier`.
Example ¶
package main import ( "fmt" "github.com/fhir-fli/fhirpath-go/internal/element/identifier" dtpb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/datatypes_go_proto" ) func main() { ident := &dtpb.Identifier{ System: &dtpb.Uri{Value: "http://fake.com"}, Value: &dtpb.String{Value: "b0459744-b74b-441a-aee4-9dd97c80c642"}, } search := identifier.QueryIdentifier(ident) fmt.Printf("identifier:exact=%s", search) }
Output: identifier:exact=http://fake.com|b0459744-b74b-441a-aee4-9dd97c80c642
Example (Escape) ¶
package main import ( "fmt" "github.com/fhir-fli/fhirpath-go/internal/element/identifier" dtpb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/datatypes_go_proto" ) func main() { ident := &dtpb.Identifier{ System: &dtpb.Uri{Value: "http://fake.com"}, Value: &dtpb.String{Value: "foo,bar|baz"}, } search := identifier.QueryIdentifier(ident) fmt.Printf("identifier:exact=%s", search) }
Output: identifier:exact=http://fake.com|foo\,bar\|baz
func QueryString ¶
QueryString formats a system and value for use in a Search query, escaping FHIR special characters `,|$\` in the input. Use this in a query param as the value with key `identifier`.
Example ¶
package main import ( "fmt" "github.com/fhir-fli/fhirpath-go/internal/element/identifier" ) func main() { search := identifier.QueryString("http://fake.com", "1234") fmt.Printf("identifier:exact=%s", search) }
Output: identifier:exact=http://fake.com|1234
Example (Escape) ¶
package main import ( "fmt" "github.com/fhir-fli/fhirpath-go/internal/element/identifier" ) func main() { search := identifier.QueryString("http://fake.com", `$foo|bar\baz`) fmt.Printf("identifier:exact=%s", search) }
Output: identifier:exact=http://fake.com|\$foo\|bar\\baz
func Secondary ¶
func Secondary(value, system string, opts ...Option) *dtpb.Identifier
Secondary is a convenience constructor for forming an identifier with a "Secondary" Use-code assigned.
func Temp ¶
func Temp(value, system string, opts ...Option) *dtpb.Identifier
Temp is a convenience constructor for forming an identifier with a "Temp" Use-code assigned.
func Update ¶
func Update(identifier *dtpb.Identifier, opts ...Option) *dtpb.Identifier
Update modifies an identifier in-place with the given identifier options.
This function returns the input identifier to allow for functional chaining.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an abstraction for options to construct or modify Identifier elements.
func IncludeExtensions ¶
IncludeExtensions return an Identifier Option that appends the specified extensions to the Identifier.Extension field.
func WithAssigner ¶
WithAssigner returns an Identifier Option that sets the Identifier.Assigner to the specified assigner reference.
func WithExtensions ¶
WithExtensions return an Identifier Option that sets the Identifier.Extension field to the specified extensions.
func WithPeriod ¶
WithPeriod returns an Identifier Option that sets the Identifier.Period to the specified period.
func WithSystem ¶
WithSystem returns an Identifier Option that sets the Identifier.System to the specified system.
func WithSystemString ¶
WithSystemString returns an Identifier Option that sets the Identifier.System to the specified system string.
func WithType ¶
func WithType(ty *dtpb.CodeableConcept) Option
WithType returns an Identifier Option that sets the Identifier.Type to the specified type.
type Use ¶
type Use = cpb.IdentifierUseCode_Value
Use is an alias of the Identifier Use-codes for easier access and readability.
const ( // UseUsual is an alias of the USUAL Identifier use-code for easier access and // readability. UseUsual Use = cpb.IdentifierUseCode_USUAL // UseOfficial is an alias of the OFFICIAL Identifier use-code for easier access // and readability. UseOfficial Use = cpb.IdentifierUseCode_OFFICIAL // UseTemp is an alias of the TEMP Identifier use-code for easier access and // readability. UseTemp Use = cpb.IdentifierUseCode_TEMP // UseSecondary is an alias of the SECONDARY Identifier use-code for easier // access and readability. UseSecondary Use = cpb.IdentifierUseCode_SECONDARY // UseOld is an alias of the OLD Identifier use-code for easier access and // readability. UseOld Use = cpb.IdentifierUseCode_OLD )