Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/import/brca/core/brca_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# folder = File.expand_path('../', __dir__)
# $LOAD_PATH.unshift(folder) unless $LOAD_PATH.include?(folder)


module Import
module Brca
module Core
Expand All @@ -34,6 +33,8 @@ def load

return load_manchester(tables) if 'R0A' == @batch.provider

return load_salisbury(tables) if 'RNZ' == @batch.provider

# Enumerate over the tables
# Under normal circustances, there will only be one table
tables.each do |_tablename, table_content|
Expand Down Expand Up @@ -63,6 +64,27 @@ def load_manchester(tables)
end
end

def load_salisbury(tables)
tables.each do |_tablename, table_content|
mapped_table = table_mapping.transform(table_content)
grouped_records_by_linkage = mapped_table.to_a[1..-1].group_by do |_klass, fields, _i|
grouping = fields.values_at('pseudo_id1', 'pseudo_id2')
rawtext = JSON.parse(fields['rawtext_clinical.to_json'])
grouping << rawtext['servicereportidentifier']
grouping << rawtext['moleculartestingtype']
grouping << rawtext['authoriseddate']
grouping
end

cleaned_records = []
# From each set of grouped records, build a normalised record
grouped_records_by_linkage.each do |_linkage, records|
cleaned_records << [records.first.first, grouped_rawtext_record_from(records)]
end
cleaned_records.each { |klass, fields| build_and_process_records(klass, fields) }
end
end

private

# `records` is an array of many [klass, fields, index]
Expand Down
Loading
Loading