oddb2xml 1.9.5 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2eecda0ca903018c3f2e274967e6c77067756ddd
4
- data.tar.gz: d3aefcd4c33172df3b8cdb6162bc7f65bc7afe1a
3
+ metadata.gz: 01fd7337753234518adea6438bb4d82670b5cb37
4
+ data.tar.gz: 8ee70f060cd40e4503b45989527336f07c8a9dfe
5
5
  SHA512:
6
- metadata.gz: 860d1342fbe204a254de1098775d57473f71412f77afdc7bf1cc396c013eace17c9d4153fa9cae194b4045390dc69ce083b9fa486bce5ffcef41ab21a22441c6
7
- data.tar.gz: 347b449c21ebc17c934519e256b16f847c2ff199fadcfe9158e6634e30d44b63ddcc13e63f8bc9f86af4b58bd9d6bd113e23fecd8847dde3931a28629676291c
6
+ metadata.gz: 73a517563d9e338e2d0781ee13965596aaf8f559cc0b049d9a325d51c4186ee637f7b08cf4c876922488169184bf27a15a0c481072038e59e1f8aaafb0a41161
7
+ data.tar.gz: 01a5e728ca3be8f21d6ec0d2546b23bd9551860494019f0abf9610373cceb526eac1e4860bcae79f7cba526fe6c2fb7d28d47ee5599c3ee89502dc46ee0367c3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (1.9.5)
4
+ oddb2xml (1.9.6)
5
5
  archive-tar-minitar (~> 0.5.2)
6
6
  mechanize (~> 2.5.1)
7
7
  nokogiri (~> 1.5.10)
@@ -56,7 +56,7 @@ GEM
56
56
  coderay (~> 1.1.0)
57
57
  method_source (~> 0.8.1)
58
58
  slop (~> 3.4)
59
- pry-byebug (3.0.0)
59
+ pry-byebug (3.0.1)
60
60
  byebug (~> 3.4)
61
61
  pry (~> 0.10)
62
62
  rack (1.6.0)
@@ -1,3 +1,7 @@
1
+ === 1.9.6 /18.02.2015
2
+
3
+ * Add all products defined in Packungen.xlsx from SwissMedic to oddb_products.xml
4
+
1
5
  === 1.9.5 /16.02.2015
2
6
 
3
7
  * Option --calc produces oddb_calc.xml with field SELLING_UNITS
@@ -437,18 +437,61 @@ module Oddb2xml
437
437
  end
438
438
  _builder.to_xml
439
439
  end
440
+ def add_missing_products_from_swissmedic
441
+ Oddb2xml.log "build_product add_missing_products_from_swissmedic. Starting"
442
+ ean13_to_product = {}
443
+ @products.each{
444
+ |obj|
445
+ ean13_to_product[obj[:ean].to_s] = obj
446
+ }
447
+ ausgabe = File.open(File.join(WorkDir, 'missing_in_refdata.txt'), 'w+')
448
+ size_old = ean13_to_product.size
449
+ @missing = []
450
+ Oddb2xml.log "build_product add_missing_products_from_swissmedic. Imported #{size_old} ean13_to_product from @products. Checking #{@packs.size} @packs"
451
+ @packs.each_with_index {
452
+ |de_idx, i|
453
+ next if ean13_to_product[de_idx[1][:ean]]
454
+ list_code = de_idx[1][:list_code]
455
+ next if list_code and /Tierarzneimittel/.match(list_code)
456
+ ean13_to_product[de_idx[1][:ean].to_s] = de_idx[1]
457
+ @missing << de_idx[1]
458
+ ausgabe.puts "#{de_idx[1][:ean]},#{de_idx[1][:sequence_name]}"
459
+ }
460
+ corrected_size = ean13_to_product.size
461
+ Oddb2xml.log "build_product add_missing_products_from_swissmedic. Added #{(corrected_size - size_old)} corrected_size #{corrected_size} size_old #{size_old} ean13_to_product."
462
+ end
463
+
440
464
  def build_product
441
465
  prepare_substances
442
466
  prepare_products
443
467
  prepare_interactions
444
468
  prepare_codes
445
- Oddb2xml.log "build_product #{@products.size} products"
469
+ add_missing_products_from_swissmedic
470
+ Oddb2xml.log "build_product #{@products.size+@missing.size} products"
446
471
  _builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
447
472
  xml.doc.tag_suffix = @tag_suffix
448
473
  datetime = Time.new.strftime('%FT%T%z')
449
474
  xml.PRODUCT(XML_OPTIONS) {
450
475
  list = []
451
476
  length = 0
477
+ @missing.each do |obj|
478
+ next if /^Q/i.match(obj[:atc])
479
+ length += 1
480
+ xml.PRD('DT' => '') {
481
+ ean = obj[:ean].to_s
482
+ xml.GTIN ean
483
+ xml.PRODNO obj[:prodno] if obj[:prodno] and obj[:prodno].empty?
484
+ xml.DSCRD obj[:sequence_name] if obj[:sequence_name]
485
+ xml.DSCRF obj[:sequence_name] if obj[:sequence_name]
486
+ xml.ATC obj[:atc_code] if obj[:atc_code]
487
+ xml.IT obj[:ith_swissmedic] if obj[:ith_swissmedic]
488
+ xml.CPT
489
+ xml.PackGrSwissmedic obj[:package_size] if obj[:package_size]
490
+ xml.EinheitSwissmedic obj[:einheit_swissmedic] if obj[:einheit_swissmedic]
491
+ xml.SubstanceSwissmedic obj[:substance_swissmedic] if obj[:substance_swissmedic]
492
+ xml.CompositionSwissmedic obj[:composition_swissmedic] if obj[:composition_swissmedic]
493
+ }
494
+ end
452
495
  @products.each do |obj|
453
496
  next if /^Q/i.match(obj[:atc])
454
497
  seq = obj[:seq]
@@ -463,7 +506,6 @@ module Oddb2xml
463
506
  xml.PRODNO ppac[:prodno] if ppac[:prodno] and !ppac[:prodno].empty?
464
507
  if seq
465
508
  %w[de fr].each do |l|
466
-
467
509
  name = "name_#{l}".intern
468
510
  desc = "desc_#{l}".intern
469
511
  elem = "DSCR" + l[0].chr.upcase
@@ -654,7 +696,6 @@ module Oddb2xml
654
696
  def build_article
655
697
  prepare_limitations
656
698
  prepare_articles
657
-
658
699
  idx = 0
659
700
  Oddb2xml.log "build_article #{idx} of #{@articles.size} articles"
660
701
  _builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
@@ -669,9 +710,11 @@ module Oddb2xml
669
710
  pac,no8 = nil,de_idx[:ean][4..11] # BAG-XML(SL/LS)
670
711
  pack_info = nil
671
712
  pack_info = @packs[no8.intern] if no8 # info from Packungen.xlsx from swissmedic_info
672
- next if pack_info and pack_info[:list_code].match(/Tierarzneimittel/) if no8 and no8.match(/47066/)
673
713
  ppac = nil # Packungen
674
714
  ean = de_idx[:ean]
715
+ next if pack_info and /Tierarzneimittel/.match(pack_info[:list_code])
716
+ next if de_idx[:desc] and /ad us vet/i.match(de_idx[:desc])
717
+
675
718
  pharma_code = de_idx[:pharmacode]
676
719
  ean = nil if ean.match(/^000000/)
677
720
  if obj[:seq]
@@ -19,7 +19,7 @@ module Oddb2xml
19
19
  def Oddb2xml.log(msg)
20
20
  return unless @options[:log]
21
21
  $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{msg}"
22
- # $stdout.flush
22
+ $stdout.flush
23
23
  end
24
24
 
25
25
  def Oddb2xml.save_options(options)
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "1.9.5"
2
+ VERSION = "1.9.6"
3
3
  end
@@ -402,8 +402,8 @@ describe Oddb2xml::Builder do
402
402
  product_xml.should_not match(/ZYVOXID/i)
403
403
  end
404
404
  doc = REXML::Document.new File.new(product_filename)
405
- XPath.match( doc, "//PRD" ).find_all{|x| true}.size.should == 4
406
- XPath.match( doc, "//GTIN" ).find_all{|x| true}.size.should == 4
405
+ XPath.match( doc, "//PRD" ).find_all{|x| true}.size.should == 17
406
+ XPath.match( doc, "//GTIN" ).find_all{|x| true}.size.should == 17
407
407
  XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should == 1
408
408
  end
409
409
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.5
4
+ version: 1.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip