ncs_mdes 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +7 -1
- data/HEURISTICS.md +111 -0
- data/bin/mdes-console +2 -0
- data/documents/2.1/NCS_Transmission_Schema_2.1.00.00.xsd +27737 -0
- data/documents/2.1/disposition_codes.yml +1758 -0
- data/documents/2.1/extract_disposition_codes.rb +56 -0
- data/documents/2.1/heuristic_overrides.yml +417 -0
- data/documents/2.2/NCS_Transmission_Schema_2.2.01.00.xsd +51765 -0
- data/documents/2.2/disposition_codes.yml +1758 -0
- data/documents/2.2/extract_disposition_codes.rb +57 -0
- data/documents/2.2/heuristic_overrides.yml +452 -0
- data/lib/ncs_navigator/mdes/source_documents.rb +4 -0
- data/lib/ncs_navigator/mdes/specification.rb +1 -1
- data/lib/ncs_navigator/mdes/variable.rb +6 -4
- data/lib/ncs_navigator/mdes/version.rb +1 -1
- data/spec/ncs_navigator/mdes/source_documents_spec.rb +41 -17
- data/spec/ncs_navigator/mdes/specification_spec.rb +65 -20
- data/spec/ncs_navigator/mdes/variable_spec.rb +5 -4
- metadata +32 -23
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
##
|
4
|
+
# A script to generate disposition_codes.yml from the MDES 2.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 'roo'
|
12
|
+
require 'yaml'
|
13
|
+
|
14
|
+
MDES_XLSX = ARGV.first or fail 'Please provide the path to the MDES spreadsheet'
|
15
|
+
TARGET = File.expand_path('../disposition_codes.yml', __FILE__)
|
16
|
+
SHEET_NAME = 'Dispositions'
|
17
|
+
|
18
|
+
MAPPED_COLUMNS = {
|
19
|
+
'A' => 'final_category',
|
20
|
+
'B' => 'sub_category',
|
21
|
+
'C' => 'disposition'
|
22
|
+
}
|
23
|
+
|
24
|
+
def normalize_whitespace(s)
|
25
|
+
s.strip.gsub(/\s+/, " ")
|
26
|
+
end
|
27
|
+
|
28
|
+
book = Excelx.new(MDES_XLSX)
|
29
|
+
|
30
|
+
# This is the array of hashes that will eventually be serialized to
|
31
|
+
# disposition_codes.yml.
|
32
|
+
dispositions = []
|
33
|
+
|
34
|
+
current_event = nil
|
35
|
+
current_category_code = nil
|
36
|
+
1.upto(book.last_row(SHEET_NAME)) do |row_number|
|
37
|
+
a, b = %w(A B).collect { |col| book.cell(row_number, col, SHEET_NAME) }
|
38
|
+
if a =~ /Category\s+(\d)\s+\((.*?)\)\s+Disposition\s+Codes/
|
39
|
+
current_event = normalize_whitespace $2
|
40
|
+
current_category_code = $1.to_i
|
41
|
+
puts "Collecting for category #{current_event} (#{current_category_code})"
|
42
|
+
elsif b =~ /\S/ && a !~ /FINAL/
|
43
|
+
disposition_hash = MAPPED_COLUMNS.inject({}) do |h, (col, key)|
|
44
|
+
h[key] = normalize_whitespace(book.cell(row_number, col, SHEET_NAME)); h
|
45
|
+
end
|
46
|
+
disposition_hash['event'] = current_event
|
47
|
+
disposition_hash['category_code'] = current_category_code
|
48
|
+
disposition_hash['interim_code'], disposition_hash['final_code'] =
|
49
|
+
normalize_whitespace(book.cell(row_number, 'D', SHEET_NAME)).split('/')
|
50
|
+
|
51
|
+
puts disposition_hash.inspect if disposition_hash['interim_code'] =~ /^02/
|
52
|
+
dispositions << disposition_hash
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
File.open(TARGET, 'w') { |f| f.write dispositions.to_yaml }
|
@@ -0,0 +1,417 @@
|
|
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_baby_name:
|
13
|
+
bv_id: birth_visit
|
14
|
+
|
15
|
+
birth_visit_baby_name_2:
|
16
|
+
bv_id: birth_visit_2
|
17
|
+
|
18
|
+
birth_visit_decorate_room:
|
19
|
+
bv_id: birth_visit
|
20
|
+
|
21
|
+
birth_visit_decorate_room_2:
|
22
|
+
bv_id: birth_visit_2
|
23
|
+
|
24
|
+
birth_visit_li:
|
25
|
+
new_address_id: address
|
26
|
+
mail_address_id: address
|
27
|
+
new_address_b_id: address
|
28
|
+
|
29
|
+
birth_visit_renovate_room:
|
30
|
+
bv_id: birth_visit
|
31
|
+
|
32
|
+
birth_visit_renovate_room_2:
|
33
|
+
bv_id: birth_visit_2
|
34
|
+
|
35
|
+
drf_therm_verification:
|
36
|
+
equip_id: env_equipment
|
37
|
+
|
38
|
+
eighteen_mth_mother:
|
39
|
+
c_addr1_id: address
|
40
|
+
c_addr2_id: address
|
41
|
+
|
42
|
+
eighteen_mth_mother_cond:
|
43
|
+
eighteen_mth_habits_id: eighteen_mth_mother_habits
|
44
|
+
|
45
|
+
eighteen_mth_mother_saq:
|
46
|
+
asq18_address_id: address
|
47
|
+
|
48
|
+
env_equipment_prob_log:
|
49
|
+
equip_id: env_equipment
|
50
|
+
staff_id_reviewer: staff
|
51
|
+
|
52
|
+
event:
|
53
|
+
participant_id: participant
|
54
|
+
|
55
|
+
household_enumeration_hidden_du:
|
56
|
+
hdu_address_id: address
|
57
|
+
|
58
|
+
incident:
|
59
|
+
inc_staff_reporter_id: staff
|
60
|
+
inc_staff_supervisor_id: staff
|
61
|
+
inc_recip_is_participant: participant
|
62
|
+
inc_recip_is_du: dwelling_unit
|
63
|
+
inc_recip_is_staff: staff
|
64
|
+
inc_recip_is_family: person
|
65
|
+
inc_recip_is_acquaintance: person
|
66
|
+
inc_contact_person: person
|
67
|
+
|
68
|
+
participant_consent:
|
69
|
+
person_who_consented_id: person
|
70
|
+
person_wthdrw_consent_id: person
|
71
|
+
|
72
|
+
participant_vis_consent:
|
73
|
+
vis_person_who_consented_id: person
|
74
|
+
|
75
|
+
participant_rvis:
|
76
|
+
rvis_person: person
|
77
|
+
|
78
|
+
pb_recruitment:
|
79
|
+
address_pb_id: address
|
80
|
+
|
81
|
+
pb_recruitment_2:
|
82
|
+
address_pb_id: address
|
83
|
+
|
84
|
+
pb_recruitment_info_source:
|
85
|
+
pb_recruitment_id: pb_recruitment
|
86
|
+
|
87
|
+
pb_recruitment_info_source_2:
|
88
|
+
pb_recruitment_id: pb_recruitment_2
|
89
|
+
|
90
|
+
pb_recruitment_prov_source:
|
91
|
+
pb_recruitment_id: pb_recruitment
|
92
|
+
|
93
|
+
pb_recruitment_prov_source_2:
|
94
|
+
pb_recruitment_id: pb_recruitment_2
|
95
|
+
|
96
|
+
pb_recruitment_prov_svc:
|
97
|
+
pb_recruitment_id: pb_recruitment
|
98
|
+
|
99
|
+
pb_recruitment_prov_svc_2:
|
100
|
+
pb_recruitment_id: pb_recruitment_2
|
101
|
+
|
102
|
+
person:
|
103
|
+
new_address_id: address
|
104
|
+
|
105
|
+
prec_therm_cert:
|
106
|
+
equip_id: env_equipment
|
107
|
+
|
108
|
+
pre_preg:
|
109
|
+
c_addr1_id: address
|
110
|
+
c_addr2_id: address
|
111
|
+
|
112
|
+
preg_screen_eh:
|
113
|
+
mail_address_id: address
|
114
|
+
new_address_id: address
|
115
|
+
|
116
|
+
preg_screen_eh_2:
|
117
|
+
mail_address_id: address
|
118
|
+
new_address_id: address
|
119
|
+
|
120
|
+
preg_screen_eh_know_ncs:
|
121
|
+
ps_eh_id: preg_screen_eh
|
122
|
+
|
123
|
+
preg_screen_eh_know_ncs_2:
|
124
|
+
ps_eh_id: preg_screen_eh_2
|
125
|
+
|
126
|
+
preg_screen_eh_race:
|
127
|
+
ps_eh_id: preg_screen_eh
|
128
|
+
|
129
|
+
preg_screen_eh_race_2:
|
130
|
+
ps_eh_id: preg_screen_eh_2
|
131
|
+
|
132
|
+
preg_screen_hi:
|
133
|
+
mail_address_id: address
|
134
|
+
new_address_id: address
|
135
|
+
|
136
|
+
preg_screen_hi_2:
|
137
|
+
mail_address_id: address
|
138
|
+
new_address_id: address
|
139
|
+
|
140
|
+
preg_screen_hi_know_ncs:
|
141
|
+
ps_hi_id: preg_screen_hi
|
142
|
+
|
143
|
+
preg_screen_hi_know_ncs_2:
|
144
|
+
ps_hi_id: preg_screen_hi_2
|
145
|
+
|
146
|
+
preg_screen_hi_race:
|
147
|
+
ps_hi_id: preg_screen_hi
|
148
|
+
|
149
|
+
preg_screen_hi_race_2:
|
150
|
+
ps_hi_id: preg_screen_hi_2
|
151
|
+
|
152
|
+
preg_screen_pb:
|
153
|
+
mail_address_id: address
|
154
|
+
new_address_id: address
|
155
|
+
|
156
|
+
preg_screen_pb_2:
|
157
|
+
mail_address_id: address
|
158
|
+
new_address_id: address
|
159
|
+
|
160
|
+
preg_screen_pb_know_ncs:
|
161
|
+
ps_pb_id: preg_screen_pb
|
162
|
+
|
163
|
+
preg_screen_pb_know_ncs_2:
|
164
|
+
ps_pb_id: preg_screen_pb_2
|
165
|
+
|
166
|
+
preg_screen_pb_race:
|
167
|
+
ps_pb_id: preg_screen_pb
|
168
|
+
|
169
|
+
preg_screen_pb_race_2:
|
170
|
+
ps_pb_id: preg_screen_pb_2
|
171
|
+
|
172
|
+
preg_visit_1:
|
173
|
+
b_address_id: address
|
174
|
+
c_addr1_id: address
|
175
|
+
c_addr2_id: address
|
176
|
+
|
177
|
+
preg_visit_1_2:
|
178
|
+
b_address_id: address
|
179
|
+
c_addr1_id: address
|
180
|
+
c_addr2_id: address
|
181
|
+
|
182
|
+
preg_visit_1_commute:
|
183
|
+
pv1_id: preg_visit_1
|
184
|
+
|
185
|
+
preg_visit_1_commute_2:
|
186
|
+
pv1_id: preg_visit_1_2
|
187
|
+
|
188
|
+
preg_visit_1_cool:
|
189
|
+
pv1_id: preg_visit_1
|
190
|
+
|
191
|
+
preg_visit_1_cool_2:
|
192
|
+
pv1_id: preg_visit_1_2
|
193
|
+
|
194
|
+
preg_visit_1_diagnose_2:
|
195
|
+
pv1_id: preg_visit_1
|
196
|
+
|
197
|
+
preg_visit_1_diagnose_2_2:
|
198
|
+
pv1_id: preg_visit_1_2
|
199
|
+
|
200
|
+
preg_visit_1_heat2:
|
201
|
+
pv1_id: preg_visit_1
|
202
|
+
|
203
|
+
preg_visit_1_heat2_2:
|
204
|
+
pv1_id: preg_visit_2
|
205
|
+
|
206
|
+
preg_visit_1_local_trav:
|
207
|
+
pv1_id: preg_visit_1
|
208
|
+
|
209
|
+
preg_visit_1_local_trav_2:
|
210
|
+
pv1_id: preg_visit_1_2
|
211
|
+
|
212
|
+
preg_visit_1_nonenglish2_2:
|
213
|
+
pv1_id: preg_visit_1_2
|
214
|
+
|
215
|
+
preg_visit_1_pdecorate_room:
|
216
|
+
pv1_id: preg_visit_1
|
217
|
+
|
218
|
+
preg_visit_1_pdecorate_room_2:
|
219
|
+
pv1_id: preg_visit_1_2
|
220
|
+
|
221
|
+
preg_visit_1_pet_type:
|
222
|
+
pv1_id: preg_visit_1
|
223
|
+
|
224
|
+
preg_visit_1_pet_type_2:
|
225
|
+
pv1_id: preg_visit_1_2
|
226
|
+
|
227
|
+
preg_visit_1_prenovate2_room:
|
228
|
+
pv1_id: preg_visit_1
|
229
|
+
|
230
|
+
preg_visit_1_prenovate_room:
|
231
|
+
pv1_id: preg_visit_1
|
232
|
+
|
233
|
+
preg_visit_1_prenovate_room_2:
|
234
|
+
pv1_id: preg_visit_1_2
|
235
|
+
|
236
|
+
preg_visit_1_room_mold:
|
237
|
+
pv1_id: preg_visit_1
|
238
|
+
|
239
|
+
preg_visit_1_room_mold_2:
|
240
|
+
pv1_id: preg_visit_1_2
|
241
|
+
|
242
|
+
preg_visit_1_saq_2:
|
243
|
+
f_addr_id: address
|
244
|
+
|
245
|
+
preg_visit_1_saq_3:
|
246
|
+
f_addr_id: address
|
247
|
+
|
248
|
+
preg_visit_1_sp_race:
|
249
|
+
pv1_id: preg_visit_1
|
250
|
+
|
251
|
+
preg_visit_1_sp_race_2:
|
252
|
+
pv1_id: preg_visit_1_2
|
253
|
+
|
254
|
+
preg_visit_2:
|
255
|
+
b_address_id: address
|
256
|
+
c_addr1_id: address
|
257
|
+
c_addr2_id: address
|
258
|
+
|
259
|
+
preg_visit_2_2:
|
260
|
+
b_address_id: address
|
261
|
+
c_addr1_id: address
|
262
|
+
c_addr2_id: address
|
263
|
+
|
264
|
+
preg_visit_2_cool:
|
265
|
+
pv2_id: preg_visit_2
|
266
|
+
|
267
|
+
preg_visit_2_cool_2:
|
268
|
+
pv2_id: preg_visit_2_2
|
269
|
+
|
270
|
+
preg_visit_2_diagnose_2:
|
271
|
+
pv2_id: preg_visit_2
|
272
|
+
|
273
|
+
preg_visit_2_diagnose_2_2:
|
274
|
+
pv2_id: preg_visit_2_2
|
275
|
+
|
276
|
+
preg_visit_2_heat2:
|
277
|
+
pv2_id: preg_visit_2
|
278
|
+
|
279
|
+
preg_visit_2_heat2_2:
|
280
|
+
pv2_id: preg_visit_2_2
|
281
|
+
|
282
|
+
preg_visit_2_pdecorate2_room:
|
283
|
+
pv2_id: preg_visit_2
|
284
|
+
|
285
|
+
preg_visit_2_pdecorate2_room_2:
|
286
|
+
pv2_id: preg_visit_2_2
|
287
|
+
|
288
|
+
preg_visit_2_prenovate_room:
|
289
|
+
pv2_id: preg_visit_2
|
290
|
+
|
291
|
+
preg_visit_2_prenovate_room_2:
|
292
|
+
pv2_id: preg_visit_2_2
|
293
|
+
|
294
|
+
preg_visit_2_room_mold:
|
295
|
+
pv2_id: preg_visit_2
|
296
|
+
|
297
|
+
preg_visit_2_room_mold_2:
|
298
|
+
pv2_id: preg_visit_2_2
|
299
|
+
|
300
|
+
preg_visit_li:
|
301
|
+
b_address_id: address
|
302
|
+
|
303
|
+
preg_visit_li_2:
|
304
|
+
b_address_id: address
|
305
|
+
|
306
|
+
preg_visit_li_cool:
|
307
|
+
pv_li_id: preg_visit_li
|
308
|
+
|
309
|
+
preg_visit_li_cool_2:
|
310
|
+
pv_li_id: preg_visit_li_2
|
311
|
+
|
312
|
+
ref_freezer_verification:
|
313
|
+
equip_id: env_equipment
|
314
|
+
|
315
|
+
sample_receipt_store:
|
316
|
+
equip_id: env_equipment
|
317
|
+
|
318
|
+
sample_shipping:
|
319
|
+
staff_id_track: staff
|
320
|
+
|
321
|
+
six_mth_mother:
|
322
|
+
c_addr1_id: address
|
323
|
+
c_addr2_id: address
|
324
|
+
|
325
|
+
six_mth_saq_formula_type:
|
326
|
+
six_mth_saq_id: six_mth_saq
|
327
|
+
|
328
|
+
six_mth_saq_formula_type_2:
|
329
|
+
six_mth_saq_id: six_mth_saq_2
|
330
|
+
|
331
|
+
six_mth_saq_supp:
|
332
|
+
six_mth_saq_id: six_mth_saq
|
333
|
+
|
334
|
+
six_mth_saq_supp_2:
|
335
|
+
six_mth_saq_id: six_mth_saq_2
|
336
|
+
|
337
|
+
six_mth_saq_water:
|
338
|
+
six_mth_saq_id: six_mth_saq
|
339
|
+
|
340
|
+
six_mth_saq_water_2:
|
341
|
+
six_mth_saq_id: six_mth_saq_2
|
342
|
+
|
343
|
+
spec_blood:
|
344
|
+
# According to the corresponding instrument, equip_id is manually entered and
|
345
|
+
# not a reference to another table.
|
346
|
+
equip_id: false
|
347
|
+
|
348
|
+
spec_cord_blood_specimen:
|
349
|
+
spec_cord_blood_id: spec_cord_blood
|
350
|
+
|
351
|
+
spec_cord_blood_specimen_2:
|
352
|
+
spec_cord_blood_id: spec_cord_blood_2
|
353
|
+
|
354
|
+
spec_receipt:
|
355
|
+
# Insufficient info to determine what this is supposed to link to
|
356
|
+
storage_container_id: false
|
357
|
+
equip_id: spec_equipment
|
358
|
+
|
359
|
+
spec_shipping:
|
360
|
+
# Insufficient info to determine what this is supposed to link to
|
361
|
+
shipper_id: false
|
362
|
+
|
363
|
+
spec_storage:
|
364
|
+
equip_id: spec_equipment
|
365
|
+
|
366
|
+
staff_exp_mngmnt_tasks:
|
367
|
+
staff_weekly_expense_id: staff_weekly_expense
|
368
|
+
|
369
|
+
staff_exp_data_cllctn_tasks:
|
370
|
+
staff_weekly_expense_id: staff_weekly_expense
|
371
|
+
|
372
|
+
trh_meter_calibration:
|
373
|
+
equip_id: spec_equipment
|
374
|
+
|
375
|
+
twelve_mth_mother:
|
376
|
+
c_addr1_id: address
|
377
|
+
c_addr2_id: address
|
378
|
+
|
379
|
+
twelve_mth_saq_formula_brand:
|
380
|
+
twelve_mth_saq_id: twelve_mth_saq
|
381
|
+
|
382
|
+
twelve_mth_saq_formula_brand_2:
|
383
|
+
twelve_mth_saq_id: twelve_mth_saq_2
|
384
|
+
|
385
|
+
twelve_mth_saq_formula_type:
|
386
|
+
twelve_mth_saq_id: twelve_mth_saq
|
387
|
+
|
388
|
+
twelve_mth_saq_formula_type_2:
|
389
|
+
twelve_mth_saq_id: twelve_mth_saq_2
|
390
|
+
|
391
|
+
twelve_mth_saq_supplement:
|
392
|
+
twelve_mth_saq_id: twelve_mth_saq
|
393
|
+
|
394
|
+
twelve_mth_saq_supplement_2:
|
395
|
+
twelve_mth_saq_id: twelve_mth_saq_2
|
396
|
+
|
397
|
+
twelve_mth_saq_water:
|
398
|
+
twelve_mth_saq_id: twelve_mth_saq
|
399
|
+
|
400
|
+
twelve_mth_saq_water_2:
|
401
|
+
twelve_mth_saq_id: twelve_mth_saq_2
|
402
|
+
|
403
|
+
twenty_four_mth_mother:
|
404
|
+
c_addr1_id: address
|
405
|
+
c_addr2_id: address
|
406
|
+
|
407
|
+
twenty_four_mth_mother_otc:
|
408
|
+
twenty_four_mth_mother_id: twenty_four_mth_mother
|
409
|
+
|
410
|
+
twenty_four_mth_mother_prescr:
|
411
|
+
twenty_four_mth_mother_id: twenty_four_mth_mother
|
412
|
+
|
413
|
+
twenty_four_mth_mother_suppl:
|
414
|
+
twenty_four_mth_mother_id: twenty_four_mth_mother
|
415
|
+
|
416
|
+
twenty_four_mth_saq:
|
417
|
+
asq24_address_id: address
|