Class: OpenEHR::RM::DataTypes::TimeSpecification::DvPeriodicTimeSpecification

Inherits:
DvTimeSpecification show all
Defined in:
lib/openehr/rm/data_types/time_specification.rb

Constant Summary collapse

PIVL_FORMALISM =
'HL7:PIVL'
EIVL_FORMALISM =
'HL7:EIVL'
PIVL_PATTERN =

Single-literal PIVL: [phase_low(;phase_high)?]/(period)@ALIGN? IST? e.g. "[200004181100;200004181110]/(7d)@DW IST"

%r{\A\[(?<phase_low>\d+)(?:;(?<phase_high>\d+))?\]/
\((?<period>\d+(?:\.\d+)?)(?<unit>[a-z]+)\)
(?:@(?<alignment>[A-Z]{2}))?(?<ist>\ ?IST)?\z}x
EIVL_PATTERN =

Single-literal EIVL: EVENT([+-]offset)? e.g. "ACM+10min"

/\A(?<event>[A-Z]+)(?:(?<sign>[+-])(?<offset>\d+(?:\.\d+)?)(?<unit>[a-z]+))?\z/
CALENDAR_CYCLE_CODES =

HL7 CalendarCycle codes (DW=day of week, HD=hour of day, ...)

%w[CY MY CM CW WY DM CD DY DW HD CH NH CN SN CS].freeze
TIMING_EVENT_CODES =

HL7 TimingEvent codes (HS=bedtime, ACM=before breakfast, ...)

%w[HS WAKE C CM CD CV AC ACM ACD ACV PC PCM PCD PCV].freeze
PERIOD_UNIT_TO_ISO8601 =

HL7 physical-quantity time units -> ISO8601 duration templates

{ 's' => 'PT%sS', 'min' => 'PT%sM', 'h' => 'PT%sH',
'd' => 'P%sD', 'wk' => 'P%sW', 'mo' => 'P%sM',
'a' => 'P%sY' }.freeze

Constants included from Support::Definition::BasicDefinition

Support::Definition::BasicDefinition::CR, Support::Definition::BasicDefinition::LF

Instance Attribute Summary collapse

Attributes inherited from DvTimeSpecification

#value

Attributes inherited from Basic::DataValue

#value

Instance Method Summary collapse

Methods inherited from DvTimeSpecification

#calender_alignment

Methods inherited from Basic::DataValue

#==, #initialize

Constructor Details

This class inherits a constructor from OpenEHR::RM::DataTypes::Basic::DataValue

Instance Attribute Details

#calendar_alignmentObject (readonly)

Returns the value of attribute calendar_alignment.



81
82
83
# File 'lib/openehr/rm/data_types/time_specification.rb', line 81

def calendar_alignment
  @calendar_alignment
end

#event_alignmentObject (readonly)

Returns the value of attribute event_alignment.



81
82
83
# File 'lib/openehr/rm/data_types/time_specification.rb', line 81

def event_alignment
  @event_alignment
end

#periodObject (readonly)

Returns the value of attribute period.



81
82
83
# File 'lib/openehr/rm/data_types/time_specification.rb', line 81

def period
  @period
end

Instance Method Details

#institution_specifiedObject Also known as: institution_specified?



96
97
98
# File 'lib/openehr/rm/data_types/time_specification.rb', line 96

def institution_specified
  @institution_specified
end

#value=(value) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/openehr/rm/data_types/time_specification.rb', line 83

def value=(value)
  unless value.respond_to?(:formalism) &&
         [PIVL_FORMALISM, EIVL_FORMALISM].include?(value.formalism)
    raise ArgumentError, "formalism must be #{PIVL_FORMALISM} or #{EIVL_FORMALISM}"
  end
  if value.formalism == PIVL_FORMALISM
    parse_pivl(value.value)
  else
    parse_eivl(value.value)
  end
  super
end