class HealthcarePhony::Adt

Attributes

adt_arguments[R]
hl7_message[R]
patient[R]
template[R]
visit[R]

Public Class Methods

new(init_args = {}) click to toggle source
# File lib/healthcare_phony.rb, line 16
def initialize(init_args = {})
  @adt_arguments = init_args
  @adt_arguments[:message_types] = 'ADT'
  set_template
  @hl7_message = Hl7Message.new(@adt_arguments)
  @patient = Patient.new(@adt_arguments)
  @visit = PatientVisit.new(@adt_arguments.merge({ visit_type: set_visit_type }))
end

Public Instance Methods

to_s() click to toggle source
# File lib/healthcare_phony.rb, line 25
def to_s
  erb_template = ERB.new(@template)
  erb_template.result_with_hash({ patient: @patient, hl7: @hl7_message, visit: @visit })
end

Private Instance Methods

set_template() click to toggle source
# File lib/healthcare_phony.rb, line 32
def set_template
  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
set_visit_type() click to toggle source
# File lib/healthcare_phony.rb, line 44
def set_visit_type
  case @hl7_message.trigger_event
  when 'A01'
    HealthcarePhony::VisitType::ADMIT
  when 'A03'
    HealthcarePhony::VisitType::DISCHARGE
  when 'A04'
    HealthcarePhony::VisitType::REGISTRATION
  else
    HealthcarePhony::VisitType::OTHER
  end
end