Class: FHIR::Basic

Inherits:
DomainResource show all
Includes:
Mongoid::Document
Defined in:
app/models/fhir/basic.rb

Overview

fhir/basic.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from FHIR::Resource

Class Method Details

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



38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/fhir/basic.rb', line 38

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

  result = self.superclass.transform_json(json_hash, target)
  result['identifier'] = json_hash['identifier'].map { |var| Identifier.transform_json(var) } unless json_hash['identifier'].nil?
  result['code'] = CodeableConcept.transform_json(json_hash['code']) unless json_hash['code'].nil?
  result['subject'] = Reference.transform_json(json_hash['subject']) unless json_hash['subject'].nil?
  result['created'] = PrimitiveDate.transform_json(json_hash['created'], json_hash['_created']) unless json_hash['created'].nil?
  result['author'] = Reference.transform_json(json_hash['author']) unless json_hash['author'].nil?

  result
end

Instance Method Details

#as_json(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/fhir/basic.rb', line 11

def as_json(*args)
  result = super      
  unless self.identifier.nil?  || !self.identifier.any? 
    result['identifier'] = self.identifier.map{ |x| x.as_json(*args) }
  end
  unless self.code.nil? 
    result['code'] = self.code.as_json(*args)
  end
  unless self.subject.nil? 
    result['subject'] = self.subject.as_json(*args)
  end
  unless self.created.nil? 
    result['created'] = self.created.value
    serialized = Extension.serializePrimitiveExtension(self.created)            
    result['_created'] = serialized unless serialized.nil?
  end
  unless self.author.nil? 
    result['author'] = self.author.as_json(*args)
  end
  result.delete('id')
  unless self.fhirId.nil?
    result['id'] = self.fhirId
    result.delete('fhirId')
  end  
  result
end