Documentation
¶
Overview ¶
Package search contains types and helpers to work with FHIR Search. You can use these to provide search capabilities for your custom implementation.
Currently, only an API with cursor-based pagination is supported. Parameters for offset based pagination might be added eventually if there is demand.
Example ¶
import "github.com/DAMEDIC/fhir-toolbox-go/capabilities/search" func (b *myAPI) SearchCapabilitiesObservation() search.Capabilities { // return supported search capabilities return search.Capabilities{ Parameters: ParameterDescriptions{ "_id": {Type: search.TypeToken}, }, } } func (b *myAPI) SearchObservation(ctx context.Context, options search.Options) (search.Result, error) { // return the search result return search.Result{ ... }, nil }
Index ¶
Constants ¶
const ( TypeNumber string = "number" TypeDate string = "date" TypeString string = "string" TypeToken string = "token" TypeReference string = "reference" TypeComposite string = "composite" TypeQuantity string = "quantity" TypeUri string = "uri" TypeSpecial string = "special" )
const ( // ModifierAbove on reference, token, uri: Tests whether the value in a resource is or subsumes the supplied parameter value (is-a, or hierarchical relationships). ModifierAbove string = "above" // ModifierBelow on reference, token, uri: Tests whether the value in a resource is or is subsumed by the supplied parameter value (is-a, or hierarchical relationships). ModifierBelow string = "below" // ModifierCodeText on reference, token: Tests whether the textual display value in a resource (e.g., CodeableConcept.text, Coding.display, or Reference.display) matches the supplied parameter value. ModifierCodeText string = "code-text" // ModifierContains on string, uri: Tests whether the value in a resource includes the supplied parameter value anywhere within the field being searched. ModifierContains string = "contains" // ModifierExact on string: Tests whether the value in a resource exactly matches the supplied parameter value (the whole string, including casing and accents). ModifierExact string = "exact" // ModifierIdentifier on reference: Tests whether the Reference.identifier in a resource (rather than the Reference.reference) matches the supplied parameter value. ModifierIdentifier string = "identifier" // ModifierInModifier on token: Tests whether the value in a resource is a member of the supplied parameter ValueSet. ModifierIn string = "in" // ModifierIterate Not allowed anywhere by default: The search parameter indicates an inclusion directive (_include, _revinclude) that is applied to an included resource instead of the matching resource. ModifierIterate string = "iterate" // ModifierMissing on date, number, quantity, reference, string, token, uri: Tests whether the value in a resource is present (when the supplied parameter value is true) or absent (when the supplied parameter value is false). ModifierMissing string = "missing" // ModifierNot on token: Tests whether the value in a resource does not match the specified parameter value. Note that this includes resources that have no value for the parameter. ModifierNot string = "not" // ModifierNotIn on reference, token: Tests whether the value in a resource is not a member of the supplied parameter ValueSet. ModifierNotIn string = "not-in" // ModifierOfType on token (only Identifier): Tests whether the Identifier value in a resource matches the supplied parameter value. ModifierOfType string = "of-type" // ModifierText on reference, token: Tests whether the textual value in a resource (e.g., CodeableConcept.text, Coding.display, Identifier.type.text, or Reference.display) matches the supplied parameter value using basic string matching (begins with or is, case-insensitive). // //on string: The search parameter value should be processed as input to a search with advanced text handling. ModifierText string = "text" // ModifierTextAdvancedModifier on reference, token: Tests whether the value in a resource matches the supplied parameter value using advanced text handling that searches text associated with the code/value - e.g., CodeableConcept.text, Coding.display, or Identifier.type.text. ModifierTextAdvanced string = "text-advanced" // ModifierType on reference: Tests whether the value in a resource points to a resource of the supplied parameter type. Note: a concrete ResourceType is specified as the modifier (e.g., not the literal :[type], but a value such as :Patient). ModifierType string = "[type]" )
const ( PrefixEqual string = "eq" PrefixNotEqual string = "ne" PrefixGreaterThan string = "gt" PrefixLessThan string = "lt" PrefixGreaterOrEqual string = "ge" PrefixLessOrEqual string = "le" PrefixStartsAfter string = "sa" PrefixEndsBefore string = "eb" )
const ( DateFormatOnlyYear = "2006" DateFormatUpToMonth = "2006-01" DateFormatUpToDay = "2006-01-02" DateFormatHourMinute = "2006-01-02T15:04Z07:00" DateFormatFullTime = "2006-01-02T15:04:05.999999999Z07:00" )
Format strings for precision aware parsing and encoding.
Variables ¶
var KnownPrefixes = []string{ PrefixEqual, PrefixNotEqual, PrefixGreaterThan, PrefixLessThan, PrefixGreaterOrEqual, PrefixLessOrEqual, PrefixStartsAfter, PrefixEndsBefore, }
Functions ¶
This section is empty.
Types ¶
type AllOf ¶
type AllOf []OneOf
All represents a slice of possible values for a single search parameter where each of the entry has to match.
type Cursor ¶
type Cursor string
Cursor is used for pagination.
It references where the server shall pick up querying additional results for multi-page queries.
type DatePrecision ¶
type DatePrecision string
DatePrecision represents the precision of date value.
const ( PrecisionYear DatePrecision = "year" PrecisionMonth DatePrecision = "month" PrecisionDay DatePrecision = "day" PrecisionHourMinute DatePrecision = "hourMinute" PrecisionFullTime DatePrecision = "time" )
type OneOf ¶
type OneOf []Value
OneOf represents a slice of possible values for a single search parameter, where only one of the values has to match.
type Options ¶
type Options struct { // Parameters defines the search parameters. Parameters map[ParameterKey]AllOf // Includes specifies the related resources to include in the search results. Includes []string // Count defines the maximum number of results to return. Count int // Cursor allows for pagination of large result sets. Cursor Cursor }
Options represents the parameters passed to a search implementation.
func ParseOptions ¶
func ParseOptions( capabilityStatement basic.CapabilityStatement, resourceType string, resolveSearchParameter func(canonical string) (model.Element, error), params url.Values, tz *time.Location, maxCount, defaultCount int, strict bool, ) (Options, error)
ParseOptions parses search options from a url.Values query string.
Only parameters supported by the backing implementation as described by the passed `capabilityStatement` for the given `resourceType` are used.
The `resolveSearchParameter` function is used to resolve SearchParameter resources from their canonical URLs found in the CapabilityStatement.
When `strict` is true, an error is returned if unsupported search parameters are encountered. When `strict` is false, unsupported search parameters are silently ignored.
Result modifying parameters are parsed into separate fields on the Options object. All other parameters are parsed into [options.Parameters].
func (Options) QueryString ¶
QueryString of the search options.
Search parameters are sorted alphabetically, result modifying parameters like `_include` are appended at the end. The function is deterministic, the same `option` input will always yield the same output.
type ParameterKey ¶
type ParameterKey struct { // Name is the name of the search parameter. Name string // Modifier is an optional modifier that can be applied to the search parameter, // such as `exact`, `contains`, `identifier`, etc. Modifier string }
ParameterKey represents a key for a search parameter, consisting of a name and an optional modifier.
func (ParameterKey) MarshalText ¶
func (p ParameterKey) MarshalText() ([]byte, error)
func (ParameterKey) String ¶
func (p ParameterKey) String() string