Class: Services::AcceptHl7MessageContext

Inherits:
Object
  • Object
show all
Defined in:
app/contexts/services/accept_hl7_message_context.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_type, body) ⇒ AcceptHl7MessageContext

Returns a new instance of AcceptHl7MessageContext.



16
17
18
19
20
# File 'app/contexts/services/accept_hl7_message_context.rb', line 16

def initialize(message_type, body)
  @message_type = message_type
  @message_body = body
  self.extend Services::Hl7AdtMessageSaver
end

Class Attribute Details

.message_processing_context_classObject

Returns the value of attribute message_processing_context_class.



6
7
8
# File 'app/contexts/services/accept_hl7_message_context.rb', line 6

def message_processing_context_class
  @message_processing_context_class
end

Instance Attribute Details

#message_bodyObject

Returns the value of attribute message_body.



9
10
11
# File 'app/contexts/services/accept_hl7_message_context.rb', line 9

def message_body
  @message_body
end

#message_typeObject

Returns the value of attribute message_type.



9
10
11
# File 'app/contexts/services/accept_hl7_message_context.rb', line 9

def message_type
  @message_type
end

Class Method Details

.call(message_type, body) ⇒ Object



11
12
13
14
# File 'app/contexts/services/accept_hl7_message_context.rb', line 11

def self.call(message_type, body)
  raise "No message processing context class specified" if self.message_processing_context_class.nil?
  AcceptHl7MessageContext.new(message_type, body).call
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
# File 'app/contexts/services/accept_hl7_message_context.rb', line 22

def call
  # Save the raw message information
  persist(message_type, message_body).tap do | msg |
    # Then drop a message on beanstalk to process it
    self.class.message_processing_context_class.ayl_send(:call, msg) if msg.valid?
  end
end