Documentation ¶
Index ¶
- Constants
- Variables
- func BadRequest(msg string, args ...any) error
- func BadRequestError(err error) error
- func Config() *fhirclient.Config
- func CreateOperationOutcomeBundleEntryFromError(err error, desc string) (*fhir.BundleEntry, error)
- func DefaultAzureScope(fhirBaseURL *url.URL) []string
- func EntryHasID(id string) func(entry fhir.BundleEntry) bool
- func EntryIsOfType(resourceType string) func(entry fhir.BundleEntry) bool
- func ExecuteTransaction(fhirClient fhirclient.Client, bundle fhir.Bundle) (fhir.Bundle, error)
- func FilterResource(fn func(resource Resource) bool) func(entry fhir.BundleEntry) bool
- func FindMatchingParticipantInCareTeam(careTeams []fhir.CareTeam, principalOrganizationIdentifiers []fhir.Identifier) *fhir.CareTeamParticipant
- func FirstBundleEntry(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool) *fhir.BundleEntry
- func HttpMethodToVerb(method string) fhir.HTTPVerb
- func IdentifierEquals(one *fhir.Identifier, other *fhir.Identifier) bool
- func IsIdentifierTaskOwnerAndRequester(task *fhir.Task, principalOrganizationIdentifier []fhir.Identifier) (bool, bool)
- func IsLogicalIdentifier(identifier *fhir.Identifier) bool
- func IsLogicalReference(reference *fhir.Reference) bool
- func IsScpSubTask(task *fhir.Task) bool
- func IsScpTask(task *fhir.Task) bool
- func LogicalReference(refType, system, identifier string) *fhir.Reference
- func LogicalReferenceEquals(ref, other fhir.Reference) bool
- func NewAuthRoundTripper(config ClientConfig, fhirClientConfig *fhirclient.Config) (http.RoundTripper, fhirclient.Client, error)
- func NewAzureFHIRClient(fhirBaseURL *url.URL, credential azcore.TokenCredential, scopes []string) fhirclient.Client
- func NewAzureHTTPClient(credential azcore.TokenCredential, scopes []string) *http.Client
- func NewErrorWithCode(message string, statusCode int) error
- func NewProxy(logger zerolog.Logger, targetFHIRBaseURL *url.URL, proxyBasePath string, ...) *httputil.ReverseProxy
- func NormalizeTransactionBundleResponseEntry(fhirClient fhirclient.Client, fhirBaseURL *url.URL, ...) (*fhir.BundleEntry, error)
- func ResourceInBundle(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool, ...) error
- func ResourceType(resource interface{}) string
- func ResourcesInBundle(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool, ...) error
- func SanitizeOperationOutcome(in fhir.OperationOutcome) fhir.OperationOutcome
- func SendResponse(httpResponse http.ResponseWriter, httpStatus int, resource interface{}, ...)
- func ToString(resource interface{}) string
- func ValidateCareTeamParticipantPeriod(participant fhir.CareTeamParticipant, now time.Time) (bool, error)
- func ValidateLogicalReference(reference *fhir.Reference, expectedType string, expectedSystem string) error
- func ValidateReference(reference fhir.Reference) bool
- func ValidateTaskRequiredFields(task fhir.Task) error
- func WriteOperationOutcomeFromError(err error, desc string, httpResponse http.ResponseWriter)
- type AuthConfig
- type AuthConfigType
- type BundleBuilder
- func (t *BundleBuilder) Append(resource interface{}, request *fhir.BundleEntryRequest, ...) *BundleBuilder
- func (t *BundleBuilder) AppendEntry(entry fhir.BundleEntry) *BundleBuilder
- func (t *BundleBuilder) Bundle() fhir.Bundle
- func (t *BundleBuilder) Create(resource interface{}, opts ...BundleEntryOption) *BundleBuilder
- func (t *BundleBuilder) Update(resource interface{}, path string, opts ...BundleEntryOption) *BundleBuilder
- type BundleEntryOption
- type ClientConfig
- type ErrorWithCode
- type Resource
- type SubscriptionNotification
- type Task
- type Workflow
Constants ¶
const BSNNamingSystem = "http://fhir.nl/fhir/NamingSystem/bsn"
BSNNamingSystem is the FHIR NamingSystem URI for the Dutch Social Security Number
const FHIRContentType = "application/fhir+json"
FHIRContentType is the content-type for FHIR payloads
const SCPTaskProfile = "http://santeonnl.github.io/shared-care-planning/StructureDefinition/SCPTask"
SCPTaskProfile contains the canonical reference of the Shared Care Planning StructureDefinition. Used in the Task.meta.profile field.
const URANamingSystem = "http://fhir.nl/fhir/NamingSystem/ura"
URANamingSystem is the FHIR NamingSystem URI for the URA
Variables ¶
var ErrEntryNotFound = errors.New("entry not found in FHIR Bundle")
Functions ¶
func BadRequest ¶
BadRequest creates an error with a status code of 400
func BadRequestError ¶
BadRequestError wraps an error with a status code of 400
func Config ¶
func Config() *fhirclient.Config
func CreateOperationOutcomeBundleEntryFromError ¶
func CreateOperationOutcomeBundleEntryFromError(err error, desc string) (*fhir.BundleEntry, error)
CreateOperationOutcomeBundleEntryFromError creates a BundleEntry with an OperationOutcome based on the given error
func DefaultAzureScope ¶
func EntryHasID ¶
func EntryHasID(id string) func(entry fhir.BundleEntry) bool
func EntryIsOfType ¶
func EntryIsOfType(resourceType string) func(entry fhir.BundleEntry) bool
func ExecuteTransaction ¶
ExecuteTransaction performs a FHIR transaction and returns the result bundle.
func FilterResource ¶
func FilterResource(fn func(resource Resource) bool) func(entry fhir.BundleEntry) bool
FilterResource returns a filter function that filters resources in a bundle.
func FindMatchingParticipantInCareTeam ¶
func FindMatchingParticipantInCareTeam(careTeams []fhir.CareTeam, principalOrganizationIdentifiers []fhir.Identifier) *fhir.CareTeamParticipant
FindMatchingParticipantInCareTeam loops through each Participant of each CareTeam present in the CarePlan, trying to match it to the Principal Organization Identifiers provided if a valid Participant is found, return it. This can be used for further validation e.g. for the Period
func FirstBundleEntry ¶
func FirstBundleEntry(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool) *fhir.BundleEntry
FirstBundleEntry returns the entry in the bundle that matches the filter.
func HttpMethodToVerb ¶
func IdentifierEquals ¶
func IdentifierEquals(one *fhir.Identifier, other *fhir.Identifier) bool
IdentifierEquals compares two logical identifiers based on their system and value. If any of the identifiers is nil or any of the system or value fields is nil, it returns false. If the system and value fields of both identifiers are equal, it returns true.
func IsIdentifierTaskOwnerAndRequester ¶
func IsIdentifierTaskOwnerAndRequester(task *fhir.Task, principalOrganizationIdentifier []fhir.Identifier) (bool, bool)
IsIdentifierTaskOwnerAndRequester checks the owner and requester of a task against the supplied principal returns 2 booleans, isOwner, and isRequester
func IsLogicalIdentifier ¶
func IsLogicalIdentifier(identifier *fhir.Identifier) bool
func IsLogicalReference ¶
func IsScpSubTask ¶
func LogicalReference ¶
func LogicalReferenceEquals ¶
LogicalReferenceEquals checks if two references are contain the same logical identifier, given their system and value. It does not compare identifier type.
func NewAuthRoundTripper ¶
func NewAuthRoundTripper(config ClientConfig, fhirClientConfig *fhirclient.Config) (http.RoundTripper, fhirclient.Client, error)
func NewAzureFHIRClient ¶
func NewAzureFHIRClient(fhirBaseURL *url.URL, credential azcore.TokenCredential, scopes []string) fhirclient.Client
NewAzureFHIRClient creates a new FHIR client that communicates with an Azure FHIR API. It uses the Managed Identity of the Azure environment to authenticate.
func NewAzureHTTPClient ¶
func NewAzureHTTPClient(credential azcore.TokenCredential, scopes []string) *http.Client
func NewErrorWithCode ¶
NewErrorWithCode constructs a new ErrorWithCode custom wrapped error
func NewProxy ¶
func NewProxy(logger zerolog.Logger, targetFHIRBaseURL *url.URL, proxyBasePath string, transport http.RoundTripper) *httputil.ReverseProxy
func NormalizeTransactionBundleResponseEntry ¶
func NormalizeTransactionBundleResponseEntry(fhirClient fhirclient.Client, fhirBaseURL *url.URL, requestEntry *fhir.BundleEntry, responseEntry *fhir.BundleEntry, result interface{}) (*fhir.BundleEntry, error)
NormalizeTransactionBundleResponseEntry normalizes a transaction bundle response entry returned from an upstream FHIR server, so it can be returned to a client, who is agnostic of the upstream FHIR server implementation. It does the following: - Change the response.location property to a relative URL if it was an absolute URL - Read the resource being referenced and unmarshal it into the given result argument (so it can be used for notification). - Set the response.resource property to the read resource
func ResourceInBundle ¶
func ResourceInBundle(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool, result interface{}) error
ResourceInBundle unmarshals the entry in the bundle that matches the given filter into the result. If the entry is not found, ErrEntryNotFound is returned.
func ResourceType ¶
func ResourceType(resource interface{}) string
func ResourcesInBundle ¶
func ResourcesInBundle(bundle *fhir.Bundle, filter func(entry fhir.BundleEntry) bool, result interface{}) error
ResourcesInBundle unmarshals all entries in the bundle that match the given filter into the result.
func SanitizeOperationOutcome ¶
func SanitizeOperationOutcome(in fhir.OperationOutcome) fhir.OperationOutcome
SanitizeOperationOutcome removes security-related information from an OperationOutcome, replacing it with a generic message, so that it can be safely returned to the client. It follows the code list from the FHIR specification: https://www.hl7.org/fhir/codesystem-issue-type.html#issue-type-security
func SendResponse ¶
func SendResponse(httpResponse http.ResponseWriter, httpStatus int, resource interface{}, additionalHeaders ...map[string]string)
func ValidateCareTeamParticipantPeriod ¶
func ValidateCareTeamParticipantPeriod(participant fhir.CareTeamParticipant, now time.Time) (bool, error)
ValidateCareTeamParticipantPeriod validates that a CareTeamParticipant has a start date, and that the start date is in the past end date is not required, but if present it will validate that it is in the future
func ValidateReference ¶
ValidateReference validates that a reference is either a logical reference, a reference to a resource, or both.
func ValidateTaskRequiredFields ¶
ValidateTaskRequiredFields Validates that all required fields are set for a Task (i.e. a cardinality of 1..*) as per: https://santeonnl.github.io/shared-care-planning/StructureDefinition-SCPTask.html and that the value is valid
func WriteOperationOutcomeFromError ¶
func WriteOperationOutcomeFromError(err error, desc string, httpResponse http.ResponseWriter)
WriteOperationOutcomeFromError writes an OperationOutcome based on the given error as HTTP response. when sent a WriteOperationOutcomeFromError, it will write the contained error code to the header, else it defaults to StatusBadRequest
Types ¶
type AuthConfig ¶
type AuthConfig struct { // Type of authentication to use, supported options: azure-managedidentity. // Leave empty for no authentication. Type AuthConfigType `koanf:"type"` OAuth2Scopes string `koanf:"scopes"` }
type AuthConfigType ¶
type AuthConfigType string
const ( Default AuthConfigType = "" AzureManagedIdentity AuthConfigType = "azure-managedidentity" )
type BundleBuilder ¶
func SearchSet ¶
func SearchSet() *BundleBuilder
func Transaction ¶
func Transaction() *BundleBuilder
func (*BundleBuilder) Append ¶
func (t *BundleBuilder) Append(resource interface{}, request *fhir.BundleEntryRequest, response *fhir.BundleEntryResponse, opts ...BundleEntryOption) *BundleBuilder
func (*BundleBuilder) AppendEntry ¶
func (t *BundleBuilder) AppendEntry(entry fhir.BundleEntry) *BundleBuilder
func (*BundleBuilder) Bundle ¶
func (t *BundleBuilder) Bundle() fhir.Bundle
func (*BundleBuilder) Create ¶
func (t *BundleBuilder) Create(resource interface{}, opts ...BundleEntryOption) *BundleBuilder
func (*BundleBuilder) Update ¶
func (t *BundleBuilder) Update(resource interface{}, path string, opts ...BundleEntryOption) *BundleBuilder
type BundleEntryOption ¶
type BundleEntryOption func(entry *fhir.BundleEntry)
func WithFullUrl ¶
func WithFullUrl(fullUrl string) BundleEntryOption
type ClientConfig ¶
type ClientConfig struct { // BaseURL is the base URL of the FHIR server to connect to. BaseURL string `koanf:"url"` // Auth is the authentication configuration for the FHIR server. Auth AuthConfig `koanf:"auth"` }
type ErrorWithCode ¶
ErrorWithCode is a wrapped error struct that can take an error message as well as an HTTP status code
func (*ErrorWithCode) Error ¶
func (e *ErrorWithCode) Error() string
type SubscriptionNotification ¶
SubscriptionNotification implements a SubscriptionNotification on FHIR R4 through a backport profile (http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-notification-r4). It provides helper functions to access the contained data.
func CreateSubscriptionNotification ¶
func CreateSubscriptionNotification(baseURL *url.URL, timestamp time.Time, subscription fhir.Reference, eventNumber int, focus fhir.Reference) SubscriptionNotification
CreateSubscriptionNotification creates a SubscriptionNotification according to https://santeonnl.github.io/shared-care-planning/Bundle-notification-msc-01.json.html
type Workflow ¶
type Workflow struct {
CarePlanService fhirclient.Client
}
Workflow that performs the HL7 FHIR Workflow Option H: https://hl7.org/fhir/R4/workflow-management.html#optionh TL;DR:
- Placer POSTs a Task to the Broker (CarePlanService)
- Broker POSTs a Task to the Filler (CarePlanContributor)
- Filler accepts the Task by setting its status to accepted
- Placer checks the status of the Task