Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

MediaWiki:Common.js

Page de l’interface de MediaWiki

Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
  • Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
  •  Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
// Forcer l'ouverture des sections hidden dans citizen qui les cachent par défaut

function ouvrirSections() {
    document.querySelectorAll('.citizen-section').forEach(function (el) {
        el.removeAttribute('hidden');
    });
}

document.addEventListener('DOMContentLoaded', ouvrirSections);

window.addEventListener('pageshow', function (e) {
    if (e.persisted) {
        ouvrirSections();
    }
});

new MutationObserver(ouvrirSections).observe(document.documentElement, { childList: true, subtree: true });





// ============================================
// CALCULATEUR IRC — Microguide
// ============================================
if (mw.config.get('wgPageName') === 'Calculateur') {

    var style = document.createElement('style');
    style.textContent = `
        #calc-app * { box-sizing: border-box; font-family: 'Segoe UI', system-ui, sans-serif; }
        #calc-app { background: #f0f4f8; padding: 16px; border-radius: 12px; }
        .calc-header { background: linear-gradient(135deg, #1a5fa8 0%, #2980d4 100%); padding: 18px 22px; border-radius: 12px; color: white; margin-bottom: 16px; }
        .calc-header h1 { margin: 0; font-size: 20px; font-weight: 700; }
        .calc-header p { margin: 4px 0 0; font-size: 12px; opacity: 0.75; }
        .calc-card { background: white; border-radius: 12px; padding: 20px 22px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; }
        .calc-card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: #0f2d5e; }
        .calc-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
        .calc-grid label { font-size: 11px; color: #64748b; font-weight: 600; display: block; margin-bottom: 4px; }
        .calc-grid input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid #e2e8f0; font-size: 14px; color: #0f2d5e; font-weight: 600; outline: none; }
        .calc-sexe-btn { padding: 6px 18px; border-radius: 8px; border: 1.5px solid #e2e8f0; background: white; color: #64748b; font-weight: 600; cursor: pointer; font-size: 13px; margin-right: 8px; }
        .calc-sexe-btn.active { border-color: #0f2d5e; background: #0f2d5e; color: white; }
        .calc-result-box { background: #f8fafc; border-radius: 10px; padding: 14px 18px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
        .calc-clcr-val { font-size: 32px; font-weight: 800; line-height: 1; }
        .calc-clcr-label { font-size: 12px; font-weight: 600; margin-top: 2px; }
        .calc-search { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1.5px solid #e2e8f0; font-size: 14px; margin-bottom: 10px; outline: none; }
        .calc-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
        .calc-cat-btn { padding: 6px 14px; border-radius: 20px; border: 1.5px solid #e2e8f0; background: white; color: #475569; font-weight: 600; cursor: pointer; font-size: 12px; }
        .calc-cat-btn.active { border-color: #0f2d5e; background: #0f2d5e; color: white; }
        .calc-drugs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
        .calc-drug-btn { padding: 6px 12px; border-radius: 8px; border: 1.5px solid #e2e8f0; background: white; color: #475569; font-weight: 500; cursor: pointer; font-size: 12px; }
        .calc-drug-btn.active { border-color: #1a9d8f; background: #e8f6f4; color: #0f7a6e; font-weight: 700; }
        .calc-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
        .calc-table th { background: #f1f5f9; padding: 8px 12px; text-align: left; font-weight: 700; color: #0f2d5e; }
        .calc-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; }
        .calc-table tr.active-row { background: #e8f4f0 !important; outline: 2px solid #1a9d8f; }
        .calc-table tr.active-row td { color: #0a5a52; font-weight: 700; }
        .calc-badge { background: #1a9d8f; color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 8px; font-weight: 700; }
        .calc-note { background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #92400e; margin-bottom: 12px; }
        .calc-warning { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 12px 16px; font-size: 11px; color: #991b1b; margin-top: 14px; }
        .calc-search-results button { display: block; width: 100%; text-align: left; padding: 8px 12px; margin-bottom: 4px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; cursor: pointer; font-size: 13px; color: #0f2d5e; }
        .calc-hint { margin-top: 12px; padding: 10px 14px; background: #f0f9ff; border-radius: 8px; font-size: 12px; color: #0369a1; }
        .calc-imc-info { border-left: 1px solid #e2e8f0; padding-left: 16px; font-size: 11px; color: #d97706; }
        @media (max-width: 600px) { .calc-grid { grid-template-columns: 1fr 1fr; } }
        .vanco-header { background: linear-gradient(135deg, #7c3aed 0%, #9f67f5 100%); padding: 18px 22px; border-radius: 12px; color: white; margin-bottom: 16px; }
        .vanco-header h1 { margin: 0; font-size: 20px; font-weight: 700; }
        .vanco-header p { margin: 4px 0 0; font-size: 12px; opacity: 0.75; }
        .vanco-card { background: white; border-radius: 12px; padding: 20px 22px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(124,58,237,0.08); border: 1px solid #ede9fe; }
        .vanco-card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: #5b21b6; }
        .vanco-section-title { font-size: 13px; font-weight: 700; color: #5b21b6; margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 2px solid #ede9fe; }
        .vanco-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
        .vanco-table th { background: #ede9fe; padding: 8px 12px; text-align: left; font-weight: 700; color: #5b21b6; }
        .vanco-table td { padding: 9px 12px; border-bottom: 1px solid #f5f3ff; }
        .vanco-table tr.vanco-active { background: #f3e8ff !important; }
        .vanco-table tr.vanco-active td { color: #6d28d9; font-weight: 700; }
        .vanco-badge { background: #7c3aed; color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 700; }
        .vanco-input-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
        .vanco-input-group { flex: 1; min-width: 120px; }
        .vanco-input-group label { font-size: 11px; color: #7c3aed; font-weight: 600; display: block; margin-bottom: 4px; }
        .vanco-input-group input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid #ede9fe; font-size: 14px; color: #4c1d95; font-weight: 600; outline: none; }
        .vanco-result-box { background: #f3e8ff; border: 2px solid #c4b5fd; border-radius: 10px; padding: 14px 18px; margin-top: 12px; display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
        .vanco-result-val { font-size: 26px; font-weight: 800; color: #6d28d9; line-height: 1; }
        .vanco-warning { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 12px 16px; font-size: 11px; color: #991b1b; margin-top: 14px; }
        .vanco-note { background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #92400e; margin-bottom: 12px; }
        .vanco-tab-btns { display: flex; gap: 8px; margin-bottom: 16px; }
        .vanco-tab-btn { padding: 7px 18px; border-radius: 8px; border: 1.5px solid #ede9fe; background: white; color: #7c3aed; font-weight: 600; cursor: pointer; font-size: 13px; }
        .vanco-tab-btn.active { background: #7c3aed; border-color: #7c3aed; color: white; }
        .vanco-prelevement { background: #f5f3ff; border-radius: 10px; padding: 14px 18px; margin-top: 12px; font-size: 13px; }
        @media (max-width: 600px) { .vanco-input-row { flex-direction: column; } }
    `;
    document.head.appendChild(style);

    var ANTIBIOS = {
        "Céphalosporines": {
            "Céfadroxil (PO)": { notes: "", doses: [
                { min: 30, max: 999, label: "500 mg PO q12h ou 1g PO q12-24h" },
                { min: 20, max: 29, label: "1g PO x1 dose puis 500 mg PO q12h" },
                { min: 10, max: 19, label: "1g PO x1 dose puis 500 mg PO q24h" },
                { min: 0, max: 9, label: "1g PO x1 dose puis 500 mg PO q24-36h" },
            ]},
            "Céfazoline (IV)": { notes: "", doses: [
                { min: 35, max: 999, label: "1-2g IV q8h (fréq. max. q6h)" },
                { min: 11, max: 34, label: "1-2g IV q12h" },
                { min: 0, max: 10, label: "1g IV q24h" },
            ]},
            "Céfépime (IV) — IIA/IU": { notes: "Infections intra-abdominales et urinaires", doses: [
                { min: 30, max: 999, label: "1-2g IV q12h" },
                { min: 11, max: 29, label: "1-2g IV q24h" },
                { min: 6, max: 10, label: "1g IV q24h" },
                { min: 0, max: 5, label: "500 mg IV q24h" },
            ]},
            "Céfépime (IV) — NF": { notes: "Neutropénie fébrile", doses: [
                { min: 30, max: 999, label: "2g IV q8h" },
                { min: 11, max: 29, label: "2g IV q12h" },
                { min: 6, max: 10, label: "2g IV q24h" },
                { min: 0, max: 5, label: "1g IV q24h" },
            ]},
            "Céfixime (PO)": { notes: "", doses: [
                { min: 21, max: 999, label: "400 mg PO q24h" },
                { min: 11, max: 20, label: "300 mg (¾ co.) PO q24h" },
                { min: 0, max: 10, label: "200 mg PO q24h" },
            ]},
            "Céfotaxime (IV)": { notes: "", doses: [
                { min: 21, max: 999, label: "1-2g IV q6-8h (jusqu'à 2g IV q4h si SNC)" },
                { min: 0, max: 20, label: "Diminuer la dose de 50%. Certains: 2g IV q12-24h" },
            ]},
            "Céfoxitine (IV)": { notes: "Dose max: 12g/jour", doses: [
                { min: 30, max: 999, label: "1-2g IV q6-8h" },
                { min: 11, max: 29, label: "1-2g IV q8-12h" },
                { min: 5, max: 10, label: "1-2g IV q12-24h" },
                { min: 1, max: 4, label: "50% de la dose IV q12-24h" },
                { min: 0, max: 0, label: "50% de la dose IV q24-48h" },
            ]},
            "Cefprozil (PO)": { notes: "", doses: [
                { min: 31, max: 999, label: "250-500 mg PO q12h" },
                { min: 0, max: 30, label: "250 mg PO q12h" },
            ]},
            "Ceftazidime (IV)": { notes: "", doses: [
                { min: 31, max: 999, label: "1-2g IV q8h" },
                { min: 16, max: 30, label: "1-2g IV q12h" },
                { min: 6, max: 15, label: "1-2g IV q24h" },
                { min: 1, max: 5, label: "500mg-1g IV q24h" },
                { min: 0, max: 0, label: "500mg-1g IV q48h" },
            ]},
            "Ceftobiprole (IV)": { notes: "Perfusion sur 4h si Clcr > 150 mL/min", doses: [
                { min: 31, max: 999, label: "500 mg IV q8h perf. sur 2h" },
                { min: 16, max: 30, label: "500 mg IV q12h perf. sur 2h" },
                { min: 6, max: 15, label: "250 mg IV q12h perf. sur 2h" },
                { min: 0, max: 5, label: "250 mg IV q24h perf. sur 2h" },
            ]},
            "Ceftriaxone (IV)": { notes: "Aucun ajustement requis sauf IR + IH (dose max: 2g/jour)", doses: [
                { min: 0, max: 999, label: "1-2g IV q24h (max: 2g IV q12h pour SNC)" },
            ]},
            "Céfuroxime axétil (PO)": { notes: "", doses: [
                { min: 11, max: 999, label: "250-500 mg PO q12h" },
                { min: 0, max: 10, label: "250 mg PO q24h" },
            ]},
            "Céfuroxime (IV)": { notes: "", doses: [
                { min: 21, max: 999, label: "750mg-1,5g IV q8h" },
                { min: 11, max: 20, label: "750 mg IV q12h" },
                { min: 0, max: 10, label: "750 mg IV q24h" },
            ]},
            "Céphalexine (PO)": { notes: "", doses: [
                { min: 41, max: 999, label: "250mg-1g PO q6h" },
                { min: 11, max: 40, label: "250-500 mg PO q8-12h" },
                { min: 0, max: 10, label: "250-500 mg PO q12-24h" },
            ]},
        },
        "Carbapénèmes": {
            "Ertapénem (IV)": { notes: "", doses: [
                { min: 31, max: 999, label: "1g IV q24h" },
                { min: 0, max: 30, label: "500 mg IV q24h" },
            ]},
            "Imipénem-Cilastatine (IV)": { notes: "PR ≥ 70 kg: 500 mg IV q6h (max 4g/jour). PR < 70 kg: voir monographie.", doses: [
                { min: 71, max: 999, label: "500 mg IV q6h (max: 4g/jour)" },
                { min: 41, max: 70, label: "500 mg IV q6-8h" },
                { min: 21, max: 40, label: "500 mg IV q8-12h" },
                { min: 6, max: 20, label: "250 mg IV q12h" },
                { min: 0, max: 5, label: "⚠️ Non recommandé" },
            ]},
            "Méropénem (IV) — usuel": { notes: "Posologie usuelle", doses: [
                { min: 26, max: 999, label: "1g IV q8h" },
                { min: 11, max: 25, label: "1g IV q12h" },
                { min: 6, max: 10, label: "500 mg IV q12h" },
                { min: 0, max: 5, label: "500 mg IV q24h" },
            ]},
            "Méropénem (IV) — SNC": { notes: "Infections du SNC", doses: [
                { min: 26, max: 999, label: "2g IV q8h" },
                { min: 11, max: 25, label: "2g IV q12h" },
                { min: 6, max: 10, label: "1g IV q12h" },
                { min: 0, max: 5, label: "1g IV q24h" },
            ]},
        },
        "Macrolides": {
            "Azithromycine (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "250-500 mg PO q24h" }]},
            "Azithromycine (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "500 mg IV q24h" }]},
            "Clarithromycine (PO)": { notes: "", doses: [
                { min: 31, max: 999, label: "250-500 mg PO q12h" },
                { min: 0, max: 30, label: "250 mg PO q24h (ou q12h si infection sévère)" },
            ]},
            "Érythromycine (PO/IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "Posologie selon indication et formulation" }]},
        },
        "Pénicillines": {
            "Amoxicilline (PO)": { notes: "", doses: [
                { min: 31, max: 999, label: "250mg-1g PO q8h" },
                { min: 11, max: 30, label: "250-500 mg PO q12h" },
                { min: 0, max: 10, label: "250-500 mg PO q24h" },
            ]},
            "Amoxicilline-Clavulanate (PO)": { notes: "", doses: [
                { min: 31, max: 999, label: "500/125 mg PO q8h ou 875/125 mg PO q12h" },
                { min: 11, max: 30, label: "500/125 mg PO q12h" },
                { min: 0, max: 10, label: "500/125 mg PO q24h" },
            ]},
            "Ampicilline (IV)": { notes: "Posologie usuelle: 1-2g IV q4-6h", doses: [
                { min: 41, max: 999, label: "1-2g IV q6h" },
                { min: 31, max: 40, label: "1-2g IV q6-8h" },
                { min: 16, max: 30, label: "1-2g IV q8-12h" },
                { min: 0, max: 15, label: "1-2g IV q12-24h" },
            ]},
            "Cloxacilline (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "250-500 mg PO q6h (jusqu'à 4g/jour)" }]},
            "Cloxacilline (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "1-2g IV q4-6h" }]},
            "Pénicilline G sodique (IV)": { notes: "DC = dose de charge", doses: [
                { min: 21, max: 999, label: "1-4 mU IV q4-6h" },
                { min: 11, max: 20, label: "DC suivie de 50% de la dose IV q4-6h" },
                { min: 0, max: 10, label: "DC suivie de 50% de la dose IV q8-12h" },
            ]},
            "Pipéracilline-Tazobactam (IV) — usuel": { notes: "Posologie usuelle", doses: [
                { min: 41, max: 999, label: "3,375g [3g/0,375g] IV q6h ou 4,5g [4g/0,5g] IV q8h" },
                { min: 21, max: 40, label: "2,25g [2g/0,25g] IV q6h" },
                { min: 0, max: 20, label: "2,25g [2g/0,25g] IV q8h" },
            ]},
            "Pipéracilline-Tazobactam (IV) — PAH/NF": { notes: "Pneumonie hospitalière ou neutropénie fébrile", doses: [
                { min: 41, max: 999, label: "4,5g [4g/0,5g] IV q6h" },
                { min: 21, max: 40, label: "3,375g [3g/0,375g] IV q6h" },
                { min: 0, max: 20, label: "2,25g [2g/0,25g] IV q6h" },
            ]},
        },
        "Fluoroquinolones": {
            "Ciprofloxacine (PO)": { notes: "", doses: [
                { min: 31, max: 999, label: "500-750 mg PO q12h" },
                { min: 16, max: 30, label: "500 mg PO q12h" },
                { min: 0, max: 15, label: "500 mg PO q24h ou 250 mg PO q12h" },
            ]},
            "Ciprofloxacine (IV)": { notes: "", doses: [
                { min: 31, max: 999, label: "400 mg IV q8-12h" },
                { min: 16, max: 30, label: "400 mg IV q12h" },
                { min: 0, max: 15, label: "400 mg IV q24h ou 200 mg IV q12h" },
            ]},
            "Lévofloxacine — légère/prostatite": { notes: "Ex: prostatite chronique", doses: [
                { min: 51, max: 999, label: "500 mg PO/IV q24h" },
                { min: 21, max: 50, label: "500 mg PO/IV x1 dose, puis 250 mg PO/IV q24h" },
                { min: 0, max: 20, label: "500 mg PO/IV x1 dose, puis 250 mg PO/IV q48h" },
            ]},
            "Lévofloxacine — PAH": { notes: "Pneumonie hospitalière", doses: [
                { min: 51, max: 999, label: "750 mg PO/IV q24h" },
                { min: 21, max: 50, label: "750 mg PO/IV q48h" },
                { min: 0, max: 20, label: "750 mg PO/IV x1 dose, puis 500 mg PO/IV q48h" },
            ]},
            "Moxifloxacine (PO/IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "400 mg PO/IV q24h" }]},
            "Norfloxacine (PO) — IU": { notes: "Infection urinaire", doses: [
                { min: 31, max: 999, label: "400 mg PO q12-24h" },
                { min: 0, max: 30, label: "400 mg PO q24h" },
            ]},
        },
        "Autres antibactériens": {
            "Clindamycine (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "150-450 mg PO q6h" }]},
            "Clindamycine (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "600-900 mg IV q8h (fréq. max.: q6h)" }]},
            "Daptomycine (IV) — usuelle": { notes: "Pour dose 6 mg/kg: utiliser PD si PR > 140 kg", doses: [
                { min: 31, max: 999, label: "4-6 mg/kg PR IV q24h" },
                { min: 0, max: 30, label: "Même dose IV q48h" },
            ]},
            "Doxycycline (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "100 mg PO q12h" }]},
            "Linézolide (PO/IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "600 mg PO/IV q12h" }]},
            "Métronidazole (PO)": { notes: "", doses: [
                { min: 11, max: 999, label: "250-500 mg PO q8h ou 500 mg PO q12h" },
                { min: 0, max: 10, label: "500 mg PO q12h" },
            ]},
            "Métronidazole (IV)": { notes: "", doses: [
                { min: 11, max: 999, label: "500 mg IV q8h (fréq. max.: q6h)" },
                { min: 0, max: 10, label: "500 mg IV q12h" },
            ]},
            "Nitrofurantoïne (PO)": { notes: "Cystite non compliquée uniquement", doses: [
                { min: 46, max: 999, label: "50-100 mg PO QID ou 100 mg PO q12h (monohydrate)" },
                { min: 31, max: 45, label: "Données limitées. Possiblement efficace à court terme." },
                { min: 0, max: 30, label: "⚠️ Contre-indiqué — risque de toxicité accru" },
            ]},
            "Tétracycline (PO)": { notes: "", doses: [
                { min: 51, max: 999, label: "250-500 mg PO q6h" },
                { min: 11, max: 50, label: "250-500 mg PO q12h" },
                { min: 0, max: 10, label: "250-500 mg PO q24h" },
            ]},
            "Tigécycline (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "100 mg IV x1 dose puis 50 mg IV q12h" }]},
            "Triméthoprime (PO)": { notes: "", doses: [
                { min: 16, max: 999, label: "100 mg PO q12h" },
                { min: 6, max: 15, label: "50 mg PO q12h" },
                { min: 0, max: 5, label: "⚠️ Non recommandé" },
            ]},
            "TMP-SMX — usuel": { notes: "80 mg TMP = 1 co SS; 160 mg TMP = 1 co DS", doses: [
                { min: 31, max: 999, label: "160-320 mg TMP PO/IV q12h" },
                { min: 16, max: 30, label: "80 mg TMP PO/IV q12h ou 160 mg TMP PO/IV q24h" },
                { min: 0, max: 15, label: "⚠️ Non recommandé" },
            ]},
            "Vancomycine (IV)": { notes: "⚠️ Amorcer empiriquement selon âge, fonction rénale et poids puis ajuster selon dosages sériques. DC = 25 mg/kg PR. DM: 15-20 mg/kg PD/dose q8-12h (max 2g/dose). Consulter pharmacien.", doses: [
                { min: 71, max: 999, label: "DM IV q12h — surveiller dosages sériques" },
                { min: 41, max: 70, label: "DM IV q24h — surveiller dosages sériques" },
                { min: 21, max: 40, label: "DM IV q36-48h — dosages sériques quotidiens" },
                { min: 11, max: 20, label: "DM IV q72-96h" },
                { min: 0, max: 10, label: "DM IV q5-7 jours — consulter pharmacien" },
            ]},
            "Vancomycine (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "125 mg PO QID (max 500 mg PO QID si infection compliquée)" }]},
        },
        "Antifongiques": {
            "Anidulafungine (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "200 mg IV x1 dose puis 100 mg IV q24h" }]},
            "Caspofungine (IV)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "70 mg IV x1 dose puis 50 mg IV q24h" }]},
            "Fluconazole (PO/IV)": { notes: "DC = 100% de la dose. Écart: 100-800 mg PO/IV q24h", doses: [
                { min: 51, max: 999, label: "DC puis 100% dose PO/IV q24h" },
                { min: 11, max: 50, label: "DC puis 50% de la dose PO/IV q24h" },
                { min: 0, max: 10, label: "DC puis 25-50% de la dose PO/IV q24h" },
            ]},
            "Isavuconazole (PO/IV)": { notes: "Aucun ajustement requis. 372 mg sulfate = 200 mg isavuconazole.", doses: [{ min: 0, max: 999, label: "DC: 200 mg PO/IV q8h x6 doses, puis 200 mg PO/IV q24h" }]},
            "Kétoconazole (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "200-400 mg PO q24h" }]},
            "Micafungine — prophylaxie": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "50-100 mg IV q24h" }]},
            "Micafungine — traitement": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "100-150 mg IV q24h" }]},
            "Terbinafine (PO)": { notes: "", doses: [
                { min: 51, max: 999, label: "250 mg PO q24h" },
                { min: 0, max: 50, label: "⚠️ Non recommandé — données limitées" },
            ]},
        },
        "Antimycobactériens": {
            "Ethambutol (PO)": { notes: "Si PR > 120% PI, baser dose sur PI.", doses: [
                { min: 31, max: 999, label: "15-25 mg/kg PO q24h" },
                { min: 0, max: 30, label: "15-25 mg/kg/dose PO DIE 3 jours/semaine" },
            ]},
            "Isoniazide (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "5 mg/kg PO q24h (max: 300 mg)" }]},
            "Pyrazinamide (PO)": { notes: "Si PR > 120% PI, baser dose sur PI.", doses: [
                { min: 31, max: 999, label: "20-25 mg/kg PO q24h (max: 2g)" },
                { min: 0, max: 30, label: "25-35 mg/kg/dose PO DIE 3 jours/semaine" },
            ]},
            "Rifabutine (PO)": { notes: "", doses: [
                { min: 16, max: 999, label: "300 mg PO q24h" },
                { min: 0, max: 15, label: "150 mg PO q24h" },
            ]},
            "Rifampicine (PO)": { notes: "Aucun ajustement requis", doses: [{ min: 0, max: 999, label: "10 mg/kg PO q24h (max: 600 mg)" }]},
        },
        "Antiviraux": {
            "Acyclovir (IV)": { notes: "Posologie usuelle: 5-15 mg/kg/dose IV q8h", doses: [
                { min: 26, max: 999, label: "100% de la dose IV q8h" },
                { min: 11, max: 25, label: "100% de la dose IV q12h" },
                { min: 6, max: 10, label: "100% de la dose IV q24h" },
                { min: 0, max: 5, label: "50% de la dose IV q24h" },
            ]},
            "Acyclovir (PO) — zona": { notes: "", doses: [
                { min: 26, max: 999, label: "800 mg PO q4h (5 fois/jour)" },
                { min: 11, max: 25, label: "800 mg PO q8h" },
                { min: 0, max: 10, label: "800 mg PO q12h" },
            ]},
            "Famciclovir (PO) — zona": { notes: "", doses: [
                { min: 41, max: 999, label: "500 mg PO q8h" },
                { min: 21, max: 40, label: "500 mg PO q12h" },
                { min: 6, max: 20, label: "500 mg PO q24h" },
                { min: 0, max: 5, label: "250 mg PO q24h" },
            ]},
            "Oseltamivir (PO) — traitement": { notes: "Influenza A et B", doses: [
                { min: 31, max: 999, label: "75 mg PO q12h" },
                { min: 11, max: 30, label: "30 mg PO q12h" },
                { min: 6, max: 10, label: "30 mg PO q24h" },
                { min: 0, max: 5, label: "75 mg PO x1 dose" },
            ]},
            "Oseltamivir (PO) — prophylaxie": { notes: "Prophylaxie Influenza A et B", doses: [
                { min: 31, max: 999, label: "75 mg PO q24h" },
                { min: 11, max: 30, label: "30 mg PO q24h" },
                { min: 6, max: 10, label: "30 mg PO q48h" },
                { min: 0, max: 5, label: "Privilégier zanamivir inhalation" },
            ]},
            "Valacyclovir (PO) — zona": { notes: "", doses: [
                { min: 31, max: 999, label: "1g PO q8h" },
                { min: 16, max: 30, label: "1g PO q12h" },
                { min: 6, max: 15, label: "1g PO q24h" },
                { min: 0, max: 5, label: "500 mg PO q24h" },
            ]},
            "Valacyclovir (PO) — herpès génital": { notes: "", doses: [
                { min: 31, max: 999, label: "1g PO q12h" },
                { min: 16, max: 30, label: "1g PO q24h" },
                { min: 0, max: 15, label: "500 mg PO q24h" },
            ]},
        },
    };

    function calcClcr(age, poids, creat, sexe) {
        var k = sexe === 'F' ? 0.85 : 1.0;
        return ((140 - age) * poids / (49 * creat)) * 60 * k;
    }
    function calcPI(taille, sexe) {
        return sexe === 'F' ? 45.5 + 0.91 * (taille - 152) : 50 + 0.91 * (taille - 152);
    }
    function calcIMC(poids, taille) {
        return poids / Math.pow(taille / 100, 2);
    }

    var state = {
        age: '', poids: '', taille: '', creat: '', sexe: 'H',
        selectedCat: '', selectedDrug: '', search: '',
        mode: 'cg', dfgDirect: '',
        vancoTab: 'calcul'
    };

    // Vancomycine — état séparé
    var vancoState = {
        poids: '', dfge: ''
    };

    // Dose de charge selon poids
    function vancoGetDoseCharge(poids) {
        var p = parseFloat(poids);
        if (isNaN(p)) return null;
        if (p < 35) return null;
        if (p <= 39.9) return 750;
        if (p <= 49.9) return 1000;
        if (p <= 59.9) return 1250;
        if (p <= 69.9) return 1500;
        if (p <= 79.9) return 1750;
        if (p <= 89.9) return 2000;
        if (p <= 99.9) return 2250;
        if (p <= 129.9) return 2500;
        return 3000;
    }

    // Dose entretien selon poids
    function vancoGetDoseEntretien(poids) {
        var p = parseFloat(poids);
        if (isNaN(p)) return null;
        if (p < 35) return null;
        if (p <= 39.9) return 500;
        if (p <= 59.9) return 750;
        if (p <= 79.9) return 1000;
        if (p <= 99.9) return 1250;
        return 1500;
    }

    // Fréquence selon DFGe
    function vancoGetFrequence(dfge) {
        var d = parseFloat(dfge);
        if (isNaN(d)) return null;
        if (d > 90) return 'q 8h';
        if (d >= 50) return 'q 12h';
        if (d >= 15) return 'q 24h';
        return 'Dose unique puis selon dosage';
    }

    // Prélèvements selon fréquence
    function vancoGetPrelevement(freq) {
        if (!freq) return null;
        if (freq === 'q 8h' || freq === 'q 12h') {
            return { pic: '60 à 120 min post fin de perfusion de la 4e dose', creux: 'Juste avant la 4e dose' };
        }
        if (freq === 'q 24h') {
            return { pic: '60 à 120 min post fin de perfusion de la 3e dose', creux: 'Juste avant la 3e dose' };
        }
        return { pic: 'Selon dosage', creux: 'Selon dosage' };
    }

    function renderVanco() {
        var app = document.getElementById('vanco-app');
        if (!app) return;
        var html = '';
        html += '<div class="vanco-header">';
        html += '<h1>Vancomycine IV — Calculateur posologique</h1>';
        html += '<p>Basé sur les lignes directrices APES • Adultes seulement • Consulter un pharmacien pour les cas complexes</p>';
        html += '</div>';
        // Tab buttons
        html += '<div id="vanco-tab-btns" class="vanco-tab-btns">';
        html += '<button class="vanco-tab-btn ' + (state.vancoTab === 'calcul' ? 'active' : '') + '" onclick="vancoSetTab(\'calcul\')">🧮 Calcul personnalisé</button>';
        html += '<button class="vanco-tab-btn ' + (state.vancoTab === 'tableau' ? 'active' : '') + '" onclick="vancoSetTab(\'tableau\')">📋 Tableau de référence</button>';
        html += '</div>';
        // Calcul section — inputs never recreated
        html += '<div id="vanco-calcul-section" style="display:' + (state.vancoTab === 'calcul' ? 'block' : 'none') + ';">';
        html += '<div class="vanco-card">';
        html += '<h2>Données du patient</h2>';
        html += '<div class="vanco-note">⚠️ Ordonnance non applicable aux usagers sous thérapie de remplacement rénal — consulter le guide.</div>';
        html += '<div class="vanco-input-row">';
        html += '<div class="vanco-input-group"><label>Poids réel (kg)</label><input id="vanco-poids" type="number" placeholder="ex: 70" onchange="vancoSetField(\'poids\',this.value)"></div>';
        html += '<div class="vanco-input-group"><label>DFGe du laboratoire (mL/min/1,73m²)</label><input id="vanco-dfge" type="number" placeholder="ex: 55" onchange="vancoSetField(\'dfge\',this.value)"></div>';
        html += '</div></div>';
        html += '<div id="vanco-results"></div>';
        html += '</div>';
        // Tableau section
        html += '<div id="vanco-tableau-section" style="display:' + (state.vancoTab === 'tableau' ? 'block' : 'none') + ';">';
        html += renderVancoTableau();
        html += '</div>';
        html += '<div class="vanco-warning">⚠️ <b>Avertissement clinique :</b> Cet outil est fourni à titre indicatif seulement. Consulter un pharmacien pour tout ajustement posologique de la vancomycine.</div>';
        app.innerHTML = html;
        renderVancoResults();
    }
    window.vancoSetField = function(field, val) {
        vancoState[field] = val;
        renderVancoResults();
    };
    window.vancoSetTab = function(tab) {
        state.vancoTab = tab;
        // Update tab buttons
        var btnC = document.querySelector('#vanco-tab-btns .vanco-tab-btn:first-child');
        var btnT = document.querySelector('#vanco-tab-btns .vanco-tab-btn:last-child');
        if (btnC) btnC.className = 'vanco-tab-btn' + (tab === 'calcul' ? ' active' : '');
        if (btnT) btnT.className = 'vanco-tab-btn' + (tab === 'tableau' ? ' active' : '');
        // Toggle sections without recreating inputs
        var calcSection = document.getElementById('vanco-calcul-section');
        var tableauSection = document.getElementById('vanco-tableau-section');
        if (calcSection) calcSection.style.display = tab === 'calcul' ? 'block' : 'none';
        if (tableauSection) tableauSection.style.display = tab === 'tableau' ? 'block' : 'none';
    };
    window.calcSetMode = function(mode) { state.mode = mode; render(); };
    window.calcSetField = function(field, val) {
        state[field] = val;
        renderResult();
    };
    window.calcSetSexe = function(sexe) { state.sexe = sexe; renderResult(); };
    window.calcSetSearch = function(val) { state.search = val; state.selectedCat = ''; state.selectedDrug = ''; renderDrugSelector(); renderDrugResult(calcClcrFromState().clcr); };
    window.calcSetCat = function(cat) { state.selectedCat = cat; state.selectedDrug = ''; renderDrugSelector(); renderDrugResult(calcClcrFromState().clcr); };
    window.calcSetDrug = function(drug) { state.selectedDrug = drug; renderDrugSelector(); renderDrugResult(calcClcrFromState().clcr); };
    window.calcSelectDrug = function(cat, drug) { state.selectedCat = cat; state.selectedDrug = drug; state.search = ''; var si = document.getElementById('calc-search-input'); if(si) si.value=''; renderDrugSelector(); renderDrugResult(calcClcrFromState().clcr); };

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', render);
    } else {
        render();
    }
}