ncs_mdes 0.9.0 → 0.10.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.
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ##
4
+ # A script to generate disposition_codes.yml from the MDES 3.1
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,656 @@
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_li_2:
34
+ cwork_address_id: address
35
+ work_address_id: address
36
+
37
+ birth_visit_renovate_room:
38
+ bv_id: birth_visit
39
+
40
+ birth_visit_renovate_room_2:
41
+ bv_id: birth_visit_2
42
+
43
+ bitsea_saq:
44
+ r_p_id: participant
45
+
46
+ breast_milk_saq:
47
+ r_p_id: participant
48
+
49
+ bsi_saq:
50
+ r_p_id: participant
51
+
52
+ child_anthro:
53
+ r_p_id: participant
54
+
55
+ child_blood:
56
+ r_p_id: participant
57
+ # According to the corresponding instrument, equip_id is manually entered
58
+ # and not a reference to another table.
59
+ equip_id: false
60
+
61
+ child_bp:
62
+ r_p_id: participant
63
+
64
+ child_saliva:
65
+ r_p_id: participant
66
+
67
+ child_saliva_saq:
68
+ r_p_id: participant
69
+
70
+ child_urine:
71
+ r_p_id: participant
72
+
73
+ core_quest:
74
+ r_p_id: participant
75
+
76
+ core_quest_child_care:
77
+ r_p_id: participant
78
+ c_address_id: address
79
+
80
+ core_quest_occupation:
81
+ r_p_id: participant
82
+ work_address_id: address
83
+
84
+ drf_therm_verification:
85
+ equip_id: env_equipment
86
+
87
+ eighteen_mth_mother:
88
+ c_addr1_id: address
89
+ c_addr2_id: address
90
+ r_p_id: participant
91
+
92
+ eighteen_mth_mother_2:
93
+ c_addr1_id: address
94
+ c_addr2_id: address
95
+ r_p_id: participant
96
+
97
+ eighteen_mth_mother_3:
98
+ r_p_id: participant
99
+
100
+ eighteen_mth_mother_cond:
101
+ eighteen_mth_habits_id: eighteen_mth_mother_habits
102
+
103
+ eighteen_mth_mother_lice_2:
104
+ eighteen_mth_mother_id: eighteen_mth_mother_2
105
+
106
+ eighteen_mth_mother_saq:
107
+ asq18_address_id: address
108
+ r_p_id: participant
109
+
110
+ eighteen_mth_mother_saq_2:
111
+ r_p_id: participant
112
+ asq18_address_id: address
113
+ home_phone_id: telephone
114
+
115
+ env_equipment_prob_log:
116
+ equip_id: env_equipment
117
+ staff_id_reviewer: staff
118
+
119
+ event:
120
+ participant_id: participant
121
+
122
+ fourteen_mth_asq_saq:
123
+ r_p_id: participant
124
+ asq14_address_id: address
125
+ home_phone_id: telephone
126
+
127
+ household_enumeration_hidden_du:
128
+ hdu_address_id: address
129
+
130
+ incident:
131
+ inc_staff_reporter_id: staff
132
+ inc_staff_supervisor_id: staff
133
+ inc_recip_is_participant: participant
134
+ inc_recip_is_du: dwelling_unit
135
+ inc_recip_is_staff: staff
136
+ inc_recip_is_family: person
137
+ inc_recip_is_acquaintance: person
138
+ inc_contact_person: person
139
+
140
+ itsp_saq:
141
+ r_p_id: participant
142
+
143
+ m_chat_saq:
144
+ r_p_id: participant
145
+
146
+ multi_mode:
147
+ r_p_id: participant
148
+
149
+ nine_mth_mother:
150
+ r_p_id: participant
151
+
152
+ nine_mth_mother_2:
153
+ r_p_id: participant
154
+
155
+ non_interview_respondent:
156
+ r_p_id: participant
157
+
158
+ participant_consent:
159
+ person_who_consented_id: person
160
+ person_wthdrw_consent_id: person
161
+
162
+ participant_consent_reconsideration:
163
+ r_p_id: participant
164
+
165
+ participant_verif:
166
+ r_p_id: participant
167
+ c_address_id: address
168
+ pa_phone_id: telephone
169
+ s_address_id: address
170
+ sa_phone_id: telephone
171
+
172
+ participant_vis_consent:
173
+ vis_person_who_consented_id: person
174
+
175
+ participant_rvis:
176
+ rvis_person: person
177
+
178
+ pb_recruitment:
179
+ address_pb_id: address
180
+
181
+ pb_recruitment_2:
182
+ address_pb_id: address
183
+
184
+ pb_recruitment_info_source:
185
+ pb_recruitment_id: pb_recruitment
186
+
187
+ pb_recruitment_info_source_2:
188
+ pb_recruitment_id: pb_recruitment_2
189
+
190
+ pb_recruitment_prov_source:
191
+ pb_recruitment_id: pb_recruitment
192
+
193
+ pb_recruitment_prov_source_2:
194
+ pb_recruitment_id: pb_recruitment_2
195
+
196
+ pb_recruitment_prov_svc:
197
+ pb_recruitment_id: pb_recruitment
198
+
199
+ pb_recruitment_prov_svc_2:
200
+ pb_recruitment_id: pb_recruitment_2
201
+
202
+ pb_samp_frame:
203
+ practice_address_id: address
204
+ contact_address_id: address
205
+ contact_email_id: email
206
+ contact_phone_num_id: telephone
207
+ contact_address_larger_id: address
208
+ contact_email_larger_id: email
209
+ contact_phone_num_larger_id: telephone
210
+
211
+ pbs_elig_screener:
212
+ r_phone_1_id: telephone
213
+ r_phone_2_id: telephone
214
+ r_email_id: email
215
+
216
+ pbs_elig_screener_pr_office:
217
+ pr_address_id: address
218
+
219
+ person:
220
+ new_address_id: address
221
+
222
+ prec_therm_cert:
223
+ equip_id: env_equipment
224
+
225
+ pre_preg:
226
+ c_addr1_id: address
227
+ c_addr2_id: address
228
+
229
+ preg_screen_eh:
230
+ mail_address_id: address
231
+ new_address_id: address
232
+
233
+ preg_screen_eh_2:
234
+ mail_address_id: address
235
+ new_address_id: address
236
+
237
+ preg_screen_eh_know_ncs:
238
+ ps_eh_id: preg_screen_eh
239
+
240
+ preg_screen_eh_know_ncs_2:
241
+ ps_eh_id: preg_screen_eh_2
242
+
243
+ preg_screen_eh_race:
244
+ ps_eh_id: preg_screen_eh
245
+
246
+ preg_screen_eh_race_2:
247
+ ps_eh_id: preg_screen_eh_2
248
+
249
+ preg_screen_hi:
250
+ mail_address_id: address
251
+ new_address_id: address
252
+
253
+ preg_screen_hi_2:
254
+ mail_address_id: address
255
+ new_address_id: address
256
+
257
+ preg_screen_hi_know_ncs:
258
+ ps_hi_id: preg_screen_hi
259
+
260
+ preg_screen_hi_know_ncs_2:
261
+ ps_hi_id: preg_screen_hi_2
262
+
263
+ preg_screen_hi_race:
264
+ ps_hi_id: preg_screen_hi
265
+
266
+ preg_screen_hi_race_2:
267
+ ps_hi_id: preg_screen_hi_2
268
+
269
+ preg_screen_pb:
270
+ mail_address_id: address
271
+ new_address_id: address
272
+
273
+ preg_screen_pb_2:
274
+ mail_address_id: address
275
+ new_address_id: address
276
+
277
+ preg_screen_pb_know_ncs:
278
+ ps_pb_id: preg_screen_pb
279
+
280
+ preg_screen_pb_know_ncs_2:
281
+ ps_pb_id: preg_screen_pb_2
282
+
283
+ preg_screen_pb_race:
284
+ ps_pb_id: preg_screen_pb
285
+
286
+ preg_screen_pb_race_2:
287
+ ps_pb_id: preg_screen_pb_2
288
+
289
+ preg_visit_1:
290
+ b_address_id: address
291
+ c_addr1_id: address
292
+ c_addr2_id: address
293
+
294
+ preg_visit_1_2:
295
+ b_address_id: address
296
+ c_addr1_id: address
297
+ c_addr2_id: address
298
+
299
+ preg_visit_1_3:
300
+ b_address_id: address
301
+ work_address_id: address
302
+
303
+ preg_visit_1_commute:
304
+ pv1_id: preg_visit_1
305
+
306
+ preg_visit_1_commute_2:
307
+ pv1_id: preg_visit_1_2
308
+
309
+ preg_visit_1_cool:
310
+ pv1_id: preg_visit_1
311
+
312
+ preg_visit_1_cool_2:
313
+ pv1_id: preg_visit_1_2
314
+
315
+ preg_visit_1_diagnose_2:
316
+ pv1_id: preg_visit_1
317
+
318
+ preg_visit_1_diagnose_2_2:
319
+ pv1_id: preg_visit_1_2
320
+
321
+ preg_visit_1_heat2:
322
+ pv1_id: preg_visit_1
323
+
324
+ preg_visit_1_heat2_2:
325
+ pv1_id: preg_visit_1_2
326
+
327
+ preg_visit_1_local_trav:
328
+ pv1_id: preg_visit_1
329
+
330
+ preg_visit_1_local_trav_2:
331
+ pv1_id: preg_visit_1_2
332
+
333
+ preg_visit_1_nonenglish2_2:
334
+ pv1_id: preg_visit_1_2
335
+
336
+ preg_visit_1_pdecorate_room:
337
+ pv1_id: preg_visit_1
338
+
339
+ preg_visit_1_pdecorate_room_2:
340
+ pv1_id: preg_visit_1_2
341
+
342
+ preg_visit_1_pet_type:
343
+ pv1_id: preg_visit_1
344
+
345
+ preg_visit_1_pet_type_2:
346
+ pv1_id: preg_visit_1_2
347
+
348
+ preg_visit_1_prenovate2_room:
349
+ pv1_id: preg_visit_1
350
+
351
+ preg_visit_1_prenovate_room:
352
+ pv1_id: preg_visit_1
353
+
354
+ preg_visit_1_prenovate_room_2:
355
+ pv1_id: preg_visit_1_2
356
+
357
+ preg_visit_1_room_mold:
358
+ pv1_id: preg_visit_1
359
+
360
+ preg_visit_1_room_mold_2:
361
+ pv1_id: preg_visit_1_2
362
+
363
+ preg_visit_1_saq_2:
364
+ f_addr_id: address
365
+
366
+ preg_visit_1_saq_3:
367
+ f_addr_id: address
368
+
369
+ preg_visit_1_saq_4:
370
+ f_addr_id: address
371
+ f_phone_id: telephone
372
+
373
+ preg_visit_1_sp_race:
374
+ pv1_id: preg_visit_1
375
+
376
+ preg_visit_1_sp_race_2:
377
+ pv1_id: preg_visit_1_2
378
+
379
+ preg_visit_2:
380
+ b_address_id: address
381
+ c_addr1_id: address
382
+ c_addr2_id: address
383
+
384
+ preg_visit_2_2:
385
+ b_address_id: address
386
+ c_addr1_id: address
387
+ c_addr2_id: address
388
+
389
+ preg_visit_2_3:
390
+ b_address_id: address
391
+ work_address_id: address
392
+ cwork_address_id: address
393
+
394
+ preg_visit_2_cool:
395
+ pv2_id: preg_visit_2
396
+
397
+ preg_visit_2_cool_2:
398
+ pv2_id: preg_visit_2_2
399
+
400
+ preg_visit_2_diagnose_2:
401
+ pv2_id: preg_visit_2
402
+
403
+ preg_visit_2_diagnose_2_2:
404
+ pv2_id: preg_visit_2_2
405
+
406
+ preg_visit_2_heat2:
407
+ pv2_id: preg_visit_2
408
+
409
+ preg_visit_2_heat2_2:
410
+ pv2_id: preg_visit_2_2
411
+
412
+ preg_visit_2_pdecorate2_room:
413
+ pv2_id: preg_visit_2
414
+
415
+ preg_visit_2_pdecorate2_room_2:
416
+ pv2_id: preg_visit_2_2
417
+
418
+ preg_visit_2_prenovate_room:
419
+ pv2_id: preg_visit_2
420
+
421
+ preg_visit_2_prenovate_room_2:
422
+ pv2_id: preg_visit_2_2
423
+
424
+ preg_visit_2_room_mold:
425
+ pv2_id: preg_visit_2
426
+
427
+ preg_visit_2_room_mold_2:
428
+ pv2_id: preg_visit_2_2
429
+
430
+ preg_visit_li:
431
+ b_address_id: address
432
+
433
+ preg_visit_li_2:
434
+ b_address_id: address
435
+
436
+ preg_visit_li_cool:
437
+ pv_li_id: preg_visit_li
438
+
439
+ preg_visit_li_cool_2:
440
+ pv_li_id: preg_visit_li_2
441
+
442
+ reconsideration_ins:
443
+ r_p_id: participant
444
+
445
+ ref_freezer_verification:
446
+ equip_id: env_equipment
447
+
448
+ sample_receipt_store:
449
+ equip_id: env_equipment
450
+
451
+ sample_shipping:
452
+ staff_id_track: staff
453
+
454
+ six_mth_mother:
455
+ c_addr1_id: address
456
+ c_addr2_id: address
457
+ r_p_id: participant
458
+
459
+ six_mth_mother_2:
460
+ r_p_id: participant
461
+
462
+ six_mth_saq_formula_type:
463
+ six_mth_saq_id: six_mth_saq
464
+
465
+ six_mth_saq_2:
466
+ r_p_id: participant
467
+
468
+ six_mth_saq_3:
469
+ r_p_id: participant
470
+
471
+ six_mth_saq_4:
472
+ r_p_id: participant
473
+
474
+ six_mth_saq_formula_type_2:
475
+ six_mth_saq_id: six_mth_saq_2
476
+
477
+ six_mth_saq_supp:
478
+ six_mth_saq_id: six_mth_saq
479
+
480
+ six_mth_saq_supp_2:
481
+ six_mth_saq_id: six_mth_saq_2
482
+
483
+ six_mth_saq_water:
484
+ six_mth_saq_id: six_mth_saq
485
+
486
+ six_mth_saq_water_2:
487
+ six_mth_saq_id: six_mth_saq_2
488
+
489
+ sixteen_mth_asq_saq:
490
+ r_p_id: participant
491
+ asq16_address_id: address
492
+ home_phone_id: telephone
493
+
494
+ spec_blood:
495
+ # According to the corresponding instrument, equip_id is manually entered
496
+ # and not a reference to another table.
497
+ equip_id: false
498
+
499
+ spec_blood_2:
500
+ # According to the corresponding instrument, equip_id is manually entered
501
+ # and not a reference to another table.
502
+ equip_id: false
503
+
504
+ spec_cord_blood_specimen:
505
+ spec_cord_blood_id: spec_cord_blood
506
+
507
+ spec_cord_blood_specimen_2:
508
+ spec_cord_blood_id: spec_cord_blood_2
509
+
510
+ spec_receipt:
511
+ # Insufficient info to determine what this is supposed to link to
512
+ storage_container_id: false
513
+ equip_id: spec_equipment
514
+
515
+ spec_shipping:
516
+ # Insufficient info to determine what this is supposed to link to
517
+ shipper_id: false
518
+
519
+ spec_storage:
520
+ equip_id: spec_equipment
521
+
522
+ staff_exp_mngmnt_tasks:
523
+ staff_weekly_expense_id: staff_weekly_expense
524
+
525
+ staff_exp_data_cllctn_tasks:
526
+ staff_weekly_expense_id: staff_weekly_expense
527
+
528
+ thirty_month_interview:
529
+ r_p_id: participant
530
+
531
+ thirty_mth_asq_saq:
532
+ r_p_id: participant
533
+ asq30_address_id: address
534
+ home_phone_id: telephone
535
+
536
+ three_mth_mother:
537
+ r_p_id: participant
538
+
539
+ three_mth_mother_2:
540
+ r_p_id: participant
541
+
542
+ three_mth_mother_3:
543
+ r_p_id: participant
544
+
545
+ tracing_int:
546
+ r_p_id: participant
547
+ new_address_id: address
548
+ home_phone_id: telephone
549
+ cell_phone_id: telephone
550
+ c_addr1_id: address
551
+ contact_phone_id: telephone
552
+ contact_phone_2_1_id: telephone
553
+ c_addr2_id: address
554
+ contact_phone_2_id: telephone
555
+ contact_phone_2_2_id: telephone
556
+ c_addr3_id: address
557
+ contact_phone_3_id: telephone
558
+ contact_phone_2_3_id: telephone
559
+
560
+ trh_meter_calibration:
561
+ equip_id: spec_equipment
562
+
563
+ twelve_mth_mother:
564
+ c_addr1_id: address
565
+ c_addr2_id: address
566
+ r_p_id: participant
567
+
568
+ twelve_mth_mother_2:
569
+ r_p_id: participant
570
+ c_addr1_id: address
571
+ c_addr2_id: address
572
+
573
+ twelve_mth_mother_3:
574
+ r_p_id: participant
575
+
576
+ twelve_mth_saq_2:
577
+ r_p_id: participant
578
+
579
+ twelve_mth_saq_3:
580
+ r_p_id: participant
581
+
582
+ twelve_mth_saq_formula_brand:
583
+ twelve_mth_saq_id: twelve_mth_saq
584
+
585
+ twelve_mth_saq_formula_brand_2:
586
+ twelve_mth_saq_id: twelve_mth_saq_2
587
+
588
+ twelve_mth_saq_formula_type:
589
+ twelve_mth_saq_id: twelve_mth_saq
590
+
591
+ twelve_mth_saq_formula_type_2:
592
+ twelve_mth_saq_id: twelve_mth_saq_2
593
+
594
+ twelve_mth_saq_supplement:
595
+ twelve_mth_saq_id: twelve_mth_saq
596
+
597
+ twelve_mth_saq_supplement_2:
598
+ twelve_mth_saq_id: twelve_mth_saq_2
599
+
600
+ twelve_mth_saq_water:
601
+ twelve_mth_saq_id: twelve_mth_saq
602
+
603
+ twelve_mth_saq_water_2:
604
+ twelve_mth_saq_id: twelve_mth_saq_2
605
+
606
+ twenty_four_mth_mother:
607
+ c_addr1_id: address
608
+ c_addr2_id: address
609
+ r_p_id: participant
610
+
611
+ twenty_four_mth_mother_2:
612
+ c_addr1_id: address
613
+ c_addr2_id: address
614
+ r_p_id: participant
615
+
616
+ twenty_four_mth_mother_3:
617
+ r_p_id: participant
618
+ work_address_id: address
619
+ work_address_a_id: address
620
+
621
+ twenty_four_mth_mother_otc:
622
+ twenty_four_mth_mother_id: twenty_four_mth_mother
623
+
624
+ twenty_four_mth_mother_prescr:
625
+ twenty_four_mth_mother_id: twenty_four_mth_mother
626
+
627
+ twenty_four_mth_mother_suppl:
628
+ twenty_four_mth_mother_id: twenty_four_mth_mother
629
+
630
+ twenty_four_mth_saq:
631
+ asq24_address_id: address
632
+ r_p_id: participant
633
+
634
+ twenty_four_mth_saq_2:
635
+ r_p_id: participant
636
+ asq24_address_id: address
637
+ home_phone_id: telephone
638
+
639
+ twenty_mth_asq_saq:
640
+ r_p_id: participant
641
+ asq20_address_id: address
642
+ home_phone_id: telephone
643
+
644
+ twenty_seven_mth_asq_saq:
645
+ r_p_id: participant
646
+ asq27_address_id: address
647
+ home_phone_id: telephone
648
+
649
+ twenty_two_mth_asq_saq:
650
+ r_p_id: participant
651
+ asq22_address_id: address
652
+ home_phone_id: telephone
653
+
654
+ validation_ins_2:
655
+ r_p_id: participant
656
+ phone_nbr_id: telephone
@@ -57,6 +57,8 @@ module NcsNavigator::Mdes
57
57
  create('2.2', '2.2/NCS_Transmission_Schema_2.2.01.01.xsd', '2.2.01.01')
58
58
  when '3.0'
59
59
  create('3.0', '3.0/NCS_Transmission_Schema_3.0.00.09.xsd', '3.0.00.09')
60
+ when '3.1'
61
+ create('3.1', '3.1/NCS_Transmission_Schema_3.1.00.00.xsd', '3.1.00.00')
60
62
  else
61
63
  raise "MDES #{version} is not supported by this version of ncs_mdes"
62
64
  end
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  module Mdes
3
- VERSION = '0.9.0'
3
+ VERSION = '0.10.0'
4
4
  end
5
5
  end