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{ Params: map[string]search.ParamDesc{ "_id": {Type: search.Token}, }, } } func (b *myAPI) SearchObservation(ctx context.Context, options search.Options) (search.Result, capabilities.FHIRError) { // return the search result return search.Result{ ... }, nil }
Index ¶
Constants ¶
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 = []Prefix{Equal, NotEqual, GreaterThan, LessThan, GreaterOrEqual, LessOrEqual, StartsAfter, EndsBefore}
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
Capabilities describe what search capabilities the server provides.
It can be used to derive CapabilityStatements which describe what a FHIR system can do.
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 Modifier ¶
type Modifier string
Modifier supported by an implementation.
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 Modifier = "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 Modifier = "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 Modifier = "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 Modifier = "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 Modifier = "exact" // ModifierIdentifier on reference: Tests whether the Reference.identifier in a resource (rather than the Reference.reference) matches the supplied parameter value. ModifierIdentifier Modifier = "identifier" // ModifierInModifier on token: Tests whether the value in a resource is a member of the supplied parameter ValueSet. ModifierInModifier = "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 Modifier = "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 Modifier = "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 Modifier = "not" // ModifierNotIn on reference, token: Tests whether the value in a resource is not a member of the supplied parameter ValueSet. ModifierNotIn Modifier = "not-in" // ModifierOfType on token (only Identifier): Tests whether the Identifier value in a resource matches the supplied parameter value. ModifierOfType Modifier = "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 Modifier = "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. ModifierTextAdvancedModifier = "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 Modifier = "[type]" )
type Options ¶
Options passed to a search implementation.
func ParseOptions ¶
func ParseOptions( searchCapabilities Capabilities, params url.Values, tz *time.Location, maxCount, defaultCount int, ) (Options, error)
ParseOptions parses search options from a url.Values query string.
Only parameters supported by the backing implementation as described by the passed `searchCapabilities` are used.
Result modifying parameters are parsed into separate fields on the Options object. All other parameters are parsed into [options.Params].
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 Params ¶
func (Params) Query ¶
Query representing the search parameters.
All contained values are sorted, but the returned url.Values is backed by a map. To obtain a deterministic query string you can call url.Values.Encode, because it will sort the keys alphabetically.
type Prefix ¶
type Prefix = string
A Prefix that some parameter types can use to change search behavior. See https://hl7.org/fhir/search.html#prefix.