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