search

package
v0.0.0-...-838d5f2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IDParam            = "_id"
	LastUpdatedParam   = "_lastUpdated"
	TagParam           = "_tag"
	ProfileParam       = "_profile"
	SecurityParam      = "_security"
	TextParam          = "_text"
	ContentParam       = "_content"
	ListParam          = "_list"
	QueryParam         = "_query"
	HasParam           = "_has"
	SortParam          = "_sort"
	CountParam         = "_count"
	IncludeParam       = "_include"
	RevIncludeParam    = "_revinclude"
	SummaryParam       = "_summary"
	ElementsParam      = "_elements"
	ContainedParam     = "_contained"
	ContainedTypeParam = "_containedType"
	OffsetParam        = "_offset" // Custom param, not in FHIR spec
	FormatParam        = "_format"
)

Constant values for search paramaters and search result parameters

Variables

View Source
var SearchParameterDictionary = map[string]map[string]SearchParamInfo{}/* 116 elements not displayed */

SearchParameterDictionary provides a mapping from FHIR resource names to a list of the search parameters they support.

This file is generated by the FHIR golang generator. This file should not be manually modified.

Functions

func ParseParamNameModifierAndPostFix

func ParseParamNameModifierAndPostFix(fullParam string) (param string, modifier string, postfix string)

ParseParamNameModifierAndPostFix parses a full parameter key and returns the parameter name, modifier, and postfix components. For example, "foo:bar.baz" would return ["foo","bar","baz"].

Types

type BSONBuilder

type BSONBuilder func(param SearchParam, searcher *MongoSearcher) (object bson.M, err error)

BSONBuilder returns a BSON object representing the passed in search parameter. This BSON object is expected to be merged with other objects and passed into Mongo's Find function.

type BSONQuery

type BSONQuery struct {
	Resource string
	Query    bson.M
	Pipeline []bson.M
}

BSONQuery is a BSON document constructed from the original string search query.

func NewBSONQuery

func NewBSONQuery(resource string) *BSONQuery

NewBSONQuery initializes a new BSONQuery and returns a pointer to that BSONQuery.

func (*BSONQuery) DebugString

func (b *BSONQuery) DebugString() string

type ChainedQueryReference

type ChainedQueryReference struct {
	Type         string // The type of resource being searched
	ChainedQuery Query
}

ChainedQueryReference represents a chained query

type CompositeParam

type CompositeParam struct {
	SearchParamInfo
	CompositeValues []string
}

CompositeParam represents a composite-flavored search parameter. The following description is from the FHIR DSTU2 specification:

A resource may also specify composite parameters that take sequences of single values that match other defined parameters as an argument. The matching parameter of each component in such a sequence is documented in the definition of the parameter. These sequences are formed by joining the single values with a "$". Note that this sequence is a single value and itself can be composed into a set of values, so that, for example, multiple matching state-on-date parameters can be specified as state-on-date=new$2013-05-04,active$2013-05-05.

func ParseCompositeParam

func ParseCompositeParam(paramString string, info SearchParamInfo) *CompositeParam

ParseCompositeParam parses a composite query string and returns a pointer to a CompositeParam based on the query and the parameter definition.

type CountCache

type CountCache struct {
	Id    string `bson:"_id"`
	Count uint32 `bson:"count"`
}

CountCache is used to cache the total count of results for a specific query. The Id is the md5 hash of the query string.

type DateParam

type DateParam struct {
	SearchParamInfo
	Date *utils.Date
}

DateParam represents a date-flavored search parameter. The following description is from the FHIR DSTU2 specification:

A date parameter searches on a date/time or period. As is usual for date/time related functionality, while the concepts are relatively straight-forward, there are a number of subtleties involved in ensuring consistent behavior.

func ParseDateParam

func ParseDateParam(paramStr string, info SearchParamInfo) *DateParam

ParseDateParam parses a date-based query string and returns a pointer to a DateParam based on the query and the parameter definition.

type Error

type Error struct {
	HTTPStatus       int
	OperationOutcome *models.OperationOutcome
}

Error is an interface for search errors, providing an HTTP status and operation outcome

func (*Error) Error

func (e *Error) Error() string

type ExternalReference

type ExternalReference struct {
	Type string
	URL  string
}

ExternalReference represents an external reference by URL

type IncludeOption

type IncludeOption struct {
	Resource  string
	Parameter SearchParamInfo
}

IncludeOption describes the data that should be included in query results

type LocalReference

type LocalReference struct {
	Type string
	ID   string
}

LocalReference represents a local reference by ID (and potentially Type)

type MongoRegistry

type MongoRegistry struct {
	// contains filtered or unexported fields
}

MongoRegistry supports the registration and lookup of Mongo search parameter implementations as BSON builders.

func GlobalMongoRegistry

func GlobalMongoRegistry() *MongoRegistry

GlobalMongoRegistry returns an instance of the global search parameter registry

func (*MongoRegistry) LookupBSONBuilder

func (r *MongoRegistry) LookupBSONBuilder(paramType string) (builder BSONBuilder, err error)

LookupBSONBuilder looks up a BSON builder by type. If no builder is registered, it will return an error.

func (*MongoRegistry) RegisterBSONBuilder

func (r *MongoRegistry) RegisterBSONBuilder(paramType string, builder BSONBuilder)

RegisterBSONBuilder registers a BSON builder for a given parameter type.

type MongoSearcher

type MongoSearcher struct {
	// contains filtered or unexported fields
}

MongoSearcher implements FHIR searches using the Mongo database.

func NewMongoSearcher

func NewMongoSearcher(db *mongowrapper.WrappedDatabase, ctx context.Context, countTotalResults, enableCISearches, tokenParametersCaseSensitive, readonly bool) *MongoSearcher

NewMongoSearcher creates a new instance of a MongoSearcher for an already open session

func NewMongoSearcherForUri

func NewMongoSearcherForUri(mongoUri string, mongoDatabaseName string, countTotalResults, enableCISearches, tokenParametersCaseSensitive, readonly bool) *MongoSearcher

NewMongoSearcher creates a new instance of a MongoSearcher with a new connection Call Close()

func (*MongoSearcher) Close

func (m *MongoSearcher) Close()

Close a MongoDB session opened by NewMongoSearcherForUri

func (*MongoSearcher) GetDB

GetDB returns a pointer to the Mongo database. This is helpful for custom search implementations.

func (*MongoSearcher) Search

func (m *MongoSearcher) Search(query Query) (resources []*models2.Resource, total uint32, err error)

Search takes a Query and returns a set of results (Resources). If an error occurs during the search the corresponding mongo error is returned and results will be nil.

type NumberParam

type NumberParam struct {
	SearchParamInfo
	Number *utils.Number
}

NumberParam represents a number-flavored search parameter. The following description is from the FHIR DSTU2 specification:

Searching on a simple numerical value in a resource.

func ParseNumberParam

func ParseNumberParam(paramStr string, info SearchParamInfo) *NumberParam

ParseNumberParam parses a number-based query string and returns a pointer to a NumberParam based on the query and the parameter definition.

type OrParam

type OrParam struct {
	SearchParamInfo
	Items []SearchParam
}

OrParam represents a search parameter that has multiple OR values. The following description is from the FHIR DSTU2 specification:

If, instead, the search is to find patients that speak either language, then this is a single parameter with multiple values, separated by a ','. For example: "/Patient?language=FR,NL". This is known as an OR search parameter, since the server is expected to respond with results which match either value.

func ParseOrParam

func ParseOrParam(paramStr []string, info SearchParamInfo) *OrParam

ParseOrParam parses a slice of values to be ORed and returns a pointer to an OrParam based on the query and the parameter definition.

type ParameterParser

type ParameterParser func(info SearchParamInfo, data SearchParamData) (SearchParam, error)

ParameterParser parses search parameter data into a SearchParam implementation.

type Prefix

type Prefix string

Prefix is an enum representing FHIR parameter prefixes. The following description is from the FHIR DSTU2 specification:

For the ordered parameter types number, date, and quantity, a prefix to the parameter value may be used to control the nature of the matching.

const (
	EQ Prefix = "eq"
	NE Prefix = "ne"
	GT Prefix = "gt"
	LT Prefix = "lt"
	GE Prefix = "ge"
	LE Prefix = "le"
	SA Prefix = "sa"
	EB Prefix = "eb"
	AP Prefix = "ap"
)

Constant values for the Prefix enum.

func ExtractPrefixAndValue

func ExtractPrefixAndValue(s string) (Prefix, string)

ExtractPrefixAndValue parses a string parameter value into an optional prefix and value.

func (Prefix) String

func (p Prefix) String() string

String returns the prefix as a string.

type QuantityParam

type QuantityParam struct {
	SearchParamInfo
	Number *utils.Number
	System string
	Code   string
}

QuantityParam represents a quantity-flavored search parameter. The following description is from the FHIR DSTU2 specification:

A quantity parameter searches on the Quantity data type.

func ParseQuantityParam

func ParseQuantityParam(paramStr string, info SearchParamInfo) *QuantityParam

ParseQuantityParam parses a quantity-based query string and returns a pointer to a QuantityParam based on the query and the parameter definition.

type Query

type Query struct {
	Resource string
	Query    string
}

Query describes a string-based FHIR query and the resource it is associated with. For example, the URL http://acme.com/Condition?patient=123&onset=2012 should be represented as:

Query { Resource: "Condition", Query: "patient=123&onset=2012" }

func (*Query) Options

func (q *Query) Options() *QueryOptions

Options parses the query string and returns the QueryOptions.

func (*Query) Params

func (q *Query) Params() []SearchParam

Params parses the query string and returns a slice containing the appropriate SearchParam instances. For example, a Query on the "Condition" resource with the query string "patient=123&onset=2012" should return a slice containing a ReferenceParam (for patient) and a DateParam (for onset).

func (*Query) SupportsPaging

func (q *Query) SupportsPaging() bool

SupportsPaging returns true if the query results can be paginated, false if not. In practice, most queries can be paginated, but queries for $everything or _summary cannot.

func (*Query) URLQueryParameters

func (q *Query) URLQueryParameters(withOptions bool) URLQueryParameters

URLQueryParameters reconstructs the URL-encoded query based on parsed parameters. This ensures better uniformity/consistency and also removes any garbage parameters or bad formatting in the passed in parameters. If withOptions is specified, the query options will also be included in the URLQueryParameters.

func (*Query) UsesChainedSearch

func (q *Query) UsesChainedSearch() bool

UsesChainedSearch returns true if the query has any chained search parameters

func (*Query) UsesIncludes

func (q *Query) UsesIncludes() bool

UsesIncludes returns true if the query has any _includes options

func (*Query) UsesPipeline

func (q *Query) UsesPipeline() bool

UsesPipeline returns true if the query requires a pipeline to execute

func (*Query) UsesRevIncludes

func (q *Query) UsesRevIncludes() bool

UsesRevIncludes returns true if the query has any _revincludes options

func (*Query) UsesReverseChainedSearch

func (q *Query) UsesReverseChainedSearch() bool

UsesReverseChainedSearch returns true if the query has any reverse chained search parameters

type QueryOptions

type QueryOptions struct {
	Count           int
	Offset          int
	Sort            []SortOption
	Include         []IncludeOption
	RevInclude      []RevIncludeOption
	IsSTU3Sort      bool
	IsIncludeAll    bool
	IsRevincludeAll bool
	Summary         string
}

QueryOptions contains option values such as count and offset.

func NewQueryOptions

func NewQueryOptions() *QueryOptions

NewQueryOptions constructs a new QueryOptions with default values (offset = 0, Count = 100)

func (*QueryOptions) URLQueryParameters

func (o *QueryOptions) URLQueryParameters() URLQueryParameters

URLQueryParameters returns URLQueryParameters representing the query options.

type ReferenceParam

type ReferenceParam struct {
	SearchParamInfo
	Reference interface{}
}

ReferenceParam represents a reference-flavored search parameter. The following description is from the FHIR DSTU2 specification:

A reference parameter refers to references between resources, e.g. find all Conditions where the subject reference is a particular patient, where the patient is selected by name or identifier.

func ParseReferenceParam

func ParseReferenceParam(paramStr string, info SearchParamInfo) *ReferenceParam

ParseReferenceParam parses a reference-based query string and returns a pointer to a ReferenceParam based on the query and the parameter definition.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry supports the registration and lookup of FHIR search parameters, both standard and custom. For custom search parameters, a parameter type implementation may also need to be registered.

func GlobalRegistry

func GlobalRegistry() *Registry

GlobalRegistry returns an instance of the global search parameter registry

func (*Registry) LookupParameterInfo

func (r *Registry) LookupParameterInfo(resource, name string) (param SearchParamInfo, err error)

LookupParameterInfo looks up search parameter info by resource and name. If no parameter info is registered, it will return an error.

func (*Registry) LookupParameterParser

func (r *Registry) LookupParameterParser(paramType string) (parser ParameterParser, err error)

LookupParameterParser looks up a parameter parser by type. If no parser is registered, it will return an error.

func (*Registry) RegisterParameterInfo

func (r *Registry) RegisterParameterInfo(param SearchParamInfo)

RegisterParameterInfo registers search param info for a given resource and name (as represented in the info). If the parameter is not of a standard fhir type (e.g., token, date, etc), then a SearchParameter for the given type should also be registered.

func (*Registry) RegisterParameterParser

func (r *Registry) RegisterParameterParser(paramType string, parser ParameterParser)

RegisterParameterParser registers a parameter parser for a given type name.

type RevIncludeOption

type RevIncludeOption struct {
	Resource  string
	Parameter SearchParamInfo
}

RevIncludeOption describes the data that should be included in query results

type ReverseChainedQueryReference

type ReverseChainedQueryReference struct {
	ReferenceName string // The name of the reference param
	Type          string // The type of resource being searched
	Query         Query
}

ReverseChainedQueryReference represents a reverse chained query

type SearchParam

type SearchParam interface {
	// contains filtered or unexported methods
}

SearchParam is an interface for all search parameter classes that exposes the SearchParamInfo.

type SearchParamData

type SearchParamData struct {
	Modifier string
	Chain    string
	Prefix   Prefix
	Value    string
}

SearchParamData represents the data associated to an instance of a search param

type SearchParamInfo

type SearchParamInfo struct {
	Resource   string
	Name       string
	Type       string
	Paths      []SearchParamPath
	Composites []string
	Targets    []string
	Prefix     Prefix
	Postfix    string
	Modifier   string
}

SearchParamInfo contains information about a FHIR search parameter, including its name, type, and paths or composites.

func (SearchParamInfo) CreateSearchParam

func (s SearchParamInfo) CreateSearchParam(paramStr string) SearchParam

CreateSearchParam converts a singular string query value (e.g. "2012") into a SearchParam object corresponding to the SearchParamInfo.

type SearchParamPath

type SearchParamPath struct {
	Path string
	Type string
}

SearchParamPath indicates a dot-separated path to the property that should be searched, as well as the FHIR type of that property (e.g., "dateTime"). The path indicates elements that are arrays by prefixing the element name with "[]" (e.g., "order.[]item.name"). In the rare case that the search path has an indexer, it will be in the brackets (e.g.,"[0]item.entry")

type SortOption

type SortOption struct {
	Descending bool
	Parameter  SearchParamInfo
}

SortOption indicates what parameter to sort on and the sort order

type StringParam

type StringParam struct {
	SearchParamInfo
	String string
}

StringParam represents a string-flavored search parameter. The following description is from the FHIR DSTU2 specification:

The string parameter refers to simple string searches against sequences of characters. Matches are case- and accent- insensitive. By default, a field matches a string query if the value of the field equals or starts with the supplied parameter value, after both have been normalized by case and accent.

func ParseStringParam

func ParseStringParam(paramString string, info SearchParamInfo) *StringParam

ParseStringParam parses a string-based query string and returns a pointer to a StringParam based on the query and the parameter definition.

type TokenParam

type TokenParam struct {
	SearchParamInfo
	System    string
	Code      string
	AnySystem bool
}

TokenParam represents a token-flavored search parameter. The following description is from the FHIR DSTU2 specification:

A token type is a parameter that searches on a pair, a URI and a value. It is used against code or identifier value where the value may have a URI that scopes its meaning. The search is performed against the pair from a Coding or an Identifier.

func ParseTokenParam

func ParseTokenParam(paramString string, info SearchParamInfo) *TokenParam

ParseTokenParam parses a token-based query string and returns a pointer to a TokenParam based on the query and the parameter definition.

type URIParam

type URIParam struct {
	SearchParamInfo
	URI string
}

URIParam represents a uri-flavored search parameter. The following description is from the FHIR DSTU2 specification:

The uri parameter refers to an element which is URI (RFC 3986). Matches are precise (e.g. case, accent, and escape) sensitive, and the entire URI must match.

func ParseURIParam

func ParseURIParam(paramStr string, info SearchParamInfo) *URIParam

ParseURIParam parses an uri-based query string and returns a pointer to an URIParam based on the query and the parameter definition.

type URLQueryParameter

type URLQueryParameter struct {
	Key   string
	Value string
}

URLQueryParameter represents a query parameter as a key/value pair.

type URLQueryParameters

type URLQueryParameters struct {
	// contains filtered or unexported fields
}

URLQueryParameters represents an ordered list of query parameters that can be manipulated in several different ways.

func ParseQuery

func ParseQuery(query string) (u URLQueryParameters, err error)

ParseQuery provides an alternative to url.ParseQuery when the order of parameters must be retained. ParseQuery parses the URL-encoded query string and returns a URLQueryParameters object that can be used to get the ordered list of parameters, a map of the parameters, or parameters by name. ParseQuery always returns a non-nil URLQueryParameters object containing all the valid query parameters found; err describes the first decoding error encountered, if any.

func (*URLQueryParameters) Add

func (u *URLQueryParameters) Add(Key string, value string)

Add adds a key/value pair to the end of the list of URLQueryParameters. If the key already exists, the key/value is still added to the end of the list, as URLQueryParameters permite duplicate keys. To replace existing values, use Set instead.

func (*URLQueryParameters) All

All returns a copy of the slice containing all of the URLQueryParameters in the original order.

func (*URLQueryParameters) Encode

func (u *URLQueryParameters) Encode() string

Encode returns a URL-encoded string representing the query parameters in the original order.

func (*URLQueryParameters) Get

func (u *URLQueryParameters) Get(key string) string

Get returns the value of the first query parameter with the specified key. If no query parameters have the specified key, an empty string is returned.

func (*URLQueryParameters) GetMulti

func (u *URLQueryParameters) GetMulti(key string) []string

GetMulti returns a slice containing the values of all the query parameters with the specified key, in the order in which they were originally specified. If no query parameters have the specified key, an empty slice is returned.

func (*URLQueryParameters) Set

func (u *URLQueryParameters) Set(key string, value string)

Set sets the value for the query parameter with the specified key. If a query parameter with the specified key already exists, it overwrites the existing value. If multiple query parameters with the specified key exist, it overwrites the value of the first matching query parameter and removes the remaining query parameters from the list. If no query parameters exist with the given key, the key/value pair are added as a new query parameter at the end of the list.

func (*URLQueryParameters) Values

func (u *URLQueryParameters) Values() url.Values

Values returns a map similar to the map that would be returned by url.ParseQuery(). The url.Values object does not guarantee that order is preserved. If order must be preserved, use on of the other functions.

Jump to

Keyboard shortcuts

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