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.
Files changed (42) hide show
  1. data/lib/apache-mime4j-0.5.jar +0 -0
  2. data/lib/commons-codec-1.3.jar +0 -0
  3. data/lib/commons-httpclient-3.1.jar +0 -0
  4. data/lib/commons-logging-1.1.1.jar +0 -0
  5. data/lib/mime/mime_message_parser.rb +52 -0
  6. data/lib/xds-facade.rb +77 -0
  7. data/lib/xds/affinity_domain_config.rb +42 -0
  8. data/lib/xds/author.rb +33 -0
  9. data/lib/xds/coded_attribute.rb +44 -0
  10. data/lib/xds/document_registry_service.rb +26 -0
  11. data/lib/xds/document_repository_service.rb +27 -0
  12. data/lib/xds/helper.rb +81 -0
  13. data/lib/xds/metadata.rb +179 -0
  14. data/lib/xds/mtom_xop_request.rb +29 -0
  15. data/lib/xds/provide_and_register_document_set_b.rb +29 -0
  16. data/lib/xds/provide_and_register_document_set_b_xop.rb +58 -0
  17. data/lib/xds/provide_and_register_document_set_b_xop_response.rb +45 -0
  18. data/lib/xds/registry_stored_query_request.rb +38 -0
  19. data/lib/xds/registry_stored_query_response.rb +31 -0
  20. data/lib/xds/retrieve_document_set_request.rb +66 -0
  21. data/lib/xds/retrieve_document_set_response.rb +41 -0
  22. data/lib/xds/source_patient_info.rb +52 -0
  23. data/lib/xds/xds_header.rb +26 -0
  24. data/lib/xds/xds_part.rb +44 -0
  25. data/lib/xds/xds_request.rb +55 -0
  26. data/lib/xds/xds_request_entity.rb +14 -0
  27. data/test/factories.rb +37 -0
  28. data/test/mime/mime_message_parser_test.rb +25 -0
  29. data/test/test_helper.rb +39 -0
  30. data/test/xds/affinity_domain_config_test.rb +26 -0
  31. data/test/xds/author_test.rb +30 -0
  32. data/test/xds/coded_attribute_test.rb +38 -0
  33. data/test/xds/metadata_test.rb +60 -0
  34. data/test/xds/provide_and_register_document_set_b_test.rb +31 -0
  35. data/test/xds/registry_stored_query_request_test.rb +32 -0
  36. data/test/xds/registry_stored_query_response_test.rb +28 -0
  37. data/test/xds/retrieve_document_set_request_test.rb +32 -0
  38. data/test/xds/retrieve_document_set_response_test.rb +43 -0
  39. data/test/xds/source_patient_info_test.rb +59 -0
  40. data/test/xds/xds_header.rb +20 -0
  41. data/test/xds/xml_helper_test.rb +124 -0
  42. metadata +122 -0
@@ -0,0 +1,43 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ class RetrieveDocumentSetResponseTest < Test::Unit::TestCase
4
+ context "A RetrieveDocumentSetRequest" do
5
+ setup do
6
+ @successful_request_xml = File.read(File.expand_path(File.dirname(__FILE__) + '/../data/successful_document_set_response.xml'))
7
+ @successful_embedded_request_xml = File.read(File.expand_path(File.dirname(__FILE__) + '/../data/successful_document_set_response_embedded.xml'))
8
+ end
9
+
10
+ should 'properly set the response status for a successful request' do
11
+ rdsr = XDS::RetrieveDocumentSetResponse.new
12
+ rdsr.parse_soap_response(@successful_request_xml)
13
+ assert rdsr.request_successful?
14
+ end
15
+
16
+ should 'properly parse out the information on the document' do
17
+ rdsr = XDS::RetrieveDocumentSetResponse.new
18
+ rdsr.parse_soap_response(@successful_request_xml)
19
+ assert rdsr.request_successful?
20
+ rds = rdsr.retrieved_documents
21
+ assert rds
22
+ assert_equal 1, rds.length
23
+ rd = rds.first
24
+ assert_equal "1.urn:uuid:3BE45FAC62CF0568A81199380869990@apache.org", rd[:content_id]
25
+ assert_equal '1.19.6.24.109.42.1', rd[:repository_unique_id]
26
+ assert_equal '1.2.3.4.100000022002209036.1196211173506.1', rd[:document_unique_id]
27
+ end
28
+
29
+ should "properly parse oout information and document content from embeeded response" do
30
+
31
+ rdsr = XDS::RetrieveDocumentSetResponse.new
32
+ rdsr.parse_soap_response(@successful_embedded_request_xml)
33
+ assert rdsr.request_successful?
34
+ rds = rdsr.retrieved_documents
35
+ assert rds
36
+ assert_equal 1, rds.length
37
+ rd = rds.first
38
+ assert rd[:content]
39
+ assert_equal '1.19.6.24.109.42.1.1', rd[:repository_unique_id]
40
+ assert_equal '1.2.3.4321.1234', rd[:document_unique_id]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,59 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ class SourcePatientInfoTest < Test::Unit::TestCase
4
+ include XmlTestHelper
5
+ context "SourcePatientInfo" do
6
+ setup do
7
+ eo_xml = REXML::Document.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../data/extrinsic_object.xml')))
8
+ @eo_node = eo_xml.root
9
+ end
10
+
11
+ should "be able to serialize to soap representaion" do
12
+
13
+ name = "name"
14
+ spi = "spi"
15
+ gender="manlyman"
16
+ dob = Time.now.strftime('%Y%m%d')
17
+ addr = "penny lane"
18
+
19
+ p = XDS::SourcePatientInfo.new(:name=>name,
20
+ :source_patient_identifier=>spi,
21
+ :gender=>gender,
22
+ :date_of_birth=>dob,
23
+ :address=>addr)
24
+
25
+ soap = p.to_soap(create_builder)
26
+ assert_xpath(soap,"/Slot[@name='sourcePatientInfo']/ValueList/Value[text() = 'PID-5|#{name}']")
27
+ assert_xpath(soap,"/Slot[@name='sourcePatientInfo']/ValueList/Value[text() = 'PID-8|#{gender}']")
28
+ assert_xpath(soap,"/Slot[@name='sourcePatientInfo']/ValueList/Value[text() = 'PID-7|#{dob}']")
29
+ assert_xpath(soap,"/Slot[@name='sourcePatientInfo']/ValueList/Value[text() = 'PID-11|#{addr}']")
30
+ assert_xpath(soap,"/Slot[@name='sourcePatientInfo']/ValueList/Value[text() = 'PID-3|#{spi}']")
31
+ end
32
+
33
+ should "match and strip HL7V2 coded fields" do
34
+ value_list = ['PID-3|pid1^^^domain', 'PID-5|Doe^John^^^', 'PID-7|19560527']
35
+ p = XDS::SourcePatientInfo.new
36
+ name = p.match_and_strip(value_list, 'PID-5')
37
+ assert name
38
+ assert_equal 'Doe^John^^^', name
39
+ end
40
+
41
+ should "return nil when trying to match and strip a field that isn't there" do
42
+ value_list = ['PID-3|pid1^^^domain', 'PID-5|Doe^John^^^', 'PID-7|19560527']
43
+ p = XDS::SourcePatientInfo.new
44
+ nuthin = p.match_and_strip(value_list, 'PID-13')
45
+ assert_nil nuthin
46
+ end
47
+
48
+ should "be able to populate values from an ExtrinsicObject node" do
49
+ patient_info = XDS::SourcePatientInfo.new
50
+ patient_info.from_extrinsic_object(@eo_node)
51
+ assert_equal 'pid1^^^domain', patient_info.source_patient_identifier
52
+ assert_equal 'Doe^John^^^', patient_info.name
53
+ assert_equal 'M', patient_info.gender
54
+ assert_equal '100 Main St^^Metropolis^Il^44130^USA', patient_info.address
55
+ assert_equal "19560527", patient_info.date_of_birth
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ class XdsHeaderTest < Test::Unit::TestCase
4
+ include XmlTestHelper
5
+ context "An XdsHeader" do
6
+ should "be able to create a header" do
7
+ header = XDS::XdsHeader.new("urn:my_endpoint_uri","urn:MyAction","urn:uid:myuid")
8
+ builder = create_builder()
9
+
10
+ doc_string = builder.wrapper(common_namespaces_for_building) do
11
+ header.to_soap(builder)
12
+ end
13
+ assert doc_string
14
+ assert_xpath(doc_string,"/wrapper/soapenv:Header/wsa:To[text() = 'urn:my_endpoint_uri']",common_namespaces)
15
+ assert_xpath(doc_string,"/wrapper/soapenv:Header/wsa:MessageID[text() = 'urn:uid:myuid']",common_namespaces)
16
+ assert_xpath(doc_string,"/wrapper/soapenv:Header/wsa:Action[text() = 'urn:MyAction']",common_namespaces)
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,124 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+ require 'lib/xds/helper'
3
+ class XmlHelperTest < Test::Unit::TestCase
4
+ include XmlTestHelper
5
+ include XDS::Helper
6
+
7
+ context "The Xml Helper" do
8
+ setup do
9
+ eo_xml = REXML::Document.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../data/extrinsic_object.xml')))
10
+ @eo_node = eo_xml.root
11
+ end
12
+
13
+ should "be able to create a slot" do
14
+
15
+ slot = create_slot(create_builder,"testSlot", ["value1","value2"])
16
+ assert_xpath(slot,"/Slot[@name='testSlot']/ValueList/Value[text() = 'value1']",{},1)
17
+ assert_xpath(slot,"/Slot[@name='testSlot']/ValueList/Value[text() = 'value2']",{},1)
18
+ end
19
+
20
+
21
+ should "be able to create a LocalizedString" do
22
+ ls = create_localized_string(create_builder,"ls_value")
23
+ assert_xpath(ls,"/LocalizedString[@value='ls_value']",{},1)
24
+ end
25
+
26
+
27
+ should "be able to create a Name element" do
28
+ name = create_name(create_builder,"name_value")
29
+ assert_xpath(name,"/Name/LocalizedString[@value='name_value']",{},1)
30
+ end
31
+
32
+ should "be able to create a Classification element" do
33
+ cl = create_classification(create_builder,"myscheme","object_id","node_rep")
34
+ assert_xpath(cl,"/Classification[@classificationScheme = 'myscheme']",{},1)
35
+ assert_xpath(cl,"/Classification[@classifiedObject = 'object_id']",{},1)
36
+ assert_xpath(cl,"/Classification[@nodeRepresentation = 'node_rep']",{},1)
37
+ end
38
+
39
+ should "be able to create a Classification element with a block" do
40
+ cl = create_classification(create_builder,"myscheme","object_id","node_rep") do |builder|
41
+ create_name(builder,"test_name")
42
+ end
43
+
44
+ assert_xpath(cl,"/Classification[@classificationScheme = 'myscheme']",{},1)
45
+ assert_xpath(cl,"/Classification[@classifiedObject = 'object_id']",{},1)
46
+ assert_xpath(cl,"/Classification[@nodeRepresentation = 'node_rep']",{},1)
47
+
48
+ assert_xpath(cl,"/Classification/Name/LocalizedString[@value='test_name']",{},1)
49
+
50
+ end
51
+
52
+
53
+ should "be able to create an ExternalIdentiier" do
54
+ ei = create_external_identifier(create_builder,"my_id","my_reg_object","scheme","schem_value")
55
+ assert_xpath(ei,"/ExternalIdentifier[@id='my_id' and @registryObject='my_reg_object' and @identificationScheme='scheme' and @value='schem_value']",{}, 1)
56
+ end
57
+
58
+
59
+ should "be able to create an ExternalIdentiier with a block" do
60
+ ei = create_external_identifier(create_builder,"id","reg_obj", "scheme","schem_value") do |builder|
61
+ create_slot(builder,"test_slot",["value1","value2"])
62
+ end
63
+ assert_xpath(ei,"/ExternalIdentifier[@identificationScheme='scheme' and @value='schem_value']",{}, 1)
64
+ assert_xpath(ei,"/ExternalIdentifier/Slot/ValueList/Value[text() = 'value1']",{},1)
65
+ assert_xpath(ei,"/ExternalIdentifier/Slot/ValueList/Value[text() = 'value2']",{},1)
66
+ end
67
+
68
+ should "be able to create an ExtrinsicObject " do
69
+ eo = create_extrinsic_object(create_builder,"my_id","my_mime","my_object_type")
70
+ assert_xpath(eo,"/ExtrinsicObject[@id='my_id' and @mimeType='my_mime' and @objectType='my_object_type']")
71
+ end
72
+
73
+
74
+ should "be able to create an ExtrinsicObject with a block" do
75
+ eo = create_extrinsic_object(create_builder,"my_id","my_mime","my_object_type") do |builder|
76
+ create_slot(builder,"test_slot",["value1","value2"])
77
+ end
78
+ assert_xpath(eo,"/ExtrinsicObject[@id='my_id' and @mimeType='my_mime' and @objectType='my_object_type']")
79
+ assert_xpath(eo,"/ExtrinsicObject/Slot/ValueList/Value[text() = 'value1']",{},1)
80
+ assert_xpath(eo,"/ExtrinsicObject/Slot/ValueList/Value[text() = 'value2']",{},1)
81
+ end
82
+
83
+ context "when getting a slot value" do
84
+ should "get the slot value" do
85
+ creation_time = get_slot_value(@eo_node, 'creationTime')
86
+ assert_equal('20041224', creation_time)
87
+ end
88
+
89
+ should "return nil when the slot doesn't exist" do
90
+ nuthin = get_slot_value(@eo_node, 'foo')
91
+ assert_nil nuthin
92
+ end
93
+
94
+ should "return the first value when there are multiple values in the list" do
95
+ uri = get_slot_value(@eo_node, 'URI')
96
+ assert_equal 'http://129.6.24.109:9080/Repository/229.6.58.29.939.txt', uri
97
+ end
98
+ end
99
+
100
+ context "when getting a slot with multiple values" do
101
+ should "get the slot values" do
102
+ uris = get_slot_values(@eo_node, 'URI')
103
+ assert uris
104
+ assert_equal 2, uris.length
105
+ assert_equal 'http://129.6.24.109:9080/Repository/229.6.58.29.939.txt', uris.first
106
+ assert_equal 'http://www.example.com', uris[1]
107
+ end
108
+ end
109
+
110
+ should 'be able to provide a block to a desired classification' do
111
+ with_classification(@eo_node, "urn:uuid:93606bcf-9494-43ec-9b4e-a7748d1a838d") do |classification|
112
+ assert_equal "urn:uuid:6d037c16-d94d-4c10-acfc-f6cae5f7287e", classification.attributes['classifiedObject']
113
+ end
114
+ end
115
+
116
+ should 'be able to get an external identifier' do
117
+ patient_id = get_external_identifier_value(@eo_node, XDS::Metadata::EXTERNAL_ID_SCHEMES[:patient_id][:scheme])
118
+ assert patient_id
119
+ assert_equal '93f3f8a6d100463^^^&1.3.6.1.4.1.21367.2005.3.7&ISO', patient_id
120
+ end
121
+
122
+ end
123
+
124
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CCHIT-xds-facade
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Project Laika
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-06 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: uuid
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: builder
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: activesupport
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "2.3"
44
+ version:
45
+ description:
46
+ email: dev@projectlaika.org
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files: []
52
+
53
+ files:
54
+ - lib/apache-mime4j-0.5.jar
55
+ - lib/commons-codec-1.3.jar
56
+ - lib/commons-httpclient-3.1.jar
57
+ - lib/commons-logging-1.1.1.jar
58
+ - lib/mime/mime_message_parser.rb
59
+ - lib/xds-facade.rb
60
+ - lib/xds/affinity_domain_config.rb
61
+ - lib/xds/author.rb
62
+ - lib/xds/coded_attribute.rb
63
+ - lib/xds/document_registry_service.rb
64
+ - lib/xds/document_repository_service.rb
65
+ - lib/xds/helper.rb
66
+ - lib/xds/metadata.rb
67
+ - lib/xds/mtom_xop_request.rb
68
+ - lib/xds/provide_and_register_document_set_b.rb
69
+ - lib/xds/provide_and_register_document_set_b_xop.rb
70
+ - lib/xds/provide_and_register_document_set_b_xop_response.rb
71
+ - lib/xds/registry_stored_query_request.rb
72
+ - lib/xds/registry_stored_query_response.rb
73
+ - lib/xds/retrieve_document_set_request.rb
74
+ - lib/xds/retrieve_document_set_response.rb
75
+ - lib/xds/source_patient_info.rb
76
+ - lib/xds/xds_header.rb
77
+ - lib/xds/xds_part.rb
78
+ - lib/xds/xds_request.rb
79
+ - lib/xds/xds_request_entity.rb
80
+ has_rdoc: true
81
+ homepage: http://projectlaika.org
82
+ licenses:
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.5
104
+ signing_key:
105
+ specification_version: 2
106
+ summary: Simple interface for XDS for use with JRuby
107
+ test_files:
108
+ - test/xds/coded_attribute_test.rb
109
+ - test/xds/source_patient_info_test.rb
110
+ - test/xds/author_test.rb
111
+ - test/xds/xml_helper_test.rb
112
+ - test/xds/retrieve_document_set_request_test.rb
113
+ - test/xds/affinity_domain_config_test.rb
114
+ - test/xds/xds_header.rb
115
+ - test/xds/metadata_test.rb
116
+ - test/xds/provide_and_register_document_set_b_test.rb
117
+ - test/xds/registry_stored_query_request_test.rb
118
+ - test/xds/retrieve_document_set_response_test.rb
119
+ - test/xds/registry_stored_query_response_test.rb
120
+ - test/mime/mime_message_parser_test.rb
121
+ - test/test_helper.rb
122
+ - test/factories.rb