Skip to content

Commit

Permalink
Created ipd_information_types_data mapper method to the v2 processor …
Browse files Browse the repository at this point in the history
…and added RSpec test case.
  • Loading branch information
Javier-Jimenez-18 committed Dec 14, 2023
1 parent 819903a commit c45b4fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/study_json_record/processor_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 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,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

0 comments on commit c45b4fa

Please sign in to comment.