Skip to content

Commit

Permalink
Merge pull request #1118 from ctti-clinicaltrials/feat/AACT-622-creat…
Browse files Browse the repository at this point in the history
…e_ipd_information_types_data_method_in_v2_processor

AACT-622: Create ipd_information_types_data mapper method in the v2 processor
  • Loading branch information
micronix authored Dec 21, 2023
2 parents cb71a49 + 97f51da commit 16fba11
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/models/study_json_record/processor_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ 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

collection = []
ipd_sharing_info_types.each do |info|
collection << { nct_id: nct_id, name: info }
end

collection
end

def keywords_data
Expand Down
13 changes: 13 additions & 0 deletions spec/models/study_json_record/processor_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,17 @@
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" },
{ nct_id: "NCT03630471", name: "SAP" },
{ nct_id: "NCT03630471", name: "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

0 comments on commit 16fba11

Please sign in to comment.