oddb2xml 2.6.6 → 2.7.1
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 +4 -4
- data/.github/workflows/ruby.yml +40 -0
- data/Elexis_Artikelstamm_v5.xsd +10 -8
- data/History.txt +29 -2
- data/bin/check_artikelstamm +1 -1
- data/lib/oddb2xml/builder.rb +53 -26
- data/lib/oddb2xml/chapter_70_hack.rb +7 -8
- data/lib/oddb2xml/cli.rb +4 -1
- data/lib/oddb2xml/downloader.rb +2 -2
- data/lib/oddb2xml/extractor.rb +0 -7
- data/lib/oddb2xml/parslet_compositions.rb +5 -1
- data/lib/oddb2xml/semantic_check.rb +6 -4
- data/lib/oddb2xml/util.rb +18 -8
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.gemspec +3 -0
- data/spec/artikelstamm_spec.rb +36 -37
- data/spec/builder_spec.rb +24 -37
- data/spec/cli_spec.rb +26 -0
- data/spec/data/Preparations.xml +139 -3
- data/spec/data/refdata_NonPharma.xml +0 -3
- data/spec/data/refdata_Pharma.xml +10 -25
- data/spec/data/swissmedic_package.xlsx +0 -0
- data/spec/data/transfer.dat +2 -1
- data/spec/data/varia_De.htm +2 -2
- data/spec/extractor_spec.rb +6 -10
- metadata +33 -6
- data/.travis.yml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31777bcd85038bd65d38d67d6ebdf2197f174389403b76ff146b18d3ef4557e
|
4
|
+
data.tar.gz: 8d8930ed04518838084ae4aeb69181418b2eddb36cfa83ece2cbc84ccd06e1f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abe9685cc40ba1fbf9525c3cbeb9f332a98725e76621074c9f1df179c91e53cb50a4f15e78a800a28224351d3a47ec8aef0e3b9ee17787a8dccd519db65bc6d8
|
7
|
+
data.tar.gz: 415b9049a316af98279f7af0b602ecd85b0bd2e86493133af512d37b494d43155822ef754ad6dcaa39b1aa474fddba57081860588b7e896da13bf891e9b522d6
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
# Using a matrix fails, because /setup-ruby always invokes bundle install without any additional args
|
20
|
+
# Fixed by adding not defining the debugger group in the Gemfile
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
os: [ ubuntu]
|
25
|
+
ruby: [2.4, 2.5, 2.6, 2.7, 3.0, head]
|
26
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v2
|
29
|
+
- uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
bundler-cache: true
|
33
|
+
|
34
|
+
- name: Install dependencies
|
35
|
+
run: |
|
36
|
+
bundle config set path .bundle/gems --local
|
37
|
+
bundle config set without debugger --local
|
38
|
+
bundle install
|
39
|
+
- name: Test with RSpec
|
40
|
+
run: bundle exec rspec
|
data/Elexis_Artikelstamm_v5.xsd
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!-- Copyright (c) 2016 MEDEVIT. All rights reserved. This program and the
|
3
|
-
accompanying materials are made available under the terms of the Eclipse
|
4
|
-
Public License v1.0 which accompanies this distribution, and is available
|
5
|
-
at http://www.eclipse.org/legal/epl-v10.html v002 - Ergänzung K Komplementärprodukt
|
6
|
-
bei generic type, Consider ATC code of length 8 (on vet.med. articles) Relax
|
7
|
-
ADDSCR occurence to 0 .. 1 v003 - PRODNO hinzugefügt LIMNAMEBAG zur formal-kennzeichnung
|
8
|
-
von identen limitations v4 - Major refactoring, see https://redmine.medelexis.ch/issues/4405
|
2
|
+
<!-- Copyright (c) 2016 MEDEVIT. All rights reserved. This program and the
|
3
|
+
accompanying materials are made available under the terms of the Eclipse
|
4
|
+
Public License v1.0 which accompanies this distribution, and is available
|
5
|
+
at http://www.eclipse.org/legal/epl-v10.html v002 - Ergänzung K Komplementärprodukt
|
6
|
+
bei generic type, Consider ATC code of length 8 (on vet.med. articles) Relax
|
7
|
+
ADDSCR occurence to 0 .. 1 v003 - PRODNO hinzugefügt LIMNAMEBAG zur formal-kennzeichnung
|
8
|
+
von identen limitations v4 - Major refactoring, see https://redmine.medelexis.ch/issues/4405
|
9
9
|
Contributors: MEDEVIT <office@medevit.at> - initial API and implementation -->
|
10
10
|
<xs:schema targetNamespace="http://elexis.ch/Elexis_Artikelstamm_v5"
|
11
11
|
elementFormDefault="qualified" attributeFormDefault="unqualified"
|
@@ -339,7 +339,6 @@
|
|
339
339
|
</xs:element>
|
340
340
|
<xs:element name="GENERIC_TYPE"
|
341
341
|
maxOccurs="1" minOccurs="0">
|
342
|
-
|
343
342
|
<xs:simpleType>
|
344
343
|
<xs:annotation>
|
345
344
|
<xs:documentation>
|
@@ -359,6 +358,9 @@
|
|
359
358
|
<xs:enumeration
|
360
359
|
value="K">
|
361
360
|
</xs:enumeration>
|
361
|
+
<xs:enumeration
|
362
|
+
value="C"> <!-- BAG 9.6.2020: BDer Buchstabe C bei «Original Generika Code» steht für Co-Marketing Arzneimittel -->
|
363
|
+
</xs:enumeration>
|
362
364
|
</xs:restriction>
|
363
365
|
</xs:simpleType>
|
364
366
|
</xs:element>
|
data/History.txt
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
=== 2.7.1 / 03.02.2021
|
2
|
+
* travis-ci -> Github Actions
|
3
|
+
* limit DSCRD/DSCRF to 120 chars as specified in the XSD
|
4
|
+
* Use huge option for nokogiri as suggested by https://github.com/sparklemotion/nokogiri/issues/2187
|
5
|
+
* Adapt artikelstamm to refdata without pharmacode
|
6
|
+
* oddb_article get pharmacode where possible from transfer.dat
|
7
|
+
|
8
|
+
=== 2.7.0 / 05.11.2020
|
9
|
+
* Chapter70 hack nur als Kommentar
|
10
|
+
* Avoid double hyphen in comment
|
11
|
+
|
12
|
+
=== 2.6.9 / 29.06.2020
|
13
|
+
|
14
|
+
* Fix problem when running bin/oddb2xml -a -f dat. Thanks to Lukas Furre for reporting the problem
|
15
|
+
* Fix warning with regular expression thas has ']'
|
16
|
+
|
17
|
+
=== 2.6.8 / 26.06.2020
|
18
|
+
|
19
|
+
* Re-Add support for Ruby Version 2.4
|
20
|
+
* Specified minimal ruby version in gemspec
|
21
|
+
* Patch artikelstamm build to emit a product for Varilrix
|
22
|
+
|
23
|
+
=== 2.6.7 / 25.06.2020
|
24
|
+
* Added value 'C' (Co-marketing) for field GENERIC_TYPE Elexis_Artikelstamm_v5.xsd from BAG Preparations.xml
|
25
|
+
* Fixed limitations coming from the chapte 70 hack
|
26
|
+
* Ruby 2.7 compatible (No URI.open warning)
|
27
|
+
|
1
28
|
=== 2.6.6 / 11.01.2020
|
2
29
|
* Fix link for varia_De.htm
|
3
30
|
|
@@ -130,7 +157,7 @@
|
|
130
157
|
|
131
158
|
=== 2.4.1 / 2.12.2016
|
132
159
|
|
133
|
-
* Update oddb2xml.gemspec to add GPL-3.0 as correct license for Rubygems as stated in LICENSE file
|
160
|
+
* Update oddb2xml.gemspec to add GPL-3.0 as correct license for Rubygems as stated in LICENSE file
|
134
161
|
* Added a hack for 24 globulina equina which commas between brackets
|
135
162
|
|
136
163
|
=== 2.4.0 /25.08.2016
|
@@ -568,7 +595,7 @@
|
|
568
595
|
|
569
596
|
* Improve NINCD detection
|
570
597
|
- Update timeout handling
|
571
|
-
- Improve pharmacode detection
|
598
|
+
- Improve pharmacode detection
|
572
599
|
|
573
600
|
=== 1.5.1 / 10.06.2013
|
574
601
|
|
data/bin/check_artikelstamm
CHANGED
data/lib/oddb2xml/builder.rb
CHANGED
@@ -520,7 +520,7 @@ module Oddb2xml
|
|
520
520
|
return false
|
521
521
|
end
|
522
522
|
return false if !name || name.empty? || name.length < 3
|
523
|
-
name
|
523
|
+
name[0..119] # limit to maximal 120 chars as specified in the XSD
|
524
524
|
end
|
525
525
|
prepare_substances
|
526
526
|
prepare_products
|
@@ -886,8 +886,12 @@ module Oddb2xml
|
|
886
886
|
xml.ART('DT' => obj[:last_change] ? obj[:last_change] : '') do
|
887
887
|
nbr_records += 1
|
888
888
|
xml.REF_DATA (obj[:refdata] || @migel[pharma_code]) ? '1' : '0'
|
889
|
-
|
890
|
-
|
889
|
+
if obj[:pharmacode] && obj[:pharmacode].length > 0
|
890
|
+
xml.PHAR obj[:pharmacode]
|
891
|
+
elsif zur_rose
|
892
|
+
puts "Adding #{zur_rose[:pharmacode]} to article GTIN #{ean}"
|
893
|
+
xml.PHAR zur_rose[:pharmacode]
|
894
|
+
end
|
891
895
|
#xml.GRPCD
|
892
896
|
#xml.CDS01
|
893
897
|
#xml.CDS02
|
@@ -988,14 +992,7 @@ module Oddb2xml
|
|
988
992
|
xml.CDTYP 'E13'
|
989
993
|
xml.BC ean # /^9999|^0000|^0$/.match(ean.to_s) ? 0 : sprintf('%013d', ean)
|
990
994
|
xml.BCSTAT 'A' # P is alternative
|
991
|
-
#xml.PHAR2
|
992
995
|
} if ean
|
993
|
-
#xml.ARTCH {
|
994
|
-
#xml.PHAR2
|
995
|
-
#xml.CHTYPE
|
996
|
-
#xml.LINENO
|
997
|
-
#xml.NOUNITS
|
998
|
-
#}
|
999
996
|
if pac and pac[:prices]
|
1000
997
|
pac[:prices].each_pair do |key, price|
|
1001
998
|
xml.ARTPRI {
|
@@ -1337,7 +1334,7 @@ module Oddb2xml
|
|
1337
1334
|
else
|
1338
1335
|
('0' * DAT_LEN[:ITHE])
|
1339
1336
|
end.to_i
|
1340
|
-
row << "%0#{DAT_LEN[:CEAN]}d" % (sprintf('%013d', ean).match(/^000000/) ? 0 : ean.to_i)
|
1337
|
+
row << "%0#{DAT_LEN[:CEAN]}d" % (sprintf('%013d', ean.to_i).match(/^000000/) ? 0 : ean.to_i)
|
1341
1338
|
row << "%#{DAT_LEN[:CMWS]}s" % '2' # pharma
|
1342
1339
|
rows << row
|
1343
1340
|
end
|
@@ -1413,7 +1410,7 @@ module Oddb2xml
|
|
1413
1410
|
return '--missing--'
|
1414
1411
|
end
|
1415
1412
|
return '--missing--' if !name || name.empty? || name.length < 3
|
1416
|
-
name
|
1413
|
+
name[0..119] # limit to maximal 120 chars as specified in the XSD
|
1417
1414
|
end
|
1418
1415
|
def override(xml, id, field, default_value)
|
1419
1416
|
has_overrides = /\d{13}/.match(id.to_s) ? @@article_overrides[id.to_i] : @@product_overrides[id.to_i]
|
@@ -1499,7 +1496,6 @@ module Oddb2xml
|
|
1499
1496
|
name ||= (item[:desc_de] + item[:name_de]) if item
|
1500
1497
|
name ||= obj[:sequence_name]
|
1501
1498
|
xml.GTIN pkg_gtin.to_s.rjust(13, '0')
|
1502
|
-
override(xml, pkg_gtin, :PHAR, pharma_code)
|
1503
1499
|
xml.SALECD('A')
|
1504
1500
|
# maxLength for DSCR is 50 for Artikelstamm v3
|
1505
1501
|
xml.DSCR(name) # for description for zur_rose
|
@@ -1557,9 +1553,20 @@ module Oddb2xml
|
|
1557
1553
|
when 'N'; xml.DEDUCTIBLE 10; # 10%
|
1558
1554
|
end if item && item[:deductible]
|
1559
1555
|
prodno = Oddb2xml.getProdnoForEan13(pkg_gtin)
|
1560
|
-
xml.PRODNO prodno if prodno
|
1561
1556
|
atc = package[:atc_code]
|
1562
1557
|
atc ||= @refdata[pkg_gtin][:seq][:atc_code] if @refdata[pkg_gtin]
|
1558
|
+
unless prodno # find a prodno from packages for vaccinations
|
1559
|
+
if atc && /^J07/.match(atc) && !/^J07AX/.match(atc)
|
1560
|
+
pack = @packs.values.find{ |v| v && v[:atc_code].eql?(atc)}
|
1561
|
+
if pack
|
1562
|
+
prodno = pack[:prodno]
|
1563
|
+
Oddb2xml.log "Patching vaccination for #{pkg_gtin} #{atc} #{name} via prodno #{prodno}"
|
1564
|
+
else
|
1565
|
+
Oddb2xml.log "unable to find a pack/prodno for vaccination for #{pkg_gtin} #{atc} #{name}"
|
1566
|
+
end
|
1567
|
+
end
|
1568
|
+
end
|
1569
|
+
xml.PRODNO prodno if prodno
|
1563
1570
|
csv = []
|
1564
1571
|
@csv_file << [pkg_gtin, name, package[:unit], measure,
|
1565
1572
|
pexf ? pexf : '',
|
@@ -1571,8 +1578,6 @@ module Oddb2xml
|
|
1571
1578
|
end
|
1572
1579
|
end
|
1573
1580
|
else # non pharma
|
1574
|
-
@csv_file << [ ean13, (obj[:desc_de] || obj[:description]), '', '',
|
1575
|
-
obj[:price], obj[:pub_price], '', '', '', '', '', '' ]
|
1576
1581
|
if @@emitted_v5_gtins.index(ean13)
|
1577
1582
|
next
|
1578
1583
|
else
|
@@ -1589,17 +1594,37 @@ module Oddb2xml
|
|
1589
1594
|
next if /^#{Oddb2xml::FAKE_GTIN_START}/.match(ean13.to_s)
|
1590
1595
|
xml.ITEM({'PHARMATYPE' => patched_pharma_type }) do
|
1591
1596
|
xml.GTIN ean13.to_s.rjust(13, '0')
|
1592
|
-
xml.PHAR obj[:pharmacode]
|
1597
|
+
xml.PHAR obj[:pharmacode] if obj[:pharmacode] && obj[:pharmacode].length > 0
|
1593
1598
|
emit_salecd(xml, ean13, obj)
|
1594
|
-
|
1599
|
+
description = obj[:desc_de] || obj[:description] # for description for zur_rose
|
1600
|
+
xml.DSCR(description)
|
1595
1601
|
xml.DSCRF(obj[:desc_fr] || '--missing--')
|
1596
1602
|
xml.COMP do
|
1597
1603
|
xml.GLN obj[:company_ean]
|
1598
1604
|
end if obj[:company_ean] && !obj[:company_ean].empty?
|
1599
|
-
|
1600
|
-
|
1605
|
+
if !(obj[:price] && !obj[:price].empty?) || !(obj[:pub_price] && !obj[:pub_price].empty?)
|
1606
|
+
zur_rose_detail = @infos_zur_rose.values.find{|x| x[:ean13].to_i == ean13.to_i}
|
1607
|
+
end
|
1608
|
+
ppub = nil; pexf=nil
|
1609
|
+
if obj[:price] && !obj[:price].empty?
|
1610
|
+
xml.PEXF (pexf = obj[:price])
|
1611
|
+
elsif zur_rose_detail
|
1612
|
+
if zur_rose_detail[:price] && !zur_rose_detail[:price].empty? && !zur_rose_detail[:price].eql?('0.00')
|
1613
|
+
Oddb2xml.log "NonPharma: #{ean13} adding PEXF #{zur_rose_detail[:price]} #{description}"
|
1614
|
+
xml.PEXF (pexf = zur_rose_detail[:price])
|
1615
|
+
end
|
1616
|
+
end
|
1617
|
+
if obj[:pub_price] && !obj[:pub_price].empty?
|
1618
|
+
xml.PPUB (ppub = obj[:pub_price])
|
1619
|
+
elsif zur_rose_detail
|
1620
|
+
if zur_rose_detail[:pub_price] && !zur_rose_detail[:pub_price].empty? && !zur_rose_detail[:pub_price].eql?('0.00')
|
1621
|
+
Oddb2xml.log "NonPharma: #{ean13} adding PPUB #{zur_rose_detail[:pub_price]} #{description}"
|
1622
|
+
xml.PPUB (ppub = zur_rose_detail[:pub_price])
|
1623
|
+
end
|
1624
|
+
end
|
1625
|
+
@csv_file << [ ean13, description, '', '', pexf, ppub, '', '', '', '', '', '' ]
|
1601
1626
|
if chap70
|
1602
|
-
xml.comment "Chapter70 hack"
|
1627
|
+
xml.comment "Chapter70 hack #{ean13.to_s.rjust(13, '0')} #{description.encode(:xml => :text).gsub('--','-')}"
|
1603
1628
|
xml.SL_ENTRY 'true'
|
1604
1629
|
xml.PRODNO obj[:pharmacode]
|
1605
1630
|
end
|
@@ -1665,7 +1690,7 @@ module Oddb2xml
|
|
1665
1690
|
myPack = @packs.values.find{ |x| x[:iksnr].to_i == obj[:seq][:swissmedic_number5].to_i } if obj[:seq]
|
1666
1691
|
if myPack && !prodno
|
1667
1692
|
prodno ||= myPack[:prodno]
|
1668
|
-
puts "Setting prodno #{prodno} for #{ean13}
|
1693
|
+
puts "Setting prodno #{prodno} for #{ean13} #{myPack[:sequence_name]}"
|
1669
1694
|
end
|
1670
1695
|
next unless prodno
|
1671
1696
|
next if emitted_prodno.index(prodno)
|
@@ -1703,12 +1728,14 @@ module Oddb2xml
|
|
1703
1728
|
used_limitations << lim_code unless used_limitations.index(lim_code)
|
1704
1729
|
xml.LIMNAMEBAG lim_code
|
1705
1730
|
elsif obj[:chapter70]
|
1706
|
-
|
1707
|
-
xml.comment "Chapter70 hack"
|
1731
|
+
xml.comment "Chapter70 hack prodno #{prodno} #{obj[:description].encode(:xml => :text).gsub('--','-')}"
|
1708
1732
|
xml.SALECD('A') # these products are always active!
|
1709
1733
|
xml.DSCR obj[:description]
|
1710
1734
|
xml.DSCRF ''
|
1711
|
-
|
1735
|
+
if @limitations.index(obj[:code])
|
1736
|
+
xml.LIMNAMEBAG obj[:code]
|
1737
|
+
used_limitations << obj[:code]
|
1738
|
+
end
|
1712
1739
|
end
|
1713
1740
|
if sequence && sequence[:substances]
|
1714
1741
|
value = nil
|
@@ -1734,7 +1761,7 @@ module Oddb2xml
|
|
1734
1761
|
end
|
1735
1762
|
emitted_lim_code << lim[:code]
|
1736
1763
|
xml.LIMITATION do
|
1737
|
-
xml.comment "Chapter70 hack" if lim[:chap70]
|
1764
|
+
xml.comment "Chapter70 2 hack" if lim[:chap70]
|
1738
1765
|
xml.LIMNAMEBAG lim[:code] # original LIMCD
|
1739
1766
|
xml.DSCR Oddb2xml.html_decode(lim[:desc_de])
|
1740
1767
|
xml.DSCRF Oddb2xml.html_decode(lim[:desc_fr])
|
@@ -12,7 +12,7 @@ module Oddb2xml
|
|
12
12
|
puts "parse_td returns: #{res}" if $VERBOSE
|
13
13
|
rescue => exc
|
14
14
|
puts "Unable to pars #{elem} #{exc}"
|
15
|
-
binding.pry
|
15
|
+
# binding.pry
|
16
16
|
return nil
|
17
17
|
end
|
18
18
|
res.flatten # .join("\t")
|
@@ -33,7 +33,7 @@ module Oddb2xml
|
|
33
33
|
effort: :tolerant,
|
34
34
|
smart: true
|
35
35
|
}
|
36
|
-
res = Ox.load(
|
36
|
+
res = Ox.load(Oddb2xml.uri_open(html_file).read, mode: :hash_no_attrs).values.first['body']
|
37
37
|
result = []
|
38
38
|
idx = 0
|
39
39
|
@@items = {}
|
@@ -50,15 +50,16 @@ module Oddb2xml
|
|
50
50
|
data = {}
|
51
51
|
pharma_code = entry.first
|
52
52
|
ean13 = (Oddb2xml::FAKE_GTIN_START + pharma_code.to_s)
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
if entry[2].encoding.to_s.eql?('ASCII-8BIT')
|
54
|
+
german = CGI.unescape(entry[2].force_encoding('ISO-8859-1'))
|
55
|
+
else
|
56
|
+
german = entry[2]
|
56
57
|
end
|
57
58
|
@@items[ean13] = {
|
58
59
|
:data_origin => 'Chapter70',
|
59
60
|
:line => entry.join(","),
|
60
61
|
:ean13 => ean13,
|
61
|
-
:description =>
|
62
|
+
:description => german,
|
62
63
|
:quantity => entry[3],
|
63
64
|
:pharmacode => pharma_code,
|
64
65
|
:pub_price => entry[4],
|
@@ -70,5 +71,3 @@ module Oddb2xml
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
73
|
-
|
74
|
-
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -88,6 +88,7 @@ module Oddb2xml
|
|
88
88
|
puts "Validatied #{@_files[:artikelstamm]}"
|
89
89
|
else
|
90
90
|
puts "Validating failed using #{cmd}"
|
91
|
+
raise "Validating failed using #{cmd}"
|
91
92
|
exit(2)
|
92
93
|
end
|
93
94
|
end
|
@@ -157,7 +158,9 @@ module Oddb2xml
|
|
157
158
|
end
|
158
159
|
end
|
159
160
|
if @options[:calc]
|
160
|
-
|
161
|
+
ext = File.extname(file)
|
162
|
+
dest = File.join(WorkDir, file.sub(ext, '_'+Time.now.strftime("%d.%m.%Y_%H.%M")+ext))
|
163
|
+
FileUtils.cp(File.join(WorkDir, file), dest, :verbose => false)
|
161
164
|
end
|
162
165
|
end
|
163
166
|
rescue Interrupt
|
data/lib/oddb2xml/downloader.rb
CHANGED
@@ -23,7 +23,7 @@ module Oddb2xml
|
|
23
23
|
else
|
24
24
|
begin
|
25
25
|
io = File.open(file, option)
|
26
|
-
data =
|
26
|
+
data = Oddb2xml.uri_open(@url).read
|
27
27
|
io.write(data)
|
28
28
|
rescue => error
|
29
29
|
puts "error #{error} while fetching #{@url}"
|
@@ -283,7 +283,7 @@ module Oddb2xml
|
|
283
283
|
include DownloadMethod
|
284
284
|
def initialize(type=:orphan, options = {})
|
285
285
|
url = BASE_URL + '/swissmedic/de/home/services/listen_neu.html'
|
286
|
-
doc = Nokogiri::HTML(
|
286
|
+
doc = Nokogiri::HTML(Oddb2xml.uri_open(url))
|
287
287
|
@type = type
|
288
288
|
@options = options
|
289
289
|
case @type
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -218,7 +218,6 @@ module Oddb2xml
|
|
218
218
|
item = {}
|
219
219
|
item[:ean13] = ean13
|
220
220
|
item[:no8] = pac.SWMC_AUTHNR
|
221
|
-
item[:pharmacode] = (phar = pac.PHAR.to_s) ? phar: '0'
|
222
221
|
item[:data_origin] = 'refdata'
|
223
222
|
item[:refdata] = true
|
224
223
|
item[:_type] = (typ = pac.ATYPE.downcase.to_sym) ? typ: ''
|
@@ -228,12 +227,6 @@ module Oddb2xml
|
|
228
227
|
item[:atc_code] = (code = pac.ATC) ? code.to_s : ''
|
229
228
|
item[:company_name] = (nam = pac.AUTH_HOLDER_NAME) ? nam: ''
|
230
229
|
item[:company_ean] = (gln = pac.AUTH_HOLDER_GLN) ? gln: ''
|
231
|
-
unless item[:pharmacode]
|
232
|
-
item[:pharmacode] = phar
|
233
|
-
unless data[item[:pharmacode]] # pharmacode => GTINs
|
234
|
-
data[item[:ean13]] = []
|
235
|
-
end
|
236
|
-
end
|
237
230
|
data[item[:ean13]] = item
|
238
231
|
end
|
239
232
|
data
|
@@ -88,7 +88,11 @@ module ParseUtil
|
|
88
88
|
composition.substances.each do
|
89
89
|
|substance_item|
|
90
90
|
active_substance_name = substance_item.name.downcase.sub(/^cum\s/, '')
|
91
|
-
substance_item.is_active_agent = (active_agents.find {|x| /#{x.downcase.
|
91
|
+
substance_item.is_active_agent = (active_agents.find {|x| /#{x.downcase.
|
92
|
+
gsub('(', '\(').
|
93
|
+
gsub(')', '\)').
|
94
|
+
gsub('[', '\[').
|
95
|
+
gsub(']', '\]')}($|\s)/.match(active_substance_name) } != nil)
|
92
96
|
substance_item.is_active_agent = true if substance_item.chemical_substance and active_agents.find {|x| x.downcase.eql?(substance_item.chemical_substance.name.downcase) }
|
93
97
|
end
|
94
98
|
comps << composition
|
@@ -64,7 +64,7 @@ module Oddb2xml
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def everyPharmaArticleHasAProductItem
|
69
69
|
result = true
|
70
70
|
puts "#{Time.now.strftime("%H:%M:%S")}: everyPharmaArticleHasAProductItem"
|
@@ -74,7 +74,7 @@ module Oddb2xml
|
|
74
74
|
unless allProductNumbers.index(item[:PRODNO])
|
75
75
|
puts "Item #{item[:GTIN]} has no Product #{item[:PRODNO]} #{item[:DSCR]}"
|
76
76
|
result = false
|
77
|
-
end
|
77
|
+
end unless item[:Chapter70_HACK]
|
78
78
|
end
|
79
79
|
result
|
80
80
|
end
|
@@ -91,17 +91,19 @@ module Oddb2xml
|
|
91
91
|
end
|
92
92
|
result
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def everyReferencedLimitationIsIncluded
|
96
|
+
result = true
|
96
97
|
puts "#{Time.now.strftime("%H:%M:%S")}: everyReferencedLimitationIsIncluded"
|
97
98
|
allLimitations = limitations.collect{ |lim| lim[:LIMNAMEBAG] }
|
98
99
|
products.each do |product|
|
99
100
|
next unless product[:LIMNAMEBAG]
|
100
101
|
unless allLimitations.index(product[:LIMNAMEBAG])
|
101
102
|
puts "product #{product[:PRODNO]} has no limitation #{product[:LIMNAMEBAG]} #{product[:DSCR]}"
|
102
|
-
|
103
|
+
result = false
|
103
104
|
end
|
104
105
|
end
|
106
|
+
result
|
105
107
|
end
|
106
108
|
|
107
109
|
def checkPackageSize
|