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) ⇒ Coded

Create a new HQMF::Coded

Parameters:



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

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#code_list_idObject (readonly)

Returns the value of attribute code_list_id.



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

def code_list_id
  @code_list_id
end

#systemObject (readonly)

Returns the value of attribute system.



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

def system
  @system
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



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

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_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



181
182
183
184
185
186
187
188
189
# File 'lib/hqmf-model/types.rb', line 181

def self.from_json(json)
  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"]
  
  HQMF::Coded.new(type,system,code,code_list_id,title)
end

Instance Method Details

#==(other) ⇒ Object



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

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

#derived?Boolean

Returns:

  • (Boolean)


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

def derived?
  false
end

#to_jsonObject



191
192
193
# File 'lib/hqmf-model/types.rb', line 191

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

#unitObject



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

def unit
  nil
end

#valueObject



195
196
197
# File 'lib/hqmf-model/types.rb', line 195

def value
  code
end