Class: FHIR::Contributor

Inherits:
Element show all
Includes:
Mongoid::Document
Defined in:
app/models/fhir/contributor.rb

Overview

fhir/contributor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.transform_json(json_hash, target = Contributor.new) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'app/models/fhir/contributor.rb', line 32

def self.transform_json(json_hash, target = Contributor.new)

  result = self.superclass.transform_json(json_hash, target)
  result['type'] = ContributorType.transform_json(json_hash['type'], json_hash['_type']) unless json_hash['type'].nil?
  result['name'] = PrimitiveString.transform_json(json_hash['name'], json_hash['_name']) unless json_hash['name'].nil?
  result['contact'] = json_hash['contact'].map { |var| ContactDetail.transform_json(var) } unless json_hash['contact'].nil?

  result
end

Instance Method Details

#as_json(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/fhir/contributor.rb', line 9

def as_json(*args)
  result = super      
  unless self.type.nil? 
    result['type'] = self.type.value
    serialized = Extension.serializePrimitiveExtension(self.type)            
    result['_type'] = serialized unless serialized.nil?
  end
  unless self.name.nil? 
    result['name'] = self.name.value
    serialized = Extension.serializePrimitiveExtension(self.name)            
    result['_name'] = serialized unless serialized.nil?
  end
  unless self.contact.nil?  || !self.contact.any? 
    result['contact'] = self.contact.map{ |x| x.as_json(*args) }
  end
  result.delete('id')
  unless self.fhirId.nil?
    result['id'] = self.fhirId
    result.delete('fhirId')
  end  
  result
end