ncs_mdes 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ##
4
+ # A script to generate disposition_codes.yml from the MDES 2.2
5
+ # spreadsheet's Dispositions tab.
6
+ #
7
+ # This script requires the 'roo' gem, which is not included in
8
+ # ncs_mdes's gemspec because it has a huge number of dependencies and
9
+ # is not needed at runtime.
10
+
11
+ require 'rubygems'
12
+ require 'roo'
13
+ require 'yaml'
14
+
15
+ MDES_XLSX = ARGV.first or fail 'Please provide the path to the MDES spreadsheet'
16
+ TARGET = File.expand_path('../disposition_codes.yml', __FILE__)
17
+ SHEET_NAME = 'Dispositions'
18
+
19
+ MAPPED_COLUMNS = {
20
+ 'A' => 'final_category',
21
+ 'B' => 'sub_category',
22
+ 'C' => 'disposition'
23
+ }
24
+
25
+ def normalize_whitespace(s)
26
+ s.strip.gsub(/\s+/, " ")
27
+ end
28
+
29
+ book = Excelx.new(MDES_XLSX)
30
+
31
+ # This is the array of hashes that will eventually be serialized to
32
+ # disposition_codes.yml.
33
+ dispositions = []
34
+
35
+ current_event = nil
36
+ current_category_code = nil
37
+ 1.upto(book.last_row(SHEET_NAME)) do |row_number|
38
+ a, b = %w(A B).collect { |col| book.cell(row_number, col, SHEET_NAME) }
39
+ if a =~ /Category\s+(\d)\s+\((.*?)\)\s+Disposition\s+Codes/
40
+ current_event = normalize_whitespace $2
41
+ current_category_code = $1.to_i
42
+ puts "Collecting for category #{current_event} (#{current_category_code})"
43
+ elsif b =~ /\S/ && a !~ /FINAL/
44
+ disposition_hash = MAPPED_COLUMNS.inject({}) do |h, (col, key)|
45
+ h[key] = normalize_whitespace(book.cell(row_number, col, SHEET_NAME)); h
46
+ end
47
+ disposition_hash['event'] = current_event
48
+ disposition_hash['category_code'] = current_category_code
49
+ disposition_hash['interim_code'], disposition_hash['final_code'] =
50
+ normalize_whitespace(book.cell(row_number, 'D', SHEET_NAME)).split('/')
51
+
52
+ puts disposition_hash.inspect if disposition_hash['interim_code'] =~ /^02/
53
+ dispositions << disposition_hash
54
+ end
55
+ end
56
+
57
+ File.open(TARGET, 'w') do |f|
58
+ f.write dispositions.sort_by { |h| [h['category_code'], h['final_code']] }.to_yaml
59
+ end
@@ -0,0 +1,526 @@
1
+ foreign_keys:
2
+ birth_visit:
3
+ new_address_id: address
4
+ mail_address_id: address
5
+ new_address_b_id: address
6
+
7
+ birth_visit_2:
8
+ new_address_id: address
9
+ mail_address_id: address
10
+ new_address_b_id: address
11
+
12
+ birth_visit_3:
13
+ cwork_address_id: address
14
+ work_address_id: address
15
+
16
+ birth_visit_baby_name:
17
+ bv_id: birth_visit
18
+
19
+ birth_visit_baby_name_2:
20
+ bv_id: birth_visit_2
21
+
22
+ birth_visit_decorate_room:
23
+ bv_id: birth_visit
24
+
25
+ birth_visit_decorate_room_2:
26
+ bv_id: birth_visit_2
27
+
28
+ birth_visit_li:
29
+ new_address_id: address
30
+ mail_address_id: address
31
+ new_address_b_id: address
32
+
33
+ birth_visit_renovate_room:
34
+ bv_id: birth_visit
35
+
36
+ birth_visit_renovate_room_2:
37
+ bv_id: birth_visit_2
38
+
39
+ drf_therm_verification:
40
+ equip_id: env_equipment
41
+
42
+ eighteen_mth_mother:
43
+ c_addr1_id: address
44
+ c_addr2_id: address
45
+ r_p_id: participant
46
+
47
+ eighteen_mth_mother_2:
48
+ c_addr1_id: address
49
+ c_addr2_id: address
50
+ r_p_id: participant
51
+
52
+ eighteen_mth_mother_cond:
53
+ eighteen_mth_habits_id: eighteen_mth_mother_habits
54
+
55
+ eighteen_mth_mother_saq:
56
+ asq18_address_id: address
57
+ r_p_id: participant
58
+
59
+ env_equipment_prob_log:
60
+ equip_id: env_equipment
61
+ staff_id_reviewer: staff
62
+
63
+ event:
64
+ participant_id: participant
65
+
66
+ household_enumeration_hidden_du:
67
+ hdu_address_id: address
68
+
69
+ incident:
70
+ inc_staff_reporter_id: staff
71
+ inc_staff_supervisor_id: staff
72
+ inc_recip_is_participant: participant
73
+ inc_recip_is_du: dwelling_unit
74
+ inc_recip_is_staff: staff
75
+ inc_recip_is_family: person
76
+ inc_recip_is_acquaintance: person
77
+ inc_contact_person: person
78
+
79
+ multi_mode:
80
+ r_p_id: participant
81
+
82
+ nine_mth_mother:
83
+ r_p_id: participant
84
+
85
+ non_interview_respondent:
86
+ r_p_id: participant
87
+
88
+ participant_consent:
89
+ person_who_consented_id: person
90
+ person_wthdrw_consent_id: person
91
+
92
+ participant_consent_reconsideration:
93
+ r_p_id: participant
94
+
95
+ participant_verif:
96
+ r_p_id: participant
97
+ c_address_id: address
98
+ pa_phone_id: telephone
99
+ s_address_id: address
100
+ sa_phone_id: telephone
101
+
102
+ participant_vis_consent:
103
+ vis_person_who_consented_id: person
104
+
105
+ participant_rvis:
106
+ rvis_person: person
107
+
108
+ pb_recruitment:
109
+ address_pb_id: address
110
+
111
+ pb_recruitment_2:
112
+ address_pb_id: address
113
+
114
+ pb_recruitment_info_source:
115
+ pb_recruitment_id: pb_recruitment
116
+
117
+ pb_recruitment_info_source_2:
118
+ pb_recruitment_id: pb_recruitment_2
119
+
120
+ pb_recruitment_prov_source:
121
+ pb_recruitment_id: pb_recruitment
122
+
123
+ pb_recruitment_prov_source_2:
124
+ pb_recruitment_id: pb_recruitment_2
125
+
126
+ pb_recruitment_prov_svc:
127
+ pb_recruitment_id: pb_recruitment
128
+
129
+ pb_recruitment_prov_svc_2:
130
+ pb_recruitment_id: pb_recruitment_2
131
+
132
+ pb_samp_frame:
133
+ practice_address_id: address
134
+ contact_address_id: address
135
+ contact_email_id: email
136
+ contact_phone_num_id: telephone
137
+ contact_address_larger_id: address
138
+ contact_email_larger_id: email
139
+ contact_phone_num_larger_id: telephone
140
+
141
+ pbs_elig_screener:
142
+ r_phone_1_id: telephone
143
+ r_phone_2_id: telephone
144
+ r_email_id: email
145
+
146
+ pbs_elig_screener_pr_office:
147
+ pr_address_id: address
148
+
149
+ person:
150
+ new_address_id: address
151
+
152
+ prec_therm_cert:
153
+ equip_id: env_equipment
154
+
155
+ pre_preg:
156
+ c_addr1_id: address
157
+ c_addr2_id: address
158
+
159
+ preg_screen_eh:
160
+ mail_address_id: address
161
+ new_address_id: address
162
+
163
+ preg_screen_eh_2:
164
+ mail_address_id: address
165
+ new_address_id: address
166
+
167
+ preg_screen_eh_know_ncs:
168
+ ps_eh_id: preg_screen_eh
169
+
170
+ preg_screen_eh_know_ncs_2:
171
+ ps_eh_id: preg_screen_eh_2
172
+
173
+ preg_screen_eh_race:
174
+ ps_eh_id: preg_screen_eh
175
+
176
+ preg_screen_eh_race_2:
177
+ ps_eh_id: preg_screen_eh_2
178
+
179
+ preg_screen_hi:
180
+ mail_address_id: address
181
+ new_address_id: address
182
+
183
+ preg_screen_hi_2:
184
+ mail_address_id: address
185
+ new_address_id: address
186
+
187
+ preg_screen_hi_know_ncs:
188
+ ps_hi_id: preg_screen_hi
189
+
190
+ preg_screen_hi_know_ncs_2:
191
+ ps_hi_id: preg_screen_hi_2
192
+
193
+ preg_screen_hi_race:
194
+ ps_hi_id: preg_screen_hi
195
+
196
+ preg_screen_hi_race_2:
197
+ ps_hi_id: preg_screen_hi_2
198
+
199
+ preg_screen_pb:
200
+ mail_address_id: address
201
+ new_address_id: address
202
+
203
+ preg_screen_pb_2:
204
+ mail_address_id: address
205
+ new_address_id: address
206
+
207
+ preg_screen_pb_know_ncs:
208
+ ps_pb_id: preg_screen_pb
209
+
210
+ preg_screen_pb_know_ncs_2:
211
+ ps_pb_id: preg_screen_pb_2
212
+
213
+ preg_screen_pb_race:
214
+ ps_pb_id: preg_screen_pb
215
+
216
+ preg_screen_pb_race_2:
217
+ ps_pb_id: preg_screen_pb_2
218
+
219
+ preg_visit_1:
220
+ b_address_id: address
221
+ c_addr1_id: address
222
+ c_addr2_id: address
223
+
224
+ preg_visit_1_2:
225
+ b_address_id: address
226
+ c_addr1_id: address
227
+ c_addr2_id: address
228
+
229
+ preg_visit_1_3:
230
+ b_address_id: address
231
+ work_address_id: address
232
+
233
+ preg_visit_1_commute:
234
+ pv1_id: preg_visit_1
235
+
236
+ preg_visit_1_commute_2:
237
+ pv1_id: preg_visit_1_2
238
+
239
+ preg_visit_1_cool:
240
+ pv1_id: preg_visit_1
241
+
242
+ preg_visit_1_cool_2:
243
+ pv1_id: preg_visit_1_2
244
+
245
+ preg_visit_1_diagnose_2:
246
+ pv1_id: preg_visit_1
247
+
248
+ preg_visit_1_diagnose_2_2:
249
+ pv1_id: preg_visit_1_2
250
+
251
+ preg_visit_1_heat2:
252
+ pv1_id: preg_visit_1
253
+
254
+ preg_visit_1_heat2_2:
255
+ pv1_id: preg_visit_1_2
256
+
257
+ preg_visit_1_local_trav:
258
+ pv1_id: preg_visit_1
259
+
260
+ preg_visit_1_local_trav_2:
261
+ pv1_id: preg_visit_1_2
262
+
263
+ preg_visit_1_nonenglish2_2:
264
+ pv1_id: preg_visit_1_2
265
+
266
+ preg_visit_1_pdecorate_room:
267
+ pv1_id: preg_visit_1
268
+
269
+ preg_visit_1_pdecorate_room_2:
270
+ pv1_id: preg_visit_1_2
271
+
272
+ preg_visit_1_pet_type:
273
+ pv1_id: preg_visit_1
274
+
275
+ preg_visit_1_pet_type_2:
276
+ pv1_id: preg_visit_1_2
277
+
278
+ preg_visit_1_prenovate2_room:
279
+ pv1_id: preg_visit_1
280
+
281
+ preg_visit_1_prenovate_room:
282
+ pv1_id: preg_visit_1
283
+
284
+ preg_visit_1_prenovate_room_2:
285
+ pv1_id: preg_visit_1_2
286
+
287
+ preg_visit_1_room_mold:
288
+ pv1_id: preg_visit_1
289
+
290
+ preg_visit_1_room_mold_2:
291
+ pv1_id: preg_visit_1_2
292
+
293
+ preg_visit_1_saq_2:
294
+ f_addr_id: address
295
+
296
+ preg_visit_1_saq_3:
297
+ f_addr_id: address
298
+
299
+ preg_visit_1_saq_4:
300
+ f_addr_id: address
301
+ f_phone_id: telephone
302
+
303
+ preg_visit_1_sp_race:
304
+ pv1_id: preg_visit_1
305
+
306
+ preg_visit_1_sp_race_2:
307
+ pv1_id: preg_visit_1_2
308
+
309
+ preg_visit_2:
310
+ b_address_id: address
311
+ c_addr1_id: address
312
+ c_addr2_id: address
313
+
314
+ preg_visit_2_2:
315
+ b_address_id: address
316
+ c_addr1_id: address
317
+ c_addr2_id: address
318
+
319
+ preg_visit_2_3:
320
+ b_address_id: address
321
+ work_address_id: address
322
+ cwork_address_id: address
323
+
324
+ preg_visit_2_cool:
325
+ pv2_id: preg_visit_2
326
+
327
+ preg_visit_2_cool_2:
328
+ pv2_id: preg_visit_2_2
329
+
330
+ preg_visit_2_diagnose_2:
331
+ pv2_id: preg_visit_2
332
+
333
+ preg_visit_2_diagnose_2_2:
334
+ pv2_id: preg_visit_2_2
335
+
336
+ preg_visit_2_heat2:
337
+ pv2_id: preg_visit_2
338
+
339
+ preg_visit_2_heat2_2:
340
+ pv2_id: preg_visit_2_2
341
+
342
+ preg_visit_2_pdecorate2_room:
343
+ pv2_id: preg_visit_2
344
+
345
+ preg_visit_2_pdecorate2_room_2:
346
+ pv2_id: preg_visit_2_2
347
+
348
+ preg_visit_2_prenovate_room:
349
+ pv2_id: preg_visit_2
350
+
351
+ preg_visit_2_prenovate_room_2:
352
+ pv2_id: preg_visit_2_2
353
+
354
+ preg_visit_2_room_mold:
355
+ pv2_id: preg_visit_2
356
+
357
+ preg_visit_2_room_mold_2:
358
+ pv2_id: preg_visit_2_2
359
+
360
+ preg_visit_li:
361
+ b_address_id: address
362
+
363
+ preg_visit_li_2:
364
+ b_address_id: address
365
+
366
+ preg_visit_li_cool:
367
+ pv_li_id: preg_visit_li
368
+
369
+ preg_visit_li_cool_2:
370
+ pv_li_id: preg_visit_li_2
371
+
372
+ ref_freezer_verification:
373
+ equip_id: env_equipment
374
+
375
+ sample_receipt_store:
376
+ equip_id: env_equipment
377
+
378
+ sample_shipping:
379
+ staff_id_track: staff
380
+
381
+ six_mth_mother:
382
+ c_addr1_id: address
383
+ c_addr2_id: address
384
+ r_p_id: participant
385
+
386
+ six_mth_saq_formula_type:
387
+ six_mth_saq_id: six_mth_saq
388
+
389
+ six_mth_saq_2:
390
+ r_p_id: participant
391
+
392
+ six_mth_saq_3:
393
+ r_p_id: participant
394
+
395
+ six_mth_saq_formula_type_2:
396
+ six_mth_saq_id: six_mth_saq_2
397
+
398
+ six_mth_saq_supp:
399
+ six_mth_saq_id: six_mth_saq
400
+
401
+ six_mth_saq_supp_2:
402
+ six_mth_saq_id: six_mth_saq_2
403
+
404
+ six_mth_saq_water:
405
+ six_mth_saq_id: six_mth_saq
406
+
407
+ six_mth_saq_water_2:
408
+ six_mth_saq_id: six_mth_saq_2
409
+
410
+ spec_blood:
411
+ # According to the corresponding instrument, equip_id is manually entered
412
+ # and not a reference to another table.
413
+ equip_id: false
414
+
415
+ spec_blood_2:
416
+ # According to the corresponding instrument, equip_id is manually entered
417
+ # and not a reference to another table.
418
+ equip_id: false
419
+
420
+ spec_cord_blood_specimen:
421
+ spec_cord_blood_id: spec_cord_blood
422
+
423
+ spec_cord_blood_specimen_2:
424
+ spec_cord_blood_id: spec_cord_blood_2
425
+
426
+ spec_receipt:
427
+ # Insufficient info to determine what this is supposed to link to
428
+ storage_container_id: false
429
+ equip_id: spec_equipment
430
+
431
+ spec_shipping:
432
+ # Insufficient info to determine what this is supposed to link to
433
+ shipper_id: false
434
+
435
+ spec_storage:
436
+ equip_id: spec_equipment
437
+
438
+ staff_exp_mngmnt_tasks:
439
+ staff_weekly_expense_id: staff_weekly_expense
440
+
441
+ staff_exp_data_cllctn_tasks:
442
+ staff_weekly_expense_id: staff_weekly_expense
443
+
444
+ three_mth_mother:
445
+ r_p_id: participant
446
+
447
+ three_mth_mother_2:
448
+ r_p_id: participant
449
+
450
+ tracing_int:
451
+ r_p_id: participant
452
+ new_address_id: address
453
+ home_phone_id: telephone
454
+ cell_phone_id: telephone
455
+ c_addr1_id: address
456
+ contact_phone_id: telephone
457
+ contact_phone_2_1_id: telephone
458
+ c_addr2_id: address
459
+ contact_phone_2_id: telephone
460
+ contact_phone_2_2_id: telephone
461
+ c_addr3_id: address
462
+ contact_phone_3_id: telephone
463
+ contact_phone_2_3_id: telephone
464
+
465
+ trh_meter_calibration:
466
+ equip_id: spec_equipment
467
+
468
+ twelve_mth_mother:
469
+ c_addr1_id: address
470
+ c_addr2_id: address
471
+ r_p_id: participant
472
+
473
+ twelve_mth_mother_2:
474
+ r_p_id: participant
475
+ c_addr1_id: address
476
+ c_addr2_id: address
477
+
478
+ twelve_mth_saq_2:
479
+ r_p_id: participant
480
+
481
+ twelve_mth_saq_formula_brand:
482
+ twelve_mth_saq_id: twelve_mth_saq
483
+
484
+ twelve_mth_saq_formula_brand_2:
485
+ twelve_mth_saq_id: twelve_mth_saq_2
486
+
487
+ twelve_mth_saq_formula_type:
488
+ twelve_mth_saq_id: twelve_mth_saq
489
+
490
+ twelve_mth_saq_formula_type_2:
491
+ twelve_mth_saq_id: twelve_mth_saq_2
492
+
493
+ twelve_mth_saq_supplement:
494
+ twelve_mth_saq_id: twelve_mth_saq
495
+
496
+ twelve_mth_saq_supplement_2:
497
+ twelve_mth_saq_id: twelve_mth_saq_2
498
+
499
+ twelve_mth_saq_water:
500
+ twelve_mth_saq_id: twelve_mth_saq
501
+
502
+ twelve_mth_saq_water_2:
503
+ twelve_mth_saq_id: twelve_mth_saq_2
504
+
505
+ twenty_four_mth_mother:
506
+ c_addr1_id: address
507
+ c_addr2_id: address
508
+ r_p_id: participant
509
+
510
+ twenty_four_mth_mother_2:
511
+ c_addr1_id: address
512
+ c_addr2_id: address
513
+ r_p_id: participant
514
+
515
+ twenty_four_mth_mother_otc:
516
+ twenty_four_mth_mother_id: twenty_four_mth_mother
517
+
518
+ twenty_four_mth_mother_prescr:
519
+ twenty_four_mth_mother_id: twenty_four_mth_mother
520
+
521
+ twenty_four_mth_mother_suppl:
522
+ twenty_four_mth_mother_id: twenty_four_mth_mother
523
+
524
+ twenty_four_mth_saq:
525
+ asq24_address_id: address
526
+ r_p_id: participant
@@ -55,6 +55,8 @@ module NcsNavigator::Mdes
55
55
  create('2.1', '2.1/NCS_Transmission_Schema_2.1.00.00.xsd', '2.1.00.00')
56
56
  when '2.2'
57
57
  create('2.2', '2.2/NCS_Transmission_Schema_2.2.01.00.xsd', '2.2.01.00')
58
+ when '3.0'
59
+ create('3.0', '3.0/NCS_Transmission_Schema_3.0.00.00.xsd', '3.0.00.00')
58
60
  else
59
61
  raise "MDES #{version} is not supported by this version of ncs_mdes"
60
62
  end
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  module Mdes
3
- VERSION = '0.6.1'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -144,6 +144,20 @@ module NcsNavigator::Mdes
144
144
  end
145
145
  end
146
146
 
147
+ describe '3.0' do
148
+ let(:version) { '3.0' }
149
+
150
+ include_context 'version docs'
151
+
152
+ it 'has the correct path for the schema' do
153
+ subject.schema.should =~ %r{3.0/NCS_Transmission_Schema_3.0.00.00.xsd$}
154
+ end
155
+
156
+ it 'has a different specification_version' do
157
+ subject.specification_version.should == '3.0.00.00'
158
+ end
159
+ end
160
+
147
161
  it 'fails for an unsupported version' do
148
162
  lambda { SourceDocuments.get('1.0') }.
149
163
  should raise_error('MDES 1.0 is not supported by this version of ncs_mdes')
@@ -82,6 +82,13 @@ module NcsNavigator::Mdes
82
82
 
83
83
  include_examples 'tables fully resolved'
84
84
  end
85
+
86
+ context 'in version 3.0' do
87
+ let(:version) { '3.0' }
88
+ let(:expected_table_count) { 397 }
89
+
90
+ include_examples 'tables fully resolved'
91
+ end
85
92
  end
86
93
 
87
94
  describe '#specification_version' do
@@ -141,6 +148,14 @@ module NcsNavigator::Mdes
141
148
  disposition_codes.size.should == 251
142
149
  end
143
150
  end
151
+
152
+ context 'in version 3.0' do
153
+ let(:disposition_codes) { Specification.new('3.0', :log => logger).disposition_codes }
154
+
155
+ it 'has 332 codes' do
156
+ disposition_codes.size.should == 332
157
+ end
158
+ end
144
159
  end
145
160
 
146
161
  describe '#[]' do
@@ -208,6 +223,13 @@ module NcsNavigator::Mdes
208
223
 
209
224
  include_examples 'types fully resolved'
210
225
  end
226
+
227
+ context 'version 3.0' do
228
+ let(:version) { '3.0' }
229
+ let(:expected_type_count) { 514 }
230
+
231
+ include_examples 'types fully resolved'
232
+ end
211
233
  end
212
234
  end
213
235
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncs_mdes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -129,6 +129,10 @@ files:
129
129
  - documents/2.2/disposition_codes.yml
130
130
  - documents/2.2/extract_disposition_codes.rb
131
131
  - documents/2.2/heuristic_overrides.yml
132
+ - documents/3.0/NCS_Transmission_Schema_3.0.00.00.xsd
133
+ - documents/3.0/disposition_codes.yml
134
+ - documents/3.0/extract_disposition_codes.rb
135
+ - documents/3.0/heuristic_overrides.yml
132
136
  - lib/ncs_navigator/mdes.rb
133
137
  - lib/ncs_navigator/mdes/disposition_code.rb
134
138
  - lib/ncs_navigator/mdes/source_documents.rb
@@ -158,18 +162,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
162
  - - ! '>='
159
163
  - !ruby/object:Gem::Version
160
164
  version: '0'
161
- segments:
162
- - 0
163
- hash: -4331102622694639655
164
165
  required_rubygems_version: !ruby/object:Gem::Requirement
165
166
  none: false
166
167
  requirements:
167
168
  - - ! '>='
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
- segments:
171
- - 0
172
- hash: -4331102622694639655
173
171
  requirements: []
174
172
  rubyforge_project:
175
173
  rubygems_version: 1.8.21