coolfhir

package
v0.0.0-...-25571b7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BSNNamingSystem = "http://fhir.nl/fhir/NamingSystem/bsn"

BSNNamingSystem is the FHIR NamingSystem URI for the Dutch Social Security Number

View Source
const FHIRContentType = "application/fhir+json"

FHIRContentType is the content-type for FHIR payloads

View Source
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.

View Source
const URANamingSystem = "http://fhir.nl/fhir/NamingSystem/ura"

URANamingSystem is the FHIR NamingSystem URI for the URA

Variables

View Source
var ErrEntryNotFound = errors.New("entry not found in FHIR Bundle")

Functions

func BadRequest

func BadRequest(msg string, args ...any) error

BadRequest creates an error with a status code of 400

func BadRequestError

func BadRequestError(err error) error

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

CreateOperationOutcomeBundleEntryFromError creates a BundleEntry with an OperationOutcome based on the given error

func DefaultAzureScope

func DefaultAzureScope(fhirBaseURL *url.URL) []string

func EntryHasID

func EntryHasID(id string) func(entry fhir.BundleEntry) bool

func EntryIsOfType

func EntryIsOfType(resourceType string) func(entry fhir.BundleEntry) bool

func ExecuteTransaction

func ExecuteTransaction(fhirClient fhirclient.Client, bundle fhir.Bundle) (fhir.Bundle, error)

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 HttpMethodToVerb(method string) fhir.HTTPVerb

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 IsLogicalReference(reference *fhir.Reference) bool

func IsScpSubTask

func IsScpSubTask(task *fhir.Task) bool

func IsScpTask

func IsScpTask(task *fhir.Task) bool

func LogicalReference

func LogicalReference(refType, system, identifier string) *fhir.Reference

func LogicalReferenceEquals

func LogicalReferenceEquals(ref, other fhir.Reference) bool

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

func NewErrorWithCode(message string, statusCode int) error

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 ToString

func ToString(resource interface{}) 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 ValidateLogicalReference

func ValidateLogicalReference(reference *fhir.Reference, expectedType string, expectedSystem string) error

func ValidateReference

func ValidateReference(reference fhir.Reference) bool

ValidateReference validates that a reference is either a logical reference, a reference to a resource, or both.

func ValidateTaskRequiredFields

func ValidateTaskRequiredFields(task fhir.Task) error

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

type BundleBuilder fhir.Bundle

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

type ErrorWithCode struct {
	Message    string
	StatusCode int
}

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 Resource

type Resource struct {
	Type string `json:"resourceType"`
	ID   string `json:"id"`
}

type SubscriptionNotification

type SubscriptionNotification fhir.Bundle

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

func (SubscriptionNotification) GetFocus

func (s SubscriptionNotification) GetFocus() (*fhir.Reference, error)

type Task

type Task fhir.Task

func (Task) ToFHIR

func (t Task) ToFHIR() (*fhir.Task, error)

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:

  1. Placer POSTs a Task to the Broker (CarePlanService)
  2. Broker POSTs a Task to the Filler (CarePlanContributor)
  3. Filler accepts the Task by setting its status to accepted
  4. Placer checks the status of the Task

func (Workflow) Invoke

func (w Workflow) Invoke(ctx context.Context, task any) (*fhir.Task, error)

func (Workflow) TaskStatus

func (w Workflow) TaskStatus(ctx context.Context, taskId string) (fhir.TaskStatus, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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