Skip to content

Commit

Permalink
add eligibility_data mapper methods to the processor
Browse files Browse the repository at this point in the history
  • Loading branch information
kholtzman5610 committed Dec 15, 2023
1 parent 819903a commit aa859e2
Show file tree
Hide file tree
Showing 3 changed files with 429 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/models/study_json_record/processor_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,29 @@ def design_data
end

def eligibility_data
return unless protocol_section
nct_id = protocol_section.dig('identificationModule', 'nctId')

eligibility = protocol_section.dig('eligibilityModule')
return unless eligibility

std_ages = eligibility.dig('stdAges')

{
nct_id: nct_id,
sampling_method: eligibility['samplingMethod'],
population: eligibility['studyPopulation'],
maximum_age: eligibility['maximumAge'] || 'N/A',
minimum_age: eligibility['minimumAge'] || 'N/A',
gender: eligibility['sex'],
gender_based: get_boolean(eligibility['genderBased']),
gender_description: eligibility['genderDescription'],
healthy_volunteers: eligibility['healthyVolunteers'],
criteria: eligibility['eligibilityCriteria'],
adult: std_ages.include?('ADULT'),
child: std_ages.include?('CHILD'),
older_adult: std_ages.include?('OLDER_ADULT')
}
end

def participant_flow_data
Expand Down
23 changes: 23 additions & 0 deletions spec/models/study_json_record/processor_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,27 @@
end
end

describe '#eligibility_data' do
it 'should test eligibility_data' do
expected_data = {
nct_id: 'NCT06171568',
sampling_method: 'NON_PROBABILITY_SAMPLE',
population: 'Patients hospitalized at Lariboisière hospital...',
maximum_age: 'N/A',
minimum_age: '18 Years',
gender: 'ALL',
gender_based: nil,
gender_description: nil,
healthy_volunteers: false,
criteria: "Inclusion Criteria:\n\n* Patient over 18 years...",
adult: true,
child: false,
older_adult: true
}

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

0 comments on commit aa859e2

Please sign in to comment.