Class: Roqua::Healthy::A19::ResponseValidator
- Inherits:
-
Object
- Object
- Roqua::Healthy::A19::ResponseValidator
- Defined in:
- lib/roqua/healthy/a19/response_validator.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#patient_id ⇒ Object
readonly
Returns the value of attribute patient_id.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
Instance Method Summary collapse
-
#initialize(response_code, parser, patient_id) ⇒ ResponseValidator
constructor
A new instance of ResponseValidator.
- #validate ⇒ Object
- #validate_200 ⇒ Object
- #validate_403 ⇒ Object
- #validate_404 ⇒ Object
- #validate_500 ⇒ Object
Constructor Details
#initialize(response_code, parser, patient_id) ⇒ ResponseValidator
Returns a new instance of ResponseValidator.
11 12 13 14 15 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 11 def initialize(response_code, parser, patient_id) @response_code = response_code @parser = parser @patient_id = patient_id end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
8 9 10 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 8 def parser @parser end |
#patient_id ⇒ Object (readonly)
Returns the value of attribute patient_id.
9 10 11 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 9 def patient_id @patient_id end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
7 8 9 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 7 def response_code @response_code end |
Instance Method Details
#validate ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 17 def validate case response_code when '200' validate_200 when '403' validate_403 when '404' validate_404 when '500' validate_500 else raise ::Roqua::Healthy::UnknownFailure, "Unexpected HTTP response code #{response_code}." end end |
#validate_200 ⇒ Object
32 33 34 35 36 37 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 32 def validate_200 = parser.fetch("HL7Message") ensure_patient_found() ensure_correct_patient() true end |
#validate_403 ⇒ Object
39 40 41 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 39 def validate_403 raise ::Roqua::Healthy::AuthenticationFailure end |
#validate_404 ⇒ Object
43 44 45 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 43 def validate_404 raise ::Roqua::Healthy::PatientNotFound end |
#validate_500 ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 47 def validate_500 failure = parser.fetch("failure") raise ::Roqua::Healthy::Timeout, failure["error"] if failure["error"] == "Timeout waiting for ACK" || failure["error"] == 'ERROR: Timeout waiting for response' raise ::Roqua::Healthy::Timeout, failure["error"] if failure["error"] == "Unable to connect to destination\tSocketTimeoutException\tconnect timed out" raise ::Roqua::Healthy::ConnectionRefused, failure["error"] if failure["error"] == "Unable to connect to destination\tConnectException\tConnection refused" || failure["error"] == 'ERROR: ConnectException: Connection refused' raise ::Roqua::Healthy::UnknownFailure, failure["error"] end |