ncs_mdes 0.3.1 → 0.4.0
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/CHANGELOG.md +16 -5
- data/documents/2.0/disposition_codes.yml +1507 -0
- data/lib/ncs_navigator/mdes/disposition_code.rb +34 -0
- data/lib/ncs_navigator/mdes/source_documents.rb +25 -0
- data/lib/ncs_navigator/mdes/specification.rb +20 -0
- data/lib/ncs_navigator/mdes/variable.rb +6 -1
- data/lib/ncs_navigator/mdes/version.rb +1 -1
- data/lib/ncs_navigator/mdes.rb +2 -0
- data/spec/ncs_navigator/mdes/source_documents_spec.rb +18 -0
- data/spec/ncs_navigator/mdes/specification_spec.rb +35 -0
- data/spec/ncs_navigator/mdes/variable_spec.rb +8 -0
- metadata +9 -38
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ncs_navigator/mdes'
|
2
|
+
|
3
|
+
module NcsNavigator::Mdes
|
4
|
+
##
|
5
|
+
# One dispostion code in the MDES.
|
6
|
+
class DispositionCode
|
7
|
+
|
8
|
+
attr_accessor :event
|
9
|
+
attr_accessor :final_category
|
10
|
+
attr_accessor :sub_category
|
11
|
+
attr_accessor :disposition
|
12
|
+
attr_accessor :interim_code
|
13
|
+
attr_accessor :final_code
|
14
|
+
|
15
|
+
##
|
16
|
+
# Given attributes (presumably loaded from a YAML file) create
|
17
|
+
# a new instance of a DispositionCode
|
18
|
+
#
|
19
|
+
# @return [DispositionCode] the created instance.
|
20
|
+
def initialize(attrs)
|
21
|
+
[:event, :final_category, :sub_category, :disposition, :interim_code, :final_code].each do |a|
|
22
|
+
self.send("#{a}=", attrs[a.to_s])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Provides a briefer inspection for cleaner IRB use.
|
28
|
+
#
|
29
|
+
# @return [String]
|
30
|
+
def inspect
|
31
|
+
"\#<#{self.class} event=#{event.inspect} disposition=#{disposition.inspect} status_code=#{interim_code.inspect}/#{final_code.inspect}>"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -56,6 +56,7 @@ module NcsNavigator::Mdes
|
|
56
56
|
sd.version = version
|
57
57
|
sd.schema = schema
|
58
58
|
sd.heuristic_overrides = "#{version}/heuristic_overrides.yml"
|
59
|
+
sd.disposition_codes = "#{version}/disposition_codes.yml"
|
59
60
|
end
|
60
61
|
end
|
61
62
|
private :create
|
@@ -125,6 +126,30 @@ module NcsNavigator::Mdes
|
|
125
126
|
def heuristic_overrides=(path)
|
126
127
|
@heuristic_overrides = path
|
127
128
|
end
|
129
|
+
|
130
|
+
##
|
131
|
+
# The absolute path to a YAML-formatted document defining
|
132
|
+
# the disposition codes as found in the Master Data Element Specifications
|
133
|
+
# spreadsheet.
|
134
|
+
#
|
135
|
+
# This is path is optional; if one is not provided no disposition
|
136
|
+
# codes will be loaded.
|
137
|
+
#
|
138
|
+
# @return [String]
|
139
|
+
def disposition_codes
|
140
|
+
absolutize(@disposition_codes)
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Set the path to the disposition codes document.
|
145
|
+
# If the path is relative (i.e., it does not begin with `/`), it
|
146
|
+
# will be interpreted relative to {#base}.
|
147
|
+
#
|
148
|
+
# @param [String] path
|
149
|
+
# @return [String] the provided path
|
150
|
+
def disposition_codes=(path)
|
151
|
+
@disposition_codes = path
|
152
|
+
end
|
128
153
|
|
129
154
|
private
|
130
155
|
|
@@ -129,6 +129,26 @@ module NcsNavigator::Mdes
|
|
129
129
|
end
|
130
130
|
private :read_types
|
131
131
|
|
132
|
+
##
|
133
|
+
# @return [Array<DispositionCode>] all the named disposition codes in the MDES.
|
134
|
+
def disposition_codes
|
135
|
+
@disposition_codes ||=
|
136
|
+
begin
|
137
|
+
if File.exist?(source_documents.disposition_codes)
|
138
|
+
YAML.load(File.read source_documents.disposition_codes).collect do |dc|
|
139
|
+
DispositionCode.new(dc)
|
140
|
+
end
|
141
|
+
else
|
142
|
+
empty_disposition_codes
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def empty_disposition_codes
|
148
|
+
[]
|
149
|
+
end
|
150
|
+
private :empty_disposition_codes
|
151
|
+
|
132
152
|
##
|
133
153
|
# A briefer inspection for nicer IRB sessions.
|
134
154
|
#
|
@@ -57,7 +57,12 @@ module NcsNavigator::Mdes
|
|
57
57
|
log = options[:log] || NcsNavigator::Mdes.default_logger
|
58
58
|
|
59
59
|
new(element['name']).tap do |var|
|
60
|
-
var.required =
|
60
|
+
var.required =
|
61
|
+
if element['minOccurs']
|
62
|
+
element['minOccurs'] != '0'
|
63
|
+
else
|
64
|
+
element['nillable'] == 'false'
|
65
|
+
end
|
61
66
|
var.pii =
|
62
67
|
case element['pii']
|
63
68
|
when 'Y'; true;
|
data/lib/ncs_navigator/mdes.rb
CHANGED
@@ -10,6 +10,8 @@ module NcsNavigator
|
|
10
10
|
autoload :Variable, 'ncs_navigator/mdes/variable'
|
11
11
|
autoload :VariableType, 'ncs_navigator/mdes/variable_type'
|
12
12
|
|
13
|
+
autoload :DispositionCode, 'ncs_navigator/mdes/disposition_code'
|
14
|
+
|
13
15
|
##
|
14
16
|
# @return the default logger for this module when no other one is
|
15
17
|
# specified. It logs to standard error.
|
@@ -60,6 +60,16 @@ module NcsNavigator::Mdes
|
|
60
60
|
SourceDocuments.new.heuristic_overrides.should be_nil
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
describe '#disposition_codes' do
|
65
|
+
let(:property) { :disposition_codes }
|
66
|
+
|
67
|
+
it_behaves_like 'an absolutizing path accessor'
|
68
|
+
|
69
|
+
it 'is optional' do
|
70
|
+
SourceDocuments.new.disposition_codes.should be_nil
|
71
|
+
end
|
72
|
+
end
|
63
73
|
|
64
74
|
describe '.get' do
|
65
75
|
describe '1.2' do
|
@@ -72,6 +82,10 @@ module NcsNavigator::Mdes
|
|
72
82
|
it 'has the correct path for the overrides' do
|
73
83
|
subject.heuristic_overrides.should =~ %r{1.2/heuristic_overrides.yml$}
|
74
84
|
end
|
85
|
+
|
86
|
+
it 'has the correct path for the disposition codes' do
|
87
|
+
subject.disposition_codes.should =~ %r{1.2/disposition_codes.yml$}
|
88
|
+
end
|
75
89
|
|
76
90
|
it 'is of the specified version' do
|
77
91
|
subject.version.should == '1.2'
|
@@ -88,6 +102,10 @@ module NcsNavigator::Mdes
|
|
88
102
|
it 'has the correct path for the overrides' do
|
89
103
|
subject.heuristic_overrides.should =~ %r{2.0/heuristic_overrides.yml$}
|
90
104
|
end
|
105
|
+
|
106
|
+
it 'has the correct path for the disposition codes' do
|
107
|
+
subject.disposition_codes.should =~ %r{2.0/disposition_codes.yml$}
|
108
|
+
end
|
91
109
|
|
92
110
|
it 'is of the specified version' do
|
93
111
|
subject.version.should == '2.0'
|
@@ -63,6 +63,41 @@ module NcsNavigator::Mdes
|
|
63
63
|
include_examples 'tables fully resolved'
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
|
68
|
+
describe '#disposition codes' do
|
69
|
+
it 'is composed of DispositionCode instances' do
|
70
|
+
Specification.new('2.0', :log => logger).disposition_codes.first.
|
71
|
+
should be_a DispositionCode
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'in version 1.2' do
|
75
|
+
let(:disposition_codes) { Specification.new('1.2', :log => logger).disposition_codes }
|
76
|
+
|
77
|
+
it 'has 0 codes' do
|
78
|
+
disposition_codes.size.should == 0
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'in version 2.0' do
|
83
|
+
let(:disposition_codes) { Specification.new('2.0', :log => logger).disposition_codes }
|
84
|
+
|
85
|
+
it 'has 251 codes' do
|
86
|
+
disposition_codes.size.should == 251
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'creates valid codes' do
|
90
|
+
code = disposition_codes.first
|
91
|
+
code.event.should == "Household Enumeration Event"
|
92
|
+
code.final_category.should == "Unknown Eligibility"
|
93
|
+
code.sub_category.should == "Unknown if Dwelling Unit"
|
94
|
+
code.disposition.should == "Not attempted"
|
95
|
+
code.interim_code.should == "010"
|
96
|
+
code.final_code.should == "510"
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
66
101
|
|
67
102
|
describe '#[]' do
|
68
103
|
let(:spec) { Specification.new('2.0') }
|
@@ -97,6 +97,14 @@ XSD
|
|
97
97
|
it 'is false when nillable' do
|
98
98
|
comments.should_not be_required
|
99
99
|
end
|
100
|
+
|
101
|
+
it 'is false when not nillable but minOccurs is 0' do
|
102
|
+
variable('<xs:element nillable="false" minOccurs="0"/>').should_not be_required
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'is true when nillable omitted but minOccurs is > 0' do
|
106
|
+
variable('<xs:element minOccurs="1"/>').should be_required
|
107
|
+
end
|
100
108
|
end
|
101
109
|
|
102
110
|
describe '#pii' do
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncs_mdes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 0.3.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Rhett Sutphin
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-28 00:00:00 -05:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,10 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 4
|
33
24
|
version: "1.4"
|
34
25
|
type: :runtime
|
35
26
|
version_requirements: *id001
|
@@ -41,10 +32,6 @@ dependencies:
|
|
41
32
|
requirements:
|
42
33
|
- - ~>
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 15
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 6
|
48
35
|
version: "2.6"
|
49
36
|
type: :development
|
50
37
|
version_requirements: *id002
|
@@ -56,11 +43,6 @@ dependencies:
|
|
56
43
|
requirements:
|
57
44
|
- - ~>
|
58
45
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 63
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
- 9
|
63
|
-
- 2
|
64
46
|
version: 0.9.2
|
65
47
|
type: :development
|
66
48
|
version_requirements: *id003
|
@@ -72,19 +54,12 @@ dependencies:
|
|
72
54
|
requirements:
|
73
55
|
- - ~>
|
74
56
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 7
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 7
|
79
|
-
- 2
|
80
57
|
version: 0.7.2
|
81
58
|
type: :development
|
82
59
|
version_requirements: *id004
|
83
|
-
description:
|
84
|
-
|
85
|
-
|
86
|
-
National Children's Study's Master Data Element Specification.
|
87
|
-
|
60
|
+
description: "\n\
|
61
|
+
Provides a consistent ruby interface to the project metainformation in the\n\
|
62
|
+
National Children's Study's Master Data Element Specification.\n"
|
88
63
|
email:
|
89
64
|
- r-sutphin@northwestern.edu
|
90
65
|
executables:
|
@@ -105,8 +80,10 @@ files:
|
|
105
80
|
- documents/1.2/Data_Transmission_Schema_V1.2.xsd
|
106
81
|
- documents/1.2/heuristic_overrides.yml
|
107
82
|
- documents/2.0/NCS_Transmission_Schema_2.0.01.02.xml
|
83
|
+
- documents/2.0/disposition_codes.yml
|
108
84
|
- documents/2.0/heuristic_overrides.yml
|
109
85
|
- lib/ncs_navigator/mdes.rb
|
86
|
+
- lib/ncs_navigator/mdes/disposition_code.rb
|
110
87
|
- lib/ncs_navigator/mdes/source_documents.rb
|
111
88
|
- lib/ncs_navigator/mdes/specification.rb
|
112
89
|
- lib/ncs_navigator/mdes/transmission_table.rb
|
@@ -136,23 +113,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
113
|
requirements:
|
137
114
|
- - ">="
|
138
115
|
- !ruby/object:Gem::Version
|
139
|
-
hash: 3
|
140
|
-
segments:
|
141
|
-
- 0
|
142
116
|
version: "0"
|
143
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
118
|
none: false
|
145
119
|
requirements:
|
146
120
|
- - ">="
|
147
121
|
- !ruby/object:Gem::Version
|
148
|
-
hash: 3
|
149
|
-
segments:
|
150
|
-
- 0
|
151
122
|
version: "0"
|
152
123
|
requirements: []
|
153
124
|
|
154
125
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
126
|
+
rubygems_version: 1.6.2
|
156
127
|
signing_key:
|
157
128
|
specification_version: 3
|
158
129
|
summary: A ruby API for various versions of the NCS MDES.
|