expression

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: 12 Imported by: 0

Documentation

Overview

Package expression provides functionality to process SNOMED CT expressions Expressions are usually multiple SNOMED CT concepts combined together, much like a sentence is made up of words.

SNOMED CT contains single concepts that actually represent expressions; these are usually historic or exist for ease of use. In order to appropriately determine equivalence, a range of functions are required to normalise any arbitrary concept or expression into a normalised form.

The ANTLR parser was generated from the original ABNF source file using http://www.robertpinchbeck.com/abnf_to_antlr/Default.aspx and running java -jar ~/Downloads/antlr-4.7.2-complete.jar -Dlanguage=Go -package ecl -o ecl ECL.g4 java -jar ~/Downloads/antlr-4.7.2-complete.jar -Dlanguage=Go -package cg -o cg CG.g4 The compositional grammar (CG) is from https://confluence.ihtsdotools.org/display/DOCSCG/5.1+Normative+Specification The expression constraint grammar (ECL) is from https://confluence.ihtsdotools.org/pages/viewpage.action?pageId=28739405

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyConstraint

func ApplyConstraint(svc *terminology.Svc, exp *snomed.Expression, s string) (bool, error)

ApplyConstraint applies an expression in the "Expression Constraint Language" (ECL) to the specified (CG) expression

func CreateSimpleExpression

func CreateSimpleExpression(concept *snomed.Concept) *snomed.Expression

CreateSimpleExpression creates an expression from a single concept

func Equal

func Equal(e1 *snomed.Expression, e2 *snomed.Expression) bool

Equal determines whether two expressions are exactly equal

func Normalize

func Normalize(svc *terminology.Svc, e *snomed.Expression) (*snomed.Expression, error)

Normalize expands an expression into a normal-form, which makes it more readily computable. This essentially simplifies all terms as much as possible taking any complex compound single-form SNOMED codes and building the equivalent expression. Such an expression can then be used to determine equivalence or analytics. See https://confluence.ihtsdotools.org/display/DOCTSG/12.3.3+Building+Long+and+Short+Normal+Forms and https://confluence.ihtsdotools.org/display/DOCTSG/12.4+Transforming+Expressions+to+Normal+Forms

func NormalizeConcept

func NormalizeConcept(svc *terminology.Svc, c *snomed.Concept) (*snomed.Expression, error)

NormalizeConcept turns a single concept into its primitive components

func Parse

func Parse(s string) (*snomed.Expression, error)

Parse parses a SNOMED expression

func Render

func Render(exp *snomed.Expression) string

Render is a simple helper to render the specified expression using a default renderer.

Types

type Normalizer

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

Normalizer handles normalization of SNOMED CT expressions in which we expand an expression into a normal-form, making it more readily computable. This essentially simplifies all terms as much as possible taking any complex compound single-form SNOMED codes and building the equivalent expression. Such an expression can then be used to determine equivalence or analytics. See https://confluence.ihtsdotools.org/display/DOCTSG/12.3.3+Building+Long+and+Short+Normal+Forms and https://confluence.ihtsdotools.org/display/DOCTSG/12.4+Transforming+Expressions+to+Normal+Forms

Any SNOMED CT expression can be transformed to its normal form by replacing each reference to a fully defined concept with a nested expression representing the definition of that concept. Transformation rules then resolve redundancies, which may arise from expanding fully defined concepts, by removing less specific attribute values.

The steps are: 1. Separate Information Model Context - https://confluence.ihtsdotools.org/display/DOCTSG/12.4.1+Separate+Information+Model+Context 2. Normalising the expression - https://confluence.ihtsdotools.org/display/DOCTSG/12.4.2+Normalize+Expression 3.

func NewNormalizer

func NewNormalizer(svc *terminology.Svc) *Normalizer

NewNormalizer creates a new normalizer for the given expression

func (*Normalizer) Normalize

func (n *Normalizer) Normalize(e *snomed.Expression) (*snomed.Expression, error)

Normalize normalizes the specified expression

type ParseError

type ParseError struct {
	Line, Column   int
	OffendingToken string
	Msg            string
}

ParseError returns information about a parsing error

func (*ParseError) Error

func (pe *ParseError) Error() string

type Renderer

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

Renderer renders a SNOMED CT expression as text such that it can be roundtripped back to an expression via parsing. This means that generated text meets the syntax in the compositional grammar.

func NewCanonicalRenderer

func NewCanonicalRenderer() *Renderer

NewCanonicalRenderer returns a renderer that formats expressions canonically. This adopts the rules outlined here: https://confluence.ihtsdotools.org/display/DOCTSG/12.4.29+Canonical+Representation

func NewDefaultRenderer

func NewDefaultRenderer() *Renderer

NewDefaultRenderer returns a renderer with the default formatting options

func NewUpdatingRenderer

func NewUpdatingRenderer(svc *terminology.Svc, tags []language.Tag) *Renderer

NewUpdatingRenderer returns a renderer that updates terms according to the preferred synonyms

func (*Renderer) Render

func (r *Renderer) Render(exp *snomed.Expression) (string, error)

Render renders a SNOMED CT expression according to the configured rendering rules

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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