Class: AllscriptsUnityClient::UnityRequest
- Inherits:
-
Object
- Object
- AllscriptsUnityClient::UnityRequest
- Defined in:
- lib/allscripts_unity_client/unity_request.rb
Overview
Transform a Unity request into a Hash suitable for sending using Savon.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#appname ⇒ Object
Returns the value of attribute appname.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#raw_dates ⇒ Object
Returns the value of attribute raw_dates.
-
#security_token ⇒ Object
Returns the value of attribute security_token.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#initialize(parameters, timezone, appname, security_token, raw_dates = false) ⇒ UnityRequest
constructor
Constructor.
-
#to_hash ⇒ Object
Convert the parameters to a Hash for Savon with all possible dates converted to the Organization’s localtime.
Constructor Details
#initialize(parameters, timezone, appname, security_token, raw_dates = false) ⇒ UnityRequest
Constructor.
- parameters
-
A Hash of Unity parameters. Takes this form:
{
'Action' => ...,
'UserID' => ...,
'Appname' => ...,
'PatientID' => ...,
'Token' => ...,
'Parameter1' => ...,
'Parameter2' => ...,
'Parameter3' => ...,
'Parameter4' => ...,
'Parameter5' => ...,
'Parameter6' => ...,
'data' => ...
}
- timezone
-
An ActiveSupport::TimeZone instance.
- appname
-
The Unity license appname.
- security_token
-
A security token from the Unity GetSecurityToken call.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 29 def initialize(parameters, timezone, appname, security_token, raw_dates=false) raise ArgumentError, 'parameters can not be nil' if parameters.nil? raise ArgumentError, 'timezone can not be nil' if timezone.nil? raise ArgumentError, 'appname can not be nil' if appname.nil? raise ArgumentError, 'security_token can not be nil' if security_token.nil? @appname = appname @security_token = security_token @parameters = parameters @timezone = timezone @raw_dates = raw_dates end |
Instance Attribute Details
#appname ⇒ Object
Returns the value of attribute appname.
5 6 7 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 5 def appname @appname end |
#parameters ⇒ Object
Returns the value of attribute parameters.
5 6 7 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 5 def parameters @parameters end |
#raw_dates ⇒ Object
Returns the value of attribute raw_dates.
5 6 7 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 5 def raw_dates @raw_dates end |
#security_token ⇒ Object
Returns the value of attribute security_token.
5 6 7 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 5 def security_token @security_token end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 5 def timezone @timezone end |
Instance Method Details
#to_hash ⇒ Object
Convert the parameters to a Hash for Savon with all possible dates converted to the Organization’s localtime.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/allscripts_unity_client/unity_request.rb', line 44 def to_hash action = @parameters[:action] userid = @parameters[:userid] appname = @parameters[:appname] || @appname patientid = @parameters[:patientid] token = @parameters[:token] || @security_token parameter1 = process_date(@parameters[:parameter1]) parameter2 = process_date(@parameters[:parameter2]) parameter3 = process_date(@parameters[:parameter3]) parameter4 = process_date(@parameters[:parameter4]) parameter5 = process_date(@parameters[:parameter5]) parameter6 = process_date(@parameters[:parameter6]) data = Utilities::encode_data(@parameters[:data]) { 'Action' => action, 'UserID' => userid, 'Appname' => appname, 'PatientID' => patientid, 'Token' => token, 'Parameter1' => parameter1, 'Parameter2' => parameter2, 'Parameter3' => parameter3, 'Parameter4' => parameter4, 'Parameter5' => parameter5, 'Parameter6' => parameter6, 'data' => data } end |