/**
  * Tell whether object has a document with the same name has this one
  * 
  * @param CMbObject $object Object to test with
  * 
  * @return boolean
  */
 function existsFor(CMbObject $object)
 {
     $ds = $this->_spec->ds;
     $doc = new CCompteRendu();
     $doc->setObject($object);
     $doc->nom = $ds->escape($this->nom);
     return $doc->countMatchingList();
 }
CPatient::massLoadIPP($patients);
CStoredObject::massCountBackRefs($sejours, "affectations");
CStoredObject::massCountBackRefs($sejours, "consultations");
CStoredObject::massCountBackRefs($sejours, "files");
// Tri par nom de patient
$sorter = CMbArray::pluck($sejours, "_ref_patient", "nom");
array_multisort($sorter, SORT_ASC, $sejours);
// Chargement du modèle
$modele = new CCompteRendu();
$modele->load($modele_id);
$modele->loadContent();
$source = $modele->generateDocFromModel();
$nbDoc = array();
foreach ($sejours as $_sejour) {
    $compte_rendu = new CCompteRendu();
    $compte_rendu->setObject($_sejour);
    $compte_rendu->nom = $modele->nom;
    $compte_rendu->modele_id = $modele->_id;
    $compte_rendu->margin_top = $modele->margin_top;
    $compte_rendu->margin_bottom = $modele->margin_bottom;
    $compte_rendu->margin_left = $modele->margin_left;
    $compte_rendu->margin_right = $modele->margin_right;
    $compte_rendu->page_height = $modele->page_height;
    $compte_rendu->page_width = $modele->page_width;
    $compte_rendu->fast_edit = $modele->fast_edit;
    $compte_rendu->fast_edit_pdf = $modele->fast_edit_pdf;
    $compte_rendu->private = $modele->private;
    $compte_rendu->_source = $source;
    $compte_rendu->factory = $modele->factory;
    $templateManager = new CTemplateManager();
    $templateManager->isModele = false;