ncs_mdes 0.2.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/.gitignore +10 -0
- data/.rvmrc +1 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +9 -0
- data/README.md +59 -0
- data/Rakefile +7 -0
- data/bin/mdes-console +21 -0
- data/documents/1.2/Data_Transmission_Schema_V1.2.xsd +13980 -0
- data/documents/2.0/NCS_Transmission_Schema_2.0.01.02.xml +26918 -0
- data/lib/ncs_navigator/mdes/source_documents.rb +103 -0
- data/lib/ncs_navigator/mdes/specification.rb +86 -0
- data/lib/ncs_navigator/mdes/transmission_table.rb +53 -0
- data/lib/ncs_navigator/mdes/variable.rb +119 -0
- data/lib/ncs_navigator/mdes/variable_type.rb +196 -0
- data/lib/ncs_navigator/mdes/version.rb +5 -0
- data/lib/ncs_navigator/mdes.rb +27 -0
- data/ncs_mdes.gemspec +27 -0
- data/spec/ncs_navigator/mdes/source_documents_spec.rb +95 -0
- data/spec/ncs_navigator/mdes/specification_spec.rb +102 -0
- data/spec/ncs_navigator/mdes/transmission_table_spec.rb +89 -0
- data/spec/ncs_navigator/mdes/variable_spec.rb +216 -0
- data/spec/ncs_navigator/mdes/variable_type_spec.rb +202 -0
- data/spec/ncs_navigator/mdes/version_spec.rb +13 -0
- data/spec/ncs_navigator/mdes_spec.rb +9 -0
- data/spec/spec_helper.rb +45 -0
- metadata +165 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.8.7-p334@ncs_mdes
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
0.2.0
|
2
|
+
=====
|
3
|
+
|
4
|
+
- Rename gem to ncs_mdes (from ncs-mdes).
|
5
|
+
- Embed the VDR transmission XSD since we now have permission to
|
6
|
+
distribute the MDES structure.
|
7
|
+
- Update version 2.0 to be based on 2.0.01.02.
|
8
|
+
|
9
|
+
0.1.0
|
10
|
+
=====
|
11
|
+
|
12
|
+
- Add mdes-console executable.
|
13
|
+
|
14
|
+
0.0.1
|
15
|
+
=====
|
16
|
+
|
17
|
+
- First version. Reads data from VDR transmission schema for MDES 1.2
|
18
|
+
and 2.0.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
NCS Navigator MDES Module
|
2
|
+
=========================
|
3
|
+
|
4
|
+
This gem provides a consistent computable interface to the National
|
5
|
+
Children's Study Master Data Element Specification. All of the data it
|
6
|
+
exposes is derived at runtime from the documents provided by the
|
7
|
+
National Children's Study Program Office, which must be available on
|
8
|
+
the system where it is running.
|
9
|
+
|
10
|
+
Use
|
11
|
+
---
|
12
|
+
|
13
|
+
require 'ncs_navigator/mdes'
|
14
|
+
require 'pp'
|
15
|
+
|
16
|
+
mdes = NcsNavigator::Mdes('1.2')
|
17
|
+
pp mdes.transmission_tables.collect(&:name)
|
18
|
+
|
19
|
+
For more details see the API documentation, starting with {NcsNavigator::Mdes::Specification}.
|
20
|
+
|
21
|
+
### Examine
|
22
|
+
|
23
|
+
This gem includes a console for interactively analyzing and randomly
|
24
|
+
poking at the MDES. It is called `mdes-console`:
|
25
|
+
|
26
|
+
$ mdes-console
|
27
|
+
Documents are expected to be in the default location.
|
28
|
+
$mdes12 is a Specification for 1.2
|
29
|
+
$mdes20 is a Specification for 2.0
|
30
|
+
ruby-1.8.7-p334 :001 >
|
31
|
+
|
32
|
+
It is based on ruby's IRB. Use it to examine the loaded MDES data
|
33
|
+
without a lot of edit-save-run cycles:
|
34
|
+
|
35
|
+
ruby-1.8.7-p334 :001 > $mdes20.transmission_tables.first.name
|
36
|
+
=> "study_center"
|
37
|
+
|
38
|
+
E.g., find all the variables of a particular XML schema type:
|
39
|
+
|
40
|
+
ruby-1.8.7-p334 :002 > $mdes20.transmission_tables.collect { |t| t.variables }.flatten.select { |v| v.type.base_type == :decimal }.collect(&:name)
|
41
|
+
=> ["correction_factor_temp", "current_temp", "maximum_temp", "minimum_temp", "precision_term_temp", "trh_temp", "salts_moist", "s_33rh_reading", "s_75rh_reading", "s_33rh_reading_calib", "s_75rh_reading_calib", "precision_term_temp", "rf_temp", "correction_factor_temp", "sample_receipt_temp"]
|
42
|
+
|
43
|
+
Or the labels for a particular code list:
|
44
|
+
|
45
|
+
ruby-1.8.7-p334 :003 > $mdes20.types.find { |t| t.name == 'confirm_type_cl7' }.code_list.collect(&:label)
|
46
|
+
=> ["Yes", "No", "Refused", "Don't Know", "Legitimate Skip", "Missing in Error"]
|
47
|
+
|
48
|
+
Or the number of code lists that include "Yes" as an option:
|
49
|
+
|
50
|
+
ruby-1.8.7-p334 :004 > $mdes20.types.select { |t| t.code_list && t.code_list.collect(&:label).include?('Yes') }.size
|
51
|
+
=> 23
|
52
|
+
|
53
|
+
Develop
|
54
|
+
-------
|
55
|
+
|
56
|
+
### Writing API docs
|
57
|
+
|
58
|
+
Run `bundle exec yard server --reload` to get a dynamically-refreshing
|
59
|
+
view of the API docs on localhost:8808.
|
data/Rakefile
ADDED
data/bin/mdes-console
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
##
|
4
|
+
# Provides a IRB session with a NcsNavigator::Mdes::Specification instance
|
5
|
+
# for free-form prodding.
|
6
|
+
|
7
|
+
require 'irb'
|
8
|
+
require 'ncs_navigator/mdes'
|
9
|
+
|
10
|
+
$mdes12 = NcsNavigator::Mdes::Specification.new('1.2')
|
11
|
+
$mdes20 = NcsNavigator::Mdes::Specification.new('2.0')
|
12
|
+
|
13
|
+
expected_loc = ENV[NcsNavigator::Mdes::SourceDocuments::BASE_ENV_VAR] ?
|
14
|
+
ENV[NcsNavigator::Mdes::SourceDocuments::BASE_ENV_VAR].inspect :
|
15
|
+
'the default location'
|
16
|
+
|
17
|
+
puts "Documents are expected to be in #{expected_loc}."
|
18
|
+
puts "$mdes12 is a Specification for 1.2"
|
19
|
+
puts "$mdes20 is a Specification for 2.0"
|
20
|
+
|
21
|
+
IRB.start(__FILE__)
|