Class: HealthcarePhony::Adt

Inherits:
Object
  • Object
show all
Defined in:
lib/healthcare_phony.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**init_args) ⇒ Adt

Returns a new instance of Adt.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/healthcare_phony.rb', line 16

def initialize(**init_args)
  @adt_arguments = init_args
  @adt_arguments[:message_types] = 'ADT'
  unless adt_arguments[:template].nil?
    @template = adt_arguments[:template]
    return
  end
  @template = if adt_arguments[:template_file].nil?
                File.read(File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'adt_example.erb'))
              else
                File.read(adt_arguments[:template_file])
              end
end

Instance Attribute Details

#adt_argumentsObject (readonly)

Returns the value of attribute adt_arguments.



14
15
16
# File 'lib/healthcare_phony.rb', line 14

def adt_arguments
  @adt_arguments
end

#templateObject (readonly)

Returns the value of attribute template.



14
15
16
# File 'lib/healthcare_phony.rb', line 14

def template
  @template
end

Instance Method Details

#to_sObject



30
31
32
33
34
35
36
# File 'lib/healthcare_phony.rb', line 30

def to_s
  template = ERB.new(@template)
  message = Hl7Message.new(@adt_arguments)
  patient = Patient.new(@adt_arguments)
  visit = PatientVisit.new(@adt_arguments)
  template.result_with_hash({ patient: patient, hl7: message, visit: visit })
end