orderprofile

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: 13 Imported by: 20

Documentation

Overview

Package orderprofile is responsible for parsing and generating Order Profiles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValueFromString

func ValueFromString(s string) (string, float64, error)

ValueFromString parses string in one of the following formats: value >value >=value <value <=value where value is either positive of negative floating point number. Returns the prefix ( > / >= / < / <= ) and the parsed number. Note: prefix is optional and defaults to an empty string. Returns an error if value can not be parsed.

Types

type OrderProfile

type OrderProfile struct {
	// UniversalService encapsulated UniversalServiceID, Order Profile name (represented as Text)
	// and CodingSystem.
	UniversalService ir.CodedElement
	// TestTypes is a map of all Test Types for the Order Profile, keys by their names.
	TestTypes map[string]*TestType
}

OrderProfile contains details of an Order Profile.

type OrderProfiles

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

OrderProfiles contains Order Profile information.

func Load

func Load(ctx context.Context, filename string, hl7Config *config.HL7Config) (*OrderProfiles, error)

Load parses the order profiles from the given file.

func New

func New(m map[string]*OrderProfile) *OrderProfiles

New returns a new OrderProfiles from a order profiles map.

func (*OrderProfiles) Generate

func (op *OrderProfiles) Generate(name string) *ir.CodedElement

Generate returns a CodedElement for the given name. If the name is constants.RandomString, it returns a CodedElement for a random Order Profile. If the name is a name of any existing Order Profile, the CodedElement for that Order Profile is returned. Otherwise, returns CodedElement with ID and Text equal to given name.

func (*OrderProfiles) Get

func (op *OrderProfiles) Get(name string) (*OrderProfile, bool)

Get returns an OrderProfile for the given Order Profile name.

type TestType

type TestType struct {
	Name ir.CodedElement

	Unit      string
	ValueType string

	RefRange       string
	ValueGenerator *ValueGenerator
	// contains filtered or unexported fields
}

TestType represents the Test Type of the Order Profile.

func (*TestType) RandomisedValueWithFlag

func (tt *TestType) RandomisedValueWithFlag(randomType string) (string, constants.AbnormalFlag, error)

RandomisedValueWithFlag generates a random value for the given type. Returns: - the value, which is either defaultValue if set, or the random value generated using the valueGenerator. - abnormal flag, HIGH if randomType is ABNORMAL_HIGH, LOW if randomType is ABNORMAL_LOW, or else an empty string. - an error if something went wrong.

type ValueGenerator

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

ValueGenerator generates the value within the range (exclusive) given the normal value range.

The ranges specified for the order profiles may sometimes be: inclusive for one border, eg.: >=5.5, exclusive, eg.: >0.25 unknown inclusivity, eg.: 0.5 - 1.6 - probably exclusive, 70-120^70^120 - probably inclusive It is though safer (and easier) to always treat the range as exclusive.

func ValueGeneratorFromRange

func ValueGeneratorFromRange(s string) (*ValueGenerator, error)

ValueGeneratorFromRange returns ValueGenerator created from string containing the normal value range. String may be in one of the following formats:

from-to from - to [ from - to ] [from-to] from-to^from^to where both: "from" and "to" are either positive or negative floating point numbers

or:

<to^^<to <to^<to <=to^^<=to <=to^<=to [ < to ] [ <= to ] [<to] [<=to] where "to" is either positive or negative floating point number; "from" is set to invalid float (open start range)

or:

>from^^>from >from^>from >=from^^>=from >=from^>=from [ > from ] [ >= from ] [>from] [>=from] where "from" is either positive or negative floating point number; "to" is set to invalid float (open end of range)

Returns error if the string cannot be parsed.

func (*ValueGenerator) AbnormalHigh

func (g *ValueGenerator) AbnormalHigh() (string, error)

AbnormalHigh returns a random number formatted as string, which is higher than the normal range. If the end of normal range is positive, it will return value between (g.to, 10 x g.to) exclusive. If the end of normal range is negative, it will return value between (g.to, 0) exclusive. Returns an error in any of the following situations:

  • the receiver is nil
  • the end of the normal range is open
  • the end of the normal range is 0 -> the assumption is that if the end of the normal range is negative, the positive numbers are invalid, thus it is impossible to generate the abnormal high value if range ends at 0

func (*ValueGenerator) AbnormalLow

func (g *ValueGenerator) AbnormalLow() (string, error)

AbnormalLow returns a random number formatted as string, which is lower than the normal range. If the start of normal range is positive, it will return value between (0, g.from) exclusive. If the start of normal range is negative, it will return value between (10 x g.from, g.from) exclusive. Returns an error in any of the following situations:

  • the receiver is nil
  • the start of the normal range is open
  • the start of the normal range is 0 -> the assumption is that if start of the normal range is positive, the negative numbers are invalid, thus it is impossible to generate the abnormal low value if range starts at 0

func (*ValueGenerator) IsHigh

func (g *ValueGenerator) IsHigh(v float64) bool

IsHigh returns whether the value v is above the range represented by ValueGenerator.

func (*ValueGenerator) IsLow

func (g *ValueGenerator) IsLow(v float64) bool

IsLow returns whether the value v is below the range represented by ValueGenerator.

func (*ValueGenerator) IsNormal

func (g *ValueGenerator) IsNormal(v float64) bool

IsNormal returns whether the value v is within range represented by ValueGenerator.

func (*ValueGenerator) Normal

func (g *ValueGenerator) Normal() (string, error)

Normal returns random number formatted as string within the normal range, ie between (g.from, g.to) exclusive.

If ValueGenerator represents a right open range, ie: >g.from (g.to is invalid):

  • if "from" is positive, the normal value is generated from (g.from, 10 x g.from).
  • if "from" is negative, the normal value is generated from (g.from, 0) to only allow negative numbers.
  • if "from" is 0, the normal value is generated from (g.from, 10); this is an arbitrary choice, as we don't really know what order of magnitude the values should be in.

If ValueGenerator represents a left open range, ie: <g.to (g.from is invalid):

  • if "to" is positive, the normal value is generated from (0, g.to) to only allow positive values.
  • if "to" is negative, the normal value is generated from (10 x g.to, g.to).
  • if "to" is 0, the normal value is generated from (-10, g.to); this is an arbitrary choice, as we don't really know what order of magnitude the values should be in.

If g == nil, returns 0. Returns error if both: start and end of the range are open.

func (*ValueGenerator) Random

func (g *ValueGenerator) Random(randomType string) (string, error)

Random returns the random value based on the randomType, which is either within normal ranges, or outside the normal ranges (ie: higher or lower). Returns error if the random value cannot be generated.

Jump to

Keyboard shortcuts

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