-- Depense genérale
SELECT  
B.*
/*	SUM(IFNULL(prt.fraisRetenu,0)) AS montantFacture,
	SUM(IFNULL(prt.montantApayer,0)) AS apresDecompten*/
FROM p_prestationactes prt INNER JOIN p_facture B ON (B.id=prt.idfacture)
INNER JOIN police P ON  (B.idPolice = P.id)
INNER JOIN clients cl ON (cl.id=P.idClient) AND cl.id<>'49'
INNER JOIN gc_assureur G ON  (P.codeGcAssureur = G.codeGcAssureur)
INNER JOIN adherent a ON ((P.id=a.idPolice) AND (P.codeSociete=a.codeSociete) AND ( a.id=B.idAdherent))
INNER JOIN p_feuillemaladie F ON (F.numeroFeuilleMaladie=B.numeroFeuilleMaladie)
-- INNER JOIN p_prestationmedicaments m ON (F.numeroFeuilleMaladie=m.numeroFeuilleMaladie) AND (prt.codePrestataire=m.codePrestataire)
-- INNER JOIN p_detailprescription D ON (D.numeroFeuilleMaladie=F.numeroFeuilleMaladie) AND (m.codeMedicament=D.codeMedicament)
WHERE (LEFT(B.dateSysteme,10) BETWEEN '2022-01-01' AND '2022-12-31' )
-- AND a.idPolice=22000019
AND B.numeroFeuilleMaladie=24942
AND G.id!='45'  AND (B.codeSociete="vitalis")  -- 54516   --54517



-- Depense genérale

UPDATE p_feuillemaladie,p_prestationactes,p_facture 
SET  p_prestationactes.idBeneficiaire=24189 , p_prestationactes.NumeroBeneficiaire='0229161206',
p_feuillemaladie.idBeneficiaire=24189 ,p_feuillemaladie.NumeroBeneficiaire='0229161206'  
,p_facture.idBeneficiaire=24189 ,p_facture.NumeroBeneficiaire='0229161206'  
WHERE p_prestationactes.idFacture=p_facture.id
AND  p_prestationactes.numeroFeuilleMaladie=p_feuillemaladie.numeroFeuilleMaladie
AND p_facture.id=p_feuillemaladie.idFactureFeuille 
AND p_feuillemaladie.numeroFeuilleMaladie = "24942"  


UPDATE p_prestationactes,p_facture 
SET  p_prestationactes.idBeneficiaire=24189 , p_prestationactes.NumeroBeneficiaire='0229161206'
,p_facture.idBeneficiaire=24189 ,p_facture.NumeroBeneficiaire='0229161206'  
WHERE p_prestationactes.idFacture=p_facture.id
AND p_prestationactes.numeroFeuilleMaladie = "24942"  


/*UPDATE p_prestationmedicaments,p_detailprescription 
SET  p_prestationmedicaments.idBeneficiaire=24189 , p_prestationmedicaments.NumeroBeneficiaire='0229161206'
,p_detailprescription.idBeneficiaire=24189 ,p_detailprescription.NumeroBeneficiaire='0229161206'  
WHERE p_prestationmedicaments.idFacture=p_detailprescription.id
AND p_prestationmedicaments.numeroFeuilleMaladie = "24942"  

SELECT p_prestationmedicaments.*
 FROM p_prestationmedicaments,p_detailprescription 
WHERE p_prestationmedicaments.numeroFeuilleMaladie=p_detailprescription.numeroFeuilleMaladie 
AND p_prestationmedicaments.codeMedicament=p_detailprescription.codeMedicament 
AND p_prestationmedicaments.numeroFeuilleMaladie = "24942"  */


