Documentation ¶
Overview ¶
Package rest provides a FHIR REST API.
Capabilities are detected by type assertion, a generated CapabilityStatement is served at the "/metadata" endpoint.
Following interactions are currently supported:
- read
- search (parameters are passed down to the supplied backend implementation)
Base URL and routes ¶
You have to pass a base URL using the config. This base URL is only used for building response Bundles. For supported interactions, the returned http.Handler has sub-routes installed. These are always installed at the root of this handler. The base URL from the config is not used.
Currently, installed patterns are:
- capabilities: "GET /metadata"
- read: "GET /{type}/{id}"
- search: "GET /{type}/"
If you do not want your FHIR handlers installed at the root, use something like
mux.Handle("/path/", http.StripPrefix("/path", serverHandler)
This allows you to implement multiple FHIR REST APIs on the same HTTP server (e.g. for multi-tenancy scenarios).
Pagination ¶
Cursor-based pagination can be implemented by the backend. Therefor the parameters "_count" and "_cursor" are passed down to the backend.
Index ¶
- Variables
- func CapabilityStatement[R model.Release](baseURL *url.URL, capabilities capabilities.Capabilities, date time.Time) basic.CapabilityStatement
- func NewRequestContextSlogHandler(h slog.Handler) slog.Handler
- func NewServer[R model.Release](backend any, config Config) (http.Handler, error)
- func SearchBundle(resourceType string, result search.Result, usedOptions search.Options, ...) (basic.Bundle, capabilities.FHIRError)
- type Config
- type Format
- type MissingIdError
- type RequestContext
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ Timezone: time.Now().Location().String(), Date: time.Now().Format(time.RFC3339), MaxCount: 500, DefaultCount: 500, DefaultFormat: FormatJSON, }
DefaultConfig sets reasonable defaults that can be used by the package user.
Functions ¶
func CapabilityStatement ¶
func CapabilityStatement[R model.Release]( baseURL *url.URL, capabilities capabilities.Capabilities, date time.Time, ) basic.CapabilityStatement
CapabilityStatement building from provided capabilities.
func SearchBundle ¶
func SearchBundle( resourceType string, result search.Result, usedOptions search.Options, searchCapabilities search.Capabilities, baseURL *url.URL, ) (basic.Bundle, capabilities.FHIRError)
SearchBundle creates a new search bundle from the given resources and parameters.
The REST server uses cursor based pagination. If the search results contains a `Next` cursor, a 'next' bundle link entry will be set.
Types ¶
type Config ¶
type Config struct { // Base path of the FHIR server, used e.g. for building bundles. Base *url.URL `json:"base"` // Timezone used for parsing date parameters without timezones. // Defaults to current server timezone. Timezone string `json:"timezone"` // Date of last capability change, used for building the CapabilityStatement. // Defaults to current time. Date string `json:"date"` // MaxCount of search bundle entries. // Defaults to 500. MaxCount int `json:"maxCount"` // DefaultCount of search bundle entries. // Defaults to 500. DefaultCount int `json:"defaultCount"` // DefaultFormat of the server. // Defaults to JSON. DefaultFormat Format `json:"defaultFormat"` }
func (Config) MarshalJSON ¶
func (*Config) UnmarshalJSON ¶
type MissingIdError ¶
type MissingIdError struct {
ResourceType string
}
MissingIdError indicates that a bundle entry is missing an id.
func (MissingIdError) Error ¶
func (e MissingIdError) Error() string
func (MissingIdError) OperationOutcome ¶
func (e MissingIdError) OperationOutcome() model.Resource
func (MissingIdError) StatusCode ¶
func (e MissingIdError) StatusCode() int