CCHIT-xds-facade 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/apache-mime4j-0.5.jar +0 -0
- data/lib/commons-codec-1.3.jar +0 -0
- data/lib/commons-httpclient-3.1.jar +0 -0
- data/lib/commons-logging-1.1.1.jar +0 -0
- data/lib/mime/mime_message_parser.rb +52 -0
- data/lib/xds-facade.rb +77 -0
- data/lib/xds/affinity_domain_config.rb +42 -0
- data/lib/xds/author.rb +33 -0
- data/lib/xds/coded_attribute.rb +44 -0
- data/lib/xds/document_registry_service.rb +26 -0
- data/lib/xds/document_repository_service.rb +27 -0
- data/lib/xds/helper.rb +81 -0
- data/lib/xds/metadata.rb +179 -0
- data/lib/xds/mtom_xop_request.rb +29 -0
- data/lib/xds/provide_and_register_document_set_b.rb +29 -0
- data/lib/xds/provide_and_register_document_set_b_xop.rb +58 -0
- data/lib/xds/provide_and_register_document_set_b_xop_response.rb +45 -0
- data/lib/xds/registry_stored_query_request.rb +38 -0
- data/lib/xds/registry_stored_query_response.rb +31 -0
- data/lib/xds/retrieve_document_set_request.rb +66 -0
- data/lib/xds/retrieve_document_set_response.rb +41 -0
- data/lib/xds/source_patient_info.rb +52 -0
- data/lib/xds/xds_header.rb +26 -0
- data/lib/xds/xds_part.rb +44 -0
- data/lib/xds/xds_request.rb +55 -0
- data/lib/xds/xds_request_entity.rb +14 -0
- data/test/factories.rb +37 -0
- data/test/mime/mime_message_parser_test.rb +25 -0
- data/test/test_helper.rb +39 -0
- data/test/xds/affinity_domain_config_test.rb +26 -0
- data/test/xds/author_test.rb +30 -0
- data/test/xds/coded_attribute_test.rb +38 -0
- data/test/xds/metadata_test.rb +60 -0
- data/test/xds/provide_and_register_document_set_b_test.rb +31 -0
- data/test/xds/registry_stored_query_request_test.rb +32 -0
- data/test/xds/registry_stored_query_response_test.rb +28 -0
- data/test/xds/retrieve_document_set_request_test.rb +32 -0
- data/test/xds/retrieve_document_set_response_test.rb +43 -0
- data/test/xds/source_patient_info_test.rb +59 -0
- data/test/xds/xds_header.rb +20 -0
- data/test/xds/xml_helper_test.rb +124 -0
- metadata +122 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
module XDS
|
2
|
+
class XdsRequest
|
3
|
+
attr_accessor :header
|
4
|
+
attr_accessor :endpoint_uri
|
5
|
+
attr_accessor :proxy_host
|
6
|
+
attr_accessor :proxy_port
|
7
|
+
|
8
|
+
def initialize(service_url,action,message_id = XdsHeader.new_message_id)
|
9
|
+
@header = XDS::XdsHeader.new(service_url,action,message_id)
|
10
|
+
@endpoint_uri = service_url
|
11
|
+
@proxy_host = XDS.proxy_config[:host]
|
12
|
+
@proxy_port = XDS.proxy_config[:port]
|
13
|
+
end
|
14
|
+
|
15
|
+
def endpoint_uri=(value)
|
16
|
+
@endpoint_uri = value
|
17
|
+
@header.endpoint_uri = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
client = create_client
|
22
|
+
post = PostMethod.new(endpoint_uri)
|
23
|
+
post.request_entity = StringRequestEntity.new(to_soap, 'application/soap+xml', 'UTF-8')
|
24
|
+
client.executeMethod(post)
|
25
|
+
post
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_soap(builder = Builder::XmlMarkup.new(:indent => 2),attributes={})
|
29
|
+
builder.instruct!
|
30
|
+
builder.soapenv(:Envelope,
|
31
|
+
"xmlns:soapenv" => "http://www.w3.org/2003/05/soap-envelope",
|
32
|
+
"xmlns"=>"http://www.w3.org/2003/05/soap-envelope",
|
33
|
+
"xmlns:wsa" =>"http://www.w3.org/2005/08/addressing") do
|
34
|
+
header.endpoint_uri = endpoint_uri
|
35
|
+
header.to_soap(builder)
|
36
|
+
to_soap_body(builder, attributes)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_soap_body(builder,attributes={})
|
41
|
+
raise "Implement Me, Really!!!!"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def create_client
|
47
|
+
client = HttpClient.new
|
48
|
+
if @proxy_host
|
49
|
+
host_config = client.host_configuration
|
50
|
+
host_config.setProxy(@proxy_host, @proxy_port || 80)
|
51
|
+
end
|
52
|
+
client
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module XDS
|
2
|
+
class XdsRequestEntity < org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity
|
3
|
+
import "org.apache.commons.httpclient.util.EncodingUtil"
|
4
|
+
MULTIPART_FORM_CONTENT_TYPE = "multipart/related"
|
5
|
+
attr_accessor :start
|
6
|
+
attr_accessor :start_info
|
7
|
+
attr_accessor :action
|
8
|
+
attr_accessor :type
|
9
|
+
|
10
|
+
def getContentType()
|
11
|
+
buffer = %{#{MULTIPART_FORM_CONTENT_TYPE}; type="#{@type}"; start="<#{@start}>"; start-info="#{@start_info}"; action="#{action}"; boundary=#{org.apache.commons.httpclient.util.EncodingUtil.getAsciiString(getMultipartBoundary())}}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/factories.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Factory.define(:author, :class => XDS::Author) do |a|
|
2
|
+
a.institution('CCHIT')
|
3
|
+
a.person('Test User')
|
4
|
+
a.role('Tester')
|
5
|
+
a.specialty('Testing Things')
|
6
|
+
end
|
7
|
+
|
8
|
+
Factory.define(:source_patient_info, :class => XDS::SourcePatientInfo) do |s|
|
9
|
+
s.source_patient_identifier('1825a09e14144fc^^^&1.19.6.24.109.42.1.3&ISO')
|
10
|
+
s.name('STEPHEN^COLBERT^^^')
|
11
|
+
s.date_of_birth(Time.now.strftime('%Y%m%d'))
|
12
|
+
s.gender('M')
|
13
|
+
s.address('101 MIDDLESEX TPKE^^BURLINGTON^MA^01803^USA')
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
Factory.define(:metadata, :class => XDS::Metadata) do |m|
|
20
|
+
m.author(Factory.build(:author))
|
21
|
+
m.class_code(XDS::CodedAttribute.new(:class_code, 'Consent', 'Consent', 'Connect-a-thon classCodes'))
|
22
|
+
m.confidentiality_code(XDS::CodedAttribute.new(:confidentiality_code, 'T', 'Taboo', 'Connect-a-thon confidentialityCodes'))
|
23
|
+
m.creation_time(Time.now.strftime('%Y%m%d'))
|
24
|
+
m.format_code(XDS::CodedAttribute.new(:format_code, 'CDAR2/IHE 1.0', 'CDAR2/IHE 1.0', 'Connect-a-thon formatCodes'))
|
25
|
+
m.healthcare_facility_type_code(XDS::CodedAttribute.new(:healthcare_facility_type_code, 'Hospital Unit', 'Hospital Unit', 'Connect-a-thon healthcareFacilityTypeCodes'))
|
26
|
+
m.language_code('en-us')
|
27
|
+
m.mime_type('text/xml')
|
28
|
+
m.patient_id('1825a09e14144fc^^^&1.19.6.24.109.42.1.3&ISO')
|
29
|
+
m.practice_setting_code(XDS::CodedAttribute.new(:practice_setting_code, 'Laboratory', 'Laboratory', 'Connect-a-thon practiceSettingCodes'))
|
30
|
+
m.source_patient_id('1234^^^projectlaika.org')
|
31
|
+
m.source_patient_info(Factory.build(:source_patient_info))
|
32
|
+
m.type_code(XDS::CodedAttribute.new(:type_code, '28570-0', 'Procedure Note', 'LOINC'))
|
33
|
+
m.unique_id("1.3.6.1.4.1.21367.2005.3.7#{Time.now.to_i}")
|
34
|
+
m.ss_unique_id("1.3.6.1.4.1.21367.2009.1.2.1.#{Time.now.to_i}")
|
35
|
+
m.source_id("1.3.6.1.4.1.21367.2009.1.2.1")
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class MimeMessageParserTest < Test::Unit::TestCase
|
4
|
+
context "A MimeMessageParser" do
|
5
|
+
setup do
|
6
|
+
@file_input_stream = java.io.FileInputStream.new(File.expand_path(File.dirname(__FILE__) + '/../data/mime_message.txt'))
|
7
|
+
@content_type = 'multipart/related; boundary=MIMEBoundaryurn_uuid_AE54CA7CD31A4A6AC31234898619749'
|
8
|
+
end
|
9
|
+
|
10
|
+
should "parse a mime message" do
|
11
|
+
parts = MIME::MimeMessageParser.parse(@file_input_stream, @content_type)
|
12
|
+
assert parts
|
13
|
+
assert_equal "<0.urn:uuid:AE54CA7CD31A4A6AC31234898619750@apache.org>", parts[0][:content_id]
|
14
|
+
assert_equal 'application/xop+xml; charset=UTF-8; type="application/soap+xml"', parts[0][:content_type]
|
15
|
+
assert_equal "<1.urn:uuid:AE54CA7CD31A4A6AC31234898619752@apache.org>", parts[1][:content_id]
|
16
|
+
assert_equal 'text/plain', parts[1][:content_type]
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
teardown do
|
21
|
+
@file_input_stream.close
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/xds-facade')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'shoulda'
|
5
|
+
require 'factory_girl'
|
6
|
+
require 'builder'
|
7
|
+
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/factories')
|
9
|
+
|
10
|
+
module XmlTestHelper
|
11
|
+
def assert_xpath(buffer, expression, namespaces = {}, desired_count = 1)
|
12
|
+
doc = REXML::Document.new(StringIO.new(buffer))
|
13
|
+
results = REXML::XPath.match(doc, expression, namespaces)
|
14
|
+
assert results
|
15
|
+
assert_equal desired_count, results.length
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_builder(builder_attributes = {:indent => 2})
|
19
|
+
Builder::XmlMarkup.new(builder_attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_xml_document(doc_string)
|
23
|
+
Rexml::Document.new(doc_string)
|
24
|
+
end
|
25
|
+
|
26
|
+
def common_namespaces
|
27
|
+
@common_namespaces ||= {'xdsb' => "urn:ihe:iti:xds-b:2007",
|
28
|
+
'soapenv' =>"http://www.w3.org/2003/05/soap-envelope",
|
29
|
+
'wsa' => "http://www.w3.org/2005/08/addressing"}
|
30
|
+
end
|
31
|
+
|
32
|
+
def common_namespaces_for_building
|
33
|
+
|
34
|
+
@common_namespaces_for_building ||= {'xmlns:xdsb' => "urn:ihe:iti:xds-b:2007",
|
35
|
+
'xmlns:soapenv' =>"http://www.w3.org/2003/05/soap-envelope",
|
36
|
+
'xmlns:wsa' => "http://www.w3.org/2005/08/addressing"}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class AffinityDomainConfigTest < Test::Unit::TestCase
|
4
|
+
context "XDS::AffinityDomainConfig" do
|
5
|
+
setup do
|
6
|
+
@adc = XDS::AffinityDomainConfig.new(File.expand_path(File.dirname(__FILE__) + '/../data/affinity_domain_config.xml'))
|
7
|
+
end
|
8
|
+
|
9
|
+
should "find a coded attribute" do
|
10
|
+
ca = @adc.coded_attribute(:format_code, 'PDF')
|
11
|
+
assert ca
|
12
|
+
assert_equal 'PDF', ca.code
|
13
|
+
assert_equal 'PDF', ca.display_name
|
14
|
+
assert_equal 'Connect-a-thon formatCodes', ca.coding_scheme
|
15
|
+
end
|
16
|
+
|
17
|
+
should "provide select options" do
|
18
|
+
options = @adc.select_options(:confidentiality_code)
|
19
|
+
assert options
|
20
|
+
first_option = options.first
|
21
|
+
assert first_option
|
22
|
+
assert_equal 'Celebrity', first_option[0]
|
23
|
+
assert_equal 'C', first_option[1]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class AuthorTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
|
6
|
+
context "XDS::Author" do
|
7
|
+
setup do
|
8
|
+
eo_xml = REXML::Document.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../data/extrinsic_object.xml')))
|
9
|
+
@eo_node = eo_xml.root
|
10
|
+
end
|
11
|
+
|
12
|
+
should "be able to create soap representaion " do
|
13
|
+
auth = XDS::Author.new("institution_value","person_value","role_value","specialty_value")
|
14
|
+
soap = auth.to_soap(create_builder,"my_object_id")
|
15
|
+
assert_xpath(soap,"/Classification[@classifiedObject='my_object_id']/Slot[@name = 'authorInstitution']/ValueList/Value[text()='institution_value]",{},1)
|
16
|
+
assert_xpath(soap,"/Classification[@classifiedObject='my_object_id']/Slot[@name='authorPerson']/ValueList/Value[text()='person_value]",{},1)
|
17
|
+
assert_xpath(soap,"/Classification[@classifiedObject='my_object_id']/Slot[@name='authorRole']/ValueList/Value[text()='role_value]",{},1)
|
18
|
+
assert_xpath(soap,"/Classification[@classifiedObject='my_object_id']/Slot[@name='authorSpecialty']/ValueList/Value[text()='specialty_value]",{},1)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be able to populate values from an ExtrinsicObject node" do
|
22
|
+
author = XDS::Author.new()
|
23
|
+
author.from_extrinsic_object(@eo_node)
|
24
|
+
assert_equal('^Dopplemeyer^Sherry^^^', author.person)
|
25
|
+
assert_equal('Primary Surgon', author.role)
|
26
|
+
assert_equal('Orthopedic', author.specialty)
|
27
|
+
assert_equal('Cleveland Clinic', author.institution)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class CodedAttributeTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
|
6
|
+
context "CodedAttribute" do
|
7
|
+
setup do
|
8
|
+
eo_xml = REXML::Document.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../data/extrinsic_object.xml')))
|
9
|
+
@eo_node = eo_xml.root
|
10
|
+
end
|
11
|
+
|
12
|
+
TYPES = {:class_code => 'urn:uuid:41a5887f-8865-4c09-adf7-e362475b143a',
|
13
|
+
:confidentiality_code => 'urn:uuid:f4f85eac-e6cb-4883-b524-f2705394840f',
|
14
|
+
:format_code => 'urn:uuid:a09d5840-386c-46f2-b5ad-9c3699a4309d',
|
15
|
+
:healthcare_facility_type_code => 'urn:uuid:f33fb8ac-18af-42cc-ae0e-ed0b0bdb91e1',
|
16
|
+
:practice_setting_code =>'urn:uuid:cccf5598-8b07-4b77-a05e-ae952c785ead',
|
17
|
+
:type_code => 'urn:uuid:f0306f51-975f-434e-a61c-c59651d33983'
|
18
|
+
}
|
19
|
+
|
20
|
+
should "be able to create a soap representation of itself" do
|
21
|
+
TYPES.each_pair do |key,value|
|
22
|
+
ca = XDS::CodedAttribute.new(key,"code_val","ds_name", "scheme")
|
23
|
+
soap = ca.to_soap(create_builder,"my_object_id")
|
24
|
+
assert_xpath(soap,"/Classification[@classificationScheme='#{value}' and @classifiedObject='my_object_id' and @nodeRepresentation='code_val' ]/Name/LocalizedString[@value='ds_name']/../../Slot[@name='codingScheme']/ValueList/Value[text()='scheme']",{},1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
should "be able to populate values from an ExtrinsicObject node" do
|
29
|
+
ca = XDS::CodedAttribute.new(:practice_setting_code)
|
30
|
+
ca.from_extrinsic_object(@eo_node)
|
31
|
+
assert_equal('Cardiology', ca.code)
|
32
|
+
assert_equal('Cardiology', ca.display_name)
|
33
|
+
assert_equal('Connect-a-thon practiceSettingCodes', ca.coding_scheme)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class MetadataTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
|
6
|
+
context "Metadata" do
|
7
|
+
setup do
|
8
|
+
response_xml = REXML::Document.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../data/query_response.xml')))
|
9
|
+
@namespaces = {'query' => "urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0", 'rim' => 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0'}.merge(common_namespaces)
|
10
|
+
@eo_node = REXML::XPath.first(response_xml, '/soapenv:Envelope/soapenv:Body/query:AdhocQueryResponse/rim:RegistryObjectList/rim:ExtrinsicObject', @namespaces)
|
11
|
+
@building_namespaces = {'xmlns:query' => "urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0", 'xmlns:rim' => 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0'}.merge(common_namespaces_for_building)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be able to serialize to soap " do
|
15
|
+
metadata = Factory.build(:metadata)
|
16
|
+
builder =create_builder
|
17
|
+
xml = metadata.to_soap(builder)
|
18
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:ExtrinsicObject", @namespaces,1)
|
19
|
+
|
20
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:RegistryPackage", @namespaces,1)
|
21
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:RegistryPackage/rim:ExternalIdentifier[@identificationScheme='urn:uuid:96fdda7c-d067-4183-912e-bf5ee74998a8']", @namespaces,1)
|
22
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:RegistryPackage/rim:ExternalIdentifier[@identificationScheme='urn:uuid:554ac39e-e3fe-47fe-b233-965d2a147832']", @namespaces,1)
|
23
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:RegistryPackage/rim:ExternalIdentifier[@identificationScheme='urn:uuid:58a6f841-87b3-4a3e-92fd-a8ffeff98427']", @namespaces,1)
|
24
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:RegistryPackage/rim:ExternalIdentifier[@identificationScheme='urn:uuid:6b5aea1a-874d-4603-a4bc-96a0a7b38446']", @namespaces,1)
|
25
|
+
|
26
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:Classification[@classificationNode='urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd' and @classifiedObject=/rim:RegistryObjectList/rim:RegistryPackage/@id]", @namespaces,1)
|
27
|
+
|
28
|
+
assert_xpath(xml, "/rim:RegistryObjectList/rim:Association[@associationType='urn:oasis:names:tc:ebxml-regrep:AssociationType:HasMember' and @sourceObject=/rim:RegistryObjectList/rim:RegistryPackage/@id]/rim:Slot[@name='SubmissionSetStatus']", @namespaces,1)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
should "be able to populate values from an ExtrinsicObject node" do
|
34
|
+
metadata = XDS::Metadata.new
|
35
|
+
metadata.load_from_extrinsic_object(@eo_node)
|
36
|
+
assert_equal '^Smitty^Gerald^^^', metadata.author.person
|
37
|
+
assert_equal 'Cleveland Clinic', metadata.author.institution
|
38
|
+
assert_equal 'Attending', metadata.author.role
|
39
|
+
assert_equal 'Orthopedic', metadata.author.specialty
|
40
|
+
assert_equal 'Communication', metadata.class_code.code
|
41
|
+
assert_equal 'Communication', metadata.class_code.display_name
|
42
|
+
assert_equal 'Connect-a-thon classCodes', metadata.class_code.coding_scheme
|
43
|
+
assert_equal "20041224", metadata.creation_time
|
44
|
+
assert_equal '93f3f8a6d100463^^^&1.3.6.1.4.1.21367.2005.3.7&ISO', metadata.patient_id
|
45
|
+
assert_equal 'pid1^^^domain', metadata.source_patient_info.source_patient_identifier
|
46
|
+
end
|
47
|
+
|
48
|
+
should "be able to load from a hash" do
|
49
|
+
metadata = XDS::Metadata.new
|
50
|
+
adc = XDS::AffinityDomainConfig.new(File.expand_path(File.dirname(__FILE__) + '/../data/affinity_domain_config.xml'))
|
51
|
+
hash = {'author' => {'person' => 'steve'}, 'practice_setting_code' => 'Anesthesia', 'repository_unique_id' => '1.2.3.4'}
|
52
|
+
metadata.from_hash(hash, adc)
|
53
|
+
assert_equal 'steve', metadata.author.person
|
54
|
+
assert metadata.practice_setting_code
|
55
|
+
assert_equal 'urn:uuid:cccf5598-8b07-4b77-a05e-ae952c785ead', metadata.practice_setting_code.classification_scheme
|
56
|
+
assert_equal 'Anesthesia', metadata.practice_setting_code.display_name
|
57
|
+
assert_equal '1.2.3.4', metadata.repository_unique_id
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class ProvideAndRegisterDocumentSetTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
context "A ProvideAndRegisterDocumentSetRequest" do
|
6
|
+
|
7
|
+
|
8
|
+
should "be able to register a document with a repository" do
|
9
|
+
@prdsr = XDS::ProvideAndRegisterDocumentSetBXop.new("http://129.6.24.109:9080/tf5/services/xdsrepositoryb",
|
10
|
+
Factory.build(:metadata), "some crappy document")
|
11
|
+
@resp = @prdsr.execute
|
12
|
+
assert @resp.success?
|
13
|
+
assert @resp.errors.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
should "be able to detect a failed PnR request " do
|
17
|
+
metadata = Factory.build(:metadata)
|
18
|
+
metadata.ss_unique_id=""
|
19
|
+
metadata.source_id=""
|
20
|
+
@prdsr = XDS::ProvideAndRegisterDocumentSetBXop.new("http://129.6.24.109:9080/tf5/services/xdsrepositoryb",
|
21
|
+
metadata, "some crappy document")
|
22
|
+
|
23
|
+
@resp = @prdsr.execute
|
24
|
+
assert ! @resp.success?
|
25
|
+
assert ! @resp.errors.empty?
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class RegistryStoredQueryRequestTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
context "A RegistryStoredQueryRequest" do
|
6
|
+
setup do
|
7
|
+
@rsqr = XDS::RegistryStoredQueryRequest.new("http://129.6.24.109:9080/axis2/services/xdsregistryb",
|
8
|
+
{"$XDSDocumentEntryPatientId" => "'93f3f8a6d100463^^^&1.3.6.1.4.1.21367.2005.3.7&ISO'",
|
9
|
+
"$XDSDocumentEntryStatus" => "('urn:oasis:names:tc:ebxml-regrep:StatusType:Approved')"})
|
10
|
+
end
|
11
|
+
|
12
|
+
should "create a SOAP Body" do
|
13
|
+
soap_body = @rsqr.to_soap_body(create_builder,'xmlns:soapenv' => "http://www.w3.org/2003/05/soap-envelope")
|
14
|
+
assert soap_body
|
15
|
+
namespaces = {'query' => "urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0", 'rim' => 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0'}.merge(common_namespaces)
|
16
|
+
assert_xpath(soap_body, "/soapenv:Body/query:AdhocQueryRequest/query:ResponseOption[@returnType='LeafClass']", namespaces)
|
17
|
+
assert_xpath(soap_body, "/soapenv:Body/query:AdhocQueryRequest/rim:AdhocQuery/rim:Slot[@name='$XDSDocumentEntryPatientId']", namespaces)
|
18
|
+
assert_xpath(soap_body, "/soapenv:Body/query:AdhocQueryRequest/rim:AdhocQuery/rim:Slot[@name='$XDSDocumentEntryStatus']", namespaces)
|
19
|
+
assert_xpath(soap_body, '/soapenv:Body/query:AdhocQueryRequest/rim:AdhocQuery/rim:Slot[@name="$XDSDocumentEntryPatientId"]/rim:ValueList/rim:Value', namespaces)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "query the NIST Public Registry" do
|
23
|
+
rmd = @rsqr.execute
|
24
|
+
assert rmd
|
25
|
+
assert_equal 5, rmd.length
|
26
|
+
md = rmd.first
|
27
|
+
assert_equal '^Smitty^Gerald^^^', md.author.person
|
28
|
+
assert_equal 'Connect-a-thon classCodes', md.class_code.coding_scheme
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class RegistryStoredQueryResponseTest < Test::Unit::TestCase
|
4
|
+
context "A RegistryStoredQueryResponse" do
|
5
|
+
setup do
|
6
|
+
@successful_request_xml = File.read(File.expand_path(File.dirname(__FILE__) + '/../data/query_response.xml'))
|
7
|
+
end
|
8
|
+
|
9
|
+
should 'properly set the response status for a successful request' do
|
10
|
+
rsqr = XDS::RegistryStoredQueryResponse.new
|
11
|
+
rsqr.parse_soap_response(@successful_request_xml)
|
12
|
+
assert rsqr.request_successful?
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'properly parse out the information on the document' do
|
16
|
+
rsqr = XDS::RegistryStoredQueryResponse.new
|
17
|
+
rsqr.parse_soap_response(@successful_request_xml)
|
18
|
+
assert rsqr.request_successful?
|
19
|
+
rmd = rsqr.retrieved_metadata
|
20
|
+
assert rmd
|
21
|
+
assert_equal 5, rmd.length
|
22
|
+
md = rmd.first
|
23
|
+
assert_equal '^Smitty^Gerald^^^', md.author.person
|
24
|
+
assert_equal 'Connect-a-thon classCodes', md.class_code.coding_scheme
|
25
|
+
assert_equal '1.19.6.24.109.42.1.5', md.repository_unique_id
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class RetrieveDocumentSetRequestTest < Test::Unit::TestCase
|
4
|
+
include XmlTestHelper
|
5
|
+
context "A RetrieveDocumentSetRequest" do
|
6
|
+
setup do
|
7
|
+
@rdsr = XDS::RetrieveDocumentSetRequest.new("http://129.6.24.109:9080/tf5/services/xdsrepositoryb")
|
8
|
+
@rdsr.add_ids_to_request('1.19.6.24.109.42.1.5', '229.6.58.29.939')
|
9
|
+
@rdsr.add_ids_to_request('1.19.6.24.109.42.1.5', '229.6.58.29.937')
|
10
|
+
end
|
11
|
+
|
12
|
+
should "create a SOAP Body" do
|
13
|
+
|
14
|
+
soap_body = @rdsr.to_soap_body(create_builder,'xmlns:soapenv' => "http://www.w3.org/2003/05/soap-envelope")
|
15
|
+
assert soap_body
|
16
|
+
assert_xpath(soap_body, "/soapenv:Body/xdsb:RetrieveDocumentSetRequest/xdsb:DocumentRequest/xdsb:RepositoryUniqueId[text()='1.19.6.24.109.42.1.5']", common_namespaces, 2)
|
17
|
+
assert_xpath(soap_body, "/soapenv:Body/xdsb:RetrieveDocumentSetRequest/xdsb:DocumentRequest/xdsb:DocumentUniqueId[text()='229.6.58.29.939']", common_namespaces)
|
18
|
+
assert_xpath(soap_body, "/soapenv:Body/xdsb:RetrieveDocumentSetRequest/xdsb:DocumentRequest/xdsb:DocumentUniqueId[text()='229.6.58.29.937']", common_namespaces)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "query the NIST Public Registry" do
|
22
|
+
docs = @rdsr.execute
|
23
|
+
|
24
|
+
assert docs
|
25
|
+
assert_equal 2, docs.length
|
26
|
+
assert_equal '1.19.6.24.109.42.1.5', docs.first[:repository_unique_id]
|
27
|
+
assert_equal '229.6.58.29.939', docs.first[:document_unique_id]
|
28
|
+
assert docs.first[:content]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|