<?php

require_once(rootDir() . 'modules/pmsi/php/etudes/cardioInterventionnelle/Mention.php');
require_once(rootDir() . 'modules/pmsi/php/etudes/cardioInterventionnelle/Modalite.php');
require_once(rootDir() . 'modules/pmsi/php/etudes/cardioInterventionnelle/FamilleActes.php');
require_once(rootDir() . 'modules/base/php/utils/Cast.php');

class AbstractCardio
{
    protected $modalite;

    protected $cdc;

    protected $iCTI_connexion;


    public function __construct()
    {
        $this->iCTI_connexion = Database2Factory::getInstance(Environnement::PROVIDER_CTI);
        $this->cdc = '2022';
    }

    public function checkCdcIsValid($year)
    {
    }

    /**
     * @param Mention $mention
     * @param string $year
     * @return void
     */
    protected function insertEtudeIsValid($mention, $year)
    {

        $isValidForPg = Cast::boolFromPhpToPg($mention->getCdcIsValid());
        $nbActesTotal = $mention->getNbActesTotal();
        $mentionCode = $mention->getCode();

        $sql = <<<SQL
            INSERT INTO pmsi.p_etude_cardio(
                cardio_mention_code,
                cardio_mention_id,
                cdc,
                est_valid,
                nb_actes,
                annee
             ) SELECT
                    code,
                    oid,
                    cdc,
                    '$isValidForPg',
                    $nbActesTotal,
                    '$year'
                FROM pmsi.t_etude_cardio_mentions
                WHERE code = '$mentionCode'
                AND cdc = '$this->cdc';
SQL;
        $this->iCTI_connexion->query($sql);

    }
}




