196 lines
6.0 KiB
Python
196 lines
6.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Kuratierte öffentliche Medikamenten- und Korrektur-Starterliste (de-CH).
|
|
|
|
Keine erfundenen Medikamentennamen. Keine ATC-Codes ohne sichere Quelle.
|
|
Nur Schreibhilfe für Transkription/Korrektur — keine Therapieempfehlung.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List, Optional, Tuple
|
|
|
|
MARKET_REGION = "de-CH"
|
|
LANGUAGE = "de"
|
|
|
|
# (brand_name, active_substance | None)
|
|
_MEDICATION_PAIRS: Tuple[Tuple[str, Optional[str]], ...] = (
|
|
("Dafalgan", "Paracetamol"),
|
|
("Paracetamol", None),
|
|
("Ibuprofen", None),
|
|
("Ponstan", "Mefenaminsäure"),
|
|
("Mefenaminsäure", None),
|
|
("Voltaren", "Diclofenac"),
|
|
("Diclofenac", None),
|
|
("Irfen", "Ibuprofen"),
|
|
("Algifor", "Ibuprofen"),
|
|
("Novalgin", "Metamizol"),
|
|
("Metamizol", None),
|
|
("Amoxicillin", None),
|
|
("Augmentin", "Co-Amoxicillin"),
|
|
("Co-Amoxicillin", None),
|
|
("Clarithromycin", None),
|
|
("Azithromycin", None),
|
|
("Doxycyclin", None),
|
|
("Dalacin", "Clindamycin"),
|
|
("Clindamycin", None),
|
|
("Fucidin", "Fusidinsäure"),
|
|
("Fusidinsäure", None),
|
|
("Bactroban", "Mupirocin"),
|
|
("Mupirocin", None),
|
|
("Betadine", None),
|
|
("Octenisept", None),
|
|
("Ialugen", None),
|
|
("Flammazine", None),
|
|
("Dermovate", "Clobetasol"),
|
|
("Clobetasol", None),
|
|
("Diprosalic", "Betamethason"),
|
|
("Betamethason", None),
|
|
("Elocom", "Mometason"),
|
|
("Mometason", None),
|
|
("Advantan", "Methylprednisolonaceponat"),
|
|
("Methylprednisolonaceponat", None),
|
|
("Protopic", "Tacrolimus"),
|
|
("Tacrolimus", None),
|
|
("Elidel", "Pimecrolimus"),
|
|
("Pimecrolimus", None),
|
|
("Roaccutan", "Isotretinoin"),
|
|
("Isotretinoin", None),
|
|
("Tretinac", "Isotretinoin"),
|
|
("Toctino", "Alitretinoin"),
|
|
("Alitretinoin", None),
|
|
("Telfast", "Fexofenadin"),
|
|
("Fexofenadin", None),
|
|
("Bilaxten", "Bilastin"),
|
|
("Bilastin", None),
|
|
("Xolair", "Omalizumab"),
|
|
("Omalizumab", None),
|
|
("Dupixent", "Dupilumab"),
|
|
("Dupilumab", None),
|
|
("Tremfya", "Guselkumab"),
|
|
("Guselkumab", None),
|
|
("Skyrizi", "Risankizumab"),
|
|
("Risankizumab", None),
|
|
("Cosentyx", "Secukinumab"),
|
|
("Secukinumab", None),
|
|
("Stelara", "Ustekinumab"),
|
|
("Ustekinumab", None),
|
|
("Ilumetri", "Tildrakizumab"),
|
|
("Tildrakizumab", None),
|
|
("Humira", "Adalimumab"),
|
|
("Adalimumab", None),
|
|
("Enbrel", "Etanercept"),
|
|
("Etanercept", None),
|
|
("Methotrexat", None),
|
|
("Folsäure", None),
|
|
("Ciclosporin", None),
|
|
("Aciclovir", None),
|
|
("Valaciclovir", None),
|
|
("Zovirax", "Aciclovir"),
|
|
("Valtrex", "Valaciclovir"),
|
|
("Lamisil", "Terbinafin"),
|
|
("Terbinafin", None),
|
|
("Itraconazol", None),
|
|
("Fluconazol", None),
|
|
("Canesten", "Clotrimazol"),
|
|
("Clotrimazol", None),
|
|
("Nizoral", "Ketoconazol"),
|
|
("Ketoconazol", None),
|
|
("Skabimed", "Permethrin"),
|
|
("Permethrin", None),
|
|
("Stromectol", "Ivermectin"),
|
|
("Ivermectin", None),
|
|
)
|
|
|
|
# Eindeutige Schreibfehler → korrekte Schreibweise (Wortgrenzen in apply_korrekturen)
|
|
PUBLIC_CORRECTION_VARIANTS: Dict[str, str] = {
|
|
"Daffalgan": "Dafalgan",
|
|
"Tremfia": "Tremfya",
|
|
"Fuzidin": "Fucidin",
|
|
"Clobetazol": "Clobetasol",
|
|
"Fusidinsaeure": "Fusidinsäure",
|
|
"Fusidinsäure": "Fusidinsäure",
|
|
"Methotrexate": "Methotrexat",
|
|
}
|
|
|
|
|
|
def _make_item_id(prefix: str, *parts: str) -> str:
|
|
import hashlib
|
|
blob = "|".join(p.strip().lower() for p in parts if p)
|
|
return f"{prefix}_{hashlib.sha256(blob.encode('utf-8')).hexdigest()[:16]}"
|
|
|
|
|
|
def build_public_medication_entries() -> List[Dict[str, Any]]:
|
|
"""Öffentliche Medikamenten-Referenzeinträge (AzA-kuratiert)."""
|
|
out: List[Dict[str, Any]] = []
|
|
seen: set[str] = set()
|
|
for brand, substance in _MEDICATION_PAIRS:
|
|
key = brand.lower()
|
|
if key in seen:
|
|
continue
|
|
seen.add(key)
|
|
entry: Dict[str, Any] = {
|
|
"item_id": _make_item_id("pubmed", brand),
|
|
"scope": "public",
|
|
"category": "medication",
|
|
"term": brand,
|
|
"preferred_spelling": brand,
|
|
"variants": [],
|
|
"language": LANGUAGE,
|
|
"market_region": MARKET_REGION,
|
|
"source": "aza_curated",
|
|
"confidence": "high",
|
|
"active": True,
|
|
"brand_name": brand,
|
|
"status": "published",
|
|
}
|
|
if substance:
|
|
entry["active_substance"] = substance
|
|
entry["note"] = f"{brand} ({substance})"
|
|
out.append(entry)
|
|
return out
|
|
|
|
|
|
def build_public_correction_entries() -> List[Dict[str, Any]]:
|
|
"""Öffentliche Korrekturpaare als Bibliothekseinträge."""
|
|
out: List[Dict[str, Any]] = []
|
|
for wrong, right in PUBLIC_CORRECTION_VARIANTS.items():
|
|
if wrong.lower() == right.lower():
|
|
continue
|
|
cat = "medication" if wrong[0].isupper() else "medical_term"
|
|
out.append({
|
|
"item_id": _make_item_id("pubcorr", wrong, right),
|
|
"scope": "public",
|
|
"category": cat,
|
|
"term": wrong,
|
|
"preferred_spelling": right,
|
|
"variants": [wrong],
|
|
"language": LANGUAGE,
|
|
"market_region": MARKET_REGION,
|
|
"source": "aza_curated",
|
|
"confidence": "high",
|
|
"active": True,
|
|
"status": "published",
|
|
})
|
|
return out
|
|
|
|
|
|
def get_public_library_entries() -> List[Dict[str, Any]]:
|
|
return build_public_medication_entries() + build_public_correction_entries()
|
|
|
|
|
|
def get_public_korrektur_mappings() -> Dict[str, Dict[str, str]]:
|
|
"""Für apply_korrekturen: {kategorie: {falsch: richtig}} — nur Korrekturvarianten."""
|
|
med: Dict[str, str] = {}
|
|
begriffe: Dict[str, str] = {}
|
|
for wrong, right in PUBLIC_CORRECTION_VARIANTS.items():
|
|
if wrong.lower() == right.lower():
|
|
continue
|
|
tgt = med if wrong[0].isupper() else begriffe
|
|
tgt[wrong] = right
|
|
out: Dict[str, Dict[str, str]] = {}
|
|
if med:
|
|
out["medikamente"] = med
|
|
if begriffe:
|
|
out["begriffe"] = begriffe
|
|
return out
|