Skip to content

Commit

Permalink
Merge pull request zdavatz#292 from ngiger/master
Browse files Browse the repository at this point in the history
zdavatz#287: Third Workaround for import_bsv
  • Loading branch information
zdavatz authored Dec 7, 2024
2 parents fec709a + 588f84a commit be4b54e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/model/patinfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
require 'model/sequence_observer'
require 'diffy'
require 'util/today'
require 'util/logfile'

module ODDB
class Patinfo
include Persistence
include Language
include SequenceObserver
def same_as?(patinfo)
LogFile.debug("#{self.class}: same_as? called for #{self.odba_id}")
false
end
def article_codes
Expand Down Expand Up @@ -65,6 +67,11 @@ def _sequence_delegate(symbol)
end
class PatinfoDocument
include Persistence
def same_as?(patinfo)
LogFile.debug("#{self.class}: same_as? called for #{self.odba_id}")
false
end

def pointer_descr
'Patinfo'
end
Expand Down
30 changes: 21 additions & 9 deletions src/plugin/bsv_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require 'zip'
require 'plugin/swissindex'
require 'util/mail'
require 'util/logfile'

module ODDB
class BsvXmlPlugin < Plugin
Expand Down Expand Up @@ -243,13 +244,20 @@ def add_bag_composition_to_sequence sequence, substances
end

composition_pointer = sequence.pointer + :bag_composition
comp = if (sequence.bag_compositions.nil? || sequence.bag_compositions.empty?) then @app.create composition_pointer else sequence.bag_compositions[0] end
comp = if (sequence.bag_compositions.nil? || sequence.bag_compositions.empty?)
then @app.create composition_pointer
else sequence.bag_compositions[0]
end
if !sequence.bag_compositions.empty?
first_composition = sequence.bag_compositions[0]
first_composition.active_agents.each do |agent|
first_composition.delete_active_agent(agent)
agent.odba_delete
first_composition.odba_store
if first_composition.respond_to?(:active_agents)
first_composition.active_agents.each do |agent|
first_composition.delete_active_agent(agent)
agent.odba_delete
first_composition.odba_store
end
else
LogFile.debug("what is it? #{self.odba_id} #{self.class} #{sequence.iksnr} first_composition #{first_composition.class} should be a Composition")
end
end

Expand All @@ -259,10 +267,14 @@ def add_bag_composition_to_sequence sequence, substances
sptr = Persistence::Pointer.new :substance
substance = @app.update sptr.creator, :lt => name
end
# TODO: LogFile.debug "#{@iksnr} #{@ikscd} update active_agent, dose, substance"
pointer = comp.pointer + [:active_agent, name]
agent = @app.update pointer.creator, :dose => dose,
:substance => substance.oid
# LogFile.debug "#{@iksnr} #{@ikscd} update active_agent,substance #{name} dose #{dose} comp is #{comp.class}"
if comp.pointer
pointer = comp.pointer + [:active_agent, name]
agent = @app.update pointer.creator, :dose => dose,
:substance => substance.oid
else
LogFile.debug "#{@iksnr} #{@ikscd} is nil: name #{name} dose #{dose}"
end
end
end
def load_ikskey pcode
Expand Down

0 comments on commit be4b54e

Please sign in to comment.