Documentation ¶
Index ¶
- Constants
- func ComposeExpression(item interface{}, canonicalValue bool) string
- func ComposeFormalStructure(term *Term) string
- func IsAsciiChar(ch rune) bool
- func IsDecimal(value string) bool
- func IsInteger(value string) bool
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func PadLeft(src string, c rune, l int) string
- type BaseUnit
- type ByCode
- type Canonical
- func (c *Canonical) DivideValueDecimal(divisor decimal.Decimal)
- func (c *Canonical) DivideValueInt(divisor int)
- func (c *Canonical) MultiplyValueDecimal(multiplicand decimal.Decimal)
- func (c *Canonical) MultiplyValueInt(multiplicand int)
- func (c *Canonical) RemoveFromUnits(i int)
- func (c *Canonical) SortUnits()
- type CanonicalUnit
- type CelsiusHandler
- type Component
- type Componenter
- type Concept
- type ConceptKind
- type Concepter
- type Converter
- type DefinedUnit
- type DefinedUnitFilter
- func (duf *DefinedUnitFilter) FilterByClass(class string) *DefinedUnitFilter
- func (duf *DefinedUnitFilter) FilterByIsArbitrary(isArbitrary bool) *DefinedUnitFilter
- func (duf *DefinedUnitFilter) FilterByIsMetric(isMetric bool) *DefinedUnitFilter
- func (duf *DefinedUnitFilter) FilterByIsSpecial(isSpecial bool) *DefinedUnitFilter
- func (duf *DefinedUnitFilter) FilterByProperty(property string) *DefinedUnitFilter
- type DefinitionParser
- type ExpressionComposer
- type ExpressionParser
- type Factor
- type FahrenheitHandler
- type FormalStructureComposer
- type HoldingHandler
- type Lexer
- type Operator
- type Pair
- type Prefix
- type Registry
- type SpecialUnitHandlerer
- type Symbol
- type Term
- type TokenType
- type UcumClassInfo
- type UcumEssenceService
- func (u *UcumEssenceService) Analyse(unit string) (string, error)
- func (u *UcumEssenceService) Convert(value decimal.Decimal, sourceUnit, destUnit string) (decimal.Decimal, error)
- func (u *UcumEssenceService) FilterDefinedModels(class string, property string, onIsMetric, isMetric bool, ...) []*DefinedUnit
- func (u *UcumEssenceService) GetCanonicalForm(value *Pair) (*Pair, error)
- func (u *UcumEssenceService) GetCanonicalUnits(unit string) (string, error)
- func (u *UcumEssenceService) GetClassInfo(class string) *UcumClassInfo
- func (u *UcumEssenceService) GetCommonDisplay(code string) string
- func (u *UcumEssenceService) GetDefinedForms(code string) ([]*DefinedUnit, error)
- func (u *UcumEssenceService) GetProperties() []string
- func (u *UcumEssenceService) IsComparable(units1, units2 string) (bool, error)
- func (u *UcumEssenceService) ListAllClasses() []string
- func (u *UcumEssenceService) ListAllProperties() []string
- func (u *UcumEssenceService) Multiply(o1, o2 *Pair) (*Pair, error)
- func (u *UcumEssenceService) Search(kind ConceptKind, text string, isRegex bool) ([]Concepter, error)
- func (u *UcumEssenceService) SearchClass(arg string) []string
- func (u *UcumEssenceService) SearchProperty(arg string) []string
- func (u *UcumEssenceService) UcumIdentification() *UcumVersionDetails
- func (u *UcumEssenceService) Validate(unit string) (bool, string)
- func (u *UcumEssenceService) ValidateCanonicalUnits(unit, canonical string) string
- func (u *UcumEssenceService) ValidateInProperty(unit, property string) string
- func (u *UcumEssenceService) ValidateUCUM() []string
- type UcumModel
- type UcumService
- type UcumValidator
- type UcumVersionDetails
- type Unit
- type Uniter
- type Value
- type XMLBaseUnit
- type XMLConcept
- type XMLDecimal
- type XMLDefinedUnit
- type XMLPrefix
- type XMLRoot
- type XMLUcumClassInfo
- type XMLUnit
- type XMLValue
Constants ¶
const NO_CHAR = 0
const UCUM_OID = "2.16.840.1.113883.6.8"
UcumEssenceService=======================================================
Variables ¶
This section is empty.
Functions ¶
func ComposeExpression ¶
func ComposeFormalStructure ¶
func IsAsciiChar ¶
Types ¶
type BaseUnit ¶
BaseUnit===================================================== Parent is Unit DIM is character indicating the Property
type ByCode ¶
type ByCode []*CanonicalUnit
type Canonical ¶
type Canonical struct { Units []*CanonicalUnit Value decimal.Decimal }
Canonical===================================================== * unit terms that are commonly used in medicine. Since the space of possible unit terms is infinite in theory and very large in practice, no attempt has been made on a systematic coverage of possible units. All necessary units can be built from the rules of The Unified Code for Units of Measure and there is no need of a particular term to be enumerated in order to be valid.
The canonical form itself consists of 3 columns: (4.1) the magnitude value of the unit term in terms of the canonical unit; (4.2) a canonical unit term; (4.3) if applicable a special conversion function code.
A canonical unit is a unit of measurement agreed upon as default in a certain context.
func (*Canonical) DivideValueDecimal ¶
func (*Canonical) DivideValueInt ¶
func (*Canonical) MultiplyValueDecimal ¶
func (*Canonical) MultiplyValueInt ¶
func (*Canonical) RemoveFromUnits ¶
type CanonicalUnit ¶
CanonicalUnit===================================================== * base a canonical unit term;
func NewCanonicalUnit ¶
func NewCanonicalUnit(base *BaseUnit, exponent int) (*CanonicalUnit, error)
type CelsiusHandler ¶
type CelsiusHandler struct { }
func (*CelsiusHandler) GetCode ¶
func (c *CelsiusHandler) GetCode() string
func (*CelsiusHandler) GetUnits ¶
func (c *CelsiusHandler) GetUnits() string
func (*CelsiusHandler) GetValue ¶
func (c *CelsiusHandler) GetValue() decimal.Decimal
type Componenter ¶
type Componenter interface { }
Component=====================================================
type Concept ¶
type Concept struct { Code string CodeUC string Kind ConceptKind Names []string PrintSymbol string }
func NewConcept ¶
func NewConcept(kind ConceptKind, code string, codeUC string) (*Concept, error)
func (Concept) GetDescription ¶
func (Concept) GetKind ¶
func (c Concept) GetKind() ConceptKind
func (Concept) GetPrintSymbol ¶
type ConceptKind ¶
type ConceptKind int
const ( PREFIX ConceptKind = iota BASEUNIT UNIT )
func ConceptKindString ¶
func ConceptKindString(s string) (ConceptKind, error)
ConceptKindString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ConceptKindValues ¶
func ConceptKindValues() []ConceptKind
ConceptKindValues returns all values of the enum
func (ConceptKind) IsAConceptKind ¶
func (i ConceptKind) IsAConceptKind() bool
IsAConceptKind returns "true" if the value is listed in the enum definition. "false" otherwise
func (ConceptKind) String ¶
func (i ConceptKind) String() string
type Concepter ¶
type Concepter interface { GetDescription() string String() string GetCode() string GetKind() ConceptKind GetNames() []string GetCodeUC() string GetPrintSymbol() string }
Concept===================================================== * Hierarchy
Concepter -> Concept -> Prefix -> Unit -> DefinedUnit
-> BaseUnit |
Uniter -> Unit -> DefinedUnit
-> BaseUnit
Base of Unit and Prefix. Top class Code = String (case sensitive c/s) CodeUC = String, case insensitive c/i) Kind = ConceptKind (PREFIX, BASEUNIT or UNIT) Name = full (official) name of the concept PrintSymbol
type Converter ¶
func NewConverter ¶
type DefinedUnit ¶
type DefinedUnit struct { Unit Class string IsSpecial bool IsArbitrary bool Metric bool Value *Value }
func NewDefinedUnit ¶
func NewDefinedUnit(code string, codeUC string) (*DefinedUnit, error)
func (DefinedUnit) GetDescription ¶
func (d DefinedUnit) GetDescription() string
type DefinedUnitFilter ¶
type DefinedUnitFilter struct {
DefinedUnits []*DefinedUnit
}
DefinedUnit===================================================== * Parent is Unit - Class "dimless" = dimensionless - Class SI "si" = the SI units (International System of Units)/ SI units are mole, steradian, hertz, newton, pascal, joule, watt, ampère, volt, farad, ohm, siemens, weber, degree, tesla, henry, lumen, lux, becquerel, gray, sievert - Class ISO1000 "iso1000" = other units from ISO 1000 - Class "const" = Natural units, velocity of light, Planck constant, etc. - Class "cgs" = The units of the older Centimeter-Gram-Second (CGS) system - Class "cust" = Customary units have once been used all over Europe. Units were taken from nature: anatomical structures (e.g., arm, foot, finger), botanical objects - Class "us-lengths" = The older U.S. units according to the definition of the inch in the U.S. Metric Law of 1866 and the definition of foot and yard that was valid from 1893 until 1959 - Class "us-volumes" = “capacity” measures, which are different for fluid goods (wine) and dry goods (grain) - Class "brit-volumes" = British Imperial volumes according to the Weights and Measures Act of 1824 - Class "avoirdupois" = The avoirdupois system is used in the U.S. as well as in coutries that use the British Imperial system. Avoirdupois is the default system of mass units used for all goods that “have weight” - Class "troy" = The troy system originates in Troyes, a City in the Champagne (France) that hosted a major European fair. - Class "apoth" = The apothecaries' system of mass units - Class "typeset" = There are three systems of typesetter's lengths in use today: Françcois-Ambroise Didot (1730-1804), Didot, U.S. type foundries - Class "heat" = Older units of heat (energy) and temperature - Class "clinical" = Units used mainly in clinical medicine - Class "chemical" = Units used mainly in chemical and biochemical laboratories - Class "levels" = Pseudo-units defined to express logarithms of ratios between two quantities of the same kind - Class "misc" = Not otherwise classified units - Class "infotech" = Units used in information technology
func NewDefinedUnitFilter ¶
func NewDefinedUnitFilter(definedUnits []*DefinedUnit) *DefinedUnitFilter
func (*DefinedUnitFilter) FilterByClass ¶
func (duf *DefinedUnitFilter) FilterByClass(class string) *DefinedUnitFilter
func (*DefinedUnitFilter) FilterByIsArbitrary ¶
func (duf *DefinedUnitFilter) FilterByIsArbitrary(isArbitrary bool) *DefinedUnitFilter
func (*DefinedUnitFilter) FilterByIsMetric ¶
func (duf *DefinedUnitFilter) FilterByIsMetric(isMetric bool) *DefinedUnitFilter
func (*DefinedUnitFilter) FilterByIsSpecial ¶
func (duf *DefinedUnitFilter) FilterByIsSpecial(isSpecial bool) *DefinedUnitFilter
func (*DefinedUnitFilter) FilterByProperty ¶
func (duf *DefinedUnitFilter) FilterByProperty(property string) *DefinedUnitFilter
type DefinitionParser ¶
type DefinitionParser struct { }
func (*DefinitionParser) UnmarshalTerminology ¶
func (d *DefinitionParser) UnmarshalTerminology(reader io.Reader) (*UcumModel, error)
type ExpressionComposer ¶
type ExpressionComposer struct { }
type ExpressionParser ¶
type ExpressionParser struct {
Model *UcumModel
}
func NewExpressionParser ¶
func NewExpressionParser(model *UcumModel) *ExpressionParser
type Factor ¶
Factor===================================================== * Parent is component Connected with TokenType NUMBER
type FahrenheitHandler ¶
type FahrenheitHandler struct { }
func (*FahrenheitHandler) GetCode ¶
func (c *FahrenheitHandler) GetCode() string
func (*FahrenheitHandler) GetUnits ¶
func (c *FahrenheitHandler) GetUnits() string
func (*FahrenheitHandler) GetValue ¶
func (c *FahrenheitHandler) GetValue() decimal.Decimal
type FormalStructureComposer ¶
type FormalStructureComposer struct { }
type HoldingHandler ¶
func NewHoldingHandler ¶
func NewHoldingHandler(code, units string, value decimal.Decimal) *HoldingHandler
func (*HoldingHandler) GetCode ¶
func (c *HoldingHandler) GetCode() string
func (*HoldingHandler) GetUnits ¶
func (c *HoldingHandler) GetUnits() string
func (*HoldingHandler) GetValue ¶
func (c *HoldingHandler) GetValue() decimal.Decimal
type Lexer ¶
func (*Lexer) TokenAsInt ¶
type Prefix ¶
Prefix===================================================== * Parent is Concept Value = is the scalar value by which the unit atom is multiplied if combined with the prefix.
func (Prefix) GetDescription ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) Get ¶
func (r *Registry) Get(code string) SpecialUnitHandlerer
type SpecialUnitHandlerer ¶
type Symbol ¶
Symbol===================================================== * // Unit may be Base Unit or DefinedUnit // Prefix only if unit is metric
func (*Symbol) InvertExponent ¶
func (s *Symbol) InvertExponent()
type Term ¶
type Term struct { Component Comp Componenter Op Operator Term *Term }
Term===================================================== op-term where op = / component component-op-term * Parent is Component
func (*Term) SetTermCheckOp ¶
type TokenType ¶
type TokenType int
const ( NONE TokenType NUMBER SYMBOL SOLIDUS PERIOD OPEN CLOSE ANNOTATION )
func TokenTypeString ¶
type UcumClassInfo ¶
type UcumEssenceService ¶
func GetInstanceOfUcumEssenceService ¶
func GetInstanceOfUcumEssenceService(xmlFileName string) (*UcumEssenceService, error)
func (*UcumEssenceService) Analyse ¶
func (u *UcumEssenceService) Analyse(unit string) (string, error)
func (*UcumEssenceService) FilterDefinedModels ¶
func (u *UcumEssenceService) FilterDefinedModels(class string, property string, onIsMetric, isMetric bool, onIsSpecial, isSpecial bool, onIsArbitrary, isArbitrary bool) []*DefinedUnit
func (*UcumEssenceService) GetCanonicalForm ¶
func (u *UcumEssenceService) GetCanonicalForm(value *Pair) (*Pair, error)
func (*UcumEssenceService) GetCanonicalUnits ¶
func (u *UcumEssenceService) GetCanonicalUnits(unit string) (string, error)
func (*UcumEssenceService) GetClassInfo ¶
func (u *UcumEssenceService) GetClassInfo(class string) *UcumClassInfo
func (*UcumEssenceService) GetCommonDisplay ¶
func (u *UcumEssenceService) GetCommonDisplay(code string) string
func (*UcumEssenceService) GetDefinedForms ¶
func (u *UcumEssenceService) GetDefinedForms(code string) ([]*DefinedUnit, error)
func (*UcumEssenceService) GetProperties ¶
func (u *UcumEssenceService) GetProperties() []string
func (*UcumEssenceService) IsComparable ¶
func (u *UcumEssenceService) IsComparable(units1, units2 string) (bool, error)
func (*UcumEssenceService) ListAllClasses ¶
func (u *UcumEssenceService) ListAllClasses() []string
func (*UcumEssenceService) ListAllProperties ¶
func (u *UcumEssenceService) ListAllProperties() []string
func (*UcumEssenceService) Multiply ¶
func (u *UcumEssenceService) Multiply(o1, o2 *Pair) (*Pair, error)
func (*UcumEssenceService) Search ¶
func (u *UcumEssenceService) Search(kind ConceptKind, text string, isRegex bool) ([]Concepter, error)
func (*UcumEssenceService) SearchClass ¶
func (u *UcumEssenceService) SearchClass(arg string) []string
func (*UcumEssenceService) SearchProperty ¶
func (u *UcumEssenceService) SearchProperty(arg string) []string
func (*UcumEssenceService) UcumIdentification ¶
func (u *UcumEssenceService) UcumIdentification() *UcumVersionDetails
func (*UcumEssenceService) Validate ¶
func (u *UcumEssenceService) Validate(unit string) (bool, string)
func (*UcumEssenceService) ValidateCanonicalUnits ¶
func (u *UcumEssenceService) ValidateCanonicalUnits(unit, canonical string) string
func (*UcumEssenceService) ValidateInProperty ¶
func (u *UcumEssenceService) ValidateInProperty(unit, property string) string
func (*UcumEssenceService) ValidateUCUM ¶
func (u *UcumEssenceService) ValidateUCUM() []string
type UcumModel ¶
type UcumModel struct { Version string Revision string RevisionDate time.Time Prefixes []*Prefix BaseUnits []*BaseUnit DefinedUnits []*DefinedUnit UcumClassInfoMap map[string]*UcumClassInfo BaseUnitsByCode map[string]*BaseUnit BaseUnitsByCodeUC map[string]*BaseUnit DefinedUnitsByCode map[string]*DefinedUnit DefinedUnitsByCodeUC map[string]*DefinedUnit PropertySearchIndex map[string][]string PropertyList []string ClassSearchIndex map[string][]string ClassList []string }
type UcumService ¶
type UcumService interface { /** * return Ucum Identification details for the version in use */ UcumIdentification() *UcumVersionDetails /** * Check UCUM. Note that this stands as a test of the service * more than UCUM itself (for version 1.7, there are no known * semantic errors in UCUM). But you should always run this test at least * once with the version of UCUM you are using to ensure that * the service implementation correctly understands the UCUM data * to which it is bound * * @return a list of internal errors in the UCUM spec. * */ ValidateUCUM() []string /** * Search through the UCUM concepts for any concept containing matching text. * Search will be limited to the kind of concept defined by kind, or all if kind * is null * * @param kind - can be null. scope of search * @param text - required * @param isRegex * @return */ Search(kind ConceptKind, text string, isRegex bool) ([]Concepter, error) /** * return a list of the defined types of units in this UCUM version * * @return */ GetProperties() []string /** * validate whether a unit code are valid UCUM units * * @param units - the unit code to check * @return nil if valid, or an error message describing the problem */ Validate(unit string) (bool, string) /** * given a unit, return a formal description of what the units stand for using * full names * @param units the unit code * @return formal description * @throws UcumException * @throws OHFException */ Analyse(unit string) (string, error) /** * validate whether a units are valid UCUM units and additionally require that the * units from a particular property * * @param units - the unit code to check * @return nil if valid, or an error message describing the problem */ ValidateInProperty(unit, property string) string /** * validate whether a units are valid UCUM units and additionally require that the * units match a particular base canonical unit * * @param units - the unit code to check * @return nil if valid, or an error message describing the problem */ ValidateCanonicalUnits(unit, canonical string) string /** * given a set of units, return their canonical form * @param unit * @return the canonical form * @throws UcumException * @throws OHFException */ GetCanonicalUnits(unit string) (string, error) /** * given two pairs of units, return true if they share the same canonical base * * @param units1 * @param units2 * @return * @throws UcumException * @ */ IsComparable(units1, units2 string) (bool, error) /** * for a given canonical unit, return all the defined units that have the * same canonical unit. * * @param code * @return * @throws UcumException * @throws OHFException */ GetDefinedForms(code string) ([]*DefinedUnit, error) /** * given a value/unit pair, return the canonical form as a value/unit pair * * 1 mm -> 1e-3 m * @param value * @return * @throws UcumException * @throws OHFException */ GetCanonicalForm(value *Pair) (*Pair, error) /** * given a value and source unit, return the value in the given dest unit * an exception is thrown if the conversion is not possible * * @param value * @param sourceUnit * @param destUnit * @return the value if a conversion is possible * @throws UcumException * @throws OHFException */ Convert(value decimal.Decimal, sourceUnit, destUnit string) (decimal.Decimal, error) /** * multiply two value/units pairs together and return the result in canonical units * * Note: since the units returned are canonical, * @param o1 * @param o2 * @return * @throws UcumException * @ */ Multiply(o1, o2 *Pair) (*Pair, error) /** * given a set of UCUM units, return a likely preferred human dense form * * SI units - as is. * Other units - improved by manual fixes, or the removal of [] * * @param code * @return the preferred human display form */ GetCommonDisplay(code string) string ListAllClasses() []string ListAllProperties() []string SearchClass(arg string) []string SearchProperty(arg string) []string GetClassInfo(class string) *UcumClassInfo FilterDefinedModels(class string, property string, onIsMetric, isMetric bool, onIsSpecial, isSpecial bool, onIsArbitrary, isArbitrary bool) []*DefinedUnit }
type UcumValidator ¶
UcumEssenceService=======================================================
func NewUcumValidator ¶
func NewUcumValidator(model *UcumModel, handlers *Registry) *UcumValidator
func (*UcumValidator) Validate ¶
func (v *UcumValidator) Validate() []string
type UcumVersionDetails ¶
UcumVersionDetails======================================================
func NewUcumVersionDetails ¶
func NewUcumVersionDetails(releaseDate time.Time, version string) *UcumVersionDetails
type Uniter ¶
Unit===================================================== * Parent is Concept Children are BaseUnit and DefinedUnit
type Value ¶
Value=====================================================
func (Value) GetDescription ¶
type XMLBaseUnit ¶
type XMLConcept ¶
type XMLDecimal ¶
type XMLDefinedUnit ¶
type XMLPrefix ¶
type XMLPrefix struct { XMLConcept Value XMLValue `xml:"value"` //"1e2" //precision 24 }
type XMLRoot ¶
type XMLRoot struct { Version string `xml:"version,attr"` Revision string `xml:"revision,attr"` RevisionDate string `xml:"revision-date,attr"` Prefixes []XMLPrefix `xml:"prefix"` BaseUnits []XMLBaseUnit `xml:"base-unit"` DefinedUnits []XMLDefinedUnit `xml:"unit"` UcumClassInfos []XMLUcumClassInfo `xml:"ucum-class"` }
func (*XMLRoot) ProcessRevisionDate ¶
type XMLUcumClassInfo ¶
type XMLUnit ¶
type XMLUnit struct { XMLConcept Property string `xml:"property"` }