Class: P15ID::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/p15id/field.rb

Constant Summary collapse

SEP =
"\x16"
FIELD_END =
"\x08"
MEASURE_LIST =
%w{ Val Low High Unit Flag EditFlag HighLowFlag }
PATINFO_LIST =
%w{ SampleID Name Gender AgeType AgeVal ChargeType
SamSourc ChartNo BedNo InsNo Dept Sender Tester Checker Remark }
LIST =
MEASURE_LIST + PATINFO_LIST

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, value: "") ⇒ Field

Val Parameter value indicated by SD field Low Lower limit of analysis result High Upper limit of analysis result Unit Unit of parameter Flag Suspect sign for parameters



18
19
20
21
22
# File 'lib/p15id/field.rb', line 18

def initialize(field:, value: "")
  raise "Invalid field '#{field}'" unless LIST.include?(field)
  @field = field
  @value = value
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



3
4
5
# File 'lib/p15id/field.rb', line 3

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/p15id/field.rb', line 3

def value
  @value
end

Instance Method Details

#to_bytesObject



28
29
30
# File 'lib/p15id/field.rb', line 28

def to_bytes
  to_s(sep: SEP, field_end: FIELD_END)
end

#to_s(sep: ",", field_end: ";") ⇒ Object



24
25
26
# File 'lib/p15id/field.rb', line 24

def to_s(sep: ",", field_end: ";")
  "#{@field}#{sep}#{@value}#{field_end}"
end