Skip to content

Commit

Permalink
Add first version of ICE client
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-krylov committed Oct 21, 2014
1 parent 40cc94e commit c436a9e
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*.gem
*.rbc
.bundle
.config
.idea
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in ruby_ICE_client.gemspec
gemspec
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,29 @@ ruby_ICE_client
A ruby client for calling ICE - Immunization Calculation Engine

http://www.hln.com/ice/

## Installation

Add this line to your application's Gemfile:

gem 'ruby_ICE_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby_ICE_client

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
46 changes: 46 additions & 0 deletions lib/ruby_ICE_client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'ruby_ICE_client/version'
require 'nokogiri'
require 'base64'

module RubyICEClient
class << self
def call(message, url)
xml = Nokogiri::XML::Builder.new
xml.Envelope {
xml.Body {
xml.evaluateAtSpecifiedTime('xmlns:ns2' => 'http://www.omg.org/spec/CDSS/201105/dss') {
xml.interactionId(scopingEntityId: 'gov.nyc.health', interactionId: '123456')
xml.specifiedTime "#{Date.today.strftime('%Y-%m-%d')}"
xml.evaluationRequest(clientLanguage: '', clientTimeZoneOffset: '') {
xml.kmEvaluationRequest {
xml.kmId(scopingEntityId: 'org.nyc.cir', businessId: 'ICE', version: '1.0.0')
}
xml.dataRequirementItemData {
xml.driId(itemId: 'cdsPayload') {
xml.containingEntityId(scopingEntityId: 'gov.nyc.health', businessId: 'ICEData', version: '1.0.0.0')
}
xml.data {
xml.informationModelSSId(scopingEntityId: 'org.opencds.vmr', businessId: 'VMR', version: '1.0')
xml.base64EncodedPayload Base64.encode64 message
}
}
}
}
}
}
ns = xml.doc.root.add_namespace_definition 'S', 'http://www.w3.org/2003/05/soap-envelope'
xml.doc.root.namespace = ns
xml.doc.root.child.namespace = ns

uri = URI.parse url
http = Net::HTTP.new uri.host, uri.port
request = Net::HTTP::Post.new uri.path
request.body = xml.to_xml
response = http.request request
response_xml = Nokogiri::XML response.body
output_message_node = response_xml.xpath '//evaluationResponse//base64EncodedPayload'

Base64.decode64 output_message_node.first.text
end
end
end
3 changes: 3 additions & 0 deletions lib/ruby_ICE_client/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module RubyICEClient
VERSION = "0.0.1"
end
25 changes: 25 additions & 0 deletions ruby_ICE_client.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ruby_ICE_client/version'

Gem::Specification.new do |spec|
spec.name = "ruby_ICE_client"
spec.version = RubyICEClient::VERSION
spec.authors = ["sergei-krylov"]
spec.email = ["[email protected]"]
spec.description = %q{A ruby client for calling ICE - Immunization Calculation Engine (http://www.hln.com/ice/)}
spec.summary = %q{}
spec.homepage = ""
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "nokogiri", "~> 1.6"
spec.add_development_dependency "base64"
end

0 comments on commit c436a9e

Please sign in to comment.