AidantPro
// ═══════════════════════════════════════════════════ // INTERFACE PHARMACIEN // ═══════════════════════════════════════════════════ const PH={ patient:null, dispenses:[], patients:[ {id:1,nom:'Pierre Dubois',age:78,gs:'A+',mutuelle:'MGEN',code:'AP-7821',nir:'1850675056082',medecin:'Dr. Martin Sophie',meds:[ {nom:'Donépézil',dose:'10mg',last:'28j',renouv:5,generique:false,prix:42.50,prixGen:null}, {nom:'Amlodipine',dose:'5mg',last:'28j',renouv:18,generique:true,prixGen:3.20,prix:7.80}, {nom:'Metformine',dose:'500mg',last:'28j',renouv:22,generique:true,prixGen:3.20,prix:7.40} ]}, {id:2,nom:'Jeanne Martin',age:82,gs:'O+',mutuelle:'Harmonie',code:'AP-4432',nir:'2820375056041',medecin:'Dr. Faure Paul',meds:[ {nom:'Lévodopa',dose:'250mg',last:'14j',renouv:12,generique:false,prix:38.00,prixGen:null}, {nom:'Bisoprolol',dose:'5mg',last:'28j',renouv:8,generique:true,prixGen:2.80,prix:6.50} ]} ] }; function showPharmacien(){ showScreen('pharmacien'); const prenom=S.user&&S.user.user_metadata&&S.user.user_metadata.prenom||''; const officine=document.getElementById('ph-officine'); if(officine)officine.textContent='Pharmacie '+(prenom||'Principale'); renderPhStats(); } function phSearch(q){ const res=document.getElementById('ph-results'); if(!q||q.length<2){res.innerHTML='';return;} const matches=PH.patients.filter(p=>p.nom.toLowerCase().includes(q.toLowerCase())||p.code.includes(q)||(p.nir&&p.nir.includes(q.replace(/\s/g,'')))); if(matches.length===0){res.innerHTML='
Aucun patient trouvé.
';return;} res.innerHTML=matches.map(p=>'
' +'
'+p.nom+'
'+p.age+' ans · '+p.gs+' · '+p.code+'
' +'
'+p.meds.length+' traitements'+(p.meds.some(m=>m.renouv<=10)?'Renouvellement':'')+'
').join(''); } function phSelectPatient(id){ const p=PH.patients.find(x=>x.id===id);if(!p)return; PH.patient=p;PH.dispenses=[]; document.getElementById('ph-pat-name').textContent=p.nom; document.getElementById('ph-pat-info').textContent=p.age+' ans - '+p.gs+' - '+p.mutuelle+' - NIR: '+(p.nir?p.nir.replace(/(\d{1})(\d{2})(\d{2})(\d{2})(\d{3})(\d{3})(\d{2})/,'$1 $2 $3 $4 $5 $6 $7'):'Non renseigné'); document.getElementById('ph-stats-panel').classList.add('hidden'); document.getElementById('ph-patient-panel').classList.remove('hidden'); document.getElementById('ph-results').innerHTML=''; document.getElementById('ph-search').value=p.nom; renderPhMeds();renderPhDispenses(); } function renderPhMeds(){ if(!PH.patient)return; const el=document.getElementById('ph-med-list'); el.innerHTML=PH.patient.meds.map(function(m,i){ return '
' +'
'+m.nom+' '+m.dose+'
' +'
Derniere dispensation : '+m.last+' | Renouvellement J-'+m.renouv+'
' +(m.generique?'Generique disponible : economie '+(m.prix-m.prixGen).toFixed(2)+'EUR':'') +'
' +'
J-'+m.renouv+'
' +'
'+m.prix.toFixed(2)+'EUR
' +'' +'
'; }).join(''); } function renderPhDispenses(){ const el=document.getElementById('ph-dispense-list'); if(PH.dispenses.length===0){el.innerHTML='
Aucune dispensation ce jour.
';return;} el.innerHTML=PH.dispenses.map(function(d,i){ return '
'+d.nom+'
'+d.dose+'
' +'
'+(d.generique?'Generique':'') +'OK' +'' +'
'; }).join(''); } function phDispense(idx){ const m=PH.patient.meds[idx]; PH.dispenses.push({nom:m.nom,dose:m.dose,generique:false,prix:m.prix}); renderPhDispenses(); } function phUseGenerique(idx){ const m=PH.patient.meds[idx]; PH.dispenses.push({nom:m.nom+' Biogaran',dose:m.dose,generique:true,prix:m.prixGen}); renderPhDispenses(); } function phAddDispense(){ const inp=document.getElementById('ph-new-med'); if(!inp.value.trim())return; PH.dispenses.push({nom:inp.value.trim(),dose:'',generique:false,prix:0}); inp.value='';renderPhDispenses(); } function phValidate(){ if(PH.dispenses.length===0){alert('Aucune dispensation a valider.');return;} const total=PH.dispenses.reduce(function(a,d){return a+(d.prix||0);},0); alert('Dispensation validee pour '+PH.patient.nom+'. '+PH.dispenses.length+' medicament(s). Le carnet AidantPro du patient a ete mis a jour.'); PH.dispenses=[];renderPhDispenses(); } function phProposeGeneriques(){ alert('Notification envoyee a l aidant de '+PH.patient.nom+'. Il pourra valider le passage aux generiques depuis son application.'); } function phBilan(){ alert('Demande de bilan medicamenteux cree. Acte remunere 60EUR par l Assurance Maladie.'); } function phScanQR(){ alert('Fonctionnalite scan QR code - disponible dans la version mobile.'); } function renderPhStats(){ document.getElementById('ph-stats-panel').classList.remove('hidden'); document.getElementById('ph-patient-panel').classList.add('hidden'); }