-- gestion des delais de carence des beneficiaitr

SET @delaiCarenceActe=0;
SET @dateFinDelaiCarence="1970-01-01";

SELECT idAdherent,numeroAdherent,id,numeroBeneficiaire,nomBeneficiaire,prenomsBeneficiaire,
idCollege,dateEntree,dateEffet,ancienAssure,'2022-05-01' AS delaisCarenceBenef, '0' AS exceptionCarence
FROM beneficiaire
WHERE idAdherent=9297
-- nomBeneficiaire like '%LASME%'

IF (exceptionCarence<>'1') THEN
	IF (delaisCarenceBenef >= dateEffet) THEN
		SELECT "VOUS NE BENEFFICIERZ PAS DE LA COUVERTURE MALADIE POUR L'INSTANT"	
	ELSE
		IF ((delaisCarenceBenef >= dateEffet) AND (exceptionCarence='0' )) THEN
	SELECT DATE_ADD(@dateEntree, INTERVAL (@delaiCarenceActe-1) DAY) INTO @dateFinDelaiCarence;
	  IF (@dateFinDelaiCarence <= CURDATE()) THEN
		SET @dateFinDelaiCarence="1970-01-01";
	  END IF;
END IF;
END IF;


 