Class: Roqua::Healthy::A19::Fetcher
- Inherits:
-
Object
- Object
- Roqua::Healthy::A19::Fetcher
- Defined in:
- lib/roqua/healthy/a19/fetcher.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#patient_id ⇒ Object
readonly
Returns the value of attribute patient_id.
Instance Method Summary collapse
-
#fetch ⇒ Object
-
#initialize(patient_id, client) ⇒ Fetcher
constructor
A new instance of Fetcher.
-
#mirth_response ⇒ Object
Constructor Details
#initialize(patient_id, client) ⇒ Fetcher
Returns a new instance of Fetcher.
14 15 16 17 |
# File 'lib/roqua/healthy/a19/fetcher.rb', line 14 def initialize(patient_id, client) @patient_id = patient_id @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'lib/roqua/healthy/a19/fetcher.rb', line 12 def client @client end |
#patient_id ⇒ Object (readonly)
Returns the value of attribute patient_id.
11 12 13 |
# File 'lib/roqua/healthy/a19/fetcher.rb', line 11 def patient_id @patient_id end |
Instance Method Details
#fetch ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/roqua/healthy/a19/fetcher.rb', line 19 def fetch response = mirth_response parser = ResponseParser.new(response) if ResponseValidator.new(response.code, parser, patient_id).validate parser.fetch("HL7Message") end end |
#mirth_response ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/roqua/healthy/a19/fetcher.rb', line 28 def mirth_response Net::HTTP.start(remote_url.host, remote_url.port, use_ssl: use_ssl?) do |http| request = Net::HTTP::Post.new(remote_url.path) request.set_form_data(mirth_params) http.request request end rescue ::Timeout::Error, Errno::ETIMEDOUT => error raise ::Roqua::Healthy::Timeout, error. rescue Errno::EHOSTUNREACH => error raise ::Roqua::Healthy::HostUnreachable, error. rescue Errno::ECONNREFUSED => error raise ::Roqua::Healthy::ConnectionRefused, error. end |