Class: MPI::Messages::RequestBuilder
- Inherits:
-
Object
- Object
- MPI::Messages::RequestBuilder
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mpi/messages/request_builder.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#search_token ⇒ Object
readonly
Returns the value of attribute search_token.
Instance Method Summary collapse
- #build_attention_line ⇒ Object private
- #build_document_component ⇒ Object private
- #build_envelope ⇒ Object private
- #build_envelope_body_component ⇒ Object private
- #build_envelope_component ⇒ Object private
- #build_header ⇒ Object private
- #build_idm ⇒ Object private
- #build_instruct_component ⇒ Object private
- #build_message_component ⇒ Object private
- #build_receiver ⇒ Object private
- #build_receiver_device ⇒ Object private
- #build_sender ⇒ Object private
- #build_sender_device ⇒ Object private
- #element(name, attributes = {}, body_text = nil) ⇒ Object private
-
#initialize(extension:, body:, search_token: nil) ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
- #perform ⇒ Object
- #processing_code ⇒ Object private
Constructor Details
#initialize(extension:, body:, search_token: nil) ⇒ RequestBuilder
Returns a new instance of RequestBuilder.
10 11 12 13 14 |
# File 'lib/mpi/messages/request_builder.rb', line 10 def initialize(extension:, body:, search_token: nil) @extension = extension @body = body @search_token = search_token end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/mpi/messages/request_builder.rb', line 8 def body @body end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
8 9 10 |
# File 'lib/mpi/messages/request_builder.rb', line 8 def extension @extension end |
#search_token ⇒ Object (readonly)
Returns the value of attribute search_token.
8 9 10 |
# File 'lib/mpi/messages/request_builder.rb', line 8 def search_token @search_token end |
Instance Method Details
#build_attention_line ⇒ Object (private)
90 91 92 93 94 |
# File 'lib/mpi/messages/request_builder.rb', line 90 def build_attention_line attention_line = element('attentionLine') attention_line << element('keyWordText', {}, 'Search.Token') attention_line << element('value', { 'xsi:type' => 'ST' }, search_token) end |
#build_document_component ⇒ Object (private)
22 23 24 25 26 |
# File 'lib/mpi/messages/request_builder.rb', line 22 def build_document_component document = Ox::Document.new(version: '1.0') document << build_instruct_component document << build_envelope_component end |
#build_envelope ⇒ Object (private)
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/mpi/messages/request_builder.rb', line 101 def build_envelope env = element( 'env:Envelope', 'xmlns:soapenc' => 'http://schemas.xmlsoap.org/soap/encoding/', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' ) env << element('env:Header') end |
#build_envelope_body_component ⇒ Object (private)
40 41 42 43 |
# File 'lib/mpi/messages/request_builder.rb', line 40 def build_envelope_body_component envelope_body = element('env:Body') envelope_body << end |
#build_envelope_component ⇒ Object (private)
35 36 37 38 |
# File 'lib/mpi/messages/request_builder.rb', line 35 def build_envelope_component envelope = build_envelope envelope << build_envelope_body_component end |
#build_header ⇒ Object (private)
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mpi/messages/request_builder.rb', line 64 def build_header element = build_idm element << element('id', root: '1.2.840.114350.1.13.0.1.7.1.1', extension: "200VGOV-#{SecureRandom.uuid}") element << element('creationTime', value: Time.now.utc.strftime('%Y%m%d%H%M%S')) element << element('versionCode', code: '4.1') element << element('interactionId', root: '2.16.840.1.113883.1.6', extension:) element << element('processingCode', code: processing_code) element << element('processingModeCode', code: 'T') element << element('acceptAckCode', code: 'AL') end |
#build_idm ⇒ Object (private)
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mpi/messages/request_builder.rb', line 53 def build_idm element( "idm:#{extension}", 'xmlns:idm' => 'http://vaww.oed.oit.va.gov', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema‐instance', 'xsi:schemaLocation' => "urn:hl7‐org:v3 ../../schema/HL7V3/NE2008/multicacheschemas/#{extension}.xsd", 'xmlns' => 'urn:hl7‐org:v3', 'ITSVersion' => 'XML_1.0' ) end |
#build_instruct_component ⇒ Object (private)
28 29 30 31 32 33 |
# File 'lib/mpi/messages/request_builder.rb', line 28 def build_instruct_component instruct = Ox::Instruct.new(:xml) instruct[:version] = '1.0' instruct[:encoding] = 'utf-8' instruct end |
#build_message_component ⇒ Object (private)
45 46 47 48 49 50 51 |
# File 'lib/mpi/messages/request_builder.rb', line 45 def = build_header << build_receiver << build_sender << build_attention_line if search_token << body end |
#build_receiver ⇒ Object (private)
75 76 77 78 |
# File 'lib/mpi/messages/request_builder.rb', line 75 def build_receiver receiver = element('receiver', typeCode: 'RCV') receiver << build_receiver_device end |
#build_receiver_device ⇒ Object (private)
80 81 82 83 |
# File 'lib/mpi/messages/request_builder.rb', line 80 def build_receiver_device device = element('device', classCode: 'DEV', determinerCode: 'INSTANCE') device << element('id', root: '1.2.840.114350.1.13.999.234', extension: '200M') end |
#build_sender ⇒ Object (private)
85 86 87 88 |
# File 'lib/mpi/messages/request_builder.rb', line 85 def build_sender sender = element('sender', typeCode: 'SND') sender << build_sender_device end |
#build_sender_device ⇒ Object (private)
96 97 98 99 |
# File 'lib/mpi/messages/request_builder.rb', line 96 def build_sender_device device = element('device', classCode: 'DEV', determinerCode: 'INSTANCE') device << element('id', root: MPI::Constants::VA_ROOT_OID, extension: '200VGOV') end |
#element(name, attributes = {}, body_text = nil) ⇒ Object (private)
116 117 118 119 120 121 |
# File 'lib/mpi/messages/request_builder.rb', line 116 def element(name, attributes = {}, body_text = nil) element = Ox::Element.new(name) attributes.each { |key, value| element[key] = value } element.replace_text(body_text) if body_text element end |
#perform ⇒ Object
16 17 18 |
# File 'lib/mpi/messages/request_builder.rb', line 16 def perform Ox.dump(build_document_component) end |
#processing_code ⇒ Object (private)
112 113 114 |
# File 'lib/mpi/messages/request_builder.rb', line 112 def processing_code Settings.mvi.processing_code end |