Class: FHIR::MedicationDispenseSubstitution

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

Overview

fhir/medication_dispense_substitution.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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



34
35
36
37
38
39
40
41
42
43
# File 'app/models/fhir/medication_dispense_substitution.rb', line 34

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

  result = self.superclass.transform_json(json_hash, target)
  result['wasSubstituted'] = PrimitiveBoolean.transform_json(json_hash['wasSubstituted'], json_hash['_wasSubstituted']) unless json_hash['wasSubstituted'].nil?
  result['type'] = CodeableConcept.transform_json(json_hash['type']) unless json_hash['type'].nil?
  result['reason'] = json_hash['reason'].map { |var| CodeableConcept.transform_json(var) } unless json_hash['reason'].nil?
  result['responsibleParty'] = json_hash['responsibleParty'].map { |var| Reference.transform_json(var) } unless json_hash['responsibleParty'].nil?

  result
end

Instance Method Details

#as_json(*args) ⇒ Object



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

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