Class: FHIR::ProvenanceEntity

Inherits:
BackboneElement show all
Includes:
Mongoid::Document
Defined in:
app/models/fhir/provenance_entity.rb

Overview

fhir/provenance_entity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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



30
31
32
33
34
35
36
37
38
# File 'app/models/fhir/provenance_entity.rb', line 30

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

  result = self.superclass.transform_json(json_hash, target)
  result['role'] = ProvenanceEntityRole.transform_json(json_hash['role'], json_hash['_role']) unless json_hash['role'].nil?
  result['what'] = Reference.transform_json(json_hash['what']) unless json_hash['what'].nil?
  result['agent'] = json_hash['agent'].map { |var| ProvenanceAgent.transform_json(var) } unless json_hash['agent'].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
# File 'app/models/fhir/provenance_entity.rb', line 9

def as_json(*args)
  result = super      
  unless self.role.nil? 
    result['role'] = self.role.value
    serialized = Extension.serializePrimitiveExtension(self.role)            
    result['_role'] = serialized unless serialized.nil?
  end
  unless self.what.nil? 
    result['what'] = self.what.as_json(*args)
  end
  unless self.agent.nil?  || !self.agent.any? 
    result['agent'] = self.agent.map{ |x| x.as_json(*args) }
  end
  result.delete('id')
  unless self.fhirId.nil?
    result['id'] = self.fhirId
    result.delete('fhirId')
  end  
  result
end