<< | Index | >>
suspend
masa@masa ~/ywesee/oddb.org $ ruby test/suite.rb ... 1006 tests, 2351 assertions, 7 failures, 43 errors
Note
Error: NoMethodError Message: undefined method `qty' for nil:NilClass Backtrace: (druby://localhost:10005) /var/www/oddb.org/ext/export/src/oddbdat.rb:408:in `structure' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/oddbdat.rb:269:in `initialize' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/oddbdat.rb:292:in `initialize' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/oddbdat.rb:53:in `new' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/oddbdat.rb:53:in `lines' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/odba_exporter.rb:175:in `export_oddbdat' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/odba_exporter.rb:174:in `each' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/odba_exporter.rb:174:in `export_oddbdat' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/odba_exporter.rb:172:in `each' (druby://localhost:10005) /var/www/oddb.org/ext/export/src/odba_exporter.rb:172:in `export_oddbdat' /var/www/oddb.org/src/plugin/oddbdat_export.rb:51:in `export' /var/www/oddb.org/src/util/exporter.rb:152:in `export_oddbdat' /var/www/oddb.org/src/util/exporter.rb:289:in `call' /var/www/oddb.org/src/util/exporter.rb:289:in `safe_export' /var/www/oddb.org/src/util/exporter.rb:150:in `export_oddbdat' /var/www/oddb.org/src/util/exporter.rb:51:in `run' /var/www/oddb.org/jobs/export_daily:13 /var/www/oddb.org/src/util/job.rb:17:in `call' /var/www/oddb.org/src/util/job.rb:17:in `run' /var/www/oddb.org/jobs/export_daily:12
Confirm the same error in local
Run
Run export_oddbdat
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Exporter.new(self).export_oddbdat
Result
Error: NoMethodError Message: undefined method `qty' for nil:NilClass Backtrace: (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:408:in `structure' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:269:in `initialize' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:292:in `initialize' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `new' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `lines' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:175:in `export_oddbdat' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:174:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:174:in `export_oddbdat' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:172:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:172:in `export_oddbdat' /home/masa/ywesee/oddb.org/src/plugin/oddbdat_export.rb:51:in `export' /home/masa/ywesee/oddb.org/src/util/exporter.rb:153:in `export_oddbdat' /home/masa/ywesee/oddb.org/src/util/exporter.rb:297:in `call' /home/masa/ywesee/oddb.org/src/util/exporter.rb:297:in `safe_export' /home/masa/ywesee/oddb.org/src/util/exporter.rb:149:in `export_oddbdat' (eval):1:in `_admin' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1399:in `_admin' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `initialize' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `new' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `_admin' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/oddbd:38
Note
Next
Experiment
src/plugin/oddbdat_export.rb#export
def export files = [] p "A" # package tables package_tables = [ AcTable, AccompTable, AcLimTable, AcmedTable, AcnamTable, AcOddbTable, AcpricealgTable, AcscTable, LimitationTable, LimTxtTable, EanTable ] ids = [] @app.each_package { |pac| ids.push(pac.odba_id) } p "A2" files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, package_tables) p "B" # codes table ids = @app.atc_classes.values.collect { |atc| atc.odba_id } p "B2" @app.each_galenic_form { |galform| ids.push(galform.odba_id) } p "B3" files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CodesTable]) p "C" # substances table ids = @app.substances.collect { |subs| subs.odba_id } p "C2" files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [ScTable]) p "D" # companies table ids = @app.companies.collect { |oid, comp| comp.odba_id } p "D2" files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CompTable]) p "E" # readme files += EXPORT_SERVER.export_oddbdat(nil, EXPORT_DIR, [Readme]) p "F" # compress EXPORT_SERVER.compress_many(EXPORT_DIR, 'oddbdat', files) end
Run again
Result
"getin export_oddbdat" "1" "2" "A" "A2"
Note
files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, package_tables)
Next
Experiment
ext/export/src/odba_exporter.rb#export_oddbdat
def OdbaExporter.export_oddbdat(odba_ids, dir, klasses) FileUtils.mkdir_p(dir) p "AA" files = klasses.collect { |klass| table = klass.new file = Tempfile.new(table.filename, dir) [file, table] } p "BB" if(odba_ids.nil?) p "CC" files.each { |file, table| file.puts table.lines } else p "DD" odba_ids.each { |odba_id| item = ODBA.cache.fetch(odba_id, nil) files.each { |file, table| file.puts table.lines(item) } #ODBA.cache.clear } end p "EE" files.each { |file, table| path = File.join(dir, table.filename) FileUtils.mv(file.path, path) } p "FF" files.collect { |file, table| table.filename } ensure if(files) files.each { |file, table| file.close! } end end
Run again
Result
"AA" "BB" "DD"
Next ext/export/src/odba_exporter.rb#export_oddbdat
def OdbaExporter.export_oddbdat(odba_ids, dir, klasses) FileUtils.mkdir_p(dir) p "AA" files = klasses.collect { |klass| table = klass.new file = Tempfile.new(table.filename, dir) [file, table] } p "BB" if(odba_ids.nil?) p "CC" files.each { |file, table| file.puts table.lines } else p "DD" odba_ids.each { |odba_id| print "odba_id=" p odba_id item = ODBA.cache.fetch(odba_id, nil) files.each { |file, table| print "file=" p file print "table.class=" p table.class file.puts table.lines(item) } #ODBA.cache.clear } end p "EE" files.each { |file, table| path = File.join(dir, table.filename) FileUtils.mv(file.path, path) } p "FF" files.collect { |file, table| table.filename } ensure if(files) files.each { |file, table| file.close! } end end
Result
... odba_id=218092 file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s01x.4036.0> table.class=ODDB::OdbaExporter::AcTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s19x.4036.0> table.class=ODDB::OdbaExporter::AccompTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s09x.4036.0> table.class=ODDB::OdbaExporter::AcLimTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s02x.4036.0> table.class=ODDB::OdbaExporter::AcmedTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s03x.4036.0> table.class=ODDB::OdbaExporter::AcnamTable
Keep in mind
Next
class AcnamTable < Table FILENAME = 's03x' def lines(package) [AcnamLine.new(package)] end end
Note
Next
class AcnamLine < PackageLine ...
Next
class PackageLine < Line def initialize(package, *args) @package = package super end end
Next
class Line def initialize(*args) @date = Date.today.strftime("%Y%m%d%H%M%S") @structure = structure end
Next
ext/export/src/oddbdat.rb::AcnamLine#structure
class AcnamLine < PackageLine LENGTH = 26 def structure seq = @package.sequence galform = if(gf = seq.galenic_forms.first) gf.to_s end conc, unit = if((dose = seq.dose) && dose.is_a?(Quanty)) [dose.qty, dose.unit] end measures = @package.parts.collect { |part| part.measure }.compact measure, munit = unless(measures.empty?) ms = measures.inject { |a, b| a + b } [ms.qty, ms.unit] if ms.is_a?(Quanty) end comform = @package.commercial_forms.first qty, qty_unit = if(munit && !munit.empty?) [measure, munit] else [@package.comparable_size.qty, comform] # <= HERE end
Note
Experiment ext/export/src/oddbdat.rb::AcnamLine#structure
class AcnamLine < PackageLine LENGTH = 26 def structure seq = @package.sequence galform = if(gf = seq.galenic_forms.first) gf.to_s end conc, unit = if((dose = seq.dose) && dose.is_a?(Quanty)) [dose.qty, dose.unit] end measures = @package.parts.collect { |part| part.measure }.compact measure, munit = unless(measures.empty?) ms = measures.inject { |a, b| a + b } [ms.qty, ms.unit] if ms.is_a?(Quanty) end comform = @package.commercial_forms.first qty, qty_unit = if(munit && !munit.empty?) [measure, munit] else [@package.comparable_size.qty, comform] # <= HERE end
Experiment
class AcnamLine < PackageLine LENGTH = 26 def structure seq = @package.sequence galform = if(gf = seq.galenic_forms.first) gf.to_s end conc, unit = if((dose = seq.dose) && dose.is_a?(Quanty)) [dose.qty, dose.unit] end measures = @package.parts.collect { |part| part.measure }.compact measure, munit = unless(measures.empty?) ms = measures.inject { |a, b| a + b } [ms.qty, ms.unit] if ms.is_a?(Quanty) end comform = @package.commercial_forms.first qty, qty_unit = if(munit && !munit.empty?) [measure, munit] else print "@package=" p @package [@package.comparable_size.qty, comform] # <= HERE end
Result
... odba_id=218092 file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s01x.4811.0> table.class=ODDB::OdbaExporter::AcTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s19x.4811.0> table.class=ODDB::OdbaExporter::AccompTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s09x.4811.0> table.class=ODDB::OdbaExporter::AcLimTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s02x.4811.0> table.class=ODDB::OdbaExporter::AcmedTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s03x.4811.0> table.class=ODDB::OdbaExporter::AcnamTable @package.class=ODDB::Package
Next
Experiment
src/model/package.rb#comparable_size
def comparable_size print "@parts=" p @parts @parts.collect { |part| part.comparable_size }.inject { |a, b| a + b } rescue RuntimeError @parts.inject(Dose.new(0)) { |comp, part| ODDB::Dose.new(comp.qty + part.comparable_size.qty) } rescue nil end
Note
Result
... odba_id=218092 file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s01x.5495.0> table.class=ODDB::OdbaExporter::AcTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s19x.5495.0> table.class=ODDB::OdbaExporter::AccompTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s09x.5495.0> table.class=ODDB::OdbaExporter::AcLimTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s02x.5495.0> table.class=ODDB::OdbaExporter::AcmedTable file=#<File:/home/masa/ywesee/oddb.org/data/downloads/s03x.5495.0> table.class=ODDB::OdbaExporter::AcnamTable @package.class=ODDB::Package @parts=[]
Note
Next
src/model/package.rb#create_part
def create_part part = Part.new part.package = self @parts.push part part end
Note
Next
class Part include Persistence include SizeParser
Next
src/model/package.rb::SizeParser#comparable_size
def comparable_size ODDB::Dose.from_quanty(@comparable_size) end
Note
src/model/package.rb::SizeParser#set_comparable_size!
def set_comparable_size! measure = (@measure.nil? || @measure == UNIT) \ ? _composition_scale \ : @measure measure ||= UNIT scale = @scale || UNIT @comparable_size = multiplier * measure / scale end
Note
Experiment
ext/export/src/oddbdat.rb::AcnamLine#structure
class AcnamLine < PackageLine LENGTH = 26 def structure seq = @package.sequence galform = if(gf = seq.galenic_forms.first) gf.to_s end conc, unit = if((dose = seq.dose) && dose.is_a?(Quanty)) [dose.qty, dose.unit] end measures = @package.parts.collect { |part| part.measure }.compact measure, munit = unless(measures.empty?) ms = measures.inject { |a, b| a + b } [ms.qty, ms.unit] if ms.is_a?(Quanty) end comform = @package.commercial_forms.first qty, qty_unit = if(munit && !munit.empty?) [measure, munit] else print "@package.class=" p @package.class if sss = @package.comparable_size print "@package.comparable_size.class=" p @package.comparable_size.class end [@package.comparable_size.qty, comform] # <= HERE end
Result
... @package.comparable_size.class=ODDB::Dose ...
Note
Consideration
src/model/package.rb#comparable_size
def comparable_size # @parts.collect { |part| part.comparable_size }.inject { |a, b| a + b } @parts.collect { |part| part.comparable_size }.inject { |a, b| a + b } or raise RuntimeError rescue RuntimeError @parts.inject(Dose.new(0)) { |comp, part| ODDB::Dose.new(comp.qty + part.comparable_size.qty) } rescue nil end
Result
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> ODBA.cache.fetch('218092', nil).name -> Phytomed Knoblauch/Weissdorn, Kapseln ch.oddb> ODBA.cache.fetch('218092', nil).comparable_size -> 0
Test
Reboot
Run
Run export_oddbdat
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Exporter.new(self).export_oddbdat
Result
Error: NoMethodError Message: undefined method `multi' for nil:NilClass Backtrace: (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:423:in `structure' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:269:in `initialize' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:292:in `initialize' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `new' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `lines' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:189:in `export_oddbdat' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:184:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:184:in `export_oddbdat' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:176:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:176:in `export_oddbdat' /home/masa/ywesee/oddb.org/src/plugin/oddbdat_export.rb:52:in `export' /home/masa/ywesee/oddb.org/src/util/exporter.rb:153:in `export_oddbdat' /home/masa/ywesee/oddb.org/src/util/exporter.rb:297:in `call' /home/masa/ywesee/oddb.org/src/util/exporter.rb:297:in `safe_export' /home/masa/ywesee/oddb.org/src/util/exporter.rb:149:in `export_oddbdat' (eval):1:in `_admin' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1399:in `_admin' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `initialize' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `new' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `_admin' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/oddbd:38
Note
class AcnamLine < PackageLine LENGTH = 26 def structure seq = @package.sequence galform = if(gf = seq.galenic_forms.first) gf.to_s end conc, unit = if((dose = seq.dose) && dose.is_a?(Quanty)) [dose.qty, dose.unit] end measures = @package.parts.collect { |part| part.measure }.compact measure, munit = unless(measures.empty?) ms = measures.inject { |a, b| a + b } [ms.qty, ms.unit] if ms.is_a?(Quanty) end comform = @package.commercial_forms.first qty, qty_unit = if(munit && !munit.empty?) [measure, munit] else [@package.comparable_size.qty, comform] end { 1 => '03', 2 => @date, 3 => '1', 4 => @package.oid, 5 => 'D', 6 => '4', 7 => seq.name, 8 => seq.name_base, 9 => seq.name_descr, 11 => galform, 12 => conc, 13 => unit, 16 => @package.parts.first.multi, #<= HERE 17 => comform, 18 => qty, 19 => qty_unit, } end end
Note
Experiment (Skip nil data)
src/model/package.rb#comparable_size
def comparable_size # @parts.collect { |part| part.comparable_size }.inject { |a, b| a + b } @parts.collect { |part| part.comparable_size }.inject { |a, b| a + b } or raise RuntimeError rescue RuntimeError @parts.inject(Dose.new(0)) { |comp, part| ODDB::Dose.new(comp.qty + part.comparable_size.qty) } rescue nil end
ext/export/src/oddbdat.rb::AcnamLine#structure
... { 1 => '03', 2 => @date, 3 => '1', 4 => @package.oid, 5 => 'D', 6 => '4', 7 => seq.name, 8 => seq.name_base, 9 => seq.name_descr, 11 => galform, 12 => conc, 13 => unit, #16 => @package.parts.first.multi, 16 => @package.parts.first ? @package.parts.first.multi : 'masa', 17 => comform, 18 => qty, 19 => qty_unit, } end
Run
Run export_oddbdat
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Exporter.new(self).export_oddbdat
Result
masa@masa ~/ywesee/oddb.org $ ls data/downloads/ -al insgesamt 19000 drwxr-xr-x 2 masa masa 4096 2. Feb 13:55 . drwxr-xr-x 8 masa masa 64 2. Feb 13:47 .. -rw-r--r-- 1 masa masa 2129601 2. Feb 13:55 oddbdat.tar.gz -rw-r--r-- 1 masa masa 2114956 2. Feb 13:55 oddbdat.zip -rw------- 1 masa masa 1564 2. Feb 13:55 README -rw------- 1 masa masa 2267400 2. Feb 13:54 s01x -rw------- 1 masa masa 1490904 2. Feb 13:54 s02x -rw------- 1 masa masa 3723469 2. Feb 13:54 s03x -rw------- 1 masa masa 1094490 2. Feb 13:54 s06x -rw------- 1 masa masa 905903 2. Feb 13:54 s07x -rw------- 1 masa masa 111740 2. Feb 13:54 s09x -rw------- 1 masa masa 1430231 2. Feb 13:54 s10x -rw------- 1 masa masa 416422 2. Feb 13:55 s11x -rw------- 1 masa masa 73769 2. Feb 13:55 s12x -rw------- 1 masa masa 105999 2. Feb 13:54 s16x -rw------- 1 masa masa 827293 2. Feb 13:54 s19x -rw------- 1 masa masa 484995 2. Feb 13:55 s40x -rw------- 1 masa masa 2023634 2. Feb 13:54 s41x -rw------- 1 masa masa 208172 2. Feb 13:54 s99x
Note
Question
Next
src/model/package.rb#create_parts
def create_part part = Part.new part.package = self @parts.push part part end
Note
Memo
Note
Solution
Question
Candidates
Conditions
Consideration
Memo
http://ch.oddb.org/de/gcc/resolve/pointer/%3A!registration%2C(reg.no.)!sequence%2C(seq.no.)!package%2C(pac.no.).
Experiment
src/model/package.rb#comparable_size
def comparable_size @parts.collect { |part| part.comparable_size }.inject{ |a, b| a + b } or raise RuntimeError rescue RuntimeError @parts.inject(Dose.new(0)) { |comp, part| ODDB::Dose.new(comp.qty + part.comparable_size.qty) } rescue nil end
ext/export/src/oddbdat.rb::AcnamLine#structure
{ 1 => '03', 2 => @date, 3 => '1', 4 => @package.oid, 5 => 'D', 6 => '4', 7 => seq.name, 8 => seq.name_base, 9 => seq.name_descr, 11 => galform, 12 => conc, 13 => unit, #16 => @package.parts.first.multi, 16 => @package.parts.first ? @package.parts.first.multi : '', 17 => comform, 18 => qty, 19 => qty_unit, } end
src/plugin/oddbdat_export.rb#export
def export files = [] # package tables package_tables = [ AcTable, AccompTable, AcLimTable, AcmedTable, AcnamTable, AcOddbTable, AcpricealgTable, AcscTable, LimitationTable, LimTxtTable, EanTable ] ids = [] dose_missing_list = [] @app.each_package { |pac| ids.push(pac.odba_id) if pac.parts.empty? dose_missing_list.push([pac.basename, pac.iksnr, pac.sequence.seqnr, pac.ikscd]) end } files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, package_tables) # codes table ids = @app.atc_classes.values.collect { |atc| atc.odba_id } @app.each_galenic_form { |galform| ids.push(galform.odba_id) } files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CodesTable]) # substances table ids = @app.substances.collect { |subs| subs.odba_id } files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [ScTable]) # companies table ids = @app.companies.collect { |oid, comp| comp.odba_id } files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CompTable]) # readme files += EXPORT_SERVER.export_oddbdat(nil, EXPORT_DIR, [Readme]) # compress EXPORT_SERVER.compress_many(EXPORT_DIR, 'oddbdat', files) # warning return dose_missing_list end
src/util/exporter.rb#export_oddbdat
def export_oddbdat dose_missing_list = [] safe_export 'oddbdat' do exporter = OdbaExporter::OddbDatExport.new(@app) dose_missing_list = exporter.export EXPORT_SERVER.clear sleep(30) run_on_weekday(1) { exporter.export_fachinfos EXPORT_SERVER.clear sleep(30) } # here to raise warning if package.parts is empty if !dose_missing_list.empty? log = Log.new(@@today) log.report = [ "Warning: Dose data is missing", "Message: export_oddbdat succeeded but the following package(s) do not have Dose data", "Package(s):", dose_missing_list.collect do |list| list[0].to_s + ", " + \ "http://ch.oddb.org/de/gcc/resolve/pointer/%3A!registration%2C" + list[1].to_s + \ "!sequence%2C" + list[2].to_s + "!package%2C" + list[3].to_s + ".\n" end ].join("\n") log.notify("Warning Export: oddbdat") end end
Run
Run export_oddbdat
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Exporter.new(self).export_oddbdat
Warning: Dose data (ODDB::Package.parts, Array of ODDB::Dose instances) is empty. Message: export_oddbdat succeeded but the following package(s) do not have Dose data. Package(s): Phytomed Knoblauch/Weissdorn, http://oddb.masa.org/de/gcc/resolve/pointer/%3A!registration%2C46799!sequence%2C02!package%2C011.
Note
Commit