// JammSanté Clinique — données démo (Clinique Teranga, Dakar)
const fmtF = n => n.toLocaleString('fr-FR').replace(/\u202F/g,' ') + ' F';

const C_CLINIC = { name:'Clinique Teranga', addr:'Sacré-Cœur 3, Dakar', tel:'+221 33 860 12 40' };

const C_STAFF = [
  { id:'s1', name:'Dr Awa Ndiaye', role:'Médecin généraliste', type:'Salarié', dispo:'Lun–Ven', color:'#0D9488', consult:14, ponctu:'96%', statut:'En consultation' },
  { id:'s2', name:'Dr Cheikh Sarr', role:'Cardiologue', type:'Vacataire', dispo:'Mar · Jeu', color:'#DB2777', consult:9, ponctu:'91%', statut:'Présent' },
  { id:'s3', name:'Dr Fatou Bâ', role:'Gynécologue', type:'Vacataire', dispo:'Lun · Mer · Ven', color:'#8B5CF6', consult:11, ponctu:'98%', statut:'Présente' },
  { id:'s4', name:'Dr Ibrahima Fall', role:'Pédiatre', type:'Salarié', dispo:'Lun–Sam', color:'#0EA5E9', consult:16, ponctu:'93%', statut:'En consultation' },
  { id:'s5', name:'Dr Mariama Sy', role:'Radiologue', type:'Vacataire', dispo:'Mer · Sam', color:'#F97316', consult:7, ponctu:'95%', statut:'Absente' },
  { id:'s6', name:'Aïssatou Diop', role:'Infirmière chef', type:'Salarié', dispo:'Lun–Ven', color:'#10B981', statut:'Présente' },
  { id:'s7', name:'Moussa Guèye', role:'Infirmier', type:'Salarié', dispo:'Garde nuit', color:'#6366F1', statut:'Garde ce soir' },
  { id:'s8', name:'Khady Mbaye', role:'Caissière principale', type:'Salarié', dispo:'Lun–Sam', color:'#0D9488', statut:'Caisse accueil' },
  { id:'s9', name:'Ndèye Faye', role:'Secrétaire accueil', type:'Salarié', dispo:'Lun–Sam', color:'#DB2777', statut:'Présente' },
  { id:'s10', name:'Omar Cissé', role:'Technicien labo', type:'Salarié', dispo:'Lun–Ven', color:'#F97316', statut:'Présent' },
];

// Rétrocession — chaque vacataire a son deal, décidé par la direction
const C_VACATAIRES = [
  { id:'s2', name:'Dr Cheikh Sarr', spec:'Cardiologie', jours:'Mardi · Jeudi', modele:'Pourcentage', taux:'65% / 35%', actes:[
    { acte:'Consultation cardio', tarif:20000, nb:34, mode:'65/35' }, { acte:'Échographie cardiaque', tarif:35000, nb:18, mode:'60/40' }, { acte:'ECG', tarif:10000, nb:26, mode:'50/50' }],
    brut:1570000, medecin:975500, clinique:594500, statut:'À valider' },
  { id:'s3', name:'Dr Fatou Bâ', spec:'Gynécologie', jours:'Lun · Mer · Ven', modele:'Pourcentage', taux:'60% / 40%', actes:[
    { acte:'Consultation gynéco', tarif:15000, nb:52, mode:'60/40' }, { acte:'Échographie pelvienne', tarif:25000, nb:31, mode:'60/40' }, { acte:'Pose implant', tarif:30000, nb:6, mode:'70/30' }],
    brut:1735000, medecin:1059000, clinique:676000, statut:'Validé' },
  { id:'s5', name:'Dr Mariama Sy', spec:'Radiologie', jours:'Mer · Sam', modele:'Fixe par acte', taux:'8 000 F / acte à la clinique', actes:[
    { acte:'Échographie abdominale', tarif:25000, nb:22, mode:'Fixe 8 000 F' }, { acte:'Écho obstétricale', tarif:25000, nb:17, mode:'Fixe 8 000 F' }],
    brut:975000, medecin:663000, clinique:312000, statut:'Payé' },
];

const C_QUEUE = [
  { id:'q1', ticket:'A-014', name:'Mame Diarra Sow', age:34, service:'Médecine générale', arrivee:'08:42', attente:'12 min', triage:'normal', statut:'En consultation', avec:'Dr Awa Ndiaye' },
  { id:'q2', ticket:'A-015', name:'Serigne Mbacké Ndao', age:61, service:'Cardiologie', arrivee:'08:55', attente:'26 min', triage:'urgent', statut:'En attente', avec:'Dr Cheikh Sarr' },
  { id:'q3', ticket:'B-006', name:'Adama Kane', age:5, service:'Pédiatrie', arrivee:'09:03', attente:'18 min', triage:'normal', statut:'En attente', avec:'Dr Ibrahima Fall' },
  { id:'q4', ticket:'A-016', name:'Yacine Thiam', age:28, service:'Gynécologie', arrivee:'09:10', attente:'9 min', triage:'normal', statut:'À la caisse', avec:'Dr Fatou Bâ' },
  { id:'q5', ticket:'C-002', name:'Pape Diouf', age:47, service:'Laboratoire', arrivee:'09:15', attente:'5 min', triage:'normal', statut:'En attente', avec:'Labo' },
  { id:'q6', ticket:'A-017', name:'Rokhaya Ndour', age:52, service:'Médecine générale', arrivee:'09:22', attente:'2 min', triage:'normal', statut:'Enregistrée', avec:'—' },
];

const C_AGENDA = [
  { doc:'Dr Awa Ndiaye', color:'#0D9488', slots:[{h:'09:00',p:'M. Diarra Sow',t:'Consultation'},{h:'09:30',p:'R. Ndour',t:'Suivi HTA'},{h:'10:00',p:'—',t:'libre'},{h:'10:30',p:'B. Sène',t:'Consultation'},{h:'11:00',p:'A. Touré',t:'Résultats labo'},{h:'11:30',p:'—',t:'libre'}] },
  { doc:'Dr Cheikh Sarr', color:'#DB2777', slots:[{h:'09:00',p:'S. M. Ndao',t:'Urgent · douleur thoracique'},{h:'09:30',p:'D. Diagne',t:'Écho cardiaque'},{h:'10:00',p:'F. Mendy',t:'ECG + consultation'},{h:'10:30',p:'M. Camara',t:'Suivi insuffisance'},{h:'11:00',p:'—',t:'libre'},{h:'11:30',p:'I. Sagna',t:'Consultation'}] },
  { doc:'Dr Fatou Bâ', color:'#8B5CF6', slots:[{h:'09:00',p:'Y. Thiam',t:'CPN T2'},{h:'09:30',p:'A. Diallo',t:'Écho pelvienne'},{h:'10:00',p:'K. Badji',t:'Consultation'},{h:'10:30',p:'—',t:'libre'},{h:'11:00',p:'N. Gomis',t:'Post-partum'},{h:'11:30',p:'S. Cissokho',t:'Contraception'}] },
  { doc:'Dr Ibrahima Fall', color:'#0EA5E9', slots:[{h:'09:00',p:'A. Kane',t:'Fièvre'},{h:'09:30',p:'M. Seck (2 ans)',t:'Vaccination'},{h:'10:00',p:'L. Barry',t:'Suivi croissance'},{h:'10:30',p:'O. Dème',t:'Consultation'},{h:'11:00',p:'F. Sané',t:'Consultation'},{h:'11:30',p:'—',t:'libre'}] },
];

const C_URGENCES = [
  { id:'u1', name:'Serigne Mbacké Ndao', age:61, motif:'Douleur thoracique', triage:'rouge', arrivee:'08:55', prise:'Dr Cheikh Sarr', statut:'En cours', constantes:'TA 165/95 · FC 104' },
  { id:'u2', name:'Bineta Sarr', age:24, motif:'Crise d\u2019asthme', triage:'orange', arrivee:'09:20', prise:'Aïssatou Diop', statut:'Nébulisation', constantes:'SpO2 91% · FR 26' },
  { id:'u3', name:'Landing Sané', age:38, motif:'Plaie main (accident atelier)', triage:'jaune', arrivee:'09:35', prise:'—', statut:'En attente', constantes:'Stable' },
];
const C_AMBULANCE = { vehicule:'Ambulance T-01', statut:'Disponible', chauffeur:'Modou Ndiaye', sorties:[
  { h:'06:40', motif:'Évacuation → Hôpital Principal (AVC suspecté)', duree:'55 min', fact:45000 },
  { h:'Hier 22:10', motif:'Transport post-op à domicile (Ouakam)', duree:'40 min', fact:25000 }] };
const C_GARDE = { nuit:'Moussa Guèye (infirmier) · Dr Ibrahima Fall (astreinte)', transmission:'2 hospitalisés stables · perfusion ch. 4 à surveiller · urgence asthme admise 23h40, sortie 6h.' };

const C_LITS = [
  { ch:'Ch. 1', lit:'1A', type:'Privée clim.', tarif:35000, statut:'occupé', patient:'Ousmane Dieng', motif:'Post-op hernie', jours:2, medecin:'Dr A. Ndiaye' },
  { ch:'Ch. 1', lit:'1B', type:'Privée clim.', tarif:35000, statut:'libre' },
  { ch:'Ch. 2', lit:'2A', type:'Double', tarif:20000, statut:'occupé', patient:'Astou Guèye', motif:'Paludisme grave', jours:3, medecin:'Dr I. Fall' },
  { ch:'Ch. 2', lit:'2B', type:'Double', tarif:20000, statut:'occupé', patient:'Mamadou Lô', motif:'Surveillance HTA', jours:1, medecin:'Dr C. Sarr' },
  { ch:'Ch. 3', lit:'3A', type:'Double', tarif:20000, statut:'nettoyage' },
  { ch:'Ch. 3', lit:'3B', type:'Double', tarif:20000, statut:'libre' },
  { ch:'Mat.', lit:'M1', type:'Maternité', tarif:30000, statut:'occupé', patient:'Ndèye Coumba Fall', motif:'Post-accouchement J1', jours:1, medecin:'Dr F. Bâ' },
  { ch:'Mat.', lit:'M2', type:'Maternité', tarif:30000, statut:'libre' },
];
const C_SEJOUR = { patient:'Astou Guèye', jours:[
  { j:'J1', lit:20000, soins:12000, medicaments:18500, actes:'Perfusion + bilan palu' },
  { j:'J2', lit:20000, soins:8000, medicaments:9500, actes:'Perfusion' },
  { j:'J3 (en cours)', lit:20000, soins:8000, medicaments:6000, actes:'Relais per os' }], total:122000, assurance:'IPM Sonatel · 80%' };

const C_BLOC = [
  { h:'08:00', acte:'Césarienne programmée', patient:'Ndèye Coumba Fall', equipe:'Dr Bâ + Dr Ndiaye + A. Diop', salle:'Bloc A', statut:'Terminé', fact:250000 },
  { h:'11:00', acte:'Hernie inguinale', patient:'Ousmane Dieng', equipe:'Dr Diallo (vacataire) + M. Guèye', salle:'Bloc A', statut:'Terminé', fact:180000 },
  { h:'15:00', acte:'Kyste ovarien (cœlioscopie)', patient:'Khady Badji', equipe:'Dr Bâ + A. Diop', salle:'Bloc A', statut:'Programmé', fact:320000 },
];
const C_MATERNITE = [
  { patient:'Ndèye Coumba Fall', evt:'Césarienne · fille 3,2 kg', h:'Ce matin 08:45', statut:'Suites de couches J0 · stable' },
  { patient:'Aminata Diédhiou', evt:'Accouchement voie basse · garçon 3,5 kg', h:'Hier 23:15', statut:'Sortie prévue demain' },
];

const C_EXAMS = [
  { id:'e1', type:'Labo', exam:'NFS + CRP', patient:'Adama Kane', prescripteur:'Dr I. Fall', demande:'09:10', delai:'45 min', statut:'En cours' },
  { id:'e2', type:'Labo', exam:'Glycémie + HbA1c', patient:'Rokhaya Ndour', prescripteur:'Dr A. Ndiaye', demande:'08:50', delai:'—', statut:'Résultat prêt', notif:true },
  { id:'e3', type:'Imagerie', exam:'Écho obstétricale T2', patient:'Yacine Thiam', prescripteur:'Dr F. Bâ', demande:'09:15', delai:'20 min', statut:'Programmé 10:30' },
  { id:'e4', type:'Imagerie', exam:'Radio thorax', patient:'Bineta Sarr', prescripteur:'Urgences', demande:'09:25', delai:'—', statut:'Résultat prêt', notif:false },
  { id:'e5', type:'Labo', exam:'Goutte épaisse', patient:'Astou Guèye', prescripteur:'Dr I. Fall', demande:'07:30', delai:'—', statut:'Validé' },
];

const C_STOCK = [
  { med:'Amoxicilline 500 mg', stock:8, seuil:20, prix:2500, exp:'11/2026', alerte:'rupture' },
  { med:'Paracétamol 1 g', stock:142, seuil:50, prix:1200, exp:'03/2027' },
  { med:'Artéméther-luméfantrine', stock:34, seuil:30, prix:3800, exp:'09/2026', alerte:'proche seuil' },
  { med:'Insuline rapide (flacon)', stock:12, seuil:10, prix:6500, exp:'01/2027', frigo:true },
  { med:'SRO sachets', stock:210, seuil:80, prix:300, exp:'06/2027' },
  { med:'Gants examen (boîte)', stock:18, seuil:25, prix:4500, exp:'—', alerte:'proche seuil', conso:true },
  { med:'Compresses stériles', stock:64, seuil:40, prix:1500, exp:'—', conso:true },
];
const C_VENTES_PHARMA = { jour:186500, ordonnances:23, internes:14 };

const C_CAISSES = [
  { nom:'Caisse accueil', agent:'Khady Mbaye', encaisse:427000, ops:31 },
  { nom:'Caisse labo', agent:'Omar Cissé', encaisse:118000, ops:12 },
  { nom:'Caisse pharmacie', agent:'Ndèye Faye', encaisse:186500, ops:23 },
];
const C_PAIEMENTS = [
  { id:'p1', h:'09:26', patient:'Yacine Thiam', desc:'Consultation gynéco + écho', total:40000, part:8000, assureur:'IPM Sonatel (80%)', mode:'Wave', statut:'Payé' },
  { id:'p2', h:'09:14', patient:'Pape Diouf', desc:'Bilan labo complet', total:28000, part:28000, assureur:'—', mode:'Espèces', statut:'Payé' },
  { id:'p3', h:'08:58', patient:'Serigne M. Ndao', desc:'Urgences + ECG', total:35000, part:10500, assureur:'CSS (70%)', mode:'—', statut:'À encaisser' },
  { id:'p4', h:'08:40', patient:'Mame Diarra Sow', desc:'Consultation générale', total:15000, part:15000, assureur:'—', mode:'Orange Money', statut:'Payé' },
  { id:'p5', h:'Hier', patient:'Ousmane Dieng', desc:'Chirurgie hernie (reste)', total:180000, part:60000, assureur:'Mutuelle CNTS (50%)', mode:'Ardoise', statut:'Échelonné · 2/3' },
];
const C_MODES = [ {mode:'Espèces', total:212000, pct:38}, {mode:'Wave / OM', total:158500, pct:28}, {mode:'Assurances (tiers payant)', total:129000, pct:23}, {mode:'Carte', total:36000, pct:6}, {mode:'Ardoise / crédit', total:26000, pct:5} ];

const C_RECOUVREMENT = [
  { assureur:'IPM Sonatel', dossiers:42, montant:2140000, statut:'Envoyé', age:'18 j', tone:'blue' },
  { assureur:'CSS', dossiers:28, montant:1230000, statut:'En retard', age:'46 j', tone:'red', relance:true },
  { assureur:'Mutuelle CNTS', dossiers:11, montant:485000, statut:'Payé ce mois', age:'—', tone:'green' },
  { assureur:'AXA Santé', dossiers:7, montant:390000, statut:'Rejets à corriger (3)', age:'32 j', tone:'amber' },
];

const C_FINANCES = {
  mois:'Juillet 2026 (au 13)', recettes:9840000, depenses:6120000,
  services:[ {s:'Consultations', v:2850000, pct:29}, {s:'Hospitalisation', v:1680000, pct:17}, {s:'Bloc & maternité', v:2230000, pct:23}, {s:'Laboratoire', v:1140000, pct:12}, {s:'Imagerie', v:820000, pct:8}, {s:'Pharmacie', v:1120000, pct:11} ],
  depensesDetail:[ {d:'Salaires & gardes', v:3200000}, {d:'Rétrocessions vacataires', v:1420000}, {d:'Médicaments & consommables', v:860000}, {d:'Électricité / eau / internet', v:390000}, {d:'Maintenance & divers', v:250000} ],
};

const C_CONGES = [
  { name:'Aïssatou Diop', type:'Congé annuel', du:'20 juil', au:'3 août', statut:'Approuvé' },
  { name:'Omar Cissé', type:'Absence maladie', du:'8 juil', au:'9 juil', statut:'Justifiée' },
  { name:'Ndèye Faye', type:'Congé annuel', du:'1 sept', au:'15 sept', statut:'En attente' },
];
const C_PAIE = [
  { name:'Dr Awa Ndiaye', base:850000, primes:120000, statut:'Payé 30 juin' },
  { name:'Aïssatou Diop', base:380000, primes:45000, statut:'Payé 30 juin' },
  { name:'Moussa Guèye', base:320000, primes:60000, statut:'Payé 30 juin · primes gardes' },
  { name:'Khady Mbaye', base:280000, primes:15000, statut:'Payé 30 juin' },
];
const C_GARDES_PLANNING = [
  { sem:'Cette semaine', nuits:[{j:'Lun',n:'M. Guèye'},{j:'Mar',n:'A. Diop'},{j:'Mer',n:'M. Guèye'},{j:'Jeu',n:'B. Ndao'},{j:'Ven',n:'A. Diop'},{j:'Sam',n:'M. Guèye'},{j:'Dim',n:'B. Ndao'}] },
];
const C_PERMISSIONS = [
  { role:'Gérant / Direction', acces:'Tout · finances, paie, rétrocessions, paramètres', tone:'teal' },
  { role:'Médecin-chef', acces:'Médical complet + rapports d\u2019activité · pas de paie', tone:'blue' },
  { role:'Médecin', acces:'Ses patients, son agenda, ses prescriptions', tone:'violet' },
  { role:'Caissière', acces:'Caisse, factures, encaissements · pas de dossiers médicaux', tone:'amber' },
  { role:'Infirmier', acces:'File d\u2019attente, constantes, soins, hospitalisation', tone:'green' },
  { role:'Secrétaire', acces:'RDV, enregistrement, communication patients', tone:'pink' },
];

const C_PATIENTS = [
  { id:'cp1', name:'Mame Diarra Sow', age:34, tel:'+221 77 512 33 40', assurance:'—', vus:'MG (Dr Ndiaye)', derniere:'Aujourd\u2019hui', solde:0 },
  { id:'cp2', name:'Serigne Mbacké Ndao', age:61, tel:'+221 76 208 11 25', assurance:'CSS · 70%', vus:'Cardio, Urgences', derniere:'Aujourd\u2019hui', solde:10500 },
  { id:'cp3', name:'Yacine Thiam', age:28, tel:'+221 78 630 44 12', assurance:'IPM Sonatel · 80%', vus:'Gynéco, Labo, Imagerie', derniere:'Aujourd\u2019hui', solde:0 },
  { id:'cp4', name:'Ousmane Dieng', age:45, tel:'+221 77 845 90 03', assurance:'Mutuelle CNTS · 50%', vus:'Chirurgie, Hospitalisation', derniere:'Hospitalisé', solde:60000 },
  { id:'cp5', name:'Astou Guèye', age:39, tel:'+221 70 118 27 66', assurance:'IPM Sonatel · 80%', vus:'MG, Labo, Hospitalisation', derniere:'Hospitalisée', solde:0 },
  { id:'cp6', name:'Adama Kane', age:5, tel:'+221 77 902 55 18 (mère)', assurance:'—', vus:'Pédiatrie, Labo', derniere:'Aujourd\u2019hui', solde:0 },
];

const C_COMMS = [
  { id:'m1', canal:'WhatsApp', type:'Rappel RDV', dest:'Khady Badji', msg:'Rappel : RDV demain 10h00 avec Dr Bâ (cœlioscopie, à jeun).', statut:'Envoyé 08:00', tone:'green' },
  { id:'m2', canal:'SMS', type:'Résultats prêts', dest:'Rokhaya Ndour', msg:'Vos résultats d\u2019analyses sont disponibles à la Clinique Teranga.', statut:'Envoyé 09:05', tone:'blue' },
  { id:'m3', canal:'WhatsApp', type:'Satisfaction', dest:'Aminata Diédhiou', msg:'Merci de votre visite. Notez votre expérience : teranga.sn/avis', statut:'Programmé à la sortie', tone:'violet' },
  { id:'m4', canal:'SMS', type:'Rappel RDV', dest:'34 patients (demain)', msg:'Envoi groupé automatique à 17h00.', statut:'Programmé', tone:'amber' },
];
const C_SATISFACTION = { score:4.6, reponses:128, plaintes:['Temps d\u2019attente caisse (6 mentions)','Climatisation salle d\u2019attente (2)'] };

const C_IA_BRIEF = [
  { icon:'alert-triangle', tone:'red', txt:'CSS : 1,23 M F en retard de 46 jours, relance recommandée aujourd\u2019hui.' },
  { icon:'pill', tone:'amber', txt:'Amoxicilline 500 mg presque épuisée (8 boîtes), commande avant jeudi.' },
  { icon:'calendar', tone:'blue', txt:'Dr Fall a 16 RDV demain (moyenne 11), proposer un renfort ou décaler 3 RDV.' },
  { icon:'wallet', tone:'teal', txt:'Recettes du jour +12% vs lundi dernier. Ticket moyen : 23 500 F.' },
];

Object.assign(window, { fmtF, C_CLINIC, C_STAFF, C_VACATAIRES, C_QUEUE, C_AGENDA, C_URGENCES, C_AMBULANCE, C_GARDE, C_LITS, C_SEJOUR, C_BLOC, C_MATERNITE, C_EXAMS, C_STOCK, C_VENTES_PHARMA, C_CAISSES, C_PAIEMENTS, C_MODES, C_RECOUVREMENT, C_FINANCES, C_CONGES, C_PAIE, C_GARDES_PLANNING, C_PERMISSIONS, C_PATIENTS, C_COMMS, C_SATISFACTION, C_IA_BRIEF });
