terminology

package
v1.0.1-0...-ff3196c Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabaseNotInitialised = errors.New("database not initialised")

ErrDatabaseNotInitialised is the error when database not properly initialised

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is the error when something isn't found

Functions

This section is empty.

Types

type Batch

type Batch interface {
	// Get an object from the specified bucket with the specified key
	Get(b bucket, key []byte, value proto.Message) error

	// Put and object into the specified bucket with the specified key, errors deferred until end of batch
	Put(b bucket, key []byte, value proto.Message)

	// Add an index entry for the specified bucket and key, errors deferred until end of batch
	AddIndexEntry(b bucket, key []byte, value []byte)

	// Does an index entry exist?
	CheckIndexEntry(b bucket, key []byte, value []byte) (bool, error)

	// Clear all entries in the bucket specified
	ClearIndexEntries(b bucket)

	// Get all index entries for the specified bucket and key
	GetIndexEntries(b bucket, key []byte) ([][]byte, error)

	// Iterate iterates through a bucket
	Iterate(b bucket, keyPrefix []byte, f func(key, value []byte) error) error
}

Batch represents an abstract batch operation against the KV store

type ConceptIDStream

type ConceptIDStream struct {
	ID  int64
	Err error
}

ConceptIDStream wraps a concept identifier with an error, for use in streaming

type ConceptReferenceStream

type ConceptReferenceStream struct {
	*snomed.ConceptReference
	Err error
}

ConceptReferenceStream wraps a concept reference with an error, helpful when streaming via channels

type ConceptStream

type ConceptStream struct {
	*snomed.Concept
	Err error
}

ConceptStream wraps a concept identifier with an error, for use in streaming

type DescriptionStream

type DescriptionStream struct {
	*snomed.Description
	Err error
}

DescriptionStream is for use in streaming descriptions

type Descriptor

type Descriptor struct {
	Version    int32
	StoreKind  string
	SearchKind string
}

Descriptor provides a simple structure for file-backed database versioning and configuration.

type ExtendedDescriptionStream

type ExtendedDescriptionStream struct {
	*snomed.ExtendedDescription
	Err error
}

ExtendedDescriptionStream is for use in streaming extended descriptions

type Importer

type Importer struct {
	snomed.ImportChannels
	// contains filtered or unexported fields
}

Importer manages the import of SNOMED CT components from the filesystem

func NewImporter

func NewImporter(storer Storer, batchSize int, threads int, verbose bool) *Importer

NewImporter creates a new Importer

func (*Importer) Import

func (im *Importer) Import(ctx context.Context, root string)

Import starts the import process

type Language

type Language int

Language defines a mapping between standard ISO language tags and the associated SNOMED-CT language reference sets TODO: add more supported languages TODO: check that the refset identifiers are correct TODO: add tests for other languages

const (
	AmericanEnglish Language = iota
	BritishEnglish
	French
	Spanish
	Danish
)

Supported languages

func LanguageForTag

func LanguageForTag(tag language.Tag) Language

LanguageForTag returns the language for the specified tag

func (Language) LanguageReferenceSetIdentifier

func (l Language) LanguageReferenceSetIdentifier() int64

LanguageReferenceSetIdentifier returns the SNOMED-CT identifier for the language reference set for this language

func (Language) String

func (l Language) String() string

String returns the string representation of this language

func (Language) Tag

func (l Language) Tag() language.Tag

Tag returns the language tag for this language

type NoopStorer

type NoopStorer struct{}

NoopStorer is a no-op storer, which does nothing with the results. Useful for profiling.

func (*NoopStorer) Put

func (ns *NoopStorer) Put(context context.Context, components interface{}) error

Put a batch of SNOMED components, which is a no-op.

type Search interface {
	Index(eds []*snomed.ExtendedDescription) error
	Search(sr *snomed.SearchRequest) ([]int64, error) //TODO: rename autocomplete
	Statistics() (uint64, error)
	Close() error
}

Search represents the backend opaque abstract SNOMED-CT search service.

type Statistics

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

Statistics on the persistence store

func (Statistics) String

func (st Statistics) String() string

type Store

type Store interface {
	// View creates a read-only transaction
	View(func(Batch) error) error

	// Update creates a read and write transaction
	Update(func(Batch) error) error

	// Close closes any resources associated with the key-value store
	Close() error
}

Store is an abstract key-value store divided into logical buckets of information.

type Storer

type Storer interface {
	Put(context context.Context, components interface{}) error
}

Storer defines the behaviour of a service that can accept a batch of SNOMED components for storage.

type Svc

type Svc struct {
	Descriptor
	// contains filtered or unexported fields
}

Svc encapsulates concrete persistent and search services and extends it by providing semantic inference and a useful, practical SNOMED-CT API.

The current priority of development is correct behaviour rather than optimisation, although most operations are extremely fast already.

TODO(mw): once 'correct', profile and optimise the slowest paths, likely adding multiple caches for the most commonly derived data structures and putting more functionality within the backend transaction, when appropriate. It won't be until API complete that we'll understand the pinch points.

It is likely that the transitive closure lists will need more caching, but it is unclear whether that is a simple flat list or, more likely now with more complex logic for expressions, the individual paths to root.

func NewService

func NewService(path string, readOnly bool) (*Svc, error)

NewService opens or creates a service at the specified location.

func (*Svc) AllChildren

func (svc *Svc) AllChildren(ctx context.Context, concept *snomed.Concept, maximum int) ([]*snomed.Concept, error)

AllChildren fetches all children of the given concept recursively. Use with caution with concepts at high levels of the hierarchy.

func (*Svc) AllChildrenIDs

func (svc *Svc) AllChildrenIDs(ctx context.Context, conceptID int64, maximum int) (children []int64, err error)

AllChildrenIDs returns all children for the specified concept. As this is potentially a very large number, you must specify an indicative maximum number.

func (*Svc) AllParentIDs

func (svc *Svc) AllParentIDs(conceptID int64) ([]int64, error)

AllParentIDs returns a list of the identifiers for all parents TODO(mw): switch to using transitive closure

func (*Svc) AllParents

func (svc *Svc) AllParents(conceptID int64) ([]*snomed.Concept, error)

AllParents returns all of the parents (recursively) for a given concept

func (*Svc) AvailableLanguages

func (svc *Svc) AvailableLanguages() ([]language.Tag, error)

AvailableLanguages returns the languages supported by the currently installed distribution Note: the sorting of the results is important for language matching, because the first matching language will be chosen, so we finish by sorting the result.

func (*Svc) ChildRelationships

func (svc *Svc) ChildRelationships(conceptID int64) ([]*snomed.Relationship, error)

ChildRelationships returns the child relationships for this concept. Child relationships are relationships in which this concept is the destination.

func (*Svc) Children

func (svc *Svc) Children(conceptID int64) ([]int64, error)

Children returns the children of the specified concept

func (*Svc) ChildrenOfKind

func (svc *Svc) ChildrenOfKind(conceptID int64, kind int64) ([]int64, error)

ChildrenOfKind returns the relations of the specified kind (type) of the specified concept.

func (*Svc) ClearPrecomputations

func (svc *Svc) ClearPrecomputations() error

ClearPrecomputations clears all pre-computations and indices

func (*Svc) Close

func (svc *Svc) Close() error

Close closes any open resources in the backend implementations

func (*Svc) ComponentFromReferenceSet

func (svc *Svc) ComponentFromReferenceSet(refset int64, component int64) ([]*snomed.ReferenceSetItem, error)

ComponentFromReferenceSet gets the specified components from the specified refset, or error

func (*Svc) ComponentReferenceSets

func (svc *Svc) ComponentReferenceSets(referencedComponentID int64) ([]int64, error)

ComponentReferenceSets returns the refset identifiers to which this component is a member

func (*Svc) Concept

func (svc *Svc) Concept(conceptID int64) (*snomed.Concept, error)

Concept returns the concept with the given identifier

func (*Svc) ConceptReference

func (svc *Svc) ConceptReference(conceptID int64, tags []language.Tag) (*snomed.ConceptReference, error)

ConceptReference creates a reference for the specified concept. This is generally more useful than simply getting the Concept itself!

func (*Svc) Concepts

func (svc *Svc) Concepts(conceptIDs ...int64) ([]*snomed.Concept, error)

Concepts returns a list of concepts with the given identifiers

func (*Svc) ConceptsForRelationship

func (svc *Svc) ConceptsForRelationship(rel *snomed.Relationship) (source *snomed.Concept, kind *snomed.Concept, target *snomed.Concept, err error)

ConceptsForRelationship returns the concepts represented within a relationship

func (*Svc) Description

func (svc *Svc) Description(descriptionID int64) (*snomed.Description, error)

Description returns the description with the given identifier

func (*Svc) Descriptions

func (svc *Svc) Descriptions(conceptID int64) (result []*snomed.Description, err error)

Descriptions returns the descriptions for a concept

func (*Svc) Export

func (svc *Svc) Export(lang string) error

Export exports all descriptions in delimited protobuf format to the command line.

func (*Svc) ExtendedConcept

func (svc *Svc) ExtendedConcept(conceptID int64, tags []language.Tag) (result *snomed.ExtendedConcept, err error)

ExtendedConcept returns a denormalised representation of a SNOMED CT concept

func (*Svc) Extract

func (svc *Svc) Extract(r *snomed.ExtractRequest, tags []language.Tag) (*snomed.ExtractResponse, error)

Extract using NLP to extract entities from a block of text using Amazon Comprehend's API

func (*Svc) FullySpecifiedName

func (svc *Svc) FullySpecifiedName(concept *snomed.Concept, tags []language.Tag) (*snomed.Description, error)

FullySpecifiedName returns the FSN (fully specified name) for the given concept, from the language reference sets specified, in order of preference

func (*Svc) GenericiseTo

func (svc *Svc) GenericiseTo(conceptID int64, includeParents bool, generics map[int64]struct{}) ([]int64, error)

GenericiseTo returns the matches for the given concept within the set specified, ordered from best to worst. It scores by looking at the paths from concept to root.

func (*Svc) GenericiseToBest

func (svc *Svc) GenericiseToBest(conceptID int64, generics map[int64]struct{}) (int64, error)

GenericiseToBest returns the best match for the given concept in the set of concepts specified. The "best" is chosen as the closest match to the specified concept and so if there are generic concepts which relate to one another, it will be the most specific (closest) match to the concept. To determine this, we use the closest match of the longest path.

func (*Svc) GenericiseToRoot

func (svc *Svc) GenericiseToRoot(conceptID int64, root int64) (int64, error)

GenericiseToRoot walks the SNOMED-CT IS-A hierarchy to find the most general concept beneath the specified root. This finds the shortest path from the concept to the specified root and then returns one concept *down* from that root.

func (*Svc) GetAssociations

func (svc *Svc) GetAssociations(conceptID int64, refsetID int64) ([]int64, error)

GetAssociations returns the associations for the specified concept e.g. to get the SAME_AS associations for a concept, GetAssociations(conceptID, snomed.SameAsReferenceSet)

func (*Svc) InstalledReferenceSets

func (svc *Svc) InstalledReferenceSets() (map[int64]struct{}, error)

InstalledReferenceSets returns a list of installed reference sets

func (*Svc) IsA

func (svc *Svc) IsA(concept *snomed.Concept, parent int64) bool

IsA tests whether the given concept is a type of the specified

func (*Svc) IsInReferenceSet

func (svc *Svc) IsInReferenceSet(referencedComponentID int64, refsetID int64) (result bool, err error)

IsInReferenceSet returns whether the specified component is in the specified reference set

func (*Svc) IsLateralisable

func (svc *Svc) IsLateralisable(id int64) (bool, error)

IsLateralisable finds out whether the specific concept is lateralisable

func (*Svc) IterateConcepts

func (svc *Svc) IterateConcepts(ctx context.Context) <-chan ConceptStream

IterateConcepts is an iterator for all concepts, useful for pre-processing and pre-computations

func (*Svc) LongestPathToRoot

func (svc *Svc) LongestPathToRoot(conceptID int64) (longest []int64, err error)

LongestPathToRoot returns the longest path to the root concept from the specified concept

func (*Svc) MapTarget

func (svc *Svc) MapTarget(refset int64, target string) ([]*snomed.ReferenceSetItem, error)

MapTarget returns the simple and complex maps for which the specified target, is the target

func (*Svc) MustGetFullySpecifiedName

func (svc *Svc) MustGetFullySpecifiedName(concept *snomed.Concept, tags []language.Tag) *snomed.Description

MustGetFullySpecifiedName returns the FSN for the given concept, or panics if there is an error or it is missing from the language reference sets specified, in order of preference

func (*Svc) MustGetPreferredSynonym

func (svc *Svc) MustGetPreferredSynonym(conceptID int64, tags []language.Tag) *snomed.Description

MustGetPreferredSynonym returns the preferred synonym for the specified concept, using the language preferences specified, in order of preference

func (*Svc) ParentIDsOfKind

func (svc *Svc) ParentIDsOfKind(conceptID int64, kinds ...int64) ([]int64, error)

ParentIDsOfKind returns the active relations of the specified kinds (types) for the specified concept Unfortunately, SNOMED-CT isn't perfect and there are some duplicate relationships so we filter these and return only unique results

func (*Svc) ParentRelationships

func (svc *Svc) ParentRelationships(conceptID int64) ([]*snomed.Relationship, error)

ParentRelationships returns the parent relationships for this concept. Parent relationships are relationships in which this concept is the source.

func (*Svc) Parents

func (svc *Svc) Parents(conceptID int64) ([]int64, error)

Parents returns the parents of the specified concept

func (*Svc) PathsToRoot

func (svc *Svc) PathsToRoot(conceptID int64) ([][]int64, error)

PathsToRoot returns the different possible paths to the root SNOMED-CT concept from this one. The passed in concept will be the first entry of each path, the SNOMED root will be the last.

func (*Svc) PerformPrecomputations

func (svc *Svc) PerformPrecomputations(ctx context.Context, batchSize int, verbose bool) error

PerformPrecomputations runs all pre-computations and generation of indices

func (*Svc) PreferredSynonym

func (svc *Svc) PreferredSynonym(conceptID int64, tags []language.Tag) (*snomed.Description, error)

PreferredSynonym returns the preferred synonym the specified concept based on the language preferences specified, in order of preference

func (*Svc) PreferredSynonymByReferenceSet

func (svc *Svc) PreferredSynonymByReferenceSet(conceptID int64, refsetID int64, tags []language.Tag) (*snomed.Description, error)

PreferredSynonymByReferenceSet determines the preferred synonym by virtue of member of the description in the specified (language) reference set. This is a more appropriate way of determining preferred synonym for concepts within, for example, the UK dm+d. See https://www.nhsbsa.nhs.uk/sites/default/files/2018-10/doc_SnomedCTUKDrugExtensionModel%20-%20v1.0.pdf and see references to the "dm+d realm description refset". This falls back to standard language based preferred term.

func (*Svc) Primitive

func (svc *Svc) Primitive(concept *snomed.Concept) (*snomed.Concept, error)

Primitive finds the closest primitive for the specified concept in the hierarchy

func (*Svc) Put

func (svc *Svc) Put(context context.Context, components interface{}) error

Put a slice of SNOMED-CT components into persistent storage. This is polymorphic but expects a slice of SNOMED CT components

func (*Svc) ReferenceSetComponents

func (svc *Svc) ReferenceSetComponents(refset int64) (map[int64]struct{}, error)

ReferenceSetComponents returns the components within a given reference set

func (*Svc) ReferenceSetItem

func (svc *Svc) ReferenceSetItem(itemID string) (*snomed.ReferenceSetItem, error)

ReferenceSetItem returns the specified reference set item

func (*Svc) Refinements

func (svc *Svc) Refinements(conceptID int64, limit int, tags []language.Tag) (*snomed.RefinementResponse, error)

Refinements determines the appropriate refinements for an arbitrary concept It is quite easy to do, we find the relationships and additionally determine whether the concept's attributes exist in the lateralisable reference set. TODO: this would be better deprecated in favour of using only expressions that would mean normalising any concept into an expression and *then* deriving possible refinements for that expression, instead.

func (*Svc) Search

func (svc *Svc) Search(req *snomed.SearchRequest, tags []language.Tag) (*snomed.SearchResponse, error)

Search searches the SNOMED CT hierarchy

func (*Svc) ShortestPathToRoot

func (svc *Svc) ShortestPathToRoot(conceptID int64) (shortest []int64, err error)

ShortestPathToRoot returns the shortest path to the root concept from the specified concept

func (*Svc) Siblings

func (svc *Svc) Siblings(conceptID int64) ([]int64, error)

Siblings returns the siblings of this concept, ie: those who share the same parents

func (*Svc) Statistics

func (svc *Svc) Statistics(lang string, verbose bool) (Statistics, error)

Statistics returns statistics for the backend store

func (*Svc) StreamAllChildrenIDs

func (svc *Svc) StreamAllChildrenIDs(ctx context.Context, conceptID int64, maximum int) <-chan ConceptIDStream

StreamAllChildrenIDs streams all of the children of the specified concept. The maximum is used as an indicative measure, rather than an absolutely exact target.

func (*Svc) StreamConceptReferences

func (svc *Svc) StreamConceptReferences(ctx context.Context, concepts <-chan ConceptIDStream, nchannels int, tags []language.Tag) <-chan ConceptReferenceStream

StreamConceptReferences is a helper function to turn a stream of identifiers into a stream of (more useful) ConceptReferences.

Jump to

Keyboard shortcuts

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