diff --git a/app/models/study_json_record/processor_v2.rb b/app/models/study_json_record/processor_v2.rb index 0b32e2d5..a14aeda0 100644 --- a/app/models/study_json_record/processor_v2.rb +++ b/app/models/study_json_record/processor_v2.rb @@ -227,6 +227,13 @@ def id_information_data end def ipd_information_types_data + return unless protocol_section + + nct_id = protocol_section.dig('identificationModule', 'nctId') + ipd_sharing_info_types = protocol_section.dig('ipdSharingStatementModule', 'infoTypes') + return unless ipd_sharing_info_types + + { nct_id: nct_id, name: ipd_sharing_info_types } end def keywords_data diff --git a/spec/models/study_json_record/processor_v2_spec.rb b/spec/models/study_json_record/processor_v2_spec.rb index 8f1280a9..1303ffc9 100644 --- a/spec/models/study_json_record/processor_v2_spec.rb +++ b/spec/models/study_json_record/processor_v2_spec.rb @@ -329,4 +329,20 @@ end end + describe '#ipd_information_types_data' do + it 'should use JSON API to generate data that will be inserted into the ipd information types table' do + expected_data = { + nct_id: "NCT03630471", + name: [ + "STUDY_PROTOCOL", + "SAP", + "ICF" + ] + } + hash = JSON.parse(File.read('spec/support/json_data/NCT03630471.json')) + processor = StudyJsonRecord::ProcessorV2.new(hash) + expect(processor.ipd_information_types_data).to eq(expected_data) + end + end + end \ No newline at end of file