Module: Qrda::Export::Helper::DateHelper

Included in:
Qrda1R5, Qrda3
Defined in:
lib/qrda-export/helper/date_helper.rb

Instance Method Summary collapse

Instance Method Details

#active_date_timeObject



34
35
36
# File 'lib/qrda-export/helper/date_helper.rb', line 34

def active_date_time
  "<effectiveTime #{value_or_null_flavor(self['activeDatetime'])}/>"
end

#author_effective_timeObject



42
43
44
# File 'lib/qrda-export/helper/date_helper.rb', line 42

def author_effective_time
  "<effectiveTime #{value_or_null_flavor(self['authorDatetime'])}/>"
end

#author_timeObject



38
39
40
# File 'lib/qrda-export/helper/date_helper.rb', line 38

def author_time
  "<time #{value_or_null_flavor(self['authorDatetime'])}/>"
end

#birth_date_timeObject



46
47
48
# File 'lib/qrda-export/helper/date_helper.rb', line 46

def birth_date_time
  "<birthTime #{value_or_null_flavor(self['birthDatetime'])}/>"
end

#completed_prevalence_periodObject



125
126
127
# File 'lib/qrda-export/helper/date_helper.rb', line 125

def completed_prevalence_period
  self['prevalencePeriod']['high'] ? true : false
end

#current_timeObject



22
23
24
# File 'lib/qrda-export/helper/date_helper.rb', line 22

def current_time
  Time.now.utc.to_formatted_s(:number)
end

#expired_date_timeObject



58
59
60
61
62
# File 'lib/qrda-export/helper/date_helper.rb', line 58

def expired_date_time
  "<effectiveTime>"\
  "<low #{value_or_null_flavor(self['expiredDatetime'])}/>"\
  "</effectiveTime>"
end

#facility_periodObject



116
117
118
119
# File 'lib/qrda-export/helper/date_helper.rb', line 116

def facility_period
  "<low #{value_or_null_flavor(self['locationPeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['locationPeriod']['high'])}/>"
end

#incision_datetimeObject



121
122
123
# File 'lib/qrda-export/helper/date_helper.rb', line 121

def incision_datetime
  "<effectiveTime #{value_or_null_flavor(self['incisionDatetime'])}/>"
end

#medication_duration_author_effective_timeObject



71
72
73
74
75
76
# File 'lib/qrda-export/helper/date_helper.rb', line 71

def medication_duration_author_effective_time
  "<effectiveTime xsi:type='IVL_TS'>"\
  "<low #{value_or_null_flavor(self['authorDatetime'])}/>"\
  "<high nullFlavor='UNK'/>"\
  "</effectiveTime>"
end

#medication_duration_effective_timeObject



109
110
111
112
113
114
# File 'lib/qrda-export/helper/date_helper.rb', line 109

def medication_duration_effective_time
  "<effectiveTime xsi:type=\"IVL_TS\">"\
  "<low #{value_or_null_flavor(self['relevantPeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['relevantPeriod']['high'])}/>"\
  "</effectiveTime>"
end

#medication_supply_request_periodObject



64
65
66
67
68
69
# File 'lib/qrda-export/helper/date_helper.rb', line 64

def medication_supply_request_period
  "<effectiveTime xsi:type='IVL_TS'>"\
  "<low #{value_or_null_flavor(self['relevantPeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['relevantPeriod']['high'])}/>"\
  "</effectiveTime>"
end

#participation_periodObject



92
93
94
95
96
97
# File 'lib/qrda-export/helper/date_helper.rb', line 92

def participation_period
  "<effectiveTime>"\
  "<low #{value_or_null_flavor(self['participationPeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['participationPeriod']['high'])}/>"\
  "</effectiveTime>"
end

#performance_period_endObject



18
19
20
# File 'lib/qrda-export/helper/date_helper.rb', line 18

def performance_period_end
  @performance_period_end.to_formatted_s(:number)
end

#performance_period_startObject



14
15
16
# File 'lib/qrda-export/helper/date_helper.rb', line 14

def performance_period_start
  @performance_period_start.to_formatted_s(:number)
end

#prevalence_periodObject



78
79
80
81
82
83
# File 'lib/qrda-export/helper/date_helper.rb', line 78

def prevalence_period
  "<effectiveTime>"\
  "<low #{value_or_null_flavor(self['prevalencePeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['prevalencePeriod']['high'])}/>"\
  "</effectiveTime>"
end

#received_date_timeObject



30
31
32
# File 'lib/qrda-export/helper/date_helper.rb', line 30

def received_date_time
  "<high #{value_or_null_flavor(self['receivedDatetime'])}/>"
end

#relevant_date_period_or_null_flavorObject



103
104
105
106
107
# File 'lib/qrda-export/helper/date_helper.rb', line 103

def relevant_date_period_or_null_flavor
  return relevant_period if self['relevantPeriod'] && (self['relevantPeriod']['low'] || self['relevantPeriod']['high'])
  return relevant_date_time_value if self['relevantDatetime']
  "<effectiveTime nullFlavor='UNK'/>"
end

#relevant_date_time_valueObject



99
100
101
# File 'lib/qrda-export/helper/date_helper.rb', line 99

def relevant_date_time_value
  "<effectiveTime #{value_or_null_flavor(self['relevantDatetime'])}/>"
end

#relevant_periodObject



85
86
87
88
89
90
# File 'lib/qrda-export/helper/date_helper.rb', line 85

def relevant_period
  "<effectiveTime>"\
  "<low #{value_or_null_flavor(self['relevantPeriod']['low'])}/>"\
  "<high #{value_or_null_flavor(self['relevantPeriod']['high'])}/>"\
  "</effectiveTime>"
end

#result_date_timeObject



54
55
56
# File 'lib/qrda-export/helper/date_helper.rb', line 54

def result_date_time
  "<effectiveTime #{value_or_null_flavor(self['resultDatetime'])}/>"
end

#result_date_time?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/qrda-export/helper/date_helper.rb', line 50

def result_date_time?
  !self['resultDatetime'].nil?
end

#sent_date_timeObject



26
27
28
# File 'lib/qrda-export/helper/date_helper.rb', line 26

def sent_date_time
  "<low #{value_or_null_flavor(self['sentDatetime'])}/>"
end

#value_or_null_flavor(time) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/qrda-export/helper/date_helper.rb', line 5

def value_or_null_flavor(time)
  # this is a bit of a hack for a defineded undefined date
  if time && DateTime.parse(time).year < 3000
    "value='#{DateTime.parse(time).utc.to_formatted_s(:number)}'"
  else
    "nullFlavor='UNK'"
  end
end