oddb2xml 2.3.7 → 2.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.txt +4 -0
- data/README.md +2 -0
- data/lib/oddb2xml/builder.rb +23 -16
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.xsd +23 -6
- data/spec/builder_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0df0b68570a06023f0f84f78759eba514f5a4b2
|
4
|
+
data.tar.gz: 484b181df37c6813c3c62ea6feeb429dee57aa55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79037072f934cba4a8910756dacf0984dd62d4f059572b50346ab3d0475377452e9c5cafb14f8961b9a88706c9a66d42ff44ef720af16d5d2ce8c7d1f7cb844
|
7
|
+
data.tar.gz: 6f444c348ee935c90d54331ebcdd8736354e00ca9e7aebc5adea2e81f8733c39db1e275001539139d8f03442c57ad75d49009e649903040a00f70275589faeea
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,8 @@ Consumers of the data file may use it to check whether they have to replace the
|
|
43
43
|
|
44
44
|
## usage
|
45
45
|
|
46
|
+
HIN (http://hin.ch) creates daily the actual file. They can be downloaded from `https://download.hin.ch/download/oddb2xml`, e.g. using `wget https://download.hin.ch/download/oddb2xml/oddb_article.xml`
|
47
|
+
|
46
48
|
see `--help`.
|
47
49
|
|
48
50
|
```
|
data/lib/oddb2xml/builder.rb
CHANGED
@@ -454,6 +454,19 @@ module Oddb2xml
|
|
454
454
|
end
|
455
455
|
|
456
456
|
def build_product
|
457
|
+
def check_name(obj, lang = :de)
|
458
|
+
ean = obj[:ean].to_i
|
459
|
+
refdata = @refdata[ean]
|
460
|
+
if lang == :de
|
461
|
+
name = (refdata && refdata[:desc_de]) ? refdata[:desc_de] : obj[:sequence_name]
|
462
|
+
elsif lang == :fr
|
463
|
+
name = (refdata && refdata[:desc_fr]) ? refdata[:desc_fr] : obj[:sequence_name]
|
464
|
+
else
|
465
|
+
return false
|
466
|
+
end
|
467
|
+
return false if !name || name.empty? || name.length < 3
|
468
|
+
name
|
469
|
+
end
|
457
470
|
prepare_substances
|
458
471
|
prepare_products
|
459
472
|
prepare_interactions
|
@@ -468,6 +481,9 @@ module Oddb2xml
|
|
468
481
|
xml.PRODUCT(XML_OPTIONS) {
|
469
482
|
list = []
|
470
483
|
@missing.each do |obj|
|
484
|
+
ean = obj[:ean].to_i
|
485
|
+
next unless check_name(obj, :de)
|
486
|
+
next unless check_name(obj, :fr)
|
471
487
|
next if /^Q/i.match(obj[:atc])
|
472
488
|
if obj[:prodno]
|
473
489
|
next if emitted.index(obj[:prodno])
|
@@ -475,16 +491,10 @@ module Oddb2xml
|
|
475
491
|
end
|
476
492
|
xml.PRD('DT' => obj[:last_change]) {
|
477
493
|
nbr_products += 1
|
478
|
-
ean = obj[:ean].to_i
|
479
494
|
xml.GTIN ean
|
480
495
|
xml.PRODNO obj[:prodno] if obj[:prodno]
|
481
|
-
|
482
|
-
|
483
|
-
xml.DSCRF refdata[:desc_fr]
|
484
|
-
else
|
485
|
-
xml.DSCRD obj[:sequence_name] if obj[:sequence_name]
|
486
|
-
xml.DSCRF obj[:sequence_name] if obj[:sequence_name]
|
487
|
-
end
|
496
|
+
xml.DSCRD check_name(obj, :de)
|
497
|
+
xml.DSCRF check_name(obj, :fr)
|
488
498
|
xml.ATC obj[:atc_code] if obj[:atc_code] and !obj[:atc_code].empty?
|
489
499
|
xml.IT obj[:ith_swissmedic] if obj[:ith_swissmedic]
|
490
500
|
xml.CPT
|
@@ -498,22 +508,19 @@ module Oddb2xml
|
|
498
508
|
@products.each do |ean13, obj|
|
499
509
|
next if /^Q/i.match(obj[:atc])
|
500
510
|
seq = obj[:seq]
|
511
|
+
ean = obj[:ean]
|
512
|
+
next unless check_name(obj, :de)
|
513
|
+
next unless check_name(obj, :fr)
|
501
514
|
xml.PRD('DT' => obj[:last_change]) do
|
502
515
|
nbr_products += 1
|
503
|
-
ean = obj[:ean]
|
504
516
|
xml.GTIN ean
|
505
517
|
ppac = ((_ppac = @packs[ean.to_s[4..11].intern] and !_ppac[:is_tier]) ? _ppac : {})
|
506
518
|
unless ppac
|
507
519
|
ppac = @packs.find{|pac| pac.ean == ean }.first
|
508
520
|
end
|
509
521
|
xml.PRODNO ppac[:prodno] if ppac[:prodno] and !ppac[:prodno].empty?
|
510
|
-
|
511
|
-
|
512
|
-
xml.DSCRF refdata[:desc_fr]
|
513
|
-
else
|
514
|
-
xml.DSCRD obj[:sequence_name] if obj[:sequence_name]
|
515
|
-
xml.DSCRF obj[:sequence_name] if obj[:sequence_name]
|
516
|
-
end
|
522
|
+
xml.DSCRD check_name(obj, :de)
|
523
|
+
xml.DSCRF check_name(obj, :fr)
|
517
524
|
#xml.BNAMD
|
518
525
|
#xml.BNAMF
|
519
526
|
#xml.ADNAMD
|
data/lib/oddb2xml/version.rb
CHANGED
data/oddb2xml.xsd
CHANGED
@@ -105,6 +105,25 @@
|
|
105
105
|
<xs:attribute name="GENERATED_BY" use="required"/>
|
106
106
|
</xs:complexType>
|
107
107
|
</xs:element>
|
108
|
+
|
109
|
+
<xs:element name="DSCRD">
|
110
|
+
<xs:simpleType>
|
111
|
+
<xs:restriction base="xs:string">
|
112
|
+
<xs:minLength value="3" />
|
113
|
+
<xs:maxLength value="120" />
|
114
|
+
</xs:restriction>
|
115
|
+
</xs:simpleType>
|
116
|
+
</xs:element>
|
117
|
+
|
118
|
+
<xs:element name="DSCRF">
|
119
|
+
<xs:simpleType>
|
120
|
+
<xs:restriction base="xs:string">
|
121
|
+
<xs:minLength value="3" />
|
122
|
+
<xs:maxLength value="120" />
|
123
|
+
</xs:restriction>
|
124
|
+
</xs:simpleType>
|
125
|
+
</xs:element>
|
126
|
+
|
108
127
|
<xs:element name="ART">
|
109
128
|
<xs:complexType>
|
110
129
|
<xs:sequence>
|
@@ -696,8 +715,8 @@
|
|
696
715
|
<xs:element ref="ns1:LIMVAL"/>
|
697
716
|
<xs:element ref="ns1:LIMNAMEBAG"/>
|
698
717
|
<xs:element ref="ns1:LIMNIV"/>
|
699
|
-
<xs:element
|
700
|
-
<xs:element
|
718
|
+
<xs:element name="DSCRD" type="xs:string"/>
|
719
|
+
<xs:element name="DSCRF" type="xs:string"/>
|
701
720
|
<xs:element ref="ns1:VDAT"/>
|
702
721
|
</xs:sequence>
|
703
722
|
<xs:attribute name="DT" use="required"/>
|
@@ -754,8 +773,8 @@
|
|
754
773
|
<xs:element ref="ns1:LIMVALMD"/>
|
755
774
|
<xs:element ref="ns1:LIMNAMEBAGMD"/>
|
756
775
|
<xs:element ref="ns1:LIMNIVMD"/>
|
757
|
-
<xs:element
|
758
|
-
<xs:element
|
776
|
+
<xs:element name="DSCRDMD" type="xs:string"/>
|
777
|
+
<xs:element name="DSCRFMD" type="xs:string"/>
|
759
778
|
<xs:element ref="ns1:VDATMD"/>
|
760
779
|
</xs:sequence>
|
761
780
|
<xs:attribute name="DT" use="required"/>
|
@@ -1040,8 +1059,6 @@
|
|
1040
1059
|
</xs:restriction>
|
1041
1060
|
</xs:simpleType>
|
1042
1061
|
</xs:element>
|
1043
|
-
<xs:element name="DSCRD" type="xs:string"/>
|
1044
|
-
<xs:element name="DSCRF" type="xs:string"/>
|
1045
1062
|
<xs:element name="IT" type="xs:string"/>
|
1046
1063
|
<xs:element name="SUBNO" type="xs:integer"/>
|
1047
1064
|
<xs:element name="QTY" type="xs:string"/>
|
data/spec/builder_spec.rb
CHANGED
@@ -310,7 +310,7 @@ def check_validation_via_xsd
|
|
310
310
|
if error.message
|
311
311
|
puts "Failed validating #{file} with #{File.size(file)} bytes using XSD from #{@oddb2xml_xsd}"
|
312
312
|
end
|
313
|
-
expect(error.message).to be_nil
|
313
|
+
expect(error.message).to be_nil, "expected #{error.message} to be nil\nfor #{file} content \n#{File.read(file)}"
|
314
314
|
end
|
315
315
|
}
|
316
316
|
end
|
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: 2.3.
|
4
|
+
version: 2.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|