oddb2xml 3.0.3 → 3.0.4
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/CLAUDE.md +3 -1
- data/Gemfile.lock +1 -1
- data/History.txt +3 -0
- data/README.md +11 -3
- data/lib/oddb2xml/downloader.rb +3 -3
- data/lib/oddb2xml/extractor.rb +16 -20
- data/lib/oddb2xml/options.rb +1 -1
- data/lib/oddb2xml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a0a4cbd5ff288013064ffb6d756ed0961fd98e52b6960fbfd32b4328a039369
|
|
4
|
+
data.tar.gz: 60c9943c0a7f344ecf87e04f16314da1b8a29e0801a8d7e814d265932f89e443
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75abbcde0acf8e33b8489dd03fc06e6bd8796f571444b0a7f7eb3cded37a25f0938d8db07a7ef6ef0023412e3ab2336c046be3447fb5dc371dd02f06c5950e12
|
|
7
|
+
data.tar.gz: 9cf7e4c5eecd5d708dea61b4c6e17a206f6f4eaa65742ae2ee0c7ea3a49d0b4e4ae2dad7d9ffd3c2e61191e8703693ea29b3aa194d517226f828282ff5b3f891
|
data/CLAUDE.md
CHANGED
|
@@ -37,7 +37,7 @@ The system follows a **download → extract → build → compress** pipeline:
|
|
|
37
37
|
|
|
38
38
|
1. **CLI** (`lib/oddb2xml/cli.rb`) — Entry point. Parses options via Optimist (`options.rb`), orchestrates the pipeline, manages multi-threaded downloads.
|
|
39
39
|
|
|
40
|
-
2. **Downloaders**
|
|
40
|
+
2. **Downloaders** — 11 subclasses of `Downloader`, each fetching from a specific Swiss data source. 10 live in `lib/oddb2xml/downloader.rb`; the FHIR downloader lives in `lib/oddb2xml/fhir_support.rb`. Files cached in `./downloads/`.
|
|
41
41
|
|
|
42
42
|
3. **Extractors** (`lib/oddb2xml/extractor.rb`) — Matching extractor classes that parse downloaded files into Ruby hashes. Formats include XML (nokogiri/sax-machine), XLSX (rubyXL), CSV, and fixed-width text. Refdata uses the new SwissReg XML format from a zip download (`files.refdata.ch`).
|
|
43
43
|
|
|
@@ -47,6 +47,8 @@ The system follows a **download → extract → build → compress** pipeline:
|
|
|
47
47
|
|
|
48
48
|
6. **Compressor** (`lib/oddb2xml/compressor.rb`) — Optional ZIP/TAR.GZ output compression.
|
|
49
49
|
|
|
50
|
+
7. **FHIR support** (`lib/oddb2xml/fhir_support.rb`) — Self-contained module providing `FhirDownloader` and FHIR NDJSON parsing. Activated via `--fhir` (or `--fhir-url=<URL>`). Downloads per-language NDJSON files (`foph-sl-export-latest-{de,fr,it}.ndjson`) from `epl.bag.admin.ch` to populate French and Italian product names/descriptions. Maps legal status codes `756005022007` and `756005022008` to Swissmedic category D.
|
|
51
|
+
|
|
50
52
|
### Key data identifiers
|
|
51
53
|
- **GTIN/EAN13**: Primary article identifier (13-digit barcode)
|
|
52
54
|
- **Pharmacode**: Swiss pharmacy code
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
=== 3.0.4 / 24.04.2026
|
|
2
|
+
* Firstbase: switch -b/--firstbase from the deprecated pillbox.oddb.org XLSX to the GS1 Switzerland CSV at https://id.gs1.ch/01/07612345000961 (full firstbase barcode registry, ~189k items). Downloaded file is now firstbase.csv; FirstbaseExtractor now parses CSV with headers instead of XLSX.
|
|
3
|
+
|
|
1
4
|
=== 3.0.3 / 24.04.2026
|
|
2
5
|
* FHIR: download per-language NDJSON files (foph-sl-export-latest-{de,fr,it}.ndjson) so French and Italian product names/descriptions are populated
|
|
3
6
|
* FHIR: map legal status code 756005022008 to Swissmedic category D (in addition to 756005022007)
|
data/README.md
CHANGED
|
@@ -51,7 +51,7 @@ HIN (http://hin.ch) creates daily the actual file. They can be downloaded from `
|
|
|
51
51
|
see `--help`.
|
|
52
52
|
|
|
53
53
|
```
|
|
54
|
-
/opt/src/
|
|
54
|
+
/opt/src/oddb2xml/bin/oddb2xml version 3.0.4
|
|
55
55
|
Usage:
|
|
56
56
|
oddb2xml [option]
|
|
57
57
|
produced files are found under data
|
|
@@ -61,6 +61,10 @@ see `--help`.
|
|
|
61
61
|
-e, --extended pharma, non-pharma plus prices and non-pharma from zurrose.
|
|
62
62
|
Products without EAN-Code will also be listed.
|
|
63
63
|
File oddb_calc.xml will also be generated
|
|
64
|
+
--fhir Use FHIR NDJSON format from FOPH/BAG instead of XML
|
|
65
|
+
from Spezialitätenliste. Downloads per-language
|
|
66
|
+
NDJSON files (de, fr, it) from epl.bag.admin.ch.
|
|
67
|
+
--fhir-url=<s> Specific FHIR NDJSON URL to download (implies --fhir)
|
|
64
68
|
-f, --format=<s> File format F, default is xml. {xml|dat}
|
|
65
69
|
If F is given, -o option is ignored. (Default: xml)
|
|
66
70
|
-i, --include Include target option for ean14 for 'dat' format.
|
|
@@ -80,6 +84,8 @@ see `--help`.
|
|
|
80
84
|
Downloaded files are saved under downloads
|
|
81
85
|
--log log important actions
|
|
82
86
|
-u, --use-ra11zip=<s> Use the ra11.zip (a zipped transfer.dat from Galexis)
|
|
87
|
+
-b, --firstbase Build all NONPHARMA articles on firstbase
|
|
88
|
+
(GS1 Switzerland CSV from id.gs1.ch)
|
|
83
89
|
-v, --version Print version and exit
|
|
84
90
|
-h, --help Show this message
|
|
85
91
|
```
|
|
@@ -106,8 +112,8 @@ FR
|
|
|
106
112
|
|
|
107
113
|
## Supported ruby version
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
You will need ruby >= 2.5 to work correctly. Current development happens on Ruby 3.2 (`.ruby-version`).
|
|
116
|
+
CI runs on Ruby 3.0, 3.1 and 3.2 via GitHub Actions — see the badge above for the latest spec results.
|
|
111
117
|
|
|
112
118
|
|
|
113
119
|
## XSD files
|
|
@@ -283,6 +289,8 @@ We use the following files:
|
|
|
283
289
|
* http://download.swissmedicinfo.ch/ (AipsDownload)
|
|
284
290
|
* https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/LPPV.txt
|
|
285
291
|
* https://raw.githubusercontent.com/zdavatz/cpp2sqlite/master/input/atc_codes_multi_lingual.txt
|
|
292
|
+
* https://epl.bag.admin.ch/static/fhir/foph-sl-export-latest-{de,fr,it}.ndjson (FHIR NDJSON, used with `--fhir`)
|
|
293
|
+
* https://id.gs1.ch/01/07612345000961 (GS1 Switzerland firstbase CSV — full barcode registry, used with `-b`/`--firstbase`)
|
|
286
294
|
|
|
287
295
|
## Rules for matching GTIN (aka EAN13), product number and IKSNR
|
|
288
296
|
|
data/lib/oddb2xml/downloader.rb
CHANGED
|
@@ -342,14 +342,14 @@ module Oddb2xml
|
|
|
342
342
|
end
|
|
343
343
|
|
|
344
344
|
class FirstbaseDownloader < Downloader
|
|
345
|
-
BASE_URL = "
|
|
345
|
+
BASE_URL = "https://id.gs1.ch/01/07612345000961"
|
|
346
346
|
include DownloadMethod
|
|
347
347
|
def initialize(type = :orphan, options = {})
|
|
348
|
-
@url = BASE_URL
|
|
348
|
+
@url = BASE_URL
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
def download
|
|
352
|
-
@file2save = File.join(DOWNLOADS, "firstbase.
|
|
352
|
+
@file2save = File.join(DOWNLOADS, "firstbase.csv")
|
|
353
353
|
report_download(@url, @file2save)
|
|
354
354
|
begin
|
|
355
355
|
download_as(@file2save, "w+")
|
data/lib/oddb2xml/extractor.rb
CHANGED
|
@@ -608,32 +608,28 @@ module Oddb2xml
|
|
|
608
608
|
|
|
609
609
|
class FirstbaseExtractor < Extractor
|
|
610
610
|
def initialize(file)
|
|
611
|
-
@
|
|
611
|
+
@file = file
|
|
612
612
|
end
|
|
613
613
|
|
|
614
614
|
def to_hash
|
|
615
615
|
data = {}
|
|
616
|
-
return data unless @
|
|
617
|
-
@
|
|
618
|
-
|
|
619
|
-
if
|
|
620
|
-
puts "Empty row (#{i}) in firstbase"
|
|
621
|
-
next
|
|
622
|
-
end
|
|
623
|
-
gtin = row[0].value.to_s.gsub(/^0+/, '')
|
|
616
|
+
return data unless @file && File.exist?(@file)
|
|
617
|
+
CSV.foreach(@file, headers: true, encoding: "UTF-8") do |row|
|
|
618
|
+
gtin = row["Gtin"].to_s.gsub(/^0+/, "")
|
|
619
|
+
next if gtin.empty?
|
|
624
620
|
data[gtin] = {
|
|
625
621
|
gtin: gtin,
|
|
626
|
-
gln: row[
|
|
627
|
-
target_market: row[
|
|
628
|
-
gpc: row[
|
|
629
|
-
trade_item_description_de: row[
|
|
630
|
-
trade_item_description_en:
|
|
631
|
-
trade_item_description_fr: row[
|
|
632
|
-
trade_item_description_it: row[
|
|
633
|
-
manufacturer_name: row[
|
|
634
|
-
start_availability_date: row[
|
|
635
|
-
gross_weight:
|
|
636
|
-
net_weight:
|
|
622
|
+
gln: row["InformationProviderGln"].to_s,
|
|
623
|
+
target_market: row["TargetMarketCountryCode"].to_s,
|
|
624
|
+
gpc: row["GpcCategoryCode"].to_s,
|
|
625
|
+
trade_item_description_de: row["TradeItemDescription_DE"].to_s,
|
|
626
|
+
trade_item_description_en: "",
|
|
627
|
+
trade_item_description_fr: row["TradeItemDescription_FR"].to_s,
|
|
628
|
+
trade_item_description_it: row["TradeItemDescription_IT"].to_s,
|
|
629
|
+
manufacturer_name: row["InformationProviderPartyName"].to_s,
|
|
630
|
+
start_availability_date: row["Date_Created_Batch"].to_s,
|
|
631
|
+
gross_weight: "",
|
|
632
|
+
net_weight: "",
|
|
637
633
|
}
|
|
638
634
|
end
|
|
639
635
|
data
|
data/lib/oddb2xml/options.rb
CHANGED
|
@@ -45,7 +45,7 @@ module Oddb2xml
|
|
|
45
45
|
opt :log, "log important actions", short: :none
|
|
46
46
|
opt :use_ra11zip, "Use the ra11.zip (a zipped transfer.dat from Galexis)",
|
|
47
47
|
default: File.exist?("ra11.zip") ? "ra11.zip" : nil, type: :string
|
|
48
|
-
opt :firstbase, "Build all NONPHARMA articles on firstbase", short: "b", default: false
|
|
48
|
+
opt :firstbase, "Build all NONPHARMA articles on firstbase (GS1 Switzerland CSV from id.gs1.ch)", short: "b", default: false
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
@opts[:percent] = @opts[:increment]
|
data/lib/oddb2xml/version.rb
CHANGED