oddb2xml 3.0.35 → 3.0.37

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
  SHA256:
3
- metadata.gz: 99321f1703f8ab1645b7cdb4049433c355330f95db7e45d8510c31cd15cf5bc7
4
- data.tar.gz: 1c5c50119b700ac8591dc087b452cdcf06be4a35382e1b5e2280a7913cd6f5d6
3
+ metadata.gz: 04b9d06b5b8705ec83e23f81210d1f28fb293cbd0671a73a218e248a512e145d
4
+ data.tar.gz: 47eb693b69d9d2cb68a5f7c8f880e8bf7299486e454b65b1a9be98e985ca8bf0
5
5
  SHA512:
6
- metadata.gz: 98e7a7a8445bdad56f3d4d722c2243a068167d8242e874d37c4d0e4ad10c2ac14588a84c031e1c279948898602d416ba91be6e59c532e9637de80818a3bc4b06
7
- data.tar.gz: 993e517ee499b12d448efb16a36f3dd72b4b1d758c7685a33b7cab6ae3b4f72bb0fd1f1ac9eb0aa2f58b7a3493432118e1221734a7b00b2976a3cc6be9ba2d1f
6
+ metadata.gz: 6c2dea28224d980fcd3bc0702f77e210c742f7dd95d3b3b2c91eedba5e91c8201505dfdbf5d01ad98faa1fe7c45eb3255583adfc9cc6fd70ac229afc5bb1ab89
7
+ data.tar.gz: fcae693b2657e658bdc06932e7b60668a694a0259bd35d97856eb8548a97d1b1a265a50bfebd7cea3d1eac5a9465cbf9db35ad0acd952ed9bd75c6f8c6052391
data/CLAUDE.md CHANGED
@@ -24,7 +24,7 @@ The system follows a **download → extract → build → compress** pipeline:
24
24
 
25
25
  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-publication-latest-{de,fr,it}.ndjson`) from `epl.bag.admin.ch/static/sl/publication/fhir` (**3.0.32 onwards**; BAG moved the export there on 24.08.2026, announced it the next evening, and oddb2xml followed in 3.0.32; the old `/static/fhir/foph-sl-export-*` answers 404 for `-latest-` while the old dated snapshots remain, so the failure looks like an import that does nothing) to populate French and Italian product names/descriptions. Maps legal status codes `756005022007` and `756005022008` to Swissmedic category D. Reads the BAG **Indikationscode** (`XXXXX.NN`) from the explicit `indicationCode` extension on each `RegulatedAuthorization.indication[].extension[regulatedAuthorization-limitation]` (BAG SL FHIR export >= v2.0.5; handled from 3.0.10). The BAG changelog states the limitation code (`ClinicalUseDefinition.id`) and the indication code are **independent** fields, so the older derivation — combining each indication CUD's `.NN` id-suffix with the reimbursement RA's `FOPHDossierNumber` — is kept only as a fallback for feeds lacking the extension. Exposed as `item[:indication_codes]` and per-package `:indication_codes` (each entry a `{code:, cud_id:, text:}` hash, where `cud_id` is the `limitationIndication` CUD reference used to resolve the text). From 3.0.7 onwards, `Builder#build_product` emits one `<INDICATION_CODE code="XXXXX.NN" cud_id="DRUG.NN">limitation text</INDICATION_CODE>` child per indication on every `<PRD>` in `oddb_product.xml`; live feed numbers: 539 products / 1,293 codes / 100 % with non-empty indication text. Mandatory on prescriptions/invoices for SL price-model drugs from 2026-07-01 — see issue [#113](https://github.com/zdavatz/oddb2xml/issues/113). **Limitation texts** (3.0.8 onwards): the `regulatedAuthorization-limitation` extension has no inline `limitationText` in the live BAG feed — it carries a `limitationIndication` reference to a `ClinicalUseDefinition` whose `indication.diseaseSymptomProcedure.concept.text` is the actual text. The parser stores the ref as `cud_ref` on each Limitation, `Bundle#cud_text_by_id` resolves DE, and `merge_language` propagates FR/IT from the per-language NDJSON files via the same CUD id. Coverage on the live feed jumped from 0 / 9'108 to 9'108 / 9'108 (issue [#116](https://github.com/zdavatz/oddb2xml/issues/116)). **Limitation code / LIMNAMEBAG** (3.0.12 onwards): FHIR has no native BAG limitation code (LIMCD), so `create_limitations_for_package` sets `LimitationCode = cud_ref` (the `limitationIndication` CUD id) instead of `""`. Without this, every FHIR limitation shared an empty `:code`; `Builder#build_artikelstamm` groups its `<LIMITATIONS>` section by code, so all of them collapsed into a single `<LIMITATION>` with an empty `<LIMNAMEBAG>` and only one text survived. Using the CUD id as the key makes each distinct limitation emit and be referenced from its `<PRODUCT>`. The downstream `bin/check_artikelstamm` (`semantic_check.rb`) also crashed on the lone-element output because Ox `:hash_no_attrs` collapses a one-child section into a Hash (and an empty one into nil) — `SemanticCheckXML#get_items` now normalises every section to an Array. **v6 Artikelstamm / per-article INDC (3.0.26 onwards):** `--artikelstamm` now emits the **Elexis Artikelstamm v6** format (namespace `http://elexis.ch/Elexis_Artikelstamm_v6`, file `artikelstamm_DDMMYYYY_v6.xml`/`.csv`, validated against the bundled `Elexis_Artikelstamm_v6.xsd`) — replacing v5. The new piece is a per-`<ITEM>` `<ARTSL>` block carrying the BAG Indikationscodes (issue [#113](https://github.com/zdavatz/oddb2xml/issues/113)): `<PM>true</PM>` plus one `<ARTLIM>` per limitation with `<LIMCD>` (= `cud_ref`, the BAG limitation code), `<INDCD>` (the `XXXXX.NN` indication code from the `indicationCode` extension), and `<VDAT>`/`<VTDAT>` (period start/end). To feed it, `create_limitations_for_package` now also carries `IndicationCode` (→ per-package `:indcd`) and `ValidThruDate` (→ `:vtdate`) on each limitation; `Builder#append_artsl`/`elexis_datetime` emit one `<ARTLIM>` per limitation that has a non-empty `:indcd` (so non-price-model items get no `<ARTSL>`). `PM` is always `true` here because the indication code is required only for SL price-model drugs, which is exactly the set of items that reach this block. The bundled `Elexis_Artikelstamm_v6.xsd` is the canonical MEDEVIT schema extended with oddb2xml's historical Italian elements (`DSCRI` on PRODUCT/LIMITATION/ITEM, `DOSAGE_FORMI` on ITEM) so the output still validates. The legacy `--no-fhir` path emits no `<ARTSL>` (no FHIR limitations). **Per-article INDC in the `-e`/`-b` feeds (3.0.27 onwards):** the same indication codes are also emitted per `<ART>` in `oddb_article.xml` via `Builder#append_indication_codes` — one `<INDICATION_CODE code="XXXXX.NN" cud_id="DRUG.NN" limcd="DRUG.NN" vdat=… vtdat=…>limitation text</INDICATION_CODE>` per limitation that carries an `:indcd` (sourced from the article's `pac[:limitations]`). This reuses the flat `<INDICATION_CODE>` element already emitted on `<PRD>` in `oddb_product.xml` (since 3.0.7), enriched with the limitation code and validity dates so it carries the full `<ARTSL>` payload. The bundled `oddb2xml.xsd` now defines `<INDICATION_CODE>` (simpleContent + `code`/`cud_id`/`limcd`/`vdat`/`vtdat` attributes) and references it from both `<ART>` and `<PRD>` — the `<PRD>` reference had been missing since the 3.0.7 addition, so the FHIR product feed only validated once this was added. **Legacy v5 opt-in (3.0.28 onwards):** `--artikelstamm-v5` additionally emits the older Artikelstamm v5 file alongside the v6 one (for consumers not yet migrated). It implies `--artikelstamm`; `Options.parse` sets `@opts[:artikelstamm] = true`. `build_artikelstamm` takes a `version:` keyword (default `6`) that drives the namespace (`Elexis_Artikelstamm_v#{version}`) and CSV/XML filename suffix; `build_artikelstamm_v5` calls it with `version: 5`. The only content difference is that the v5 path skips `append_artsl` (the v5 schema has no `<ARTSL>` element). The CLI `files` map adds an `:artikelstamm_v5` entry (→ `build_artikelstamm_v5` via the `to_xml` subject dispatch) and validates it against the bundled `Elexis_Artikelstamm_v5.xsd`. Both files come from one build — the `@prepared` guard means the shared download/prepare phase runs once. **Selbstbehalt / costShare (3.0.31 onwards):** the `reimbursementSL` extension's `costShare` valueInteger is the BAG Selbstbehalt percentage; it maps to the legacy `FlagSB` semantics of the old BAG `Preparations.xml` — `40` → `item[:deductible] = "Y"` (raised Selbstbehalt: `<SLOPLUS>1</SLOPLUS>` in `oddb_article.xml`, `<DEDUCTIBLE>40</DEDUCTIBLE>` in the Artikelstamm), `10` → `"N"` (ordinary Selbstbehalt: `SLOPLUS` 2 / `DEDUCTIBLE` 10), `20` → `deductible20 = "Y"` (transitional rate, issue #81). Until 3.0.31 the mapping was inverted (`10` → `"Y"`), so **every** SL article claimed a 40 % Selbstbehalt. On the live feed only 385 of 10'388 packages (222 preparations) carry `costShare` 40; the value never mixes within one preparation, so keeping the flag at sequence level is safe.
26
26
 
27
- 8. **Refdata cleanup** (`lib/oddb2xml/refdata_cleanup.rb`) — Compensates for known data-quality issues in upstream Refdata.Articles.xml before they reach the output. Each fix is guarded by a Swissmedic-side heuristic (e.g. comma in `substance_swissmedic` to distinguish mono products from real combinations). Currently fixes (a) the doubled-dose template bug (`X mg / X mg / Stk`, `fix_double_dose`, guarded by `single_substance?`); (b) the spelled-out German galenic form `Retardtabletten` → house-style abbreviation `Ret Tabl` (`normalize_galenic_form` / `GALENIC_NORMALISATIONS`, issue #112 case #13, e.g. RINVOQ — a narrow word-boundary substitution that leaves legitimate brand suffixes like `TRAMAL retard` and Mepha's `Lactab` untouched); and (c) dose info Refdata dropped from `<FullName>`, sourced from the Swissmedic composition string `pack[:composition_swissmedic]` — `fix_missing_combo_dose` (#6, appends a combination's 2nd component strength), `fix_missing_dose` (#4, inserts a mono product's missing strength before the pack count), `fix_missing_volume` (#7, appends an injectable's per-pen volume); and (d) 50-char-truncation repairs — `fix_truncated_metoject` (#1, rebuilds METOJECT Autoinjektor names from the intact `<brand> Autoinjektor <dose>/<vol>` prefix + Swissmedic `size`, localised DE/FR/IT) and `fix_truncated_volume_unit` (#3, restores the cut `ml` of the VERACTIV Vitamin D3 drops). The (c) and (d) fixes are scoped to explicit IKSNR allow-lists (`COMBO_DOSE_IKSNR`/`MISSING_DOSE_IKSNR`/`MISSING_VOLUME_IKSNR`/`METOJECT_IKSNR`/`VERACTIV_VITD3_IKSNR`): a dry run proved a blanket heuristic mis-fires on hundreds of legitimate names (sodium counter-ion doses, strength-less phyto/powder products, concentration names like `CIMZIA 200 mg/ml`), so only catalogued registrations are touched — add an IKSNR to grow coverage. Called from `Builder#apply_refdata_description_cleanups!` at the start of `prepare_articles`. See GitHub issue #112 for the catalogue.
27
+ 8. **Refdata cleanup** (`lib/oddb2xml/refdata_cleanup.rb`) — Compensates for known data-quality issues in upstream Refdata.Articles.xml before they reach the output. Each fix is guarded by a Swissmedic-side heuristic (e.g. comma in `substance_swissmedic` to distinguish mono products from real combinations). Currently fixes (a) the doubled-dose template bug (`X mg / X mg / Stk`, `fix_double_dose`, guarded by `single_substance?`); (b) the spelled-out German galenic form `Retardtabletten` → house-style abbreviation `Ret Tabl` (`normalize_galenic_form` / `GALENIC_NORMALISATIONS`, issue #112 case #13, e.g. RINVOQ — a narrow word-boundary substitution that leaves legitimate brand suffixes like `TRAMAL retard` and Mepha's `Lactab` untouched); and (c) dose info Refdata dropped from `<FullName>`, sourced from the Swissmedic composition string `pack[:composition_swissmedic]` — `fix_missing_combo_dose` (#6, appends a combination's 2nd component strength), `fix_missing_dose` (#4, inserts a mono product's missing strength before the pack count), `fix_missing_volume` (#7, appends an injectable's per-pen volume); and (d) 50-char-truncation repairs — `fix_truncated_metoject` (#1, rebuilds METOJECT Autoinjektor names from the intact `<brand> Autoinjektor <dose>/<vol>` prefix + Swissmedic `size`, localised DE/FR/IT) and `fix_truncated_volume_unit` (#3, restores the cut `ml` of the VERACTIV Vitamin D3 drops). The (c) and (d) fixes are scoped to explicit IKSNR allow-lists (`COMBO_DOSE_IKSNR`/`MISSING_DOSE_IKSNR`/`MISSING_VOLUME_IKSNR`/`METOJECT_IKSNR`/`VERACTIV_VITD3_IKSNR`): a dry run proved a blanket heuristic mis-fires on hundreds of legitimate names (sodium counter-ion doses, strength-less phyto/powder products, concentration names like `CIMZIA 200 mg/ml`), so only catalogued registrations are touched — add an IKSNR to grow coverage. (e) **German-only wrong pack volume** (`fix_german_volume_from_fr_it`, **3.0.36**, 28.09.2026, reported by zollsoft; the four records were reported to Refdata the same day so the source can be corrected — once it is, the rule becomes a no-op): Refdata's DE `<FullName>` for PRIVIGEN 400 ml (7680583140053) reads `… 200 ml Dfl` while FR/IT say 400 ml, and FERINJECT/VIYANA/FERYXA 1000 mg say `10 ml` in DE against `20 ml` in FR/IT. This one is deliberately **not** IKSNR-scoped: it is a cross-language check inside Refdata's own record (FR and IT must agree on exactly one standalone `<n> ml`, DE must carry exactly one and differ; concentrations like `mg/ml` or `1000 mg/20ml` are excluded by the look-behind), and a dry run over all 16'967 articles of the live file changed exactly those four, each confirmed by ZurRose `transfer.dat` and, for PRIVIGEN, the BAG FHIR name. Runs per item after the per-language pipeline, logged as `German pack volume disagreeing with FR/IT`. Called from `Builder#apply_refdata_description_cleanups!` at the start of `prepare_articles`. See GitHub issue #112 for the catalogue.
28
28
 
29
29
  9. **Chapter-70 hack** (`lib/oddb2xml/chapter_70_hack.rb`) — Legacy scraper for the SL "Komplementärarzneimittel" products (homeopathic/anthroposophic/phytotherapeutic), called only from `Builder#build_artikelstamm`. **Deprecated / non-FHIR only (3.0.11 onwards):** the source page `varia_De.htm` was rebuilt as a JavaScript SPA with no static data table, so the scraper now returns nothing there. These products + limitations now come through the FHIR feed (SL classification `20. KOMPLEMENTÄRARZNEIMITTEL`, 221 products on the live DE feed with real GTINs and limitation texts), so `build_artikelstamm` **skips the scraper entirely when `@options[:fhir]`** (the default for `--artikelstamm` since 3.0.9). In `--no-fhir` mode the scraper degrades gracefully (skips non-row/`<script>` nodes and empty tables, warns, returns `[]`) instead of raising `NoMethodError`. See GitHub issue #118.
30
30
 
@@ -32,6 +32,8 @@ The system follows a **download → extract → build → compress** pipeline:
32
32
 
33
33
  11. **Rogger name preferences** (`lib/oddb2xml/rogger_names.rb`, `-r`/`--rogger`, 3.0.30 onwards) — Replaces the German article description (`desc_de`) with the preferred name from the **"Rogger Mediliste"** for every GTIN on that list. The list collects the name conflicts Frau Rogger (Vitabyte/Zur Rose, task #OX-5985-1594) reports between the Spirig/Galexis names and what Vitabyte shows from raw Refdata; most entries are the issue-#112 Refdata bugs with their corrected names (METOJECT truncation, CETIRIZIN missing strength, ATOVAQUON missing 2nd combo dose, MOUNJARO missing pen volume, RINVOQ `Retardtabletten`), plus two not (yet) catalogued in `refdata_cleanup.rb`: GABAPENTIN Spirig HC Kaps (IKSNR 66594, strength doubled as a glued brand token `Spirig HC 100mg Kaps 100 mg`) and MELATONIN Spirig HC 100 Stk (redundant `retard` before `Ret Tabl`). Source of truth is the shared Google Sheet "Rogger Mediliste" (link-shared read-only); `RoggerDownloader` fetches its CSV export (`GTIN,Mediname`) **directly** (`docs.google.com/spreadsheets/d/<id>/export?format=csv&gid=0`), so sheet edits reach the feeds without any release step, with a bundled fallback `data/rogger_liste.csv` (refresh at release time). `RoggerNames.load` returns `gtin => name` (never raises; UTF-8-forced because the list carries `µg`; `rogger_csv?` rejects non-CSV responses such as a Google sign-in page if the sheet ever loses its link-sharing, engaging the fallback). The override runs as the **last step of `Builder#apply_refdata_description_cleanups!`** (`apply_rogger_name_overrides!`), so it sees and wins over the issue-#112 cleanups; the list is German-only, FR/IT descriptions are untouched. CLI wires `builder.rogger_names` only when `--rogger` is set (default off, all feeds unchanged without it).
34
34
 
35
+ 12. **Swissmedic lists** (`SwissmedicDownloader` in `downloader.rb`, **3.0.37**) — the authorised packages (`:package`) and orphan drugs (`:orphan`) xlsx. **New Swissmedic website, 01.12.2026:** the old listing page `/swissmedic/de/home/services/listen_neu.html` (and every old `/dam/swissmedic/…` file URL) answers **404**; the lists hang off `LISTING_URL` = `/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html`, linked by **file name** (`zugelassene-packungen-ham_de_fr.<hash>.xlsx`, `liste-orphandrug-internet_de_fr.<hash>.xlsx`, link text likewise) instead of "Zugelassene Packungen"; the hash changes with every update, so the link is still scraped (`find_link`: file name first, the old link text as fallback). Sheet layout unchanged. **The new site published both lists dated 28.02.2026** while the old one had served 31.10.2026 (17'894 vs 18'136 package rows) — taking it would silently drop eight months of authorisations. So every download's `Stand / Etat au` date is read (`SwissmedicDownloader.stand`, from `xl/sharedStrings.xml`): with **`ODDB2XML_LAST_GOOD_DIR`** set, the newest list seen is kept there and a download dated earlier, a failed download or a missing link falls back to it with a stderr warning; without it a list older than `STALE_DAYS` (62) only warns. `run_oddb2xml.sh` exports it as `<OUT_DIR>-state/swissmedic` (seeded 01.12.2026 with the 31.10.2026 lists). `initialize` used to skip `Downloader#initialize`, so `@retry_times` was nil and the first retry would have raised `NoMethodError`; it is set explicitly now. Swissmedic was told about the stale lists via Anfragen@swissmedic.ch. rust2xml, aips2sqlite and cpp2sqlite read the same lists and were fixed the same day. Spec note: the downloader specs' `common_after` pretty-prints the VCR cassette with `python -mjson.tool`; on a host with only `python3` that **empties** `oddb2xml.json` and every later replaying example fails (23 failures under seed 24955) — the new Swissmedic specs therefore tear down without it.
36
+
35
37
  ### Key data identifiers
36
38
  - **GTIN/EAN13**: Primary article identifier (13-digit barcode)
37
39
  - **Pharmacode**: Swiss pharmacy code
@@ -49,15 +51,19 @@ These scripts run the public download server at `https://mediupdatexml.oddb.org`
49
51
  - **`run_oddb2xml.sh`** — nightly build driver (cron: `0 1 * * * zdavatz`). Downloads the upstream sources **once**, then builds the `-b`/firstbase feed at price increments `45/50/55` plus `default` (no increment) into `$OUT_DIR` (`/home/zdavatz/oddb2xml`, one subdir each). The shared `downloads/` cache and transient zip live in `$BUILD_DIR` (`<OUT_DIR>-build`), **outside** `$OUT_DIR` so the transfer never uploads the multi-hundred-MB cache. Final step ("2b") regenerates the landing page. Each `oddb2xml` invocation is wrapped in `run_with_retry` (default **3 attempts, 120 s apart**, tunable via `ODDB2XML_RETRIES`/`ODDB2XML_RETRY_DELAY`): a transient upstream download failure (e.g. Swissmedic resetting the connection, `Errno::ECONNRESET`) previously aborted the whole `set -e` run 14 s in and left the feeds a day stale, so it now retries before giving up; a genuine repeated failure still stops the run. **Firstbase (GS1 NONPHARMA) last-good fallback (3.0.29 onwards):** the GS1 `GetFirstbaseHealthcare` export (`id.gs1.ch/01/07612345000961` → `apitools.gs1.ch`) has been answering `403 - Forbidden`, which blanked `firstbase.csv` and dropped **every** NONPHARMA article from the `-b` feed (landing page then showed `NONPHARMA = 0 − 1 = −1`). The script keeps the last successful `firstbase.csv` in a persistent cache `$FIRSTBASE_CACHE` (default `<OUT_DIR>-state/firstbase.csv`) **outside** `$BUILD_DIR` so it survives the nightly `rm -rf`, seeds it into `downloads/` before the build, and refreshes it after a successful download. The gem side (`FirstbaseDownloader#download`, rewritten in 3.0.29) makes the seed usable: it still attempts the live GS1 fetch on the first (downloading) build, but only overwrites `firstbase.csv` when the response is a real non-empty CSV (`firstbase_csv?` rejects HTML/`403 - Forbidden`/empty bodies and open-uri exceptions), otherwise it **keeps the existing seeded file** instead of the old `"w+"` truncate-to-zero. A recovered GS1 therefore refreshes the data automatically; while GS1 is down the feed serves yesterday's (last-good) NONPHARMA rather than nothing. `generate_index_html.sh` also guards the NONPHARMA count so an empty CSV renders `—` (not `−1`). **ZurRose/pillbox last-good seed + first-build `--skip-download` (2026-07-07):** the actual reason the nightly feed went stale after 2026-07-03 was **not** firstbase (a firstbase failure is non-fatal) but **ZurRose**: `pillbox.oddb.org:80` started refusing connections around 01:00 every night from 2026-07-04 on, so `ZurroseDownloader` wrote a 0-byte `transfer.zip`, `unzip` produced no `transfer.dat`, and `downloader.rb:221` raised `Errno::ENOENT`, aborting the whole `set -e` run (all three retries hit the same dead pillbox). Fix is **script-only, no gem release**: `get_transfer.sh` (cron 00:30) already mirrors the ZurRose zip locally at `$GET_TRANSFER_ZIP` (`/home/zdavatz/software/get_transfer/TRANSFER.ZIP`), so the **first** `build_one` now runs a `first_build_attempt` helper that (a) `seed_downloads` — resets `downloads/` to contain only that seeded `transfer.zip` — then (b) runs `oddb2xml --skip-download -b -c zip`. The `--skip-download` flag makes `Cli#run` **skip the `FileUtils.rm_f(Dir.glob(DOWNLOADS/*))` wipe (cli.rb:50)** that used to delete the seed, so `Oddb2xml.skip_download` reuses the seeded `transfer.zip` for ZurRose (no pillbox fetch) while `download_as` still fetches **every other source fresh** (Swissmedic, Refdata, BAG, FHIR NDJSON, Weleda/WALA, and firstbase — proven: `--skip-download` only reuses files already present in `downloads/`, it does not suppress downloading absent ones). Seeding happens **per attempt** inside `run_with_retry`, so a retry restarts from a clean cache (clears partials) while keeping the seed. **Consequence for firstbase:** it is now downloaded **once** by the first build and reused by the `45/50/55`/artikelstamm increments via `--skip-download` — and it is **no longer pre-seeded into `downloads/`** from `$FIRSTBASE_CACHE` (under `--skip-download` a *present* `firstbase.csv` would be reused verbatim and never refreshed, freezing NONPHARMA). GS1's `id.gs1.ch` route currently returns a real 151 MB CSV, so firstbase fetches fresh; `$FIRSTBASE_CACHE` is still refreshed from the fresh file after the build for reference/recovery. The 3.0.29 gem-side `firstbase_csv?`/keep-existing logic is retained but only engages on the non-`--skip-download` path.
50
52
  - **`generate_index_html.sh DOCROOT [FIRSTBASE_CSV]`** — single source of truth for the landing page. Writes `index.html` + a self-contained `logo.svg` **atomically** (temp + `mv`, so either owner — root from setup, `zdavatz` from cron — can refresh it). Computes live counts: PHARMA = `<SMNO>` count in `default/oddb_article.xml`, NONPHARMA = firstbase CSV rows − 1, total ART = `<ART ` count. Also runs **`visitor_stats.py`** and embeds its graph. Re-run standalone any time (it only reads already-built files); a separate cron line refreshes it **hourly** (`5 * * * * zdavatz`) so counts + graph stay current between nightly builds.
51
53
  - **`visitor_stats.py LOG_GLOB CACHE_DIR [DAYS]`** — emits the visitors/sessions/region graph as an inline-SVG HTML **fragment** (last `DAYS`, default 14): Besucher = distinct IPs/day, Sitzungen = 30-min-inactivity sessions per `(IP, User-Agent)`, plus a top-6 country breakdown by IP. Bots are filtered by User-Agent. Region lookup is **fully self-contained** — pure Python stdlib + the free **DB-IP country-lite CSV** (CC-BY, no licence key) cached in the build `downloads/` dir and refreshed monthly; **no apt package, no gem, no system GeoIP DB**. Prints nothing (page degrades to omitting the section) when the Apache log is unreadable or empty. Reading `/var/log/apache2` requires the cron user to be in the **`adm`** group (`sudo usermod -aG adm zdavatz`).
52
- - **`swissmedic_watch.sh`** — outage/block auto-recovery (cron: `*/30 * * * * zdavatz`). Since the Swissmedic platform migration (~2026-06-23, now a Swisscom-operated gateway), `www.swissmedic.ch` intermittently resets this host's automated connections **after the TLS handshake** (TCP RST), which aborts `run_oddb2xml.sh` under `set -e` and leaves the feeds stale (the block is host/IP- and client-fingerprint-sensitive: a real browser works, `curl`/`wget`/Ruby get reset, while other admin.ch hosts answer fine — so it is a WAF/bot rule, not an outage). The watcher polls Swissmedic with **oddb2xml's own client** (a Ruby `open-uri` canary on `listen_neu.html`); while blocked it is a silent no-op, and the moment it gets HTTP 200 it launches **one** build and emails. It fires **at most once per day** (stamp in `$STATE_DIR`, default `<OUT_DIR>-watch`, kept **outside** the wiped `$BUILD_DIR`), and skips when a build is already running or today's `default/oddb_article.xml` is already fresh. **PATH assembly (2026-07-28 onwards):** cron hands the watcher a minimal PATH, so it builds one explicitly — `/usr/local/bin` (where a root `gem install` under Debian's system Ruby puts the binstub) + the user gem bin dir (`$(ruby -e 'print Gem.user_dir')/bin`, where an *unprivileged* `gem install` silently lands instead, because `/var/lib/gems` is not writable) + rbenv shims **only when they exist** (the pre-2026-07 box; `RBENV_VERSION=3.4.5` is exported only in that case). The previous hardcoded rbenv-only PATH carried no `/usr/local/bin`, so the first watcher-triggered build on the rebuilt server died `oddb2xml: Kommando nicht gefunden` (exit 127) on all three retries before aborting. `run_oddb2xml.sh` step 1 extends PATH the same way right after its `gem install`, for the same reason.
53
- - **`transfer.sh`** — optional hand-off (scp) of `$OUT_DIR` to the HIN host; `SCP_DEST` is required-but-unset until the HIN host is known. **Obsolete, not merely unwired (issue [#127](https://github.com/zdavatz/oddb2xml/issues/127)):** it is not in `/etc/cron.d/mediupdatexml` and `SCP_DEST` still has no default — and it should stay that way, because **HIN no longer hosts a copy at all**. Their page `www.hin.ch/de/services/mediupdate-xml.cfm#section_2` links *this* site's URLs directly (`default/`, `45/`, `50/`, `55/`, `aips2sqlite/`) and mentions `download.hin.ch` exactly **zero** times, so there is nothing left to scp. The trap is that the unfed legacy path `https://download.hin.ch/download/oddb2xml/` **still answers HTTP 200**, serving the build of **22.06.2026** (`GENERATED_BY="oddb2xml 3.0.25"`, `Last-Modified: Sun, 21 Jun 2026 23:01:34 GMT`) — the whole directory carries that one date. It looks authoritative, it 404s nothing, and that is how issue #127 was filed against us for data that was current here all along. When someone reports stale data, **check which host they fetched from before touching the build**: `mediupdatexml.oddb.org` is the source of truth. HIN has been asked to 301 or retire the old path. `README.md` and `QA.md` now point at `mediupdatexml.oddb.org` throughout. For twenty days one link on HIN's page was genuinely broken and it was **ours**: `/aips2sqlite/oddb2xml_swissmedic_sequences.csv` answered 404 — **not** because the server rebuild lost it, but because aips2sqlite hit **the same Refdata barcode bug as issue #122**: `ean_code.length()` on the missing `<DataCarrierIdentifier>` threw a `NullPointerException` out of four copied loops, and `generate_aips_fi` deleted the published CSV *before* regenerating it, so under `set -e` each crash left nothing rather than yesterday's file. Fixed 02.09.2026 in aips2sqlite `ad2fc58` (all four loops skip barcode-less articles; the CSV is now published by `mv` only after a run that passed a row-count check). **When Refdata breaks one of the two projects, check the other** — they parse the same file with the same assumption.
54
+ - **`swissmedic_watch.sh`** — outage/block auto-recovery (cron: `*/30 * * * * zdavatz`). **Canary moved 01.12.2026** to the new listing page `verzeichnisse-humanarzneimittel.html`: the old `listen_neu.html` answers 404 since the new Swissmedic website, which the watcher would have read as a permanent block and never launched a build again. Since the Swissmedic platform migration (~2026-06-23, now a Swisscom-operated gateway), `www.swissmedic.ch` intermittently resets this host's automated connections **after the TLS handshake** (TCP RST), which aborts `run_oddb2xml.sh` under `set -e` and leaves the feeds stale (the block is host/IP- and client-fingerprint-sensitive: a real browser works, `curl`/`wget`/Ruby get reset, while other admin.ch hosts answer fine — so it is a WAF/bot rule, not an outage). The watcher polls Swissmedic with **oddb2xml's own client** (a Ruby `open-uri` canary on `listen_neu.html`); while blocked it is a silent no-op, and the moment it gets HTTP 200 it launches **one** build and emails. It fires **at most once per day** (stamp in `$STATE_DIR`, default `<OUT_DIR>-watch`, kept **outside** the wiped `$BUILD_DIR`), and skips when a build is already running or today's `default/oddb_article.xml` is already fresh. **PATH assembly (2026-07-28 onwards):** cron hands the watcher a minimal PATH, so it builds one explicitly — `/usr/local/bin` (where a root `gem install` under Debian's system Ruby puts the binstub) + the user gem bin dir (`$(ruby -e 'print Gem.user_dir')/bin`, where an *unprivileged* `gem install` silently lands instead, because `/var/lib/gems` is not writable) + rbenv shims **only when they exist** (the pre-2026-07 box; `RBENV_VERSION=3.4.5` is exported only in that case). The previous hardcoded rbenv-only PATH carried no `/usr/local/bin`, so the first watcher-triggered build on the rebuilt server died `oddb2xml: Kommando nicht gefunden` (exit 127) on all three retries before aborting. `run_oddb2xml.sh` step 1 extends PATH the same way right after its `gem install`, for the same reason.
55
+ - **`transfer.sh`** — optional hand-off (scp) of `$OUT_DIR` to the HIN host; `SCP_DEST` is required-but-unset until the HIN host is known. **Obsolete, not merely unwired (issue [#127](https://github.com/zdavatz/oddb2xml/issues/127)):** it is not in `/etc/cron.d/mediupdatexml` and `SCP_DEST` still has no default — and it should stay that way, because **HIN no longer hosts a copy at all**. Their page `www.hin.ch/de/services/mediupdate-xml.cfm#section_2` links *this* site's URLs directly (`default/`, `45/`, `50/`, `55/`, `aips2sqlite/`) and mentions `download.hin.ch` exactly **zero** times, so there is nothing left to scp. The trap is that the unfed legacy path `https://download.hin.ch/download/oddb2xml/` **still answers HTTP 200**, serving the build of **22.06.2026** (`GENERATED_BY="oddb2xml 3.0.25"`, `Last-Modified: Sun, 21 Jun 2026 23:01:34 GMT`) — the whole directory carries that one date. It looks authoritative, it 404s nothing, and that is how issue #127 was filed against us for data that was current here all along. When someone reports stale data, **check which host they fetched from before touching the build**: `mediupdatexml.oddb.org` is the source of truth. HIN has been asked to 301 or retire the old path. `README.md` and `QA.md` now point at `mediupdatexml.oddb.org` throughout. For twenty days one link on HIN's page was genuinely broken and it was **ours**: `/aips2sqlite/oddb2xml_swissmedic_sequences.csv` answered 404 — **not** because the server rebuild lost it, but because aips2sqlite hit **the same Refdata barcode bug as issue #122**: `ean_code.length()` on the missing `<DataCarrierIdentifier>` threw a `NullPointerException` out of four copied loops, and `generate_aips_fi` deleted the published CSV *before* regenerating it, so under `set -e` each crash left nothing rather than yesterday's file. Fixed 02.09.2026 in aips2sqlite `ad2fc58` (all four loops skip barcode-less articles; the CSV is now published by `mv` only after a run that passed a row-count check). **When Refdata breaks one of the two projects, check the other** — they parse the same file with the same assumption. Second aips2sqlite outage of the same shape, 16.–22.09.2026: swissdrg.org retired the file id behind the DE *Fallpauschalenkatalog* download and served an HTML page *"Ungültige Datei"* with **HTTP 200** for it; `FileUtils.copyURLToFile` wrote the page over `swiss_drg_de_xlsx.xlsx`, `XSSFWorkbook` threw `POIXMLException: Package should contain a content type part` (a RuntimeException past the `IOException`-only catch), and the `--lang=de --xml` step died nightly for a week — `amiko_db_full_idx_de.db` in `jars/output/` shrank to 16 kB while the FR DB and the sequences CSV (built by the later `--nodown` steps, which never touch that file) stayed at 15.09. A downstream user (Swiss Medical Record) reported the identical trace from their own jar. Fixed 22.09.2026 in aips2sqlite `8cf81a6`: new file id `1444/1029` (same 6.0/2017 catalogue), zip-magic check with last-good keep on download, and `extractSwissDRGInfo` skips with a `SKIPPED` warning instead of aborting — the Swiss DRG Zusatzentgelte are optional enrichment, **a missing side file must never abort the run**. Nothing on the host tells you when the 04:30 job dies (no MTA), so the `jars/output/` timestamps are the monitor.
54
56
  - **`setup_new_server.sh`** (2026-07-28 onwards) — one-command rebuild of a bare Debian host into this download site, written after **HIN deleted the previous server**: everything that had accumulated by hand on that box, so a rebuild is not a day of archaeology. Root, idempotent. Installs the packages (`apache2` + `certbot`; **`ruby-full`** — Debian 13 ships Ruby 3.3, matching the repo `.ruby-version`, so the new host has **no rbenv**; `cron`, absent on a minimal image; `unzip`/`zip` for the ZurRose transfer and the build zip; `poppler-utils` for `pdftotext` in `tools/generate_bag_sl_group_prices.rb`; nokogiri/ffi build headers), adds `$RUN_USER` to **`adm`** (so `visitor_stats.py` may read `/var/log/apache2`), sets the home dir to **711** (so `www-data` can traverse to `$OUT_DIR` without listing it), `gem install oddb2xml`, creates the five directories (`$OUT_DIR`, `-build`, `-state`, `-watch` — the last two deliberately outside the nightly-wiped `-build` — and `$GET_TRANSFER_DIR`, symlinking the tracked `get_transfer.sh` into it), writes **`/etc/cron.d/mediupdatexml`** (the whole schedule in one re-creatable file rather than the old box's per-user crontab: `get_transfer` 00:30, nightly build 01:00, rust2xml Artikelstamm 03:00, aips2sqlite Fachinfos 04:30, landing page hourly at `:05`, Swissmedic watcher every 30 min) plus a logrotate rule for the cron logs, then hands over to `setup_aips2sqlite.sh` and `setup_mediupdatexml_web.sh`. Env: `RUN_USER`, `OUT_DIR`, `SKIP_WEB=1`, `SKIP_GEM=1`, `SKIP_AIPS=1`. **Deliberately out of scope** (gone with the old server, restored separately): an MTA for the cron `MAILTO`.
55
57
  - **`setup_mediupdatexml_web.sh`** — one-time root setup of the Apache vhost + initial page. Skips the Let's Encrypt step with a hint when the domain does not yet resolve in **public** DNS (checked via Cloudflare DoH, not the local resolver, which may hold a stale or negative cache).
56
58
  - **`setup_aips2sqlite.sh`** (2026-08-01 onwards) — provisions the **aips2sqlite** half of the site, restored after the server rebuild. The landing page links a whole `/aips2sqlite/` section (Fachinformationen as XML, the AmiKo `.db` files, `oddb2xml_swissmedic_sequences.csv`, `atc_codes_used_set.txt`); `setup_mediupdatexml_web.sh` writes the Apache alias `/aips2sqlite` → `<checkout>/jars/output`, but on the rebuilt host neither the JRE nor that directory existed, so **every link answered 403** — Apache falls back to the default `<Directory /> Require all denied` when the aliased path does not exist, so a *missing* target reads as *forbidden*, not *not found*. Root, idempotent: installs **`openjdk-21-jre-headless`** (the repo ships a prebuilt fat jar `jars/aips2sqlite.jar`, so a JRE suffices — no JDK/Gradle unless the jar is rebuilt; the only AWT user, `BarCode.java`/barcode4j, is off the Fachinfo path), clones the checkout if missing, creates `jars/output` + `jars/downloads` owned by `$RUN_USER`, and appends the 04:30 cron entry to `/etc/cron.d/mediupdatexml` if not already there (`SKIP_CRON=1` when called from `setup_new_server.sh`, which writes that line itself). Generating the data is a separate build-user step: `aips2sqlite/scripts/generate_aips_fi` (~1 h; `--lang=de --xml`, then `--lang=fr --xml --nodown`, then `--nodown --smsequence`, renaming `swiss_medic_sequences.csv` → `oddb2xml_swissmedic_sequences.csv`). `REFDATA_API_KEY` (developer.refdata.ch) is **optional** for this path: the Refdata Partner SOAP download it gates is consumed only by the Takeda partner export, and its failure is caught and logged, so the FI/sequences output is complete without it.
59
+ - **`setup_rust2xml_web.sh`** (15.11.2026) — root, idempotent: the search page https://mediupdatexml.oddb.org/suche/ over the rust2xml database (user: "eine Suchfunktion für die DB welche mit rust2xml generiert wird … gleich wie wir es für cosmon implementiert haben", i.e. trindex.oddb.org). Enables `mod_proxy` + `mod_proxy_http`, writes `/etc/apache2/conf-available/mediupdatexml-suche.conf` (`RedirectMatch ^/suche$ /suche/`, `ProxyPass /suche/ http://127.0.0.1:3020/` — the prefix is stripped, the page uses relative URLs) and appends an `@reboot` start of `rust2xml/scripts/rust2xml_web.sh` to `/etc/cron.d/mediupdatexml` (`SKIP_CRON=1` from `setup_new_server.sh`, which writes that line itself). Everything else lives in the rust2xml repo: `rust2xml --sqlite` writes the database in the same 03:00 run as the Artikelstamm (about a minute, ~140 MB), `run_artikelstamm.sh` publishes it by rename as `artikelstamm/rust2xml/rust2xml.sqlite` and calls `rust2xml_web.sh ensure`, and the server (`rust2xml-web`, `src/web.rs`) opens it read-only per request. `generate_index_html.sh` shows a "rust2xml — Suche und SQLite-Datenbank" section: the database link once the file exists, the search link and a search field at the top of the page (a plain GET form to `suche/?q=…`, opens in a new tab, `target=_blank`; user: "ich sehe keine search bar hier", then "öffne das Suchfenster in einem neuen Tab") **only while `https://mediupdatexml.oddb.org/suche/api/stand` answers 200** (`SEARCH_URL`), so the page never carries a dead link while Apache is not set up or the server is down.
57
60
  - **`setup_rust2xml.sh`** — the build-user (never root) counterpart: installs the Rust toolchain via **rustup** — not Debian's `rustc`, because `rust2xml/scripts/run_artikelstamm.sh` sources `$HOME/.cargo/env` to find cargo under cron's minimal PATH — and runs `cargo build --release --bin rust2xml` in `$RUST2XML_DIR` (default `~/software/rust2xml`), feeding the 03:00 cron entry that publishes rust2xml's own Artikelstamm to `/artikelstamm/rust2xml/`. Idempotent: re-running updates the toolchain and rebuilds only if sources changed.
58
61
 
59
62
  Only the scripts are git-tracked; the generated `index.html`/`logo.svg` and the `downloads/` cache are not.
60
63
 
64
+ ### Reporting upstream data bugs and closing the loop
65
+ When a user reports wrong output that turns out to be an upstream data error, fix or compensate in oddb2xml **and** report the error to the source (Refdata: Nicolas Florin), describing only the data defect. After the gem release that carries the fix, mail the original reporter with the version number and when it reaches the nightly feeds (it does so only after the server has the new gem installed; `run_oddb2xml.sh` step 1 does `gem install` nightly).
66
+
61
67
  ## Testing
62
68
 
63
69
  - Framework: RSpec with flexmock (mocking), webmock + VCR (HTTP recording/playback)
@@ -65,4 +71,4 @@ Only the scripts are git-tracked; the generated `index.html`/`logo.svg` and the
65
71
  - `spec/spec_helper.rb` defines test constants (GTINs) and configures VCR to avoid real HTTP calls during tests
66
72
  - CI runs on Ruby 3.2 and 3.3 (`.github/workflows/ruby.yml`); 3.0/3.1 cannot resolve the lockfile since `public_suffix` 7 (Feb 2026) and are EOL
67
73
  - **Never call `Kernel#exit` inside `lib/`.** Until 02.09.2026 `Builder#prepare_substances` did (`exit 2` when an `-e`/`--artikelstamm` build had no substances). Under rspec that killed the *process* mid-run: the summary still printed, reading e.g. `1193 examples, 0 failures`, but the count was a random fraction of the ~1640 examples and the exit status was 2 — CI had been red on every run for over a year while local runs looked green to anyone reading the summary line instead of `$?`. The trigger was the June-2026 FHIR default: `-e` implies `--fhir`, `epl.bag.admin.ch` was never stubbed, `FhirExtractor added 0 items`, empty substances, exit. Builder now raises `Oddb2xml::NoSubstancesError` (`util.rb`) and only `bin/oddb2xml` turns that into exit status 2, so production keeps its contract and rspec sees an ordinary failure. `mock_downloads` stubs the three NDJSON URLs with `spec/data/fhir/cyramza.ndjson` (one bundle — enough to stay non-empty, not enough for price assertions), and the four CLI specs that assert on SL prices run with `--no-fhir` against the stubbed `Preparations.xml`, which is what they were written for. **When judging a run, read the exit status and the example count, not the failure count.**
68
- - **Dependabot security jobs (fixed 02.09.2026, `b9e1f09`):** the "bundler in /. for savon/json" runs had failed for months. Two lessons. (a) Dependabot resolves the lockfile against the **lowest** Ruby the gemspec allows — with `required_ruby_version >= 2.5.0` it could not pick json ≥ 2.8 (needs 2.7), so a stale floor silently blocks every security update; the floor is `>= 3.2.0` now. (b) A gem that is only `require`d but never called still carries its advisories: `savon` (two HIGH, GHSA Savon::Model evaluates WSDL operation names) had been dead since the SwissReg migration `4c65a9c` (March 2026), pinned `~> 2.12.0` so the fix 2.17.2 was unreachable. Removing it also removed akami/gyoku/nori/wasabi/httpi/socksify — and exposed that `HTTPI.log = false` in `Downloader#initialize` was loaded only through savon (305 NameErrors), so that line and `httpi` went too. Before bumping a pinned gem, `grep -rn "Savon::"`-style for actual use first. **The published 3.0.34 gem still declares `savon` and `httpi`**, so every `gem install oddb2xml` — including the nightly's step 1 — pulls the vulnerable savon 2.12.1 until 3.0.35 is released. `rubyntlm`, `multi_json` and the two `net/ntlm` requires in `downloader.rb` are the same kind of SOAP-era leftover (zero references), not yet removed.
74
+ - **Dependabot security jobs (fixed 02.09.2026, `b9e1f09`):** the "bundler in /. for savon/json" runs had failed for months. Two lessons. (a) Dependabot resolves the lockfile against the **lowest** Ruby the gemspec allows — with `required_ruby_version >= 2.5.0` it could not pick json ≥ 2.8 (needs 2.7), so a stale floor silently blocks every security update; the floor is `>= 3.2.0` now. (b) A gem that is only `require`d but never called still carries its advisories: `savon` (two HIGH, GHSA Savon::Model evaluates WSDL operation names) had been dead since the SwissReg migration `4c65a9c` (March 2026), pinned `~> 2.12.0` so the fix 2.17.2 was unreachable. Removing it also removed akami/gyoku/nori/wasabi/httpi/socksify — and exposed that `HTTPI.log = false` in `Downloader#initialize` was loaded only through savon (305 NameErrors), so that line and `httpi` went too. Before bumping a pinned gem, `grep -rn "Savon::"`-style for actual use first. 3.0.34 and earlier still declare `savon` and `httpi` and pull the vulnerable savon 2.12.1; 3.0.35 onwards is clean. **Open as of 3.0.36:** two HIGH Dependabot alerts (#84, #85) for `rubyzip` < 3.4.0 (path traversal) — not yet bumped. The same sweep later removed `multi_json` and the direct `rubyntlm` pin plus the two `net/ntlm` requires in `downloader.rb` (zero references, SOAP-era leftovers); `rubyntlm` itself stays in the lockfile as a transitive dependency of `mechanize`, which carries the same `>= 0.6.3` CVE floor.
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (3.0.35)
4
+ oddb2xml (3.0.37)
5
5
  csv
6
6
  htmlentities
7
7
  mechanize (>= 2.8.5)
8
8
  minitar
9
- multi_json
10
9
  nokogiri (>= 1.18.10)
11
10
  optimist
12
11
  ox
@@ -14,7 +13,6 @@ PATH
14
13
  rack (>= 3.1.20)
15
14
  rexml (>= 3.3.9)
16
15
  rubyXL (~> 3.4.0)
17
- rubyntlm (>= 0.6.3)
18
16
  rubyzip (~> 3.0.1)
19
17
  sax-machine
20
18
  spreadsheet
@@ -70,7 +68,6 @@ GEM
70
68
  mime-types-data (3.2026.0203)
71
69
  mini_portile2 (2.8.9)
72
70
  minitar (1.1.0)
73
- multi_json (1.19.1)
74
71
  mutex_m (0.3.0)
75
72
  net-http-digest_auth (1.4.1)
76
73
  net-http-persistent (4.0.8)
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ === 3.0.37 / 01.12.2026
2
+ * Swissmedic moved to a new website on 01.12.2026. The page oddb2xml read the list links from (/swissmedic/de/home/services/listen_neu.html) and every old file URL answer 404, so every run that downloads Swissmedic failed. SwissmedicDownloader now reads the authorised packages and the orphan drugs list from https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html, where they are linked by file name. The sheet layout is unchanged. Reported by zollsoft.
3
+ * The new site published both lists dated 28.02.2026, while the old site had served 31.10.2026 (17'894 instead of 18'136 package rows). oddb2xml now reads the "Stand / Etat au" date of every download and warns on stderr when a list is more than 62 days old. With ODDB2XML_LAST_GOOD_DIR set it keeps the newest list it has seen there and builds from that copy, with a warning, when a download is dated earlier, fails, or the listing page has no link. The nightly build on mediupdatexml.oddb.org sets it.
4
+ * SwissmedicDownloader never set the retry counter of Downloader, so its first retry would have raised NoMethodError. Fixed.
5
+ * Suite: 1654 examples, 0 failures.
6
+
7
+ === 3.0.36 / 28.09.2026
8
+ * Bugfix (Refdata cleanup): correct the German pack volume when Refdata's German name disagrees with its own French and Italian names. Reported by zollsoft for PRIVIGEN 10% 400 ml (GTIN 7680583140053), whose German description in oddb_product.xml and oddb_article.xml read "200 ml" -- the German name of the 200 ml pack -- while French, Italian, ZurRose and the BAG FHIR feed all say 400 ml. The same Refdata defect affects FERINJECT, VIYANA and FERYXA 1000 mg (German "10 ml", correct 20 ml). The fix changes exactly these four articles on the September 2026 Refdata file; concentrations such as mg/ml are never touched. Suite: 1646 examples, 0 failures.
9
+ * Builder creates WORK_DIR before writing missing_in_refdata.txt and the Artikelstamm CSV (order-dependent spec failure, seed 17155).
10
+ * Dependencies: multi_json and the direct rubyntlm pin removed (SOAP-era leftovers, no references); rubyntlm stays as a dependency of mechanize.
11
+
1
12
  === 3.0.35 / 02.09.2026
2
13
  * Security: drop the savon dependency (two HIGH advisories, GHSA "Savon::Model evaluates WSDL operation names as Ruby source"). It had not been used since the SwissReg migration in 3.0.19 (commit 4c65a9c, March 2026) -- only a require remained -- but the gemspec pin ~> 2.12.0 kept every installer on the vulnerable 2.12.1 and blocked Dependabot's fix to 2.17.2. Removing it also drops akami, gyoku, nori, wasabi, httpi and socksify from the dependency tree; the one leftover reference, HTTPI.log = false in Downloader#initialize, had only ever been loaded through savon and is gone too. json is raised to 2.21.2 (LOW advisory: generator heap buffer overflow when streaming to an IO). 3.0.34 and earlier still declare savon and httpi, so `gem install oddb2xml` on those versions pulls savon 2.12.1 -- upgrade.
3
14
  * required_ruby_version is now >= 3.2 (was >= 2.5.0). Ruby 3.0 and 3.1 are end-of-life and have not been able to resolve the lockfile since public_suffix 7 (February 2026); the stale floor also made Dependabot resolve against Ruby 2.5, which is why its json update could never succeed. CI runs on 3.2 and 3.3.
data/README.md CHANGED
@@ -25,13 +25,13 @@ creates .dat files according to ([IGM-11](http://dev.ywesee.com/uploads/att/IGM.
25
25
  * oddb.dat
26
26
  * oddb_with_migel.dat
27
27
 
28
- the files are using [Refdata](https://files.refdata.ch/simis-public-prod/Articles/1.0/Refdata.Articles.zip), [BAG-XML](http://bag.e-mediat.net/SL2007.Web.External/Default.aspx?webgrab=ignore) and [Swissmedic](http://www.swissmedic.ch/daten/00080/00251/index.html?lang=de) as sources.
28
+ the files are using [Refdata](https://files.refdata.ch/simis-public-prod/Articles/1.0/Refdata.Articles.zip), [BAG-XML](http://bag.e-mediat.net/SL2007.Web.External/Default.aspx?webgrab=ignore) and [Swissmedic](https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html) as sources.
29
29
 
30
30
  The following additional data is in the files:
31
31
 
32
32
  * [Wirkstoffe](http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip) (BAG XML)
33
33
  * [Kühlkette](http://www.swissmedic.ch/daten/00080/00254/index.html?lang=de&download=NHzLpZeg7t,lnp6I0NTU042l2Z6ln1acy4Zn4Z2qZpnO2Yuq2Z6gpJCDdH57e2ym162epYbg2c_JjKbNoKOn6A--) (Swissmedic)
34
- * [Orphan Drugs](http://www.swissmedic.ch/daten/00081/index.html?lang=de&download=NHzLpZeg7t,lnp6I0NTU042l2Z6ln1acy4Zn4Z2qZpnO2Yuq2Z6gpJCDdH55f2ym162epYbg2c_JjKbNoKSn6A--&.xls) (Swissmedic)
34
+ * [Orphan Drugs](https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html) (Swissmedic)
35
35
  * [FI: de, fr](http://download.swissmedicinfo.ch) (Swissmedic)
36
36
  * Limitation-Texte (BAG XML)
37
37
  * Interaktionen [EPha.ch](http://epha.ch)
@@ -303,7 +303,7 @@ product.xml has relation to substance as `<SUBNO>`.
303
303
 
304
304
  We use the following files:
305
305
 
306
- * https://www.swissmedic.ch/arzneimittel/00156/00221/00222/00230/index.html?lang=de (Präparateliste und zugelassene Packungen)
306
+ * https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html (zugelassene Packungen and orphan drugs; the file links are read off this page, see below)
307
307
  * https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/interactions_de_utf8.csv
308
308
  * https://files.refdata.ch/simis-public-prod/Articles/1.0/Refdata.Articles.zip
309
309
  * http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip
@@ -317,6 +317,17 @@ We use the following files:
317
317
  * https://epl.bag.admin.ch/static/sl/publication/fhir/foph-sl-publication-latest-{de,fr,it}.ndjson (FHIR NDJSON, used with `--fhir`)
318
318
  * https://id.gs1.ch/01/07612345000961 (GS1 Switzerland firstbase CSV — full barcode registry, used with `-b`/`--firstbase`)
319
319
 
320
+ **Swissmedic lists and their date (3.0.37).** Swissmedic moved to a new website
321
+ on 01.12.2026; the lists now hang off the page above and are linked by file name
322
+ (`zugelassene-packungen-ham_de_fr…xlsx`, `liste-orphandrug-internet_de_fr…xlsx`).
323
+ On that day both lists were published dated 28.02.2026 although the old site had
324
+ served 31.10.2026. oddb2xml reads the "Stand / Etat au" date of every download
325
+ and warns on stderr when a list is more than 62 days old. Set
326
+ `ODDB2XML_LAST_GOOD_DIR` to a persistent directory to have it keep the newest
327
+ list it has seen there: a download dated earlier, a failed download or a
328
+ listing page without the link then falls back to the kept copy (with a warning)
329
+ instead of building from older data or failing.
330
+
320
331
  ## Indikationscode (BAG XXXXX.NN)
321
332
 
322
333
  In `--fhir` mode, oddb2xml extracts the BAG **Indikationscode** for SL
@@ -457,6 +468,16 @@ Currently active fixes (`lib/oddb2xml/refdata_cleanup.rb`):
457
468
  duplicate token is collapsed to a single occurrence. Real combination
458
469
  products (e.g. PHESGO 600 mg / 600 mg / 10 ml — pertuzumab + trastuzumab)
459
470
  are detected via the comma in `substance_swissmedic` and left untouched.
471
+ * **German pack volume disagreeing with French and Italian** (3.0.36) — Refdata
472
+ sometimes carries a wrong volume in the German name only, e.g.
473
+ `PRIVIGEN 10% Inf Lös 200 ml Dfl` for the 400 ml pack (GTIN 7680583140053)
474
+ while the French and Italian names say 400 ml. When the French and Italian
475
+ names agree on a single standalone `<n> ml` and the German one differs, the
476
+ German number is replaced. Concentrations such as `mg/ml` are ignored. On
477
+ the September 2026 file this changes exactly four articles (PRIVIGEN 400 ml,
478
+ FERINJECT, VIYANA and FERYXA 1000 mg 20 ml), all confirmed by ZurRose.
479
+ The four records have been reported to Refdata; once corrected at the
480
+ source the rule simply stops matching.
460
481
 
461
482
  The cleanup runs at the start of `prepare_articles` in `Builder` and is
462
483
  idempotent. Each rule is guarded by a Swissmedic-side heuristic so genuine
@@ -570,6 +591,22 @@ they are the reference setup for running oddb2xml unattended.
570
591
  cron entry that regenerates the Fachinformationen. Run as root; idempotent.
571
592
  Without it every `/aips2sqlite/` link answers 403, because Apache denies a
572
593
  path that does not exist.
594
+ The job's output is only as robust as its side files: when one of the
595
+ `/aips2sqlite/` files goes stale or tiny, look at the timestamps and sizes in
596
+ `jars/output/` first (a `amiko_db_full_idx_de.db` of a few kB means the
597
+ `--lang=de` step died) and then at `generate_aips_fi.log` -- twice now an
598
+ upstream file changed shape (Refdata articles without barcode, 08/2026;
599
+ SwissDRG serving an HTML page for a retired xlsx id, 09/2026) and the Java
600
+ side crashed instead of skipping. Both are fixed in aips2sqlite; the rule
601
+ there is that a missing side file costs its data, never the run.
602
+ * `setup_rust2xml_web.sh` — the search page at
603
+ [mediupdatexml.oddb.org/suche/](https://mediupdatexml.oddb.org/suche/):
604
+ enables `mod_proxy`/`mod_proxy_http`, proxies `/suche/` to `rust2xml-web`
605
+ on `127.0.0.1:3020` and adds an `@reboot` start to the cron file. Run as
606
+ root; idempotent. The server and its database come from the
607
+ [rust2xml](https://github.com/zdavatz/rust2xml) 03:00 job, which also
608
+ publishes `artikelstamm/rust2xml/rust2xml.sqlite`. The landing page links
609
+ the search only while it answers.
573
610
  * `transfer.sh` — optional scp hand-off of the output tree to the HIN
574
611
  download server. **Obsolete, and deliberately not wired up**: `SCP_DEST` has
575
612
  no default and the script is not in `/etc/cron.d/mediupdatexml`. HIN links
@@ -131,11 +131,17 @@ module Oddb2xml
131
131
  end
132
132
  item[key] = desc if desc != original
133
133
  end
134
+ fixed_de = RefdataCleanup.fix_german_volume_from_fr_it(item[:desc_de], item[:desc_fr], item[:desc_it])
135
+ if fixed_de != item[:desc_de]
136
+ item[:desc_de] = fixed_de
137
+ counts[:de_volume] += 1
138
+ end
134
139
  end
135
140
  labels = {metoject: "truncated METOJECT name", veractiv_vol: "truncated volume unit",
136
141
  double_dose: "double-dose pattern", galenic: "galenic form",
137
142
  combo_dose: "missing combo 2nd dose", missing_dose: "missing strength",
138
- volume: "missing injection volume"}
143
+ volume: "missing injection volume",
144
+ de_volume: "German pack volume disagreeing with FR/IT"}
139
145
  counts.each do |rule, n|
140
146
  Oddb2xml.log("Refdata cleanup: fixed #{labels[rule]} in #{n} description(s)") if n > 0
141
147
  end
@@ -587,6 +593,12 @@ module Oddb2xml
587
593
  ean13_to_product[ean13] = obj
588
594
  obj[:pharmacode] ||= @refdata[ean13][:pharmacode] if @refdata[ean13]
589
595
  }
596
+ # The CLI creates WORK_DIR before building, but Builder is also driven
597
+ # directly (fhir_spec), and then this was the first write into it --
598
+ # Errno::ENOENT whenever the random spec order got here before any CLI
599
+ # example had created the directory. ZurroseExtractor guards its own
600
+ # WORK_DIR write the same way.
601
+ FileUtils.makedirs(WORK_DIR)
590
602
  ausgabe = File.open(File.join(WORK_DIR, "missing_in_refdata.txt"), "w+")
591
603
  size_old = ean13_to_product.size
592
604
  @missing = []
@@ -1656,6 +1668,7 @@ module Oddb2xml
1656
1668
  def build_artikelstamm(version: 6)
1657
1669
  @@emitted_v6_gtins = []
1658
1670
  @artikelstamm_version = version
1671
+ FileUtils.makedirs(WORK_DIR) # same guard as add_missing_products_from_swissmedic
1659
1672
  @csv_file = CSV.open(File.join(WORK_DIR, "artikelstamm_#{Date.today.strftime("%d%m%Y")}_v#{version}.csv"), "w+")
1660
1673
  @csv_file << ["gtin", "name", "pkg_size", "galenic_form", "price_ex_factory", "price_public", "prodno", "atc_code", "active_substance", "original", "it-code", "sl-liste"]
1661
1674
  @csv_file.sync = true
@@ -1,5 +1,3 @@
1
- require "net/ntlm/version" # needed to avoid error: uninitialized constant Net::NTLM::VERSION
2
- require "rubyntlm"
3
1
  require "mechanize"
4
2
  require "zip"
5
3
  require "open-uri"
@@ -308,19 +306,73 @@ module Oddb2xml
308
306
  end
309
307
  end
310
308
 
309
+ # Swissmedic's lists of authorised packages and of orphan drugs.
310
+ #
311
+ # Swissmedic moved to a new website on 01.12.2026. The old listing page
312
+ # /swissmedic/de/home/services/listen_neu.html answers 404, the lists now hang
313
+ # off LISTING_URL, and their links are named after the file
314
+ # ("zugelassene-packungen-ham_de_fr XLSX 3 MB") instead of "Zugelassene
315
+ # Packungen". The file URLs carry a content hash that changes with every
316
+ # update, so they are still read off the page, matched by the file name.
317
+ #
318
+ # On the same day the new site served both lists dated 28.02.2026 while the
319
+ # old site had served 31.10.2026. Taking such a file would silently drop
320
+ # eight months of authorisations, so every download is checked for the
321
+ # "Stand / Etat au" date in the sheet:
322
+ # * with ODDB2XML_LAST_GOOD_DIR set, the newest file seen so far is kept
323
+ # there; a download dated earlier than it is replaced by the kept copy,
324
+ # and so is a failed download or a listing page without the link
325
+ # * without it, a list older than STALE_DAYS only produces a warning
326
+ # Warnings go to stderr, because Oddb2xml.log prints nothing without --log.
311
327
  class SwissmedicDownloader < Downloader
312
328
  BASE_URL = "https://www.swissmedic.ch"
329
+ LISTING_URL = BASE_URL + "/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html"
330
+ # file name on the new site, link text on the old one
331
+ LINKS = {
332
+ package: [/zugelassene-packungen-ham/i, /Zugelassene Packungen/],
333
+ orphan: [/liste-orphandrug/i, /Humanarzneimittel mit Status Orphan Drug/]
334
+ }
335
+ STALE_DAYS = 62
313
336
  include DownloadMethod
337
+
338
+ # The "Stand / Etat au: dd.mm.yyyy" date written into the sheet's header.
339
+ def self.stand(file)
340
+ return nil unless Oddb2xml.valid_zip?(file)
341
+ strings = Zip::File.open(file) do |zip|
342
+ entry = zip.find_entry("xl/sharedStrings.xml")
343
+ entry ? entry.get_input_stream.read.force_encoding("UTF-8") : ""
344
+ end
345
+ m = strings.match(/Stand\s*\/\s*[EÉ]tat au:?\s*(\d{1,2})\.(\d{1,2})\.(\d{4})/)
346
+ m && Date.new(m[3].to_i, m[2].to_i, m[1].to_i)
347
+ rescue => e
348
+ warn "oddb2xml: cannot read the Stand of #{file}: #{e.message}"
349
+ nil
350
+ end
351
+
352
+ # The href of the list's link on the listing page, or nil.
353
+ def self.find_link(doc, type)
354
+ by_file, by_text = LINKS.fetch(type)
355
+ links = doc.xpath("//a[@href]")
356
+ link = links.find { |a| by_file.match(a["href"]) && /\.xlsx?\b/i.match(a["href"]) } ||
357
+ links.find { |a| by_text.match(a.text) }
358
+ link && link["href"]
359
+ end
360
+
314
361
  def initialize(type = :orphan, options = {})
315
- url = BASE_URL + "/swissmedic/de/home/services/listen_neu.html"
316
- doc = Nokogiri::HTML(Oddb2xml.uri_open(url))
317
362
  @type = type
318
363
  @options = options
319
- case @type
320
- when :orphan
321
- @direct_url_link = BASE_URL + doc.xpath("//a").find { |x| /Humanarzneimittel mit Status Orphan Drug/.match(x.children.text) }.attributes["href"].value
322
- when :package
323
- @direct_url_link = BASE_URL + doc.xpath("//a").find { |x| /Zugelassene Packungen/.match(x.children.text) }.attributes["href"].value
364
+ @retry_times = 3 # Downloader#initialize is not called, retrievable? needs it
365
+ @direct_url_link = nil
366
+ begin
367
+ doc = Nokogiri::HTML(Oddb2xml.uri_open(LISTING_URL))
368
+ href = self.class.find_link(doc, @type)
369
+ if href
370
+ @direct_url_link = href.start_with?("http") ? href : BASE_URL + href
371
+ else
372
+ @link_error = "no link to the #{@type} list on #{LISTING_URL}"
373
+ end
374
+ rescue => e
375
+ @link_error = "#{LISTING_URL}: #{e.message}"
324
376
  end
325
377
  end
326
378
 
@@ -332,6 +384,7 @@ module Oddb2xml
332
384
  return File.expand_path(@file2save)
333
385
  end
334
386
  begin
387
+ raise Oddb2xml::IncompleteDownloadError, @link_error unless @direct_url_link
335
388
  @url = @direct_url_link
336
389
  download_as(@file2save, "w+")
337
390
  # The Swissmedic file is an .xlsx (a ZIP). Downloads through scanning
@@ -342,6 +395,7 @@ module Oddb2xml
342
395
  raise Oddb2xml::IncompleteDownloadError,
343
396
  "Swissmedic #{@type} xlsx is empty or truncated (#{File.size(@file2save)} bytes)"
344
397
  end
398
+ keep_newest_stand
345
399
  if @options[:artikelstamm]
346
400
  # ssconvert is in the package gnumeric (Debian)
347
401
  cmd = "ssconvert '#{@file2save}' '#{File.join(DOWNLOADS, File.basename(@file2save).sub(/\.xls.*/, ".csv"))}' 2> /dev/null"
@@ -349,17 +403,55 @@ module Oddb2xml
349
403
  system(cmd)
350
404
  end
351
405
  return File.expand_path(@file2save)
352
- rescue Timeout::Error, Errno::ETIMEDOUT, Oddb2xml::IncompleteDownloadError => error
353
- if retrievable?
406
+ rescue Timeout::Error, Errno::ETIMEDOUT, Oddb2xml::IncompleteDownloadError, OpenURI::HTTPError, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED => error
407
+ if @direct_url_link && retrievable?
354
408
  Oddb2xml.log("Retrying Swissmedic #{@type} download: #{error.message}")
355
409
  retry
356
410
  end
411
+ return File.expand_path(@file2save) if use_last_good("download failed: #{error.message}")
357
412
  raise
358
413
  ensure
359
414
  Oddb2xml.download_finished(@file2save, false)
360
415
  end
361
416
  File.expand_path(@file2save)
362
417
  end
418
+
419
+ private
420
+
421
+ def last_good_file
422
+ dir = ENV["ODDB2XML_LAST_GOOD_DIR"].to_s
423
+ dir.empty? ? nil : File.join(dir, "swissmedic_#{@type}.xlsx")
424
+ end
425
+
426
+ # Replace @file2save by the kept copy, if there is one.
427
+ def use_last_good(reason)
428
+ kept = last_good_file
429
+ return false unless kept && Oddb2xml.valid_zip?(kept)
430
+ FileUtils.makedirs(File.dirname(@file2save))
431
+ FileUtils.cp(kept, @file2save)
432
+ warn "oddb2xml: Swissmedic #{@type} list: #{reason}; using the last good copy dated #{self.class.stand(kept) || "?"} (#{kept})"
433
+ true
434
+ end
435
+
436
+ def keep_newest_stand
437
+ stand = self.class.stand(@file2save)
438
+ kept = last_good_file
439
+ kept_stand = kept && File.exist?(kept) ? self.class.stand(kept) : nil
440
+ if stand && kept_stand && stand < kept_stand
441
+ use_last_good("#{@url} is dated #{stand}, older than the last good copy")
442
+ return
443
+ end
444
+ if kept && stand
445
+ FileUtils.makedirs(File.dirname(kept))
446
+ FileUtils.cp(@file2save, kept)
447
+ end
448
+ if stand.nil?
449
+ warn "oddb2xml: Swissmedic #{@type} list #{@url} carries no readable Stand date"
450
+ elsif (Date.today - stand).to_i > STALE_DAYS
451
+ warn "oddb2xml: Swissmedic #{@type} list #{@url} is dated #{stand}, #{(Date.today - stand).to_i} days old"
452
+ end
453
+ Oddb2xml.log("Swissmedic #{@type} list dated #{stand}")
454
+ end
363
455
  end
364
456
 
365
457
  class SwissmedicInfoDownloader < Downloader
@@ -194,5 +194,30 @@ module Oddb2xml
194
194
  return desc unless VERACTIV_VITD3_IKSNR.include?(iksnr_of(no8))
195
195
  desc.sub(/(\d)\s*m\z/, '\1ml')
196
196
  end
197
+
198
+ # Refdata sometimes carries a wrong pack volume in the German name only,
199
+ # while the French and Italian names of the same article agree with each
200
+ # other and with ZurRose/BAG. Seen September 2026 (reported by zollsoft):
201
+ # 7680583140053 DE "PRIVIGEN 10% Inf Lös 200 ml Dfl" FR/IT "400 ml"
202
+ # 7680578510052 DE "FERINJECT … 1000 mg 10 ml …" FR/IT "20 ml"
203
+ # 7680693600058 VIYANA, 7680694120050 FERYXA same as FERINJECT
204
+ # A scan of all 16'971 Refdata articles found exactly these four, all
205
+ # confirmed wrong by ZurRose transfer.dat. The guard is strict: each name
206
+ # must carry exactly one standalone "<n> ml" (a concentration like
207
+ # "mg/ml" or "1000 mg/20ml" is not standalone), FR and IT must agree, and
208
+ # only the number in DE is replaced.
209
+ ML_TOKEN = %r{(?<![/\d.,])(\d+(?:[.,]\d+)?)(\s*ml)\b}i
210
+
211
+ def self.fix_german_volume_from_fr_it(de, fr, it)
212
+ return de if [de, fr, it].any? { |d| d.nil? || d.empty? }
213
+ de_ml = de.scan(ML_TOKEN)
214
+ fr_ml = fr.scan(ML_TOKEN)
215
+ it_ml = it.scan(ML_TOKEN)
216
+ return de unless de_ml.size == 1 && fr_ml.size == 1 && it_ml.size == 1
217
+ want = fr_ml.first.first.tr(",", ".")
218
+ return de unless it_ml.first.first.tr(",", ".") == want
219
+ return de if de_ml.first.first.tr(",", ".") == want
220
+ de.sub(ML_TOKEN) { "#{fr_ml.first.first}#{$2}" }
221
+ end
197
222
  end
198
223
  end
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "3.0.35"
2
+ VERSION = "3.0.37"
3
3
  end
data/oddb2xml.gemspec CHANGED
@@ -32,8 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "rubyXL", "~> 3.4.0"
33
33
  spec.add_dependency "sax-machine" # , '~> 0.1.0'
34
34
  spec.add_dependency "parslet" # , '~> 1.7.0'
35
- spec.add_dependency "rubyntlm", ">= 0.6.3"
36
- spec.add_dependency "multi_json" # , '>= 0.3.2'
37
35
  spec.add_dependency "optimist"
38
36
  spec.add_dependency "xml-simple"
39
37
  spec.add_dependency "ox"
@@ -55,6 +55,38 @@ if [[ -f "$SCRIPT_DIR/visitor_stats.py" ]]; then
55
55
  "$ACCESS_LOG_GLOB" "$(dirname "$FIRSTBASE_CSV")" "$STATS_DAYS" 2>/dev/null || true)
56
56
  fi
57
57
 
58
+ # rust2xml section: the search page (rust2xml-web behind /suche/, see
59
+ # setup_rust2xml_web.sh) is linked only once it actually answers, so the page
60
+ # never carries a dead link before Apache is set up or while the server is
61
+ # down; the database is linked once the 03:00 run has published it.
62
+ SEARCH_URL="${SEARCH_URL:-https://mediupdatexml.oddb.org/suche/api/stand}"
63
+ RUST2XML_DB="${DOCROOT%/}/artikelstamm/rust2xml/rust2xml.sqlite"
64
+ rust2xml_items=""
65
+ search_box=""
66
+ if [[ "$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "$SEARCH_URL" 2>/dev/null || true)" == "200" ]]; then
67
+ # The search field at the top of the page: a plain GET form to the search
68
+ # page, which picks up ?q= on load. Opens in a new tab like every link here
69
+ # (user, 15.11.2026: "öffne das Suchfenster in einem neuen Tab").
70
+ search_box=' <form class="search" action="suche/" method="get" target="_blank" role="search">
71
+ <input type="search" name="q" placeholder="Artikel suchen: Name, Wirkstoff, GTIN, Pharmacode oder ATC-Code" aria-label="Artikel suchen" required minlength="2">
72
+ <button type="submit">Suchen</button>
73
+ </form>
74
+ '
75
+ rust2xml_items+=' <li><a href="suche/">suche/</a> <span class="desc">— Artikel suchen nach Name, Wirkstoff, GTIN, Pharmacode oder ATC-Code, mit Preisen, Limitationen und BAG-Indikationscodes</span></li>
76
+ '
77
+ fi
78
+ if [[ -s "$RUST2XML_DB" ]]; then
79
+ rust2xml_items+=' <li><a href="artikelstamm/rust2xml/rust2xml.sqlite">rust2xml.sqlite</a> <span class="desc">— dieselben Daten als SQLite-Datenbank (Artikel, Produkte, Limitationen, Wirkstoffe, Interaktionen), täglich um 03:00 mit rust2xml erzeugt</span></li>
80
+ '
81
+ fi
82
+ rust2xml_section=""
83
+ if [[ -n "$rust2xml_items" ]]; then
84
+ rust2xml_section=" <h2>rust2xml — Suche und SQLite-Datenbank</h2>
85
+ <ul>
86
+ ${rust2xml_items} </ul>
87
+ "
88
+ fi
89
+
58
90
  mkdir -p "$DOCROOT"
59
91
 
60
92
  # Logo (self-contained SVG): brand-blue rounded badge, white pharma/Swiss cross
@@ -120,6 +152,12 @@ cat > "$tmp" <<HTML
120
152
  .topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
121
153
  .topbar .title h1 { margin: 0 0 .2rem; }
122
154
  .topbar .logo { width: 64px; height: 64px; flex: 0 0 auto; }
155
+ form.search { display: flex; gap: .5rem; margin: 1.2rem 0 .4rem; }
156
+ form.search input { flex: 1; min-width: 0; font-size: 1.05rem; padding: .6rem .8rem;
157
+ border: 1px solid #c8d2df; border-radius: 8px; }
158
+ form.search input:focus { outline: 2px solid #0a58ca; border-color: transparent; }
159
+ form.search button { font-size: 1rem; padding: .6rem 1.1rem; border: 0; border-radius: 8px;
160
+ background: #0a58ca; color: #fff; cursor: pointer; }
123
161
  </style>
124
162
  </head>
125
163
  <body>
@@ -131,6 +169,7 @@ cat > "$tmp" <<HTML
131
169
  <a href="mailto:zdavatz@ywesee.com" title="Fragen? zdavatz at ywesee dot com"><img class="logo" src="logo.svg" alt="oddb2xml Logo" width="64" height="64"></a>
132
170
  </header>
133
171
 
172
+ ${search_box}
134
173
  <div class="stats">
135
174
  <div class="stat"><div class="n">$(group "$pharma")</div><div class="l">Medikamente (PHARMA)</div></div>
136
175
  <div class="stat"><div class="n"><a href="https://id.gs1.ch/01/07612345000961">$(group "$nonpharma")</a></div><div class="l">Firstbase-Produkte (NONPHARMA)</div></div>
@@ -160,6 +199,7 @@ cat > "$tmp" <<HTML
160
199
  <li><a href="artikelstamm/rust2xml/">artikelstamm/rust2xml/</a> <span class="desc">— derselbe Artikelstamm v6 + v5, erzeugt mit <a href="https://github.com/zdavatz/rust2xml">rust2xml</a> (Rust-Port), täglich um 03:00 aus denselben Live-Quellen</span></li>
161
200
  </ul>
162
201
 
202
+ ${rust2xml_section}
163
203
  <h2>aips2sqlite — Fachinformationen &amp; AmiKo-Datenbanken</h2>
164
204
  <ul>
165
205
  <li><a href="/aips2sqlite/fis/">fis/</a> <span class="desc">— Fachinformationen als XML/HTML (DE/FR/IT)</span></li>
@@ -109,6 +109,16 @@ GET_TRANSFER_ZIP="${GET_TRANSFER_ZIP:-/home/zdavatz/software/get_transfer/TRANSF
109
109
  # archived to this persistent cache after the build for reference / recovery.
110
110
  FIRSTBASE_CACHE="${FIRSTBASE_CACHE:-${OUT_DIR%/}-state/firstbase.csv}"
111
111
 
112
+ # 3c. Swissmedic last-good lists (oddb2xml >= 3.0.37). The gem keeps the newest
113
+ # Swissmedic package and orphan list it has seen in this directory and refuses
114
+ # a download dated earlier ("Stand / Etat au"), as well as a failed download or
115
+ # a listing page without the link: it then builds from the kept copy and says
116
+ # so on stderr. Needed since the new Swissmedic website (01.12.2026) published
117
+ # both lists dated 28.02.2026 while the old site had served 31.10.2026.
118
+ # Outside BUILD_DIR, which is wiped every night.
119
+ export ODDB2XML_LAST_GOOD_DIR="${ODDB2XML_LAST_GOOD_DIR:-${OUT_DIR%/}-state/swissmedic}"
120
+ mkdir -p "$ODDB2XML_LAST_GOOD_DIR"
121
+
112
122
  # seed_downloads — reset downloads/ so it contains only the ZurRose transfer.zip
113
123
  # seed. A following --skip-download build reuses that zip (no pillbox fetch) and
114
124
  # downloads every other source fresh. Called before each attempt of the first
@@ -132,6 +132,10 @@ MAILTO=$RUN_USER
132
132
 
133
133
  # every 30 min Rebuild automatically once Swissmedic answers again after a block.
134
134
  */30 * * * * $RUN_USER $SCRIPT_DIR/swissmedic_watch.sh
135
+
136
+ # @reboot rust2xml-web, the search page at /suche/ (run_artikelstamm.sh
137
+ # restarts it after each nightly build).
138
+ @reboot $RUN_USER [ -x $RUST2XML_DIR/scripts/rust2xml_web.sh ] && sleep 30 && $RUST2XML_DIR/scripts/rust2xml_web.sh start >> $STATE_DIR/rust2xml_web.log 2>&1
135
139
  EOF
136
140
  chmod 644 /etc/cron.d/mediupdatexml
137
141
 
@@ -162,6 +166,8 @@ fi
162
166
  if [[ "${SKIP_WEB:-0}" != "1" ]]; then
163
167
  step "Provisioning the Apache vhost (setup_mediupdatexml_web.sh)"
164
168
  "$SCRIPT_DIR/setup_mediupdatexml_web.sh"
169
+ step "Proxying /suche/ to rust2xml-web (setup_rust2xml_web.sh)"
170
+ SKIP_CRON=1 RUN_USER="$RUN_USER" RUST2XML_DIR="$RUST2XML_DIR" "$SCRIPT_DIR/setup_rust2xml_web.sh" # cron entry already written above
165
171
  fi
166
172
 
167
173
  cat <<EOF
@@ -171,6 +177,7 @@ cat <<EOF
171
177
  Next steps (as $RUN_USER, not root):
172
178
  1. ZurRose mirror (needed by step 3): $GET_TRANSFER_DIR/get_transfer.sh
173
179
  2. Rust toolchain for the 03:00 job: $SCRIPT_DIR/setup_rust2xml.sh
180
+ (the 03:00 run also writes rust2xml.sqlite and starts the /suche/ server)
174
181
  3. First build (takes ~1-2 h): $SCRIPT_DIR/run_oddb2xml.sh
175
182
  4. First Fachinfo run (takes ~1 h): $AIPS_DIR/scripts/generate_aips_fi
176
183
  5. Landing page: $SCRIPT_DIR/generate_index_html.sh $OUT_DIR
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # setup_rust2xml_web.sh — serve the rust2xml search page at
4
+ # https://mediupdatexml.oddb.org/suche/ (the counterpart of trindex.oddb.org
5
+ # in cosmon, user 15.11.2026).
6
+ #
7
+ # rust2xml-web (rust2xml repo, src/web.rs) listens on 127.0.0.1:3020 and reads
8
+ # the database the 03:00 run publishes, artikelstamm/rust2xml/rust2xml.sqlite.
9
+ # Apache proxies /suche/ to it; the page uses relative URLs, so the prefix is
10
+ # stripped. run_artikelstamm.sh (re)starts the server after every nightly
11
+ # build through rust2xml/scripts/rust2xml_web.sh; the @reboot line below
12
+ # brings it back after a reboot.
13
+ #
14
+ # Run with: sudo scripts/setup_rust2xml_web.sh
15
+ # Idempotent: safe to re-run.
16
+ #
17
+ # Environment:
18
+ # RUN_USER build/cron user (default zdavatz)
19
+ # RUST2XML_DIR rust2xml checkout (default /home/$RUN_USER/software/rust2xml)
20
+ # BIND where rust2xml-web listens (default 127.0.0.1:3020)
21
+ # SKIP_CRON set to 1 to leave /etc/cron.d/mediupdatexml alone
22
+ set -euo pipefail
23
+
24
+ RUN_USER="${RUN_USER:-zdavatz}"
25
+ RUST2XML_DIR="${RUST2XML_DIR:-/home/$RUN_USER/software/rust2xml}"
26
+ BIND="${BIND:-127.0.0.1:3020}"
27
+ STATE_DIR="${STATE_DIR:-/home/$RUN_USER/oddb2xml-state}"
28
+ CRON_FILE=/etc/cron.d/mediupdatexml
29
+ CONF=/etc/apache2/conf-available/mediupdatexml-suche.conf
30
+
31
+ step() { printf '\n==> %s\n' "$*"; }
32
+
33
+ if [[ $EUID -ne 0 ]]; then
34
+ echo "Please run as root: sudo $0" >&2
35
+ exit 1
36
+ fi
37
+
38
+ step "Enabling mod_proxy + mod_proxy_http"
39
+ a2enmod proxy proxy_http >/dev/null
40
+
41
+ step "Writing $CONF (/suche/ -> http://$BIND/)"
42
+ cat > "$CONF" <<EOF
43
+ # rust2xml-web: search page over rust2xml.sqlite (rust2xml/src/web.rs).
44
+ # Served on both the HTTP and HTTPS vhosts of mediupdatexml.oddb.org.
45
+ # Managed by oddb2xml/scripts/setup_rust2xml_web.sh; edit there, not here.
46
+ RedirectMatch 301 ^/suche$ /suche/
47
+ ProxyPass /suche/ http://$BIND/
48
+ ProxyPassReverse /suche/ http://$BIND/
49
+ EOF
50
+ a2enconf mediupdatexml-suche >/dev/null
51
+
52
+ if [[ "${SKIP_CRON:-0}" != "1" ]]; then
53
+ step "Scheduling the server start after a reboot"
54
+ if [[ ! -f "$CRON_FILE" ]]; then
55
+ echo "!! $CRON_FILE does not exist yet — run setup_new_server.sh first,"
56
+ echo " it writes the full schedule including this entry."
57
+ elif grep -q 'rust2xml_web.sh' "$CRON_FILE"; then
58
+ echo "entry already present in $CRON_FILE"
59
+ else
60
+ cat >> "$CRON_FILE" <<EOF
61
+
62
+ # @reboot rust2xml-web, the search page at /suche/ (run_artikelstamm.sh
63
+ # restarts it after each nightly build).
64
+ @reboot $RUN_USER [ -x $RUST2XML_DIR/scripts/rust2xml_web.sh ] && sleep 30 && $RUST2XML_DIR/scripts/rust2xml_web.sh start >> $STATE_DIR/rust2xml_web.log 2>&1
65
+ EOF
66
+ echo "appended to $CRON_FILE"
67
+ fi
68
+ fi
69
+
70
+ step "Testing config and reloading Apache"
71
+ apache2ctl configtest
72
+ systemctl reload apache2
73
+
74
+ step "Checking that rust2xml-web answers"
75
+ code=$(curl -s -o /dev/null -w '%{http_code}' "http://$BIND/api/stand" || true)
76
+ if [[ "$code" == "200" ]]; then
77
+ echo "rust2xml-web answers on $BIND."
78
+ else
79
+ echo "!! rust2xml-web does not answer on $BIND (HTTP $code). As $RUN_USER:"
80
+ echo " $RUST2XML_DIR/scripts/rust2xml_web.sh start"
81
+ fi
@@ -25,7 +25,10 @@ BUILD_DIR="${BUILD_DIR:-${OUT_DIR%/}-build}"
25
25
  # deletes at the start of every build.
26
26
  STATE_DIR="${STATE_DIR:-${OUT_DIR%/}-watch}"
27
27
  ARTICLE_XML="$OUT_DIR/default/oddb_article.xml"
28
- CANARY_URL="https://www.swissmedic.ch/swissmedic/de/home/services/listen_neu.html"
28
+ # The page oddb2xml reads the list links from. The old listen_neu.html answers
29
+ # 404 since the new Swissmedic website (01.12.2026); probing it would make the
30
+ # watcher believe Swissmedic is blocked for good and never launch a build.
31
+ CANARY_URL="https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html"
29
32
 
30
33
  # Cron hands us a minimal PATH, so spell out where the oddb2xml binstub can be,
31
34
  # covering every way this host might have installed it: Debian's system Ruby
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="de"><head><meta charset="utf-8"><title>Verzeichnisse Humanarzneimittel</title></head>
3
+ <body>
4
+ <!-- Trimmed copy of https://www.swissmedic.ch/de/therapeutic-products-lists-data/listen-und-verzeichnisse/verzeichnisse-humanarzneimittel.html
5
+ as of 01.12.2026 (the new Swissmedic website): the lists are linked by their file name. -->
6
+ <main>
7
+ <a href="/de/therapeutic-products-lists-data/listen-und-verzeichnisse.html">Listen und Verzeichnisse</a>
8
+ <a href="/dam/jcr:6b53f4f4-ab98-4b8b-9a07-a7cd00293723/Zugelassene_Arzneimittel_HAM.d9f6edf51ab52a6c6e8407ac02bfb7bb.xlsx">Zugelassene Arzneimittel <span>XLSX 984 KB</span></a>
9
+ <a href="/dam/jcr:8a79b49d-be31-4638-86af-939d4d135ba0/erweiterte-arzneimittelliste-ham_de_fr.e7103a1befa3e7a9d1da88626eb18c74.xlsx">erweiterte-arzneimittelliste-ham_de_fr <span>XLSX 2 MB</span></a>
10
+ <a href="/dam/jcr:4ae7cc38-8e86-46e8-9b6f-fd43f9b29f50/zugelassene-packungen-ham_de_fr.ea30273073a26b5b558a5b99a1b3bc8f.xlsx">zugelassene-packungen-ham_de_fr <span>XLSX 3 MB</span></a>
11
+ <a href="#17">1.7. Wichtige Arzneimittel für seltene Krankheiten (Orphan Drugs bei Humanarzneimitteln)</a>
12
+ <a href="/dam/jcr:4366c635-3a80-419d-b2e1-8d4eb5694ee0/liste-orphandrug-internet_de_fr.33c6e6c91b0a52636be6f39d893e8457.xlsx">liste-orphandrug-internet_de_fr <span>XLSX 335 KB</span></a>
13
+ </main>
14
+ </body></html>
@@ -307,6 +307,96 @@ describe Oddb2xml::SwissmedicDownloader do
307
307
  end
308
308
  end
309
309
 
310
+ # The new Swissmedic website (01.12.2026): new listing page, links named after
311
+ # the file, and lists published with an older Stand than before.
312
+ describe "Oddb2xml::SwissmedicDownloader on the new website" do
313
+ include ServerMockHelper
314
+ let(:dir) { File.join(Oddb2xml::WORK_DIR, "swissmedic_spec") }
315
+ let(:last_good) { File.join(dir, "last_good") }
316
+ let(:package_url) { "https://www.swissmedic.ch/dam/jcr:4ae7cc38-8e86-46e8-9b6f-fd43f9b29f50/zugelassene-packungen-ham_de_fr.ea30273073a26b5b558a5b99a1b3bc8f.xlsx" }
317
+
318
+ # a minimal xlsx whose header says "Stand / Etat au: <date>"
319
+ def xlsx_dated(path, date)
320
+ FileUtils.makedirs(File.dirname(path))
321
+ FileUtils.rm_f(path)
322
+ Zip::File.open(path, create: true) do |zip|
323
+ zip.get_output_stream("xl/sharedStrings.xml") do |f|
324
+ f.write(%(<sst><si><t>Zugelassene Packungen Humanarzneimittel</t></si><si><t>Stand / Etat au: #{date}</t></si>#{"<si><t>x</t></si>" * 20}</sst>))
325
+ end
326
+ end
327
+ path
328
+ end
329
+
330
+ before(:each) do
331
+ mock_downloads
332
+ common_before
333
+ FileUtils.rm_rf(dir)
334
+ FileUtils.makedirs(Oddb2xml::DOWNLOADS)
335
+ ENV.delete("ODDB2XML_LAST_GOOD_DIR")
336
+ end
337
+ # Not common_after: it pipes the VCR cassette through `python -mjson.tool`,
338
+ # and on a host without a `python` binary that empties the cassette and
339
+ # breaks every later example that replays it.
340
+ after(:each) do
341
+ ENV.delete("ODDB2XML_LAST_GOOD_DIR")
342
+ FileUtils.rm_rf(dir)
343
+ Dir.chdir(@saved_dir) if @saved_dir && File.directory?(@saved_dir)
344
+ end
345
+
346
+ it "finds both lists on the new listing page by their file name" do
347
+ doc = Nokogiri::HTML(File.read(File.join(Oddb2xml::SpecData, "swissmedic_verzeichnisse_ham.html")))
348
+ expect(Oddb2xml::SwissmedicDownloader.find_link(doc, :package)).to match(/zugelassene-packungen-ham_de_fr\.\h+\.xlsx\z/)
349
+ expect(Oddb2xml::SwissmedicDownloader.find_link(doc, :orphan)).to match(/liste-orphandrug-internet_de_fr\.\h+\.xlsx\z/)
350
+ end
351
+
352
+ it "still finds them by link text on the old listing page" do
353
+ doc = Nokogiri::HTML(File.read(File.join(Oddb2xml::SpecData, "listen_neu.html")))
354
+ expect(Oddb2xml::SwissmedicDownloader.find_link(doc, :package)).to match(/packungen/i)
355
+ end
356
+
357
+ it "reads the Stand date of a list" do
358
+ expect(Oddb2xml::SwissmedicDownloader.stand(xlsx_dated(File.join(dir, "a.xlsx"), "31.10.2026"))).to eq Date.new(2026, 10, 31)
359
+ end
360
+
361
+ it "keeps the last good copy when the download is dated earlier" do
362
+ ENV["ODDB2XML_LAST_GOOD_DIR"] = last_good
363
+ xlsx_dated(File.join(last_good, "swissmedic_package.xlsx"), "31.10.2026")
364
+ stub_request(:get, package_url).to_return(body: File.binread(xlsx_dated(File.join(dir, "old.xlsx"), "28.02.2026")))
365
+ file = nil
366
+ expect { file = Oddb2xml::SwissmedicDownloader.new(:package).download }.to output(/dated 2026-02-28, older than the last good copy/).to_stderr
367
+ expect(Oddb2xml::SwissmedicDownloader.stand(file)).to eq Date.new(2026, 10, 31)
368
+ end
369
+
370
+ it "replaces the last good copy with a newer download" do
371
+ ENV["ODDB2XML_LAST_GOOD_DIR"] = last_good
372
+ xlsx_dated(File.join(last_good, "swissmedic_package.xlsx"), "28.02.2026")
373
+ stub_request(:get, package_url).to_return(body: File.binread(xlsx_dated(File.join(dir, "new.xlsx"), "30.11.2026")))
374
+ file = Oddb2xml::SwissmedicDownloader.new(:package).download
375
+ expect(Oddb2xml::SwissmedicDownloader.stand(file)).to eq Date.new(2026, 11, 30)
376
+ expect(Oddb2xml::SwissmedicDownloader.stand(File.join(last_good, "swissmedic_package.xlsx"))).to eq Date.new(2026, 11, 30)
377
+ end
378
+
379
+ it "falls back to the last good copy when the listing page is gone" do
380
+ ENV["ODDB2XML_LAST_GOOD_DIR"] = last_good
381
+ xlsx_dated(File.join(last_good, "swissmedic_package.xlsx"), "31.10.2026")
382
+ stub_request(:get, Oddb2xml::SwissmedicDownloader::LISTING_URL).to_return(status: 404, body: "not found")
383
+ downloader = Oddb2xml::SwissmedicDownloader.new(:package)
384
+ file = nil
385
+ expect { file = downloader.download }.to output(/using the last good copy dated 2026-10-31/).to_stderr
386
+ expect(Oddb2xml::SwissmedicDownloader.stand(file)).to eq Date.new(2026, 10, 31)
387
+ end
388
+
389
+ it "fails when the listing page is gone and there is no last good copy" do
390
+ stub_request(:get, Oddb2xml::SwissmedicDownloader::LISTING_URL).to_return(status: 404, body: "not found")
391
+ expect { Oddb2xml::SwissmedicDownloader.new(:package).download }.to raise_error(Oddb2xml::IncompleteDownloadError, /404/)
392
+ end
393
+
394
+ it "warns about a stale list when no last good copy is kept" do
395
+ stub_request(:get, package_url).to_return(body: File.binread(xlsx_dated(File.join(dir, "old.xlsx"), "28.02.2026")))
396
+ expect { Oddb2xml::SwissmedicDownloader.new(:package).download }.to output(/is dated 2026-02-28, \d+ days old/).to_stderr
397
+ end
398
+ end
399
+
310
400
  describe Oddb2xml::EphaDownloader do
311
401
  include ServerMockHelper
312
402
  before(:each) do
@@ -384,4 +384,47 @@ describe Oddb2xml::Builder do
384
384
  expect(builder.refdata["7680576900046"][:desc_de]).to eq "VERACTIV Vitamin D3 Wild Huile Trp 20'000 U.I. 10ml"
385
385
  end
386
386
  end
387
+
388
+ describe ".fix_german_volume_from_fr_it" do
389
+ let(:fix) { ->(de, fr, it) { Oddb2xml::RefdataCleanup.fix_german_volume_from_fr_it(de, fr, it) } }
390
+
391
+ it "takes the volume from FR/IT when DE disagrees (PRIVIGEN 400 ml, zollsoft 09/2026)" do
392
+ expect(fix.call("PRIVIGEN 10% Inf Lös 200 ml Dfl", "PRIVIGEN 10% sol perf 400 ml flac",
393
+ "PRIVIGEN 10% sol inf 400 ml flac")).to eq "PRIVIGEN 10% Inf Lös 400 ml Dfl"
394
+ end
395
+
396
+ it "fixes FERINJECT 1000 mg 10 ml -> 20 ml" do
397
+ expect(fix.call("FERINJECT Disp Inj/Inf 1000 mg 10 ml 1 Flasche", "FERINJECT disp inj/pf 1000 mg 20 ml 1 flacon",
398
+ "FERINJECT disp inj/inf 1000 mg 20 ml 1 flacone")).to eq "FERINJECT Disp Inj/Inf 1000 mg 20 ml 1 Flasche"
399
+ end
400
+
401
+ it "leaves DE alone when FR and IT disagree with each other" do
402
+ de = "X Inf Lös 200 ml Dfl"
403
+ expect(fix.call(de, "X sol perf 400 ml flac", "X sol inf 300 ml flac")).to eq de
404
+ end
405
+
406
+ it "ignores concentrations such as mg/ml or 1000 mg/20ml" do
407
+ de = "CIMZIA Inj Lös 200 mg/ml Fertspr 2 Stk"
408
+ expect(fix.call(de, "CIMZIA sol inj 200 mg/2ml ser pré 2 pce", "CIMZIA sol inj 200 mg/2ml sir pre 2 pz")).to eq de
409
+ end
410
+
411
+ it "does nothing with more than one volume in a name" do
412
+ de = "Y 5 ml + 10 ml"
413
+ expect(fix.call(de, "Y 5 ml + 20 ml", "Y 5 ml + 20 ml")).to eq de
414
+ end
415
+
416
+ it "does nothing when a language is missing" do
417
+ expect(fix.call("Z 10 ml", "", "Z 20 ml")).to eq "Z 10 ml"
418
+ end
419
+
420
+ it "is applied by Builder#apply_refdata_description_cleanups!" do
421
+ builder = Oddb2xml::Builder.new
422
+ builder.packs = {"58314053" => {}}
423
+ builder.refdata = {"7680583140053" => {ean13: "7680583140053", no8: "58314053",
424
+ desc_de: "PRIVIGEN 10% Inf Lös 200 ml Dfl", desc_fr: "PRIVIGEN 10% sol perf 400 ml flac",
425
+ desc_it: "PRIVIGEN 10% sol inf 400 ml flac"}}
426
+ builder.apply_refdata_description_cleanups!
427
+ expect(builder.refdata["7680583140053"][:desc_de]).to eq "PRIVIGEN 10% Inf Lös 400 ml Dfl"
428
+ end
429
+ end
387
430
  end
data/spec/spec_helper.rb CHANGED
@@ -252,6 +252,10 @@ def mock_downloads
252
252
  end
253
253
  {"https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/interactions_de_utf8.csv" => "epha_interactions.csv",
254
254
  "https://www.swissmedic.ch/swissmedic/de/home/services/listen_neu.html" => "listen_neu.html",
255
+ # the new Swissmedic website (01.12.2026)
256
+ Oddb2xml::SwissmedicDownloader::LISTING_URL => "swissmedic_verzeichnisse_ham.html",
257
+ "https://www.swissmedic.ch/dam/jcr:4ae7cc38-8e86-46e8-9b6f-fd43f9b29f50/zugelassene-packungen-ham_de_fr.ea30273073a26b5b558a5b99a1b3bc8f.xlsx" => "swissmedic_package.xlsx",
258
+ "https://www.swissmedic.ch/dam/jcr:4366c635-3a80-419d-b2e1-8d4eb5694ee0/liste-orphandrug-internet_de_fr.33c6e6c91b0a52636be6f39d893e8457.xlsx" => "swissmedic_orphan.xlsx",
255
259
  "https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/status_ophan%20Drug.xlsx.download.xlsx/Liste_OrphanDrug_Internet_2019_01_31.xlsx" => "swissmedic_orphan.xlsx",
256
260
  "https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/zugelassene_packungen_ham.xlsx.download.xlsx/Zugelassene_Packungen%20HAM_31012019.xlsx" => "swissmedic_package.xlsx",
257
261
  "http://pillbox.oddb.org/TRANSFER.ZIP" => "transfer.zip",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.35
4
+ version: 3.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
@@ -121,34 +121,6 @@ dependencies:
121
121
  - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
- - !ruby/object:Gem::Dependency
125
- name: rubyntlm
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: 0.6.3
131
- type: :runtime
132
- prerelease: false
133
- version_requirements: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: 0.6.3
138
- - !ruby/object:Gem::Dependency
139
- name: multi_json
140
- requirement: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- type: :runtime
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
124
  - !ruby/object:Gem::Dependency
153
125
  name: optimist
154
126
  requirement: !ruby/object:Gem::Requirement
@@ -478,6 +450,7 @@ files:
478
450
  - scripts/setup_mediupdatexml_web.sh
479
451
  - scripts/setup_new_server.sh
480
452
  - scripts/setup_rust2xml.sh
453
+ - scripts/setup_rust2xml_web.sh
481
454
  - scripts/swissmedic_watch.sh
482
455
  - scripts/transfer.sh
483
456
  - scripts/visitor_stats.py
@@ -535,6 +508,7 @@ files:
535
508
  - spec/data/swissmedic_orphans.html
536
509
  - spec/data/swissmedic_package.xlsx
537
510
  - spec/data/swissmedic_packages.html
511
+ - spec/data/swissmedic_verzeichnisse_ham.html
538
512
  - spec/data/transfer.dat
539
513
  - spec/data/v5_first.xml
540
514
  - spec/data/v5_second.xml
@@ -641,6 +615,7 @@ test_files:
641
615
  - spec/data/swissmedic_orphans.html
642
616
  - spec/data/swissmedic_package.xlsx
643
617
  - spec/data/swissmedic_packages.html
618
+ - spec/data/swissmedic_verzeichnisse_ham.html
644
619
  - spec/data/transfer.dat
645
620
  - spec/data/v5_first.xml
646
621
  - spec/data/v5_second.xml