Class: HQMF::Coded

Inherits:
Object
  • Object
show all
Includes:
HQMF::Conversion::Utilities
Defined in:
lib/hqmf-model/types.rb

Overview

Represents a HQMF CD value which has a code and codeSystem

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(type, system, code, code_list_id = nil, title = nil, null_flavor = nil, original_text = nil) ⇒ Coded

Create a new HQMF::Coded

Parameters:



163
164
165
166
167
168
169
170
171
# File 'lib/hqmf-model/types.rb', line 163

def initialize(type,system,code,code_list_id=nil,title=nil,null_flavor=nil,original_text=nil)
  @type = type
  @system = system
  @code = code
  @code_list_id = code_list_id
  @title = title
  @null_flavor = null_flavor
  @original_text = original_text
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def code
  @code
end

#code_list_idObject (readonly)

Returns the value of attribute code_list_id.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def code_list_id
  @code_list_id
end

#null_flavorObject (readonly)

Returns the value of attribute null_flavor.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def null_flavor
  @null_flavor
end

#original_textObject (readonly)

Returns the value of attribute original_text.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def original_text
  @original_text
end

#systemObject (readonly)

Returns the value of attribute system.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def system
  @system
end

#titleObject (readonly)

Returns the value of attribute title.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



157
158
159
# File 'lib/hqmf-model/types.rb', line 157

def type
  @type
end

Class Method Details

.for_code_list(code_list_id, title = nil) ⇒ Object



173
174
175
# File 'lib/hqmf-model/types.rb', line 173

def self.for_code_list(code_list_id,title=nil)
  HQMF::Coded.new('CD',nil,nil,code_list_id,title)
end

.for_null_flavor(null_flavor, original_text = nil) ⇒ Object



181
182
183
# File 'lib/hqmf-model/types.rb', line 181

def self.for_null_flavor(null_flavor,original_text=nil)
  HQMF::Coded.new('CD',nil,nil,nil,nil,null_flavor,original_text)
end

.for_single_code(system, code, title = nil) ⇒ Object



177
178
179
# File 'lib/hqmf-model/types.rb', line 177

def self.for_single_code(system,code,title=nil)
  HQMF::Coded.new('CD',system,code,nil,title)
end

.from_json(json) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/hqmf-model/types.rb', line 185

def self.from_json(json)
  json = json.with_indifferent_access
  type = json["type"] if json["type"]
  system = json["system"] if json["system"]
  code = json["code"] if json["code"]
  code_list_id = json["code_list_id"] if json["code_list_id"]
  title = json["title"] if json["title"]
  null_flavor = json["null_flavor"] if json["null_flavor"]
  original_text = json["original_text"] if json["original_text"]
  
  HQMF::Coded.new(type,system,code,code_list_id,title, null_flavor, original_text)
end

Instance Method Details

#==(other) ⇒ Object



214
215
216
# File 'lib/hqmf-model/types.rb', line 214

def ==(other)
  check_equality(self,other)
end

#derived?Boolean

Returns:

  • (Boolean)


206
207
208
# File 'lib/hqmf-model/types.rb', line 206

def derived?
  false
end

#to_jsonObject



198
199
200
# File 'lib/hqmf-model/types.rb', line 198

def to_json
  build_hash(self, [:type,:system,:code,:code_list_id,:title,:null_flavor,:original_text])
end

#unitObject



210
211
212
# File 'lib/hqmf-model/types.rb', line 210

def unit
  nil
end

#valueObject



202
203
204
# File 'lib/hqmf-model/types.rb', line 202

def value
  code
end