fhircore

package
v0.0.0-...-e69eef7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package fhircore contains utility functions to deal with core FHIR types.

Index

Constants

View Source
const (
	MRNIdentifierCode    = "MR"
	MRNIdentifierDisplay = "Medical Record Number"
	NHSIdentifierCode    = "NH"
	NHSIdentifierDisplay = "UK National Health System identifier"

	VisitNumberIdentifierCode    = "VN"
	VisitNumberIdentifierDisplay = "Visit number"

	SecondaryMRNIdentifierCode   = "MR_S"
	SecondaryMRIdentifierDisplay = "Medical record number (secondary)"

	IdentifierAssigningAuthorityExt = "IdentifierAssigningAuthority"
	IdentifierAssigningFacilityExt  = "IdentifierAssigningFacility"
	IdentifierTypeCodeExt           = "IdentifierTypeCode"

	// IdentifierTypeCodeSystem represents values in http://hl7.org/fhir/valueset-identifier-type.html
	IdentifierTypeCodeSystem = "http://hl7.org/fhir/ValueSet/identifier-type"
)

Variables

View Source
var (
	ErrMissingExtension = errors.New("extension not present")
	ErrMissingValue     = errors.New("malformed extension: missing value")
	ErrValue            = errors.New("malformed extension: cannot get value of the expected type")
)

Functions

func AddNewExtensionsOnly

func AddNewExtensionsOnly(source []*pb.Extension, target []*pb.Extension) []*pb.Extension

AddNewExtensionsOnly adds the "target" extensions to "source", as long as the extensions aren't present in "source".

func AddOrUpdateExtension

func AddOrUpdateExtension(extensions []*pb.Extension, newExt *pb.Extension) ([]*pb.Extension, error)

AddOrUpdateExtension either updates the provided extension, if there is already one with the same URL, or inserts it at the end. It returns the updated list of extensions. If there are multiple extensions with the same URL, it returns an error.

func AddOrUpdateIdentifier

func AddOrUpdateIdentifier(identifiers []*pb.Identifier, identifier *pb.Identifier) []*pb.Identifier

AddOrUpdateIdentifier will either update the provided identifier, if there already is one with the same Code, or will insert a new one. AddOrUpdateIdentifier returns the updated list of identifiers. The entire identifier is updated. If the matched identifier has multiple Coding items, all of those will be lost if the provided identifier has a single Coding (which is usually the case).

func AllergyIntoleranceRef

func AllergyIntoleranceRef(id string) *pb.Reference

func Boolean

func Boolean(b bool) *pb.Boolean

func BooleanExtension

func BooleanExtension(url string, value bool) *pb.Extension

BooleanExtension creates an extension with a boolean value.

func Code

func Code(c string) *pb.Code

func Coding

func Coding(code string, system string, display string) *pb.Coding

func ConditionRef

func ConditionRef(id string) *pb.Reference

func Date

func Date(t time.Time, p pb.Date_Precision) *pb.Date

func DateTime

func DateTime(t time.Time, z string, p pb.DateTime_Precision) *pb.DateTime

DateTime creates a FHIR DateTime from the provided time, using z as the timezone. If precision p is set to seconds, the time is truncated.

func DateTimeExtension

func DateTimeExtension(url string, t time.Time, precision pb.DateTime_Precision) *pb.Extension

DateTimeExtension creates a DateTime extension.

func DateTimeToTime

func DateTimeToTime(t *pb.DateTime) time.Time

DateTimeToTime returns time.Time from the FHIR proto, assuming that the time unit is microseconds, which is a standard for streams-internal interfaces.

func Decimal

func Decimal(s string) (*pb.Decimal, error)

func DeleteAllExtensions

func DeleteAllExtensions(extensions []*pb.Extension, url string) []*pb.Extension

DeleteAllExtensions deletes all extensions with the matching URL from a list of Extension and returns the pruned list.

func DiagnosticReportRef

func DiagnosticReportRef(id string) *pb.Reference

func DocumentReferenceRef

func DocumentReferenceRef(id string) *pb.Reference

func EncounterRef

func EncounterRef(id string) *pb.Reference

func FindAllExtensions

func FindAllExtensions(extensions []*pb.Extension, url string) []*pb.Extension

FindAllExtensions returns all the extensions with the provided URL.

func FindFirstExtension

func FindFirstExtension(extensions []*pb.Extension, url string) *pb.Extension

FindFirstExtension returns the first Extension in extensions with the provided URL, or nil if not found.

func FindIdentifiers

func FindIdentifiers(identifiers []*pb.Identifier, code string) []*pb.Identifier

FindIdentifiers returns the list of identifiers that match the given code.

func FindLastExtension

func FindLastExtension(extensions []*pb.Extension, url string) *pb.Extension

FindLastExtension returns the last Extension in extensions with the provided URL, or nil if not found.

func GetBooleanExtension

func GetBooleanExtension(extensions []*pb.Extension, name string) (bool, error)

GetBooleanExtension gets the boolean contained in the extension with the provided name. If the extension is not found, it returns ErrMissingExtension.

func GetDateTimeExtension

func GetDateTimeExtension(extensions []*pb.Extension, name string) (*pb.DateTime, error)

GetDateTimeExtension gets the DateTime value from the extension with the provided name. If the extension is not found, it returns ErrMissingExtension. If the extension is found but it's not of DateTime type, it returns an error. Use DateTimeToTime on the returned value to convert it to time.Time.

func GetIntegerExtension

func GetIntegerExtension(extensions []*pb.Extension, name string) (int32, error)

GetIntegerExtension gets the integer contained in the extension with the provided name. If the extension is not found, it returns ErrMissingExtension.

func GetMRN

func GetMRN(ids []*pb.Identifier) []string

GetMRN returns the MRNs in the provided list of Identifiers.

func GetNHS

func GetNHS(ids []*pb.Identifier) []string

GetNHS returns the NHS numbers in the provided list of Identifiers. Generally there will be just one.

func GetStringExtension

func GetStringExtension(extensions []*pb.Extension, name string) (string, error)

GetStringExtension gets the string contained in the extension with the provided name. If the extension is not found, it returns ErrMissingExtension.

func GetValue

func GetValue(id *pb.Identifier) string

func Id

func Id(i string) *pb.Id

func Identifier

func Identifier(value string, code string) *pb.Identifier

Identifier creates an identifier proto with the given parameters.

func IdentifierMRN

func IdentifierMRN(value string) *pb.Identifier

func IdentifierNHS

func IdentifierNHS(value string) *pb.Identifier

func IdentifierSecondaryMRN

func IdentifierSecondaryMRN(value string, typeCode string, authority string, facility string) *pb.Identifier

IdentifierSecondaryMRN creates a secondary MRN identifier.

We use all of authority, facility and typeCode, even if they are empty, because MRNs need to match all of those in order to be considered equal.

func IdentifierVisitNumber

func IdentifierVisitNumber(value string) *pb.Identifier

func Instant

func Instant(t time.Time, z string) *pb.Instant

func Integer

func Integer(i int32) *pb.Integer

func IntegerExtension

func IntegerExtension(url string, value int32) *pb.Extension

IntegerExtension creates an extension with an integer value.

func LocationRef

func LocationRef(id string) *pb.Reference

func ObservationRef

func ObservationRef(id string) *pb.Reference

func OrganizationRef

func OrganizationRef(id string) *pb.Reference

func PatientRef

func PatientRef(id string) *pb.Reference

func PersonRef

func PersonRef(id string) *pb.Reference

func PractitionerRef

func PractitionerRef(id string) *pb.Reference

func ProcedureRef

func ProcedureRef(id string) *pb.Reference

func ServiceRequestRef

func ServiceRequestRef(id string) *pb.Reference

func String

func String(s string) *pb.String

func StringExtension

func StringExtension(url string, value string) *pb.Extension

StringExtension creates an extension with a string value.

func Time

func Time(t time.Time, p pb.Time_Precision) *pb.Time

func UnixMicro

func UnixMicro(t time.Time) int64

UnixMicro returns the number of microseconds elapsed since January 1, 1970 UTC.

func Uri

func Uri(u string) *pb.Uri

Types

This section is empty.

Jump to

Keyboard shortcuts

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