Skip to content

Commit

Permalink
AACT-611 add design_data mapper methods to the processor
Browse files Browse the repository at this point in the history
  • Loading branch information
kholtzman5610 committed Dec 8, 2023
1 parent 56f850c commit f9c999b
Show file tree
Hide file tree
Showing 3 changed files with 436 additions and 3 deletions.
59 changes: 59 additions & 0 deletions app/models/study_json_record/processor_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,65 @@ def brief_summary_data
end

def design_data
return unless protocol_section
nct_id = protocol_section.dig('identificationModule', 'nctId')
puts "NCT ID: #{nct_id}"

info = protocol_section.dig('designModule', 'designInfo')
return unless info

masking = key_check(info['maskingInfo'])
who_masked = masking.dig('whoMasked') || []
observations = info.dig('observationalModel') || []
time_perspectives = info.dig('timePerspective') || []

masking_value = masking['masking']

masking_description = case masking_value
when 'NONE'
'None (Open Label)'
when 'SINGLE'
'Single'
when 'DOUBLE'
'Double'
when 'TRIPLE'
'Triple'
when 'QUADRUPLE'
'Quadruple'
else
'Unknown'
end

{
nct_id: nct_id,
allocation: info['allocation'],
observational_model: observations.join(', '),
intervention_model: info['interventionModel'],
intervention_model_description: info['interventionModelDescription'],
primary_purpose: info['primaryPurpose'],
time_perspective: time_perspectives.join(', '),
masking: masking_value,
masking_description: masking_description,
subject_masked: is_masked?(who_masked, ['PARTICIPANT']),
caregiver_masked: is_masked?(who_masked, ['CARE_PROVIDER']),
investigator_masked: is_masked?(who_masked, ['INVESTIGATOR']),
outcomes_assessor_masked: is_masked?(who_masked, ['OUTCOMES_ASSESSOR']),
}
end

def key_check(key)
key ||= {}
end


def is_masked?(who_masked_array, query_array)
# example who_masked array ["PARTICIPANT", "CARE_PROVIDER", "INVESTIGATOR", "OUTCOMES_ASSESSOR"]
return unless query_array

query_array.each do |term|
return true if who_masked_array.try(:include?, term)
end
nil
end

def eligibility_data
Expand Down
27 changes: 24 additions & 3 deletions spec/models/study_json_record/processor_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@
processor = StudyJsonRecord::ProcessorV2.new(hash)
expect(processor.brief_summary_data).to eq(expected_data)
end
end



describe 'design_data' do
it 'should test design_data' do
expected_data = {
nct_id: 'NCT03418623',
allocation: 'RANDOMIZED',
intervention_model: 'CROSSOVER',
observational_model: '',
primary_purpose: 'BASIC_SCIENCE',
time_perspective: '',
masking: 'QUADRUPLE',
masking_description: 'Quadruple',
intervention_model_description: 'After the eligibility of a subject has been determined in an initial...',
subject_masked: true,
caregiver_masked: true,
investigator_masked: true,
outcomes_assessor_masked: true
}

hash = JSON.parse(File.read('spec/support/json_data/NCT03418623.json'))
processor = StudyJsonRecord::ProcessorV2.new(hash)
expect(processor.design_data).to eq(expected_data)
end
end
end
end
Loading

0 comments on commit f9c999b

Please sign in to comment.