/**
  * @see parent::store()
  */
 function store()
 {
     $is_new = !$this->_id;
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($is_new || $this->fieldModified("name")) {
         CExObject::clearLocales();
     }
     return null;
 }
 /**
  * @see parent::checkProperty()
  */
 function checkProperty($object)
 {
     if ($this->notNull && $this->nullify) {
         return "Spécifications de propriété incohérentes entre 'notNull' et 'nullify'";
     }
     $fieldName = $this->fieldName;
     $propValue = CMbFieldSpec::checkNumeric($object->{$fieldName}, true);
     if ($propValue === null || $object->{$fieldName} === "") {
         return "N'est pas une référence (format non numérique)";
     }
     if ($propValue == 0) {
         return "ne peut pas être une référence nulle";
     }
     if ($propValue < 0) {
         return "N'est pas une référence (entier négatif)";
     }
     if (!$this->class and !$this->meta) {
         return "Type d'objet cible on défini";
     }
     $class = $this->class;
     if ($meta = $this->meta) {
         $class = $object->{$meta};
     }
     // Gestion des objets étendus ayant une pseudo-classe
     $ex_object = CExObject::getValidObject($class);
     if ($ex_object) {
         if (!$this->unlink && !$ex_object->load($propValue)) {
             return "Objet référencé de type '{$class}' introuvable";
         }
     } else {
         if (!is_subclass_of($class, "CStoredObject")) {
             return "La classe '{$class}' n'est pas une classe d'objet enregistrée";
         }
         /** @var CStoredObject $ref */
         $ref = new $class();
         if (!$this->unlink && !$ref->idExists($propValue)) {
             return "Objet référencé de type '{$class}' introuvable";
         }
     }
     return null;
 }
 /**
  * Load target of meta object
  *
  * @param bool $cache Utilisation du cache
  *
  * @return CMbObject
  */
 function loadTargetObject($cache = true)
 {
     if ($this->_ref_object || !$this->object_class) {
         return $this->_ref_object;
     }
     if (!class_exists($this->object_class)) {
         $ex_object = CExObject::getValidObject($this->object_class);
         if (!$ex_object) {
             CModelObject::error("Unable-to-create-instance-of-object_class%s-class", $this->object_class);
             return null;
         } else {
             $ex_object->load($this->object_id);
             $this->_ref_object = $ex_object;
         }
     } else {
         $this->_ref_object = $this->loadFwdRef("object_id", $cache);
     }
     if (!$this->_ref_object->_id) {
         $this->_ref_object->load(null);
         $this->_ref_object->_view = "Element supprimé";
     }
     return $this->_ref_object;
 }
Beispiel #4
0
 /**
  * @see parent::fillLimitedTemplate()
  */
 function fillLimitedTemplate(&$template)
 {
     $this->loadRefConsult();
     $this->_ref_consult->loadRefPraticien();
     $this->notify("BeforeFillLimitedTemplate", $template);
     // Duplication des champs de la consultation
     $template->addProperty("RPU - Consultation - Praticien nom", $this->_ref_consult->_ref_praticien->_user_first_name);
     $template->addProperty("RPU - Consultation - Praticien prénom", $this->_ref_consult->_ref_praticien->_user_last_name);
     $template->addProperty("RPU - Consultation - Motif", $this->_ref_consult->motif);
     $template->addProperty("RPU - Consultation - Remarques", $this->_ref_consult->rques);
     $template->addProperty("RPU - Consultation - Examen", $this->_ref_consult->examen);
     $template->addProperty("RPU - Consultation - Traitement", $this->_ref_consult->traitement);
     $template->addProperty("RPU - Diagnostic infirmier", $this->diag_infirmier);
     $template->addProperty("RPU - Prise en charge douleur", $this->pec_douleur);
     $template->addProperty("RPU - PeC Transport", $this->getFormattedValue("pec_transport"));
     $template->addProperty("RPU - Motif", $this->motif);
     $template->addProperty("RPU - CCMU", $this->getFormattedValue("ccmu"));
     $template->addProperty("RPU - Code GEMSA", $this->getFormattedValue("gemsa"));
     $template->addDateTimeProperty("RPU - Départ Radio", $this->radio_debut);
     $template->addDateTimeProperty("RPU - Retour Radio", $this->radio_fin);
     $template->addDateTimeProperty("RPU - Dépôt Biologie", $this->bio_depart);
     $template->addDateTimeProperty("RPU - Réception Biologie", $this->bio_retour);
     $template->addDateTimeProperty("RPU - Attente spécialiste", $this->specia_att);
     $template->addDateTimeProperty("RPU - Arrivée spécialiste", $this->specia_arr);
     $template->addProperty("RPU - Accident du travail", $this->getFormattedValue("date_at"));
     $libelle_at = $this->date_at ? "Accident du travail du " . $this->getFormattedValue("date_at") : "";
     $template->addProperty("RPU - Libellé accident du travail", $libelle_at);
     $template->addProperty("RPU - Sortie autorisée", $this->getFormattedValue("sortie_autorisee"));
     $lit = new C**t();
     if ($this->box_id) {
         $lit->load($this->box_id);
     }
     $template->addProperty("RPU - Box", $lit->_view);
     if (CAppUI::conf("dPurgences old_rpu") == "1") {
         if (CModule::getActive("sherpa")) {
             $template->addProperty("RPU - Soins pour trauma", $this->getFormattedValue("urtrau"));
             $template->addProperty("RPU - Cause du transfert", $this->getFormattedValue("urmuta"));
         }
         $template->addProperty("RPU - Type de pathologie", $this->getFormattedValue("type_pathologie"));
     } else {
         $template->addProperty("RPU - Orientation", $this->getFormattedValue("orientation"));
     }
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "RPU");
     }
     $this->notify("AfterFillLimitedTemplate", $template);
 }
 function fillLimitedTemplate(&$template)
 {
     $this->loadRefsFwd(1);
     $this->loadRefPraticien();
     $this->loadRefChir2();
     $this->loadRefChir3();
     $this->loadRefChir4();
     $this->loadRefsFiles();
     $this->loadAffectationsPersonnel();
     $plageop = $this->_ref_plageop;
     $plageop->loadAffectationsPersonnel();
     foreach ($this->_ext_codes_ccam as $_code) {
         $_code->getRemarques();
         $_code->getActivites();
     }
     $this->notify("BeforeFillLimitedTemplate", $template);
     for ($i = 1; $i < 5; $i++) {
         $prop = "_ref_chir" . ($i == 1 ? "" : "_{$i}");
         $praticien = $this->{$prop};
         $praticien->loadRefFunction();
         $praticien->loadRefDiscipline();
         $praticien->loadRefSpecCPAM();
         $number = $i == 1 ? "" : " {$i}";
         $template->addProperty("Opération - Chirurgien{$number}", $praticien->_id ? "Dr " . $praticien->_view : '');
         $template->addProperty("Opération - Chirurgien{$number} - Nom", $praticien->_user_last_name);
         $template->addProperty("Opération - Chirurgien{$number} - Prénom", $praticien->_user_first_name);
         $template->addProperty("Opération - Chirurgien{$number} - Initiales", $praticien->_shortview);
         $template->addProperty("Opération - Chirurgien{$number} - Discipline", $praticien->_ref_discipline->_view);
         $template->addProperty("Opération - Chirurgien{$number} - Spécialité", $praticien->_ref_spec_cpam->_view);
         $template->addProperty("Opération - Chirurgien{$number} - CAB", $praticien->cab);
         $template->addProperty("Opération - Chirurgien{$number} - CONV", $praticien->conv);
         $template->addProperty("Opération - Chirurgien{$number} - ZISD", $praticien->zisd);
         $template->addProperty("Opération - Chirurgien{$number} - IK", $praticien->ik);
         $template->addProperty("Opération - Chirurgien{$number} - Titres", $praticien->titres);
         $template->addProperty("Opération - Chirurgien{$number} - ADELI", $praticien->adeli);
         $template->addBarcode("Opération - Chirurgien{$number} - Code barre ADELI", $praticien->adeli, array("barcode" => array("title" => CAppUI::tr("CMediusers-adeli"))));
         $template->addProperty("Opération - Chirurgien{$number} - RPPS", $praticien->rpps);
         $template->addBarcode("Opération - Chirurgien{$number} - Code barre RPPS", $praticien->rpps, array("barcode" => array("title" => CAppUI::tr("CMediusers-rpps"))));
         $template->addProperty("Opération - Chirurgien{$number} - E-mail", $praticien->_user_email);
         $template->addProperty("Opération - Chirurgien{$number} - E-mail Apicrypt", $praticien->mail_apicrypt);
     }
     $template->addProperty("Opération - Anesthésiste - nom", @$this->_ref_anesth->_user_last_name);
     $template->addProperty("Opération - Anesthésiste - prénom", @$this->_ref_anesth->_user_first_name);
     $template->addProperty("Opération - Anesthésie", $this->_lu_type_anesth);
     $template->addProperty("Opération - libellé", $this->libelle);
     $template->addProperty("Opération - CCAM1 - code", @$this->_ext_codes_ccam[0]->code);
     $template->addProperty("Opération - CCAM1 - description", @$this->_ext_codes_ccam[0]->libelleLong);
     $template->addProperty("Opération - CCAM1 - montant activité 1", @$this->_ext_codes_ccam[0]->activites[1]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM1 - montant activité 4", @$this->_ext_codes_ccam[0]->activites[4]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM2 - code", @$this->_ext_codes_ccam[1]->code);
     $template->addProperty("Opération - CCAM2 - description", @$this->_ext_codes_ccam[1]->libelleLong);
     $template->addProperty("Opération - CCAM2 - montant activité 1", @$this->_ext_codes_ccam[1]->activites[1]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM2 - montant activité 4", @$this->_ext_codes_ccam[1]->activites[4]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM3 - code", @$this->_ext_codes_ccam[2]->code);
     $template->addProperty("Opération - CCAM3 - description", @$this->_ext_codes_ccam[2]->libelleLong);
     $template->addProperty("Opération - CCAM3 - montant activité 1", @$this->_ext_codes_ccam[2]->activites[1]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM3 - montant activité 4", @$this->_ext_codes_ccam[2]->activites[4]->phases[0]->tarif);
     $template->addProperty("Opération - CCAM - codes", implode(" - ", $this->_codes_ccam));
     if (CModule::getActive("tarmed") && CAppUI::conf("tarmed CCodeTarmed use_cotation_tarmed")) {
         $this->loadRefsActes();
         $template->addProperty("Opération - TARMED - codes", CActeTarmed::actesHtml($this), '', false);
         $template->addProperty("Opération - Caisse - codes", CActeCaisse::actesHtml($this), '', false);
     }
     $template->addProperty("Opération - CCAM - descriptions", implode(" - ", CMbArray::pluck($this->_ext_codes_ccam, "libelleLong")));
     $template->addProperty("Opération - salle", @$this->_ref_salle->nom);
     $template->addProperty("Opération - côté", $this->cote);
     $template->addProperty("Opération - position", $this->getFormattedValue("position"));
     $template->addDateProperty("Opération - date", $this->_datetime_best != " 00:00:00" ? $this->_datetime_best : "");
     $template->addLongDateProperty("Opération - date longue", $this->_datetime_best != " 00:00:00" ? $this->_datetime_best : "");
     $template->addTimeProperty("Opération - heure", $this->time_operation);
     $template->addTimeProperty("Opération - durée", $this->temp_operation);
     $template->addTimeProperty("Opération - durée réelle", $this->_duree_interv);
     $template->addTimeProperty("Opération - entrée bloc", $this->entree_salle);
     $template->addTimeProperty("Opération - pose garrot", $this->pose_garrot);
     $template->addTimeProperty("Opération - début induction", $this->induction_debut);
     $template->addTimeProperty("Opération - début op", $this->debut_op);
     $template->addTimeProperty("Opération - fin op", $this->fin_op);
     $template->addTimeProperty("Opération - fin induction", $this->induction_fin);
     $template->addTimeProperty("Opération - retrait garrot", $this->retrait_garrot);
     $template->addTimeProperty("Opération - sortie bloc", $this->sortie_salle);
     $template->addTimeProperty("Opération - entrée SSPI", $this->entree_reveil);
     $template->addTimeProperty("Opération - sortie SSPI", $this->sortie_reveil_reel);
     $template->addProperty("Opération - dépassement anesth", $this->depassement_anesth);
     $template->addProperty("Opération - Passage USCPO", "{$this->duree_uscpo} nuit(s)");
     if (CModule::getActive("mvsante")) {
         $template->addTimeProperty("Opération - Remise au chirurgien", $this->remise_chir);
         /** @var CLiaisonLibelleInterv[] $liaisons_libelles */
         $liaisons_libelles = $this->loadBackRefs("liaison_libelle", "numero");
         CMbObject::massLoadFwdRef($liaisons_libelles, "libelleop_id");
         $libelles = array(0 => "", 1 => "", 2 => "", 3 => "");
         foreach ($liaisons_libelles as $_liaison) {
             $libelles[$_liaison->numero - 1] = $_liaison->loadRefLibelle()->nom;
         }
         $template->addProperty("Opération - Libellé 1", $libelles[0]);
         $template->addProperty("Opération - Libellé 2", $libelles[1]);
         $template->addProperty("Opération - Libellé 3", $libelles[2]);
         $template->addProperty("Opération - Libellé 4", $libelles[3]);
     }
     $template->addProperty("Opération - depassement", $this->depassement);
     $template->addProperty("Opération - exams pre-op", $this->examen);
     $template->addProperty("Opération - matériel", $this->materiel);
     $template->addProperty("Opération - exam per-op", $this->exam_per_op);
     $template->addProperty("Opération - convalescence", $this->_ref_sejour->convalescence);
     $template->addProperty("Opération - remarques", $this->rques);
     $template->addProperty("Opération - Score ASA", $this->getFormattedValue("ASA"));
     $consult_anesth = $this->_ref_consult_anesth;
     $consult = $consult_anesth->loadRefConsultation();
     $consult->loadRefPlageConsult();
     $prat = $consult->loadRefPraticien();
     $template->addDateProperty("Opération - Consultation anesthésie - Date", $consult->_id ? $consult->_datetime : "");
     $template->addLongDateProperty("Opération - Consultation anesthésie - Date (longue)", $consult->_id ? $consult->_datetime : "");
     $template->addLongDateProperty("Opération - Consultation anesthésie - Date (longue, minuscule)", $consult->_id ? $consult->_datetime : "", true);
     $template->addTimeProperty("Opération - Consultation anesthésie - Heure", $consult->_id ? $consult->_datetime : "");
     $template->addProperty("Opération - Consultation anesthésie - Praticien - Prénom", $consult->_id ? $prat->_user_first_name : "");
     $template->addProperty("Opération - Consultation anesthésie - Praticien - Nom", $consult->_id ? $prat->_user_last_name : "");
     $template->addProperty("Opération - Consultation anesthésie - Remarques", $consult->rques);
     /** @var CMediusers $prat_visite */
     $prat_visite = $this->loadFwdRef("prat_visite_anesth_id", true);
     $template->addDateProperty("Opération - Visite pré anesthésie - Date", $this->date_visite_anesth);
     $template->addLongDateProperty("Opération - Visite pré anesthésie - Date (longue)", $this->date_visite_anesth);
     $template->addProperty("Opération - Visite pré anesthésie - Rques", $this->getFormattedValue("rques_visite_anesth"));
     $template->addProperty("Opération - Visite pré anesthésie - Autorisation", $this->getFormattedValue("autorisation_anesth"));
     $template->addProperty("Opération - Visite pré anesthésie - Praticien - Prénom", $prat_visite->_user_first_name);
     $template->addProperty("Opération - Visite pré anesthésie - Praticien - Nom", $prat_visite->_user_last_name);
     $template->addBarcode("Opération - Code Barre ID", $this->_id);
     $list = CMbArray::pluck($this->_ref_files, "file_name");
     $template->addListProperty("Opération - Liste des fichiers", $list);
     foreach ($this->_ref_affectations_personnel as $emplacement => $affectations) {
         $locale = CAppUI::tr("CPersonnel.emplacement.{$emplacement}");
         $property = implode(" - ", CMbArray::pluck($affectations, "_ref_personnel", "_ref_user", "_view"));
         $template->addProperty("Opération - personnel réel - {$locale}", $property);
     }
     foreach ($plageop->_ref_affectations_personnel as $emplacement => $affectations) {
         $locale = CAppUI::tr("CPersonnel.emplacement.{$emplacement}");
         $property = implode(" - ", CMbArray::pluck($affectations, "_ref_personnel", "_ref_user", "_view"));
         $template->addProperty("Opération - personnel prévu - {$locale}", $property);
     }
     $evts = $incidents = array();
     foreach ($this->loadRefsAnesthPerops() as $_evt) {
         if ($_evt->incident) {
             $incidents[] = $_evt;
             continue;
         }
         $evts[] = $_evt;
     }
     $template->addListProperty("Opération - Evenements per-opératoires", $evts);
     $template->addListProperty("Opération - Incidents per-opératoires", $incidents);
     CSupervisionGraph::addObservationDataToTemplate($template, $this, "Opération");
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "Opération");
     }
     if (CAppUI::conf("dPsalleOp enable_surveillance_perop")) {
         $obs_view = "";
         if ($template->valueMode && $this->_id && $this->graph_pack_id) {
             /** @var CObservationResultSet[] $list_obr */
             list($list, $grid, $graphs, $labels, $list_obr) = CObservationResultSet::getChronological($this, $this->graph_pack_id);
             foreach ($grid as $_row) {
                 /** @var CObservationResult[] $_row */
                 foreach ($_row as $_cell) {
                     if ($_cell && $_cell->file_id) {
                         $_cell->loadRefFile()->getDataUri();
                     }
                 }
             }
             $smarty = new CSmartyDP("modules/dPpatients");
             // Horizontal
             $smarty->assign("observation_grid", $grid);
             $smarty->assign("observation_labels", $labels);
             $smarty->assign("observation_list", $list_obr);
             $smarty->assign("in_compte_rendu", true);
             $obs_view = $smarty->fetch("inc_observation_results_grid.tpl", '', '', 0);
             $obs_view = preg_replace('`([\\n\\r])`', '', $obs_view);
         }
         $template->addProperty("Opération - Tableau supervision", $obs_view, '', false);
     }
     $this->notify("AfterFillLimitedTemplate", $template);
 }
 /**
  * @see parent::fillLimitedTemplate
  */
 function fillLimitedTemplate(&$template)
 {
     global $rootName;
     $this->updateFormFields();
     $this->notify("BeforeFillLimitedTemplate", $template);
     $template->addProperty("Anesthésie - Tabac", $this->tabac);
     $template->addProperty("Anesthésie - Oenolisme", $this->oenolisme);
     $dossier_medical = $this->loadRefPatient()->loadRefDossierMedical();
     $template->addProperty("Anesthésie - Groupe sanguin", $dossier_medical->groupe_sanguin . " " . $dossier_medical->rhesus);
     $template->addProperty("Anesthésie - RAI", $this->rai);
     $template->addProperty("Anesthésie - Hb", "{$this->hb} g/dl");
     $template->addProperty("Anesthésie - Ht", "{$this->ht} %");
     $template->addProperty("Anesthésie - Ht final", "{$this->ht_final} %");
     $template->addProperty("Anesthésie - PSA", "{$this->_psa} ml/GR");
     $template->addProperty("Anesthésie - Plaquettes", $this->plaquettes * 1000 . "/mm3");
     $template->addProperty("Anesthésie - Créatinine", "{$this->creatinine} mg/l");
     $template->addProperty("Anesthésie - Clairance", "{$this->_clairance} ml/min");
     $template->addProperty("Anesthésie - Na+", "{$this->na} mmol/l");
     $template->addProperty("Anesthésie - K+", "{$this->k} mmol/l");
     $template->addProperty("Anesthésie - TP", "{$this->tp} %");
     $template->addProperty("Anesthésie - TCA", "{$this->tca_temoin} s / {$this->tca} s");
     $template->addProperty("Anesthésie - TS Ivy", "{$this->_min_tsivy} min {$this->_sec_tsivy} s");
     $template->addProperty("Anesthésie - ECBU", $this->ecbu);
     $template->addProperty("Anesthésie - Commentaire", $this->result_com);
     $template->addProperty("Anesthésie - ASA", $this->_ref_operation->ASA ? $this->_ref_operation->getFormattedValue("ASA") : $this->getFormattedValue("ASA"));
     $template->addProperty("Anesthésie - Préparation pré-opératoire", $this->prepa_preop);
     $template->addProperty("Anesthésie - Prémédication", $this->premedication);
     $template->addProperty("Anesthésie - Position", $this->_ref_operation->getFormattedValue('position'));
     $list = CMbArray::pluck($this->loadRefsTechniques(), 'technique');
     $template->addListProperty("Anesthésie - Techniques complémentaires", $list);
     $template->addProperty("Anesthésie - Résultats ECG", $this->result_ecg);
     $template->addProperty("Anesthésie - Résultats Radio pulmonaire", $this->result_rp);
     $template->addProperty("Anesthésie - Examen cardiovasculaire", $this->examenCardio);
     $template->addProperty("Anesthésie - Examen pulmonaire", $this->examenPulmo);
     $template->addProperty("Anesthésie - Examen digestif", $this->examenDigest);
     $template->addProperty("Anesthésie - Examen autre", $this->examenAutre);
     $template->addProperty("Anesthésie - Type d'anesthésie", $this->_ref_operation->type_anesth ? $this->_ref_operation->getFormattedValue("type_anesth") : $this->getFormattedValue("type_anesth"));
     $template->addProperty("Anesthésie - Ouverture de la bouche", $this->getFormattedValue('bouche'), null, false);
     $template->addProperty("Anesthésie - Intubation", CAppUI::tr("CConsultAnesth-_intub_" . ($this->_intub_difficile ? "difficile" : "pas_difficile")));
     $ventilation = $this->plus_de_55_ans ? "Plus de 55 ans, " : "";
     $ventilation .= $this->imc_sup_26 ? "IMC > 26Kg/m², " : "";
     $ventilation .= $this->edentation ? "Edentation, " : "";
     $ventilation .= $this->ronflements ? "Ronflements, " : "";
     $ventilation .= $this->barbe ? "Barbe" : "";
     $ventilation .= $this->piercing ? "Piercing" : "";
     $template->addProperty("Anesthésie - Critères de ventilation", $ventilation ? $ventilation : "Aucun", null, false);
     $template->addProperty("Anesthésie - Distance thyro-mentonnière", $this->getFormattedValue('distThyro'), null, false);
     $template->addProperty("Anesthésie - Mobilité cervicale", $this->getFormattedValue('mob_cervicale'), null, false);
     $template->addProperty("Anesthésie - Etat bucco-dentaire", $this->etatBucco);
     $img = "";
     if ($this->mallampati) {
         $img = $this->mallampati . '<br /> .
     <img src="/' . $rootName . '/images/pictures/' . $this->mallampati . '.png" alt="' . $this->mallampati . '" />';
     }
     $template->addProperty("Anesthésie - Mallampati", $img, null, false);
     $template->addProperty("Anesthésie - Mallampati (texte seul)", $this->getFormattedValue("mallampati"));
     $template->addProperty("Anesthésie - Remarques", $this->conclusion);
     $template->addProperty("Anesthésie - Score APFEL", $this->_score_apfel);
     $template->addProperty("Anesthésie - Stratégie antibioprophylactique ", $this->strategie_antibio);
     // Constantes médicales dans le contexte de la consultation
     $this->loadRefConsultation();
     $patient = $this->loadRefPatient();
     $patient->loadRefLatestConstantes(null, null, $this->_ref_consultation, false);
     $const_dates = $patient->_latest_constantes_dates;
     $const_med = $patient->_ref_constantes_medicales;
     $const_med->updateFormFields();
     $grid_complet = CConstantesMedicales::buildGridLatest($const_med, $const_dates, true);
     $grid_minimal = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false);
     $grid_valued = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false, true);
     $smarty = new CSmartyDP("modules/dPpatients");
     // Horizontal
     $smarty->assign("constantes_medicales_grid", $grid_complet);
     $constantes_complet_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_complet_horiz = preg_replace('`([\\n\\r])`', '', $constantes_complet_horiz);
     $smarty->assign("constantes_medicales_grid", $grid_minimal);
     $constantes_minimal_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_minimal_horiz = preg_replace('`([\\n\\r])`', '', $constantes_minimal_horiz);
     $smarty->assign("constantes_medicales_grid", $grid_valued);
     $constantes_valued_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_valued_horiz = preg_replace('`([\\n\\r])`', '', $constantes_valued_horiz);
     // Vertical
     $smarty->assign("constantes_medicales_grid", $grid_complet);
     $constantes_complet_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_complet_vert = preg_replace('`([\\n\\r])`', '', $constantes_complet_vert);
     $smarty->assign("constantes_medicales_grid", $grid_minimal);
     $constantes_minimal_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_minimal_vert = preg_replace('`([\\n\\r])`', '', $constantes_minimal_vert);
     $smarty->assign("constantes_medicales_grid", $grid_valued);
     $constantes_valued_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_valued_vert = preg_replace('`([\\n\\r])`', '', $constantes_valued_vert);
     $template->addProperty("Anesthésie - Constantes - mode complet horizontal", $constantes_complet_horiz, '', false);
     $template->addProperty("Anesthésie - Constantes - mode minimal horizontal", $constantes_minimal_horiz, '', false);
     $template->addProperty("Anesthésie - Constantes - mode avec valeurs horizontal", $constantes_valued_horiz, '', false);
     $template->addProperty("Anesthésie - Constantes - mode complet vertical", $constantes_complet_vert, '', false);
     $template->addProperty("Anesthésie - Constantes - mode minimal vertical", $constantes_minimal_vert, '', false);
     $template->addProperty("Anesthésie - Constantes - mode avec valeurs vertical", $constantes_valued_vert, '', false);
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "Anesthésie");
     }
     $this->notify("AfterFillLimitedTemplate", $template);
 }
<?php

/**
 * $Id: ajax_edit_ex_picture.php 26570 2014-12-24 10:56:29Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 26570 $
 */
CCanDo::checkEdit();
$ex_picture_id = CValue::get("ex_picture_id");
$ex_group_id = CValue::get("ex_group_id");
CExObject::$_locales_cache_enabled = false;
$ex_group = new CExClassFieldGroup();
$ex_group->load($ex_group_id);
$ex_picture = new CExClassPicture();
if ($ex_picture->load($ex_picture_id)) {
    $ex_picture->loadRefsNotes();
} else {
    $ex_picture->ex_group_id = $ex_group_id;
    $ex_picture->disabled = "0";
}
$ex_picture->loadRefPredicate()->loadView();
$ex_picture->loadRefExClass();
$ex_picture->loadRefFile();
$smarty = new CSmartyDP();
$smarty->assign("ex_picture", $ex_picture);
$smarty->assign("ex_group", $ex_group);
$smarty->display("inc_edit_ex_picture.tpl");
 /**
  * Duplicates the object
  *
  * - field_groups
  *   - class_fields
  *     - field_translations
  *     - list_items
  *     - ex_triggers
  *     - (predicates)
  * 
  *   - host_fields
  *   - class_messages
  * 
  * - constraints
  * - ex_triggers
  *
  * @return null|string Store-like message
  */
 function duplicate()
 {
     if (!$this->_id) {
         return null;
     }
     // Load all field values
     $this->load();
     $new = new self();
     $new->cloneFrom($this);
     $new->name .= " (Copie)";
     $new->_dont_create_default_group = true;
     $this->_duplication_mapping = array();
     if ($msg = $new->store()) {
         return $msg;
     }
     // field_groups
     foreach ($this->loadRefsGroups() as $_group) {
         if ($msg = $this->duplicateObject($_group, "ex_class_id", $new->_id, $_new_group)) {
             continue;
         }
         $fwd_field = "ex_group_id";
         $fwd_value = $_new_group->_id;
         // class_fields
         foreach ($_group->loadRefsFields() as $_field) {
             $_exclude_fields = array("predicate_id", "subgroup_id");
             if ($msg = $this->duplicateObject($_field, "ex_group_id", $_new_group->_id, $_new_field, $_exclude_fields)) {
                 continue;
             }
             $_fwd_field = "ex_class_field_id";
             $_fwd_value = $_new_field->_id;
             // field_translations
             $this->duplicateBackRefs($_field, "field_translations", $_fwd_field, $_fwd_value);
             // list_items
             $this->duplicateBackRefs($_field, "list_items", "field_id", $_fwd_value);
             // ex_triggers
             $this->duplicateBackRefs($_field, "ex_triggers", $_fwd_field, $_fwd_value);
             // predicates
             //$this->duplicateBackRefs($_field, "predicates", $_fwd_field, $_fwd_value);
         }
         // host_fields
         $this->duplicateBackRefs($_group, "host_fields", $fwd_field, $fwd_value);
         // class_messages
         $this->duplicateBackRefs($_group, "class_messages", $fwd_field, $fwd_value, array("predicate_id", "subgroup_id"));
         // subgroups
         $this->duplicateBackRefs($_group, "subgroups", "parent_id", $fwd_value, array("predicate_id", "subgroup_id"));
     }
     // ex_triggers
     $this->duplicateBackRefs($this, "ex_triggers", "ex_class_triggered_id", $new->_id);
     CExObject::clearLocales();
     $this->_duplication_mapping = array();
     return null;
 }
if ($event_name) {
    $ex_class_event->event_name = $event_name;
}
$ex_class_event->ex_class_id = $ex_class_id;
$ex_class_event->loadMatchingObject();
/** @var CExObject $ex_object */
if (!$ex_object_id) {
    $ex_class = new CExClass();
    $ex_class->load($ex_class_id);
    $ex_objects = $ex_class_event->getExObjectForHostObject($object);
    $ex_object = reset($ex_objects);
    if (!$ex_object) {
        $ex_object = $ex_class->getExObjectInstance();
    }
} else {
    $ex_object = new CExObject($ex_class_id);
}
if ($preview) {
    $ex_object->_preview = true;
}
$creation_date = $ex_object->getCreateDate();
if ($object->_id && $object instanceof CSejour) {
    $object->loadRefCurrAffectation($creation_date);
}
$printer_id = null;
$printers = CMediusers::get()->loadRefFunction()->loadBackRefs("printers");
if (count($printers)) {
    $printer = reset($printers);
    $printer_id = $printer->_id;
}
$ex_object->_event_name = $event_name;
 /**
  * @see parent::store()
  */
 function store()
 {
     CExObject::$_locales_cache_enabled = false;
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($this->_compute_view) {
         $this->loadView();
     }
     return null;
 }
Beispiel #11
0
 function fillLimitedTemplate(&$template)
 {
     CDestinataire::makeAllFor($this);
     $destinataires = CDestinataire::$destByClass;
     foreach ($destinataires as $_destinataires_by_class) {
         foreach ($_destinataires_by_class as $_destinataire) {
             if (!isset($_destinataire->nom) || strlen($_destinataire->nom) == 0 || $_destinataire->nom === " ") {
                 continue;
             }
             $template->destinataires[] = array("nom" => $_destinataire->nom, "email" => $_destinataire->email, "tag" => $_destinataire->tag);
         }
     }
     $this->loadRefsFwd();
     $this->loadRefLatestConstantes(null, array(), null, false);
     $this->loadIPP();
     $this->loadLastINS();
     $this->notify("BeforeFillLimitedTemplate", $template);
     $template->addProperty("Patient - article", $this->_civilite);
     $template->addProperty("Patient - article long", ucfirst($this->_civilite_long));
     $template->addProperty("Patient - article long (minuscule)", strtolower($this->_civilite_long));
     $template->addProperty("Patient - nom", $this->nom);
     $template->addProperty("Patient - nom jeune fille", $this->nom_jeune_fille);
     $template->addProperty("Patient - prénom", $this->prenom);
     $template->addProperty("Patient - adresse", $this->adresse);
     $template->addProperty("Patient - ville", $this->ville);
     $template->addProperty("Patient - cp", $this->cp);
     $template->addProperty("Patient - années", $this->_annees);
     $template->addProperty("Patient - âge", $this->_age);
     $template->addProperty("Patient - date de naissance", $this->getFormattedValue("naissance"));
     $template->addProperty("Patient - lieu de naissance", $this->lieu_naissance);
     $template->addProperty("Patient - sexe", strtolower($this->getFormattedValue("sexe")));
     $template->addProperty("Patient - sexe court", substr(strtolower($this->getFormattedValue("sexe")), 0, 1));
     $template->addProperty("Patient - numéro d'assuré", $this->getFormattedValue("matricule"));
     $template->addProperty("Patient - téléphone", $this->getFormattedValue("tel"));
     $template->addProperty("Patient - mobile", $this->getFormattedValue("tel2"));
     $template->addProperty("Patient - téléphone autre", $this->tel_autre);
     $template->addProperty("Patient - profession", $this->profession);
     $template->addProperty("Patient - IPP", $this->_IPP);
     $template->addProperty("Patient - Qualité bénéficiaire", $this->qual_beneficiaire);
     $this->guessExoneration();
     $template->addProperty("Patient - Qualité bénéficiaire - Libellé", $this->libelle_exo);
     $template->addProperty("Patient - Numéro de sécurité sociale", $this->getFormattedValue("matricule"));
     $template->addBarcode("Patient - Code barre ID", $this->_id);
     $template->addBarcode("Patient - Code barre IPP", $this->_IPP);
     $template->addBarcode("Patient - Code barre INS", $this->_ref_last_ins ? $this->_ref_last_ins->ins : "");
     if ($this->sexe === "m") {
         $template->addProperty("Patient - il/elle", "il");
         $template->addProperty("Patient - Il/Elle (majuscule)", "Il");
         $template->addProperty("Patient - le/la", "le");
         $template->addProperty("Patient - Le/La (majuscule)", "Le");
         $template->addProperty("Patient - du/de la", "du");
         $template->addProperty("Patient - au/à la", "au");
         $template->addProperty("Patient - accord genre", "");
     } else {
         $template->addProperty("Patient - il/elle", "elle");
         $template->addProperty("Patient - Il/Elle (majuscule)", "Elle");
         $template->addProperty("Patient - le/la", "la");
         $template->addProperty("Patient - Le/La (majuscule)", "La");
         $template->addProperty("Patient - du/de la", "de la");
         $template->addProperty("Patient - au/à la", "à la");
         $template->addProperty("Patient - accord genre", "e");
     }
     $medecin = $this->_ref_medecin_traitant->_id ? $this->_ref_medecin_traitant : new CMedecin();
     $template->addProperty("Patient - médecin traitant", "{$medecin->nom} {$medecin->prenom}");
     $template->addProperty("Patient - médecin traitant - Nom Prénom", "{$medecin->nom} {$medecin->prenom}");
     $template->addProperty("Patient - médecin traitant - nom", $medecin->nom);
     $template->addProperty("Patient - médecin traitant - prenom", $medecin->prenom);
     $template->addProperty("Patient - médecin traitant - adresse", "{$medecin->adresse} \n {$medecin->cp} {$medecin->ville}");
     $template->addProperty("Patient - médecin traitant - voie", $medecin->adresse);
     $template->addProperty("Patient - médecin traitant - cp", $medecin->cp);
     $template->addProperty("Patient - médecin traitant - ville", $medecin->ville);
     $template->addProperty("Patient - médecin traitant - confraternité", $medecin->_confraternite);
     $template->addProperty("Patient - médecin traitant - tel", $medecin->getFormattedValue("tel"));
     $template->addProperty("Patient - médecin traitant - fax", $medecin->getFormattedValue("fax"));
     if ($medecin->sexe == "f") {
         $template->addProperty("Patient - médecin traitant - accord genre", "e");
         $template->addProperty("Patient - médecin traitant - article long", "Mme le docteur");
     } elseif ($medecin->sexe == "m") {
         $template->addProperty("Patient - médecin traitant - accord genre", "");
         $template->addProperty("Patient - médecin traitant - article long", "Mr le docteur");
     } else {
         $template->addProperty("Patient - médecin traitant - accord genre", "");
         $template->addProperty("Patient - médecin traitant - article long", "le docteur");
     }
     // Employeur
     $this->loadRefsCorrespondantsPatient();
     $correspondants = $this->_ref_cp_by_relation;
     foreach ($correspondants as $relation => $_correspondants) {
         $_correspondant = @reset($_correspondants);
         // Dans le cas d'un modèle, création d'un correspondant pour chaque type de relation
         if (!count($_correspondants)) {
             $_correspondant = new CCorrespondantPatient();
             $_correspondant->relation = $relation;
         }
         switch ($_correspondant->relation) {
             case "employeur":
                 $template->addProperty("Patient - employeur - nom", $_correspondant->nom);
                 $template->addProperty("Patient - employeur - adresse", $_correspondant->adresse);
                 $template->addProperty("Patient - employeur - cp", $_correspondant->cp);
                 $template->addProperty("Patient - employeur - ville", $_correspondant->ville);
                 $template->addProperty("Patient - employeur - tel", $_correspondant->getFormattedValue("tel"));
                 $template->addProperty("Patient - employeur - mobile", $_correspondant->getFormattedValue("mob"));
                 $template->addProperty("Patient - employeur - urssaf", $_correspondant->urssaf);
                 break;
             case "prevenir":
                 $template->addProperty("Patient - prévenir - nom", $_correspondant->nom);
                 $template->addProperty("Patient - prévenir - prénom", $_correspondant->prenom);
                 $template->addProperty("Patient - prévenir - adresse", $_correspondant->adresse);
                 $template->addProperty("Patient - prévenir - cp", $_correspondant->cp);
                 $template->addProperty("Patient - prévenir - ville", $_correspondant->ville);
                 $template->addProperty("Patient - prévenir - tel", $_correspondant->getFormattedValue("tel"));
                 $template->addProperty("Patient - prévenir - mobile", $_correspondant->getFormattedValue("mob"));
                 $template->addProperty("Patient - prévenir - parente", $_correspondant->parente);
                 break;
             case "confiance":
                 $template->addProperty("Patient - confiance - nom", $_correspondant->nom);
                 $template->addProperty("Patient - confiance - nom de jeune fille", $_correspondant->nom_jeune_fille);
                 $template->addProperty("Patient - confiance - prénom", $_correspondant->prenom);
                 $template->addProperty("Patient - confiance - date de naissance", $_correspondant->getFormattedValue("naissance"));
                 $template->addProperty("Patient - confiance - adresse", $_correspondant->adresse);
                 $template->addProperty("Patient - confiance - cp", $_correspondant->cp);
                 $template->addProperty("Patient - confiance - ville", $_correspondant->ville);
                 $template->addProperty("Patient - confiance - tel", $_correspondant->getFormattedValue("tel"));
                 $template->addProperty("Patient - confiance - mobile", $_correspondant->getFormattedValue("mob"));
                 $template->addProperty("Patient - confiance - parente", $_correspondant->parente);
         }
     }
     // Vider les anciens holders
     for ($i = 1; $i < 4; $i++) {
         $template->addProperty("Patient - médecin correspondant {$i}");
         $template->addProperty("Patient - médecin correspondant {$i} - adresse");
         $template->addProperty("Patient - médecin correspondant {$i} - spécialité");
     }
     $this->loadRefsCorrespondants();
     $i = 0;
     $noms = array();
     foreach ($this->_ref_medecins_correspondants as $corresp) {
         $i++;
         $corresp->loadRefsFwd();
         $medecin = $corresp->_ref_medecin;
         $nom = "{$medecin->nom} {$medecin->prenom}";
         $noms[] = $nom;
         $template->addProperty("Patient - médecin correspondant {$i}", $nom);
         $template->addProperty("Patient - médecin correspondant {$i} - adresse", "{$medecin->adresse}\n{$medecin->cp} {$medecin->ville}");
         $template->addProperty("Patient - médecin correspondant {$i} - spécialité", CMbString::htmlEntities($medecin->disciplines));
     }
     $template->addProperty("Patient - médecins correspondants", implode(" - ", $noms));
     //Liste des séjours du patient
     $this->loadRefsSejours();
     if (is_array($this->_ref_sejours)) {
         foreach ($this->_ref_sejours as $_sejour) {
             $_sejour->loadRefPraticien();
         }
         $smarty = new CSmartyDP("modules/dPpatients");
         $smarty->assign("sejours", $this->_ref_sejours);
         $sejours = $smarty->fetch("print_closed_sejours.tpl", '', '', 0);
         $sejours = preg_replace('`([\\n\\r])`', '', $sejours);
     } else {
         $sejours = CAppUI::tr("CSejour.none");
     }
     $template->addProperty("Patient - liste des séjours", $sejours, '', false);
     $const_med = $this->_ref_constantes_medicales;
     $const_dates = $this->_latest_constantes_dates;
     $grid_complet = CConstantesMedicales::buildGridLatest($const_med, $const_dates, true);
     $grid_minimal = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false);
     $grid_valued = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false, true);
     $smarty = new CSmartyDP("modules/dPpatients");
     // Horizontal
     $smarty->assign("constantes_medicales_grid", $grid_complet);
     $constantes_complet_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_complet_horiz = preg_replace('`([\\n\\r])`', '', $constantes_complet_horiz);
     $smarty->assign("constantes_medicales_grid", $grid_minimal);
     $constantes_minimal_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_minimal_horiz = preg_replace('`([\\n\\r])`', '', $constantes_minimal_horiz);
     $smarty->assign("constantes_medicales_grid", $grid_valued);
     $constantes_valued_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0);
     $constantes_valued_horiz = preg_replace('`([\\n\\r])`', '', $constantes_valued_horiz);
     // Vertical
     $smarty->assign("constantes_medicales_grid", $grid_complet);
     $constantes_complet_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_complet_vert = preg_replace('`([\\n\\r])`', '', $constantes_complet_vert);
     $smarty->assign("constantes_medicales_grid", $grid_minimal);
     $constantes_minimal_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_minimal_vert = preg_replace('`([\\n\\r])`', '', $constantes_minimal_vert);
     $smarty->assign("constantes_medicales_grid", $grid_valued);
     $constantes_valued_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0);
     $constantes_valued_vert = preg_replace('`([\\n\\r])`', '', $constantes_valued_vert);
     // Liste des fichiers
     $this->loadRefsFiles();
     $list = CMbArray::pluck($this->_ref_files, "file_name");
     $template->addListProperty("Patient - Liste des fichiers", $list);
     // Identité
     $identite = $this->loadNamedFile("identite.jpg");
     $template->addImageProperty("Patient - Photo d'identite", $identite->_id);
     $template->addProperty("Patient - Constantes - mode complet horizontal", $constantes_complet_horiz, '', false);
     $template->addProperty("Patient - Constantes - mode minimal horizontal", $constantes_minimal_horiz, '', false);
     $template->addProperty("Patient - Constantes - mode avec valeurs horizontal", $constantes_valued_horiz, '', false);
     $template->addProperty("Patient - Constantes - mode complet vertical", $constantes_complet_vert, '', false);
     $template->addProperty("Patient - Constantes - mode minimal vertical", $constantes_minimal_vert, '', false);
     $template->addProperty("Patient - Constantes - mode avec valeurs vertical", $constantes_valued_vert, '', false);
     $template->addProperty("Patient - poids", "{$const_med->poids} kg");
     $template->addProperty("Patient - taille", "{$const_med->taille} cm");
     $template->addProperty("Patient - Pouls", $const_med->pouls);
     $template->addProperty("Patient - IMC", $const_med->_imc);
     $template->addProperty("Patient - VST", $const_med->_vst);
     $template->addProperty("Patient - température", $const_med->temperature . "°");
     $template->addProperty("Patient - TA", $const_med->ta ? "{$const_med->_ta_systole} / {$const_med->_ta_diastole}" : "");
     $template->addProperty("Patient - Saturation (spo2)", $const_med->spo2);
     // Assuré social
     $template->addProperty("Patient - Assuré social - nom", $this->assure_nom);
     $template->addProperty("Patient - Assuré social - nom jeune fille", $this->assure_nom_jeune_fille);
     $template->addProperty("Patient - Assuré social - prénom", $this->assure_prenom);
     $template->addProperty("Patient - Assuré social - date de naissance", $this->getFormattedValue("assure_naissance"));
     $template->addProperty("Patient - Assuré social - article", $this->_assure_civilite);
     $template->addProperty("Patient - Assuré social - article long", $this->_assure_civilite_long);
     $template->addProperty("Patient - Assuré social - adresse", $this->assure_adresse);
     $template->addProperty("Patient - Assuré social - ville", $this->assure_ville);
     $template->addProperty("Patient - Assuré social - cp", $this->assure_cp);
     $template->addProperty("Patient - Assuré social - pays", $this->assure_pays);
     $template->addProperty("Patient - Assuré social - téléphone", $this->assure_tel);
     $template->addProperty("Patient - Assuré social - mobile", $this->assure_tel2);
     $template->addProperty("Patient - Assuré social - cp naissance", $this->assure_cp_naissance);
     $template->addProperty("Patient - Assuré social - lieu de naissance", $this->assure_lieu_naissance);
     $template->addProperty("Patient - Assuré social - profession", $this->assure_profession);
     // Bénéficiaire de soins
     $template->addProperty("Patient - Bénéficiaire de soin - code régime", $this->code_regime);
     $template->addProperty("Patient - Bénéficiaire de soin - caisse gest", $this->caisse_gest);
     $template->addProperty("Patient - Bénéficiaire de soin - centre gest", $this->centre_gest);
     $template->addProperty("Patient - Bénéficiaire de soin - code gest", $this->code_gestion);
     $template->addProperty("Patient - Bénéficiaire de soin - régime santé", $this->regime_sante);
     $template->addDateProperty("Patient - Bénéficiaire de soin - début période", $this->deb_amo);
     $template->addDateProperty("Patient - Bénéficiaire de soin - fin période", $this->fin_amo);
     $template->addProperty("Patient - Bénéficiaire de soin - régime am", $this->getFormattedValue("regime_am"));
     $template->addProperty("Patient - Bénéficiaire de soin - ald", $this->getFormattedValue("ald"));
     $template->addProperty("Patient - Bénéficiaire de soin - incapable majeur", $this->getFormattedValue("incapable_majeur"));
     $template->addProperty("Patient - Bénéficiaire de soin - cmu", $this->getFormattedValue("cmu"));
     $template->addProperty("Patient - Bénéficiaire de soin - ATNC", $this->getFormattedValue("ATNC"));
     $template->addDateProperty("Patient - Bénéficiaire de soin - validité vitale", $this->fin_validite_vitale);
     $template->addProperty("Patient - Bénéficiaire de soin - médecin traitant déclaré", $this->getFormattedValue("medecin_traitant_declare"));
     $template->addProperty("Patient - Bénéficiaire de soin - types contrat mutuelle", addslashes($this->mutuelle_types_contrat));
     $template->addProperty("Patient - Bénéficiaire de soin - notes amo", addslashes($this->notes_amo));
     $template->addProperty("Patient - Bénéficiaire de soin - libellé exo", addslashes($this->libelle_exo));
     $template->addProperty("Patient - Bénéficiaire de soin - notes amc", addslashes($this->notes_amc));
     if (CModule::getActive("maternite")) {
         $allaitement = $this->loadLastAllaitement();
         $template->addDateProperty("Patient - Allaitement - Début", $allaitement->date_debut);
         $template->addDateProperty("Patient - Allaitement - Fin", $allaitement->date_fin);
         $grossesse = $this->loadLastGrossesse();
         $template->addDateProperty("Patient - Grossesse - Terme prévu", $grossesse->terme_prevu);
         $template->addDateProperty("Patient - Grossesse - Date des dernières règles", $grossesse->date_dernieres_regles);
         $template->addProperty("Patient - Grossesse - En cours", $grossesse->getFormattedValue("active"));
         $template->addProperty("Patient - Grossesse - Multiple", $grossesse->getFormattedValue("multiple"));
         $template->addProperty("Patient - Grossesse - Allaitement maternel", $grossesse->getFormattedValue("allaitement_maternel"));
         $template->addProperty("Patient - Grossesse - Fausse couche", $grossesse->getFormattedValue('fausse_couche'), null, false);
         $template->addProperty("Patient - Grossesse - Lieu d'accouchement", $grossesse->getFormattedValue("lieu_accouchement"));
         $template->addProperty("Patient - Grossesse - Remarques", $grossesse->rques);
     }
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "Patient");
     }
     $this->notify("AfterFillLimitedTemplate", $template);
 }
 } elseif ($_trans_const instanceof CConsultation) {
     // On n'affiche pas les consultations annulées
     if ($_trans_const->annule) {
         unset($sejour->_ref_suivi_medical[$_key]);
         continue;
     }
     if ($forms_active) {
         foreach ($_trans_const->_refs_dossiers_anesth as $key => $_dossier_anesth) {
             $_dossier_anesth->loadRefOperation();
         }
         if ($_trans_const->type == "entree") {
             $has_obs_entree = 1;
         }
         $forms = CExObject::loadExObjectsFor($_trans_const);
         foreach ($_trans_const->_refs_dossiers_anesth as $_dossier_anesth) {
             $_forms = CExObject::loadExObjectsFor($_dossier_anesth);
             $forms += $_forms;
         }
         $_trans_const->_list_forms = $forms;
     }
     $list_trans_const[$_trans_const->_datetime] = $_trans_const;
 } elseif ($_trans_const instanceof CPrescriptionLineElement || $_trans_const instanceof CPrescriptionLineComment) {
     $list_trans_const["{$_trans_const->debut} {$_trans_const->time_debut}"] = $_trans_const;
     $_trans_const->loadRefPraticien();
     continue;
 } elseif (is_array($_trans_const)) {
     $list_trans_const[$_key] = $_trans_const;
 } elseif ($_trans_const instanceof CObservationMedicale) {
     $sort_key = "{$_trans_const->date} {$_trans_const->_guid}";
     $list_trans_const[$sort_key] = $_trans_const;
 } else {
 /**
  * Check if we can create a new instance of the ExObject
  *
  * @param CMbObject $host Host object
  *
  * @return bool
  */
 function canCreateNew(CMbObject $host)
 {
     switch ($this->unicity) {
         default:
         case "no":
             return true;
         case "host":
             // Host
             $ex_object = new CExObject($this->_id);
             $ex_object->setObject($host);
             if ($ex_object->countMatchingList() > 0) {
                 return false;
             }
             /*
                     // Reférence 1
                     $ex_object = new CExObject($this->_id);
                     $ex_object->setReferenceObject_1($host);
                     
                     if ($ex_object->countMatchingList() > 0) {
                       return false;
                     }
                     
                     // Référence 2
                     $ex_object = new CExObject($this->_id);
                     $ex_object->setReferenceObject_2($host);
                     
                     if ($ex_object->countMatchingList() > 0) {
                       return false;
                     }*/
     }
     return true;
 }
 /**
  * Mass loading of CExObjects
  *
  * @param self[] $list List of ExLinks
  *
  * @return void
  */
 static function massLoadExObjects(array $list)
 {
     $ex_object_id_by_ex_class = array();
     $ex_links_by_ex_class = array();
     foreach ($list as $_link) {
         $_ex_class_id = $_link->ex_class_id;
         $ex_object_id_by_ex_class[$_ex_class_id][] = $_link->ex_object_id;
         $ex_links_by_ex_class[$_ex_class_id][] = $_link;
     }
     foreach ($ex_object_id_by_ex_class as $_ex_class_id => $_ex_object_ids) {
         $_ex_object = new CExObject($_ex_class_id);
         $where = array("ex_object_id" => $_ex_object->getDS()->prepareIn($_ex_object_ids));
         $_ex_objects = $_ex_object->loadList($where);
         /** @var CExLink $_link */
         foreach ($ex_links_by_ex_class[$_ex_class_id] as $_link) {
             $_link->_ref_ex_object = $_ex_objects[$_link->ex_object_id];
         }
     }
 }
 /**
  * @see parent::store()
  */
 function store()
 {
     if ($msg = parent::store()) {
         return $msg;
     }
     CExObject::clearLocales();
     return null;
 }
Beispiel #16
0
<?php

/**
 * $Id: view_ex_object.php 26472 2014-12-17 14:30:07Z armengaudmc $
 *
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 26472 $
 */
CCanDo::checkRead();
$ex_class_id = CValue::get("ex_class_id");
$ex_object_id = CValue::get("ex_object_id");
if (!$ex_class_id) {
    $msg = "Impossible d'afficher le formulaire sans connaître la classe de base";
    CAppUI::stepAjax($msg, UI_MSG_WARNING);
    trigger_error($msg, E_USER_ERROR);
    return;
}
$ex_object = new CExObject($ex_class_id);
$ex_object->load($ex_object_id);
// Création du template
$smarty = new CSmartyDP("modules/forms");
$smarty->assign("ex_object", $ex_object);
$smarty->display("view_ex_object.tpl");
<?php

/**
 * $Id$
 *  
 * @category CCAM
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$count = CExObject::clearLocales();
CAppUI::stepAjax("module-forms-msg-cache-ex_class-suppr", UI_MSG_OK, $count);
 /**
  * @param CMbObject $object
  *
  * @return CExObject[][]
  */
 static function getExObjectsOf(CMbObject $object)
 {
     CExClassField::$_load_lite = true;
     CExObject::$_multiple_load = true;
     $group_id = CGroups::loadCurrent()->_id;
     $where = array("group_id = '{$group_id}' OR group_id IS NULL");
     if (empty(CExClass::$_list_cache)) {
         $ex_class = new CExClass();
         CExClass::$_list_cache = $ex_class->loadList($where, "name");
         if (!CExObject::$_locales_cache_enabled) {
             foreach (CExClass::$_list_cache as $_ex_class) {
                 foreach ($_ex_class->loadRefsGroups() as $_group) {
                     $_group->loadRefsFields();
                     foreach ($_group->_ref_fields as $_field) {
                         $_field->updateTranslation();
                     }
                 }
             }
         }
     }
     $ex_objects = array();
     $limit = 1;
     $ref_objects_cache = array();
     foreach (CExClass::$_list_cache as $_ex_class_id => $_ex_class) {
         $_ex_object = new CExObject($_ex_class_id);
         $where = array("(reference_class  = '{$object->_class}' AND reference_id  = '{$object->_id}') OR\n         (reference2_class = '{$object->_class}' AND reference2_id = '{$object->_id}') OR\n         (object_class     = '{$object->_class}' AND object_id     = '{$object->_id}')");
         $ljoin = array();
         /** @var CExObject[] $_ex_objects */
         $_ex_objects = $_ex_object->loadList($where, "{$_ex_object->_spec->key} DESC", $limit, null, $ljoin);
         foreach ($_ex_objects as $_ex) {
             $_ex->_ex_class_id = $_ex_class_id;
             $_ex->load();
             $guid = "{$_ex->object_class}-{$_ex->object_id}";
             if (!isset($ref_objects_cache[$guid])) {
                 $_ex->loadTargetObject()->loadComplete();
                 // to get the view
                 $ref_objects_cache[$guid] = $_ex->_ref_object;
             } else {
                 $_ex->_ref_object = $ref_objects_cache[$guid];
             }
             if ($_ex->additional_id) {
                 $_ex->loadRefAdditionalObject();
             }
             $ex_objects[$_ex_class_id][$_ex->_id] = $_ex;
         }
         if (isset($ex_objects[$_ex_class_id])) {
             krsort($ex_objects[$_ex_class_id]);
         }
     }
     ksort($ex_objects);
     return $ex_objects;
 }
 *
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 25935 $
 */
CCanDo::checkRead();
$date_min = CValue::getOrSession("date_min");
$date_max = CValue::getOrSession("date_max");
$group_id = CValue::getOrSession("group_id");
$concept_search = CValue::get("concept_search");
// concept values
CExClassField::$_load_lite = true;
CExObject::$_multiple_load = true;
CExObject::$_load_lite = true;
$ex_class = new CExClass();
$where = array("ex_link.group_id" => " = '{$group_id}'");
$ljoin = array();
$search = null;
if ($concept_search) {
    $concept_search = stripslashes($concept_search);
    $search = CExConcept::parseSearch($concept_search);
}
$ex_link = new CExLink();
$use_user_logs = $date_min < CExObject::DATE_LIMIT;
if ($use_user_logs) {
    $where["user_log.date"] = "BETWEEN '{$date_min} 00:00:00' AND '{$date_max} 23:59:59'";
    $where["user_log.type"] = "= 'create'";
    $where["user_log.object_class"] = "LIKE 'CExObject%'";
    $ljoin["user_log"] = "user_log.object_id = ex_link.ex_object_id AND user_log.object_class = CONCAT('CExObject_',ex_link.ex_class_id)";
 /**
  * @see parent::fillLimitedTemplate()
  */
 function fillLimitedTemplate(&$template)
 {
     $chir = $this->_ref_plageconsult->_ref_chir;
     // Ajout du praticien pour les destinataires possibles (dans l'envoi d'un email)
     $template->destinataires[] = array("nom" => "Dr " . $chir->_user_last_name . " " . $chir->_user_first_name, "email" => $chir->_user_email, "tag" => "Praticien");
     $this->updateFormFields();
     $this->loadRefsFwd();
     $this->notify("BeforeFillLimitedTemplate", $template);
     $template->addDateProperty("Consultation - date", $this->_ref_plageconsult->date);
     $template->addLongDateProperty("Consultation - date longue", $this->_ref_plageconsult->date);
     $template->addTimeProperty("Consultation - heure", $this->heure);
     $locExamFields = array("motif" => "motif", "rques" => "remarques", "examen" => "examen", "traitement" => "traitement", "histoire_maladie" => "histoire maladie", "conclusion" => "conclusion");
     foreach ($this->_exam_fields as $field) {
         $loc_field = $locExamFields[$field];
         $template->addProperty("Consultation - {$loc_field}", $this->{$field});
     }
     if (!in_array("traitement", $this->_exam_fields)) {
         $template->addProperty("Consultation - traitement", $this->traitement);
     }
     $medecin = new CMedecin();
     $medecin->load($this->adresse_par_prat_id);
     $nom = "{$medecin->nom} {$medecin->prenom}";
     $template->addProperty("Consultation - adressé par", $nom);
     $template->addProperty("Consultation - adressé par - adresse", "{$medecin->adresse}\n{$medecin->cp} {$medecin->ville}");
     $template->addProperty("Consultation - Accident du travail", $this->getFormattedValue("date_at"));
     $libelle_at = $this->date_at ? "Accident du travail du " . $this->getFormattedValue("date_at") : "";
     $template->addProperty("Consultation - Libellé accident du travail", $libelle_at);
     $this->loadRefsFiles();
     $list = CMbArray::pluck($this->_ref_files, "file_name");
     $template->addListProperty("Consultation - Liste des fichiers", $list);
     $template->addProperty("Consultation - Fin arrêt de travail", CMbDT::dateToLocale(CMbDT::date($this->fin_at)));
     $template->addProperty("Consultation - Prise en charge arrêt de travail", $this->getFormattedValue("pec_at"));
     $template->addProperty("Consultation - Reprise de travail", CMbDT::dateToLocale(CMbDT::date($this->reprise_at)));
     $template->addProperty("Consultation - Accident de travail sans arrêt de travail", $this->getFormattedValue("at_sans_arret"));
     $template->addProperty("Consultation - Arrêt maladie", $this->getFormattedValue("arret_maladie"));
     $this->loadRefsExamsComp();
     $exam = new CExamComp();
     foreach ($exam->_specs["realisation"]->_locales as $key => $locale) {
         $exams = isset($this->_types_examen[$key]) ? $this->_types_examen[$key] : array();
         $template->addListProperty("Consultation - Examens complémentaires - {$locale}", $exams);
     }
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "Consultation");
     }
     // Séjour et/ou intervention créés depuis la consultation
     $sejour_relie = reset($this->loadBackRefs("sejours_lies"));
     $interv_reliee = reset($this->loadBackRefs("intervs_liees"));
     if ($interv_reliee) {
         $sejour_relie = $interv_reliee->loadRefSejour();
     } else {
         if (!$sejour_relie) {
             $sejour_relie = new CSejour();
         }
         if (!$interv_reliee) {
             $interv_reliee = new COperation();
         }
     }
     $interv_reliee->loadRefChir();
     $interv_reliee->loadRefPlageOp();
     $interv_reliee->loadRefSalle();
     $sejour_relie->loadRefPraticien();
     // Intervention reliée
     $template->addProperty("Consultation - Opération reliée - Chirurgien", $interv_reliee->_ref_chir->_view);
     $template->addProperty("Consultation - Opération reliée - Libellé", $interv_reliee->libelle);
     $template->addProperty("Consultation - Opération reliée - Salle", $interv_reliee->_ref_salle->nom);
     $template->addDateProperty("Consultation - Opération reliée - Date", $interv_reliee->_datetime_best);
     // Séjour relié
     $template->addDateProperty("Consultation - Séjour relié - Date entrée", $sejour_relie->entree);
     $template->addLongDateProperty("Consultation - Séjour relié - Date entrée (longue)", $sejour_relie->entree);
     $template->addTimeProperty("Consultation - Séjour relié - Heure entrée", $sejour_relie->entree);
     $template->addDateProperty("Consultation - Séjour relié - Date sortie", $sejour_relie->sortie);
     $template->addLongDateProperty("Consultation - Séjour relié - Date sortie (longue)", $sejour_relie->sortie);
     $template->addTimeProperty("Consultation - Séjour relié - Heure sortie", $sejour_relie->sortie);
     $template->addDateProperty("Consultation - Séjour relié - Date entrée réelle", $sejour_relie->entree_reelle);
     $template->addTimeProperty("Consultation - Séjour relié - Heure entrée réelle", $sejour_relie->entree_reelle);
     $template->addDateProperty("Consultation - Séjour relié - Date sortie réelle", $sejour_relie->sortie_reelle);
     $template->addTimeProperty("Consultation - Séjour relié - Heure sortie réelle", $sejour_relie->sortie_reelle);
     $template->addProperty("Consultation - Séjour relié - Praticien", "Dr " . $sejour_relie->_ref_praticien->_view);
     $template->addProperty("Consultation - Séjour relié - Libelle", $sejour_relie->getFormattedValue("libelle"));
     $this->notify("AfterFillLimitedTemplate", $template);
 }
$group_id = CValue::get("group_id");
$concept_search = CValue::get("concept_search");
CValue::setSession('reference_class', $reference_class);
CValue::setSession('reference_id', $reference_id);
if ($reference_class) {
    /** @var CMbObject $reference */
    $reference = new $reference_class();
    if ($reference_id) {
        $reference->load($reference_id);
    }
} else {
    $reference = null;
}
CExClassField::$_load_lite = true;
CExObject::$_multiple_load = true;
CExObject::$_load_lite = $detail < 2;
$group_id = $group_id ? $group_id : CGroups::loadCurrent()->_id;
$where = array("group_id = '{$group_id}' OR group_id IS NULL");
if ($ex_class_id) {
    $where['ex_class_id'] = "= '{$ex_class_id}'";
}
if (empty(CExClass::$_list_cache)) {
    $ex_class = new CExClass();
    /** @var CExClass[] $ex_classes */
    $ex_classes = $ex_class->loadList($where, "name");
    $categories = CStoredObject::massLoadFwdRef($ex_classes, "category_id");
    $categories = CStoredObject::naturalSort($categories, array("title"));
    $categories = array(new CExClassCategory()) + $categories;
    foreach ($ex_classes as $_ex_class) {
        $_category_id = $_ex_class->category_id ?: 0;
        $categories[$_category_id]->_ref_ex_classes[$_ex_class->_id] = $_ex_class;
 /**
  * Make an instance of a ModelObject
  *
  * @param string $class Object class to get an instance of
  *
  * @return null|self
  */
 static function getInstance($class)
 {
     $object = CExObject::getValidObject($class);
     if (!$object) {
         // Non existing class
         if (!self::classExists($class)) {
             return null;
         }
         return new $class();
     }
     return $object;
 }
 /**
  * Get the host object of $this
  *
  * @param CExObject $ex_object The ExObject to get the host object of
  *
  * @return CMbObject|null
  */
 function getHostObject(CExObject $ex_object)
 {
     // Load the list of objects
     /** @var CMbObject[] $objects */
     $objects = array();
     // Links are stored
     if ($ex_object->_id) {
         $links = $ex_object->loadRefsLinks(true);
         // Direct reference
         foreach ($links as $_link) {
             $objects[] = $_link->loadTargetObject();
         }
     } else {
         $objects = array($ex_object->_ref_object, $ex_object->_ref_reference_object_1, $ex_object->_ref_reference_object_2);
     }
     // Direct reference
     foreach ($objects as $_object) {
         if ($this->host_class == $_object->_class) {
             return $this->_ref_host_object = $_object;
         }
     }
     // Indirect references
     foreach ($objects as $_object) {
         $_obj = $_object->getRelatedObjectOfClass($this->host_class);
         if ($_obj && $_obj->_id) {
             return $this->_ref_host_object = $_obj;
         }
     }
     return $this->_ref_host_object = new $this->host_class();
 }
Beispiel #24
0
 /**
  * @see parent::fillLimitedTemplate()
  */
 function fillLimitedTemplate(&$template)
 {
     // Ajout du praticien pour les destinataires possibles (dans l'envoi d'un email)
     $chir = $this->loadRefPraticien();
     $template->destinataires[] = array("nom" => "Dr " . $chir->_user_last_name . " " . $chir->_user_first_name, "email" => $chir->_user_email, "tag" => "Praticien");
     $this->notify("BeforeFillLimitedTemplate", $template);
     $this->loadRefsOperations();
     $template->addLongDateProperty("Admission - Date longue", $this->entree_prevue);
     $template->addDateProperty("Admission - Date", $this->entree_prevue);
     $template->addTimeProperty("Admission - Heure", $this->entree_prevue);
     $template->addProperty("Admission - Type", $this->getFormattedValue("type"));
     $template->addProperty("Hospitalisation - Durée", $this->_duree_prevue);
     $template->addDateProperty("Hospitalisation - Date sortie", $this->sortie_prevue);
     $template->addProperty("Hospitalisation - Date sortie longue", $this->getFormattedValue("sortie_prevue"));
     $this->loadNDA();
     $template->addProperty("Sejour - Numéro de dossier", $this->_NDA);
     $template->addProperty("Sejour - Concerné par l'ALD", $this->getFormattedValue("ald"));
     $template->addBarcode("Sejour - Code barre ID", $this->_id);
     $template->addBarcode("Sejour - Code barre NDOS", $this->_NDA);
     $template->addDateProperty("Sejour - Date entrée", $this->entree);
     $template->addLongDateProperty("Sejour - Date entrée (longue)", $this->entree);
     $template->addTimeProperty("Sejour - Heure entrée", $this->entree);
     $template->addDateProperty("Sejour - Date sortie", $this->sortie);
     $template->addLongDateProperty("Sejour - Date sortie (longue)", $this->sortie);
     $template->addTimeProperty("Sejour - Heure sortie", $this->sortie);
     $template->addDateProperty("Sejour - Date entrée réelle", $this->entree_reelle);
     $template->addTimeProperty("Sejour - Heure entrée réelle", $this->entree_reelle);
     $template->addDateProperty("Sejour - Date sortie réelle", $this->sortie_reelle);
     $template->addTimeProperty("Sejour - Heure sortie réelle", $this->sortie_reelle);
     $template->addProperty("Sejour - Mode d'entrée", $this->getFormattedValue("mode_entree"));
     $template->addProperty("Sejour - Mode de sortie", $this->getFormattedValue("mode_sortie"));
     $template->addProperty("Sejour - Service de sortie", $this->getFormattedValue("service_sortie_id"));
     $template->addProperty("Sejour - Etablissement de sortie", $this->getFormattedValue("etablissement_sortie_id"));
     $template->addProperty("Sejour - Commentaires de sortie", $this->getFormattedValue("commentaires_sortie"));
     $template->addProperty("Sejour - Libelle", $this->getFormattedValue("libelle"));
     $template->addProperty("Sejour - Transport", $this->getFormattedValue("transport"));
     /** @var CExamIgs $last_exam_igs */
     $last_exam_igs = $this->loadLastBackRef("exams_igs");
     $template->addProperty("Sejour - Score IGS", $last_exam_igs->_id ? $last_exam_igs->scoreIGS : "");
     $template->addProperty("Sejour - Score IGS Simplifié", $last_exam_igs->_id ? $last_exam_igs->simplified_igs : "");
     $consult_anesth = $this->loadRefsConsultAnesth();
     $consult = $consult_anesth->loadRefConsultation();
     $consult->loadRefPlageConsult();
     $cpa_datetime = $consult->_id ? $consult->_datetime : "";
     $template->addDateProperty("Sejour - Consultation anesthésie - Date", $cpa_datetime);
     $template->addLongDateProperty("Sejour - Consultation anesthésie - Date (longue)", $cpa_datetime);
     $template->addLongDateProperty("Sejour - Consultation anesthésie - Date (longue, minuscule)", $cpa_datetime);
     $template->addTimeProperty("Sejour - Consultation anesthésie - Heure", $cpa_datetime);
     $this->loadRefsFiles();
     $list = CMbArray::pluck($this->_ref_files, "file_name");
     $template->addListProperty("Sejour - Liste des fichiers", $list);
     if (CAppUI::conf("dPurgences old_rpu") == "1") {
         if (CModule::getActive("sherpa")) {
             $rpu = $this->loadRefRPU();
             $template->addProperty("Sejour - Provenance", $rpu->_id ? $rpu->getFormattedValue("urprov") : "");
         }
     } else {
         $template->addProperty("Sejour - Provenance", $this->getFormattedValue("provenance"));
         $template->addProperty("Sejour - Destination", $this->getFormattedValue("destination"));
     }
     $this->loadRefPraticien();
     $template->addProperty("Hospitalisation - Praticien", "Dr " . $this->_ref_praticien->_view);
     $this->loadRefsAffectations();
     $this->_ref_last_affectation->loadView();
     $last_affectation = $this->_ref_last_affectation;
     $template->addProperty("Hospitalisation - Dernière affectation", $last_affectation->_view);
     $template->addProperty("Hospitalisation - Dernière affectation (Service)", $last_affectation->loadRefService()->_view);
     $template->addProperty("Hospitalisation - Dernière affectation (Secteur)", $last_affectation->_ref_service->loadRefSecteur()->nom);
     $affectations = array();
     if (count($this->_ref_affectations)) {
         foreach ($this->_ref_affectations as $_aff) {
             $affectations[] = "{$_aff->_view} du " . CMbDT::format($_aff->entree, CAppUI::conf("datetime")) . " au " . CMbDT::format($_aff->sortie, CAppUI::conf("datetime"));
         }
     }
     $template->addListProperty("Sejour - Affectations", $affectations);
     // Diagnostics
     $this->loadExtDiagnostics();
     $diag = $this->DP ? "{$this->DP}: {$this->_ext_diagnostic_principal->libelle}" : null;
     $template->addProperty("Sejour - Diagnostic Principal", $diag);
     $diag = $this->DR ? "{$this->DR}: {$this->_ext_diagnostic_relie->libelle}" : null;
     $template->addProperty("Sejour - Diagnostic Relié", $diag);
     $template->addProperty("Sejour - Remarques", $this->rques);
     // Chargement du suivi medical (transmissions, observations, prescriptions)
     $this->loadSuiviMedical();
     // Transmissions
     $transmissions = array();
     if (isset($this->_back["transmissions"])) {
         foreach ($this->_back["transmissions"] as $_trans) {
             $datetime = CMbDT::format($_trans->date, CAppUI::conf('datetime'));
             $transmissions["{$_trans->date} {$_trans->_guid}"] = "{$_trans->text}, le {$datetime}, {$_trans->_ref_user->_view}";
         }
     }
     $template->addListProperty("Sejour - Transmissions", $transmissions);
     $this->loadRefsTransmissions(false, true, false);
     $transmissions_hautes = array();
     foreach ($this->_ref_transmissions as $_trans) {
         $_trans->loadRefUser();
         $datetime = CMbDT::format($_trans->date, CAppUI::conf('datetime'));
         $transmissions_hautes["{$_trans->date} {$_trans->_guid}"] = "{$_trans->text}, le {$datetime}, {$_trans->_ref_user->_view}";
     }
     $template->addListProperty("Sejour - Transmissions - importance haute", $transmissions_hautes);
     $this->loadRefsTransmissions(true, false, true);
     $transmissions_macro = array();
     foreach ($this->_ref_transmissions as $_trans) {
         $_trans->loadRefUser();
         $datetime = CMbDT::format($_trans->date, CAppUI::conf('datetime'));
         $transmissions_macro["{$_trans->date} {$_trans->_guid}"] = "{$_trans->text}, le {$datetime}, {$_trans->_ref_user->_view}";
     }
     $template->addListProperty("Sejour - Transmissions - macrocible", $transmissions_macro);
     // Observations
     $observations = array();
     if (isset($this->_back["observations"])) {
         foreach ($this->_back["observations"] as $_obs) {
             $datetime = CMbDT::format($_obs->date, CAppUI::conf('datetime'));
             $observations["{$_obs->date} {$_obs->_guid}"] = "{$_obs->text}, le {$datetime}, {$_obs->_ref_user->_view}";
         }
         ksort($observations);
     }
     $template->addListProperty("Sejour - Observations", $observations);
     // Observation d'entrée
     /** @var CConsultation $obs_entree */
     $obs_entree = $this->loadRefObsEntree();
     $template->addProperty("Sejour - Observation entrée - Motif", $obs_entree->getFormattedValue("motif"));
     $template->addProperty("Sejour - Observation entrée - Examen clinique", $obs_entree->getFormattedValue("examen"));
     $template->addProperty("Sejour - Observation entrée - Remarques", $obs_entree->getFormattedValue("rques"));
     $template->addProperty("Sejour - Observation entrée - Traitements", $obs_entree->getFormattedValue("traitement"));
     $template->addProperty("Sejour - Observation entrée - Histoire de la maladie", $obs_entree->getFormattedValue("histoire_maladie"));
     $template->addProperty("Sejour - Observation entrée - Au total", $obs_entree->getFormattedValue("conclusion"));
     // Prescriptions
     $lines = array();
     if (CModule::getActive('dPprescription')) {
         $prescription = $this->loadRefPrescriptionSejour();
         $prescription->loadRefsLinesAllComments();
         $prescription->loadRefsLinesElement();
         if (isset($prescription->_ref_prescription_lines_all_comments)) {
             foreach ($prescription->_ref_prescription_lines_all_comments as $_comment) {
                 $datetime = CMbDT::format("{$_comment->debut} {$_comment->time_debut}", CAppUI::conf('datetime'));
                 $lines["{$_comment->debut} {$_comment->time_debut} {$_comment->_guid}"] = "{$_comment->_view}, {$datetime}, {$_comment->_ref_praticien->_view}";
             }
         }
         if (isset($prescription->_ref_prescription_lines_element)) {
             foreach ($prescription->_ref_prescription_lines_element as $_line_element) {
                 $datetime = CMbDT::format("{$_line_element->debut} {$_line_element->time_debut}", CAppUI::conf('datetime'));
                 $view = "{$_line_element->_view}";
                 if ($_line_element->commentaire) {
                     $view .= " ({$_line_element->commentaire})";
                 }
                 $view .= ", {$datetime}, " . $_line_element->_ref_praticien->_view;
                 $lines["{$_line_element->debut} {$_line_element->time_debut} {$_line_element->_guid}"] = $view;
             }
         }
         krsort($lines);
         $template->addListProperty("Sejour - Prescription light", $lines);
     }
     // Suivi médical: transmissions, observations, prescriptions
     $suivi_medical = $transmissions + $observations + $lines;
     krsort($suivi_medical);
     $template->addListProperty("Sejour - Suivi médical", $suivi_medical);
     // Interventions
     $operations = array();
     foreach ($this->_ref_operations as $_operation) {
         $_operation->loadRefPlageOp(true);
         $datetime = $_operation->getFormattedValue("_datetime");
         $chir = $_operation->loadRefChir(true);
         $operations[] = "le {$datetime}, par {$chir->_view}" . ($_operation->libelle ? " : {$_operation->libelle}" : "");
     }
     $template->addListProperty("Sejour - Intervention - Liste", $operations);
     // Dernière intervention
     $this->_ref_last_operation->fillLimitedTemplate($template);
     // Consultations
     $consults = array();
     foreach ($this->loadRefsConsultations() as $_consult) {
         $_consult->loadRefsDossiersAnesth();
         if (count($_consult->_refs_dossiers_anesth)) {
             foreach ($_consult->_refs_dossiers_anesth as $_dossier_anesth) {
                 if ($_dossier_anesth->conclusion) {
                     $consults[] = $_dossier_anesth->conclusion;
                 }
             }
         } else {
             if ($_consult->conclusion) {
                 $consults[] = $_consult->conclusion;
             }
         }
     }
     $template->addListProperty("Sejour - Conclusions des consultations", $consults);
     if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") {
         $items_liaisons = $this->loadBackRefs("items_liaisons", "date");
         CStoredObject::massLoadFwdRef($items_liaisons, "item_souhait_id");
         CStoredObject::massLoadFwdRef($items_liaisons, "sous_item_id");
         $souhaits = array();
         $ponctuelles = array();
         foreach ($items_liaisons as $_liaison) {
             $item_souhait = $_liaison->loadRefItem();
             if ($item_souhait->object_class == "CPrestationPonctuelle") {
                 $ponctuelles[] = $item_souhait->nom;
                 continue;
             }
             $sous_item = $_liaison->loadRefSousItem();
             $nom = $item_souhait;
             if ($sous_item->_id) {
                 $nom = $sous_item->nom;
             }
             $souhaits[] = $nom;
         }
         $template->addListProperty("Sejour - Prestations souhaitées", $souhaits);
         $template->addListProperty("Sejour - Prestations ponctuelles", $ponctuelles);
     }
     // Régime
     $regimes = array();
     if ($this->hormone_croissance) {
         $regimes[] = CAppUI::tr("CSejour-hormone_croissance");
     }
     if ($this->repas_sans_sel) {
         $regimes[] = CAppUI::tr("CSejour-repas_sans_sel");
     }
     if ($this->repas_sans_porc) {
         $regimes[] = CAppUI::tr("CSejour-repas_sans_porc");
     }
     if ($this->repas_diabete) {
         $regimes[] = CAppUI::tr("CSejour-repas_diabete");
     }
     if ($this->repas_sans_residu) {
         $regimes[] = CAppUI::tr("CSejour-repas_sans_residu");
     }
     if (!count($regimes)) {
         $template->addProperty("Sejour - Régime", CAppUI::tr("CSejour-no_diet_specified"));
     } else {
         $template->addListProperty("Sejour - Régime", $regimes);
     }
     if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") {
         $liaisons_j = $dates = $list_souhaits = array();
         self::getIntervallesPrestations($liaisons_j, $dates);
         foreach ($liaisons_j as $prestation_id => $_liaisons) {
             foreach ($_liaisons as $date => $_liaison) {
                 if (!$_liaison->item_souhait_id) {
                     continue;
                 }
                 $_item_souhait = $_liaison->loadRefItem();
                 $_sous_item = $_liaison->loadRefSousItem();
                 $dates_liaison = $dates[$_liaison->_id];
                 $list_souhaits[] = "Du " . CMbDT::dateToLocale($dates_liaison["debut"]) . " au " . CMbDT::dateToLocale($dates_liaison["fin"]) . " : " . ($_sous_item->_id ? $_sous_item->nom : $_item_souhait->nom);
             }
         }
         $template->addListProperty("Sejour - Prestations souhaitées", $list_souhaits);
     }
     if (CModule::getActive("forms")) {
         CExObject::addFormsToTemplate($template, $this, "Sejour");
     }
     if (CModule::getActive("dPfacturation") && CAppUI::conf("dPplanningOp CFactureEtablissement use_facture_etab")) {
         $this->loadRefsFactureEtablissement();
         $this->loadNRA();
         $this->_ref_last_facture->fillLimitedTemplate($template);
         $template->addProperty("Sejour - Nature du séjour", $this->getFormattedValue("_type_sejour"));
         $template->addProperty("Sejour - Remarques base", $this->getFormattedValue("_rques_assurance_maladie"));
         $template->addProperty("Sejour - Remarques compl.", $this->getFormattedValue("_rques_assurance_accident"));
         $template->addProperty("Sejour - Numéro de cas", $this->_ref_NRA && $this->_ref_NRA->_id ? $this->_ref_NRA->id400 : "-");
     }
     if (CModule::getActive("mvsante")) {
         CMVSante::fillLimitedTemplate($template, $this);
     }
     if (CModule::getActive("maternite")) {
         $grossesse = $this->loadRefGrossesse();
         $naissance = new CNaissance();
         $enfant = new CPatient();
         $constantes_enfant = new CConstantesMedicales();
         if ($this->grossesse_id && count($grossesse->loadRefsNaissances())) {
             /** @var CNaissance $naissance */
             $naissance = reset($grossesse->_ref_naissances);
             $enfant = $naissance->loadRefSejourEnfant()->loadRefPatient();
             $constantes_enfant = reset($enfant->loadRefLatestConstantes(null, array("poids")));
         }
         $template->addProperty("Sejour - Accouchement - Heure de naissance", $naissance->getFormattedValue("_heure"));
         $date_naiss = $naissance->date_time;
         $date_naiss_word = CMbDT::format($date_naiss, "%A") . " " . CMbString::toWords(CMbDT::format($date_naiss, "%d")) . " " . CMbDT::format($date_naiss, "%B") . " " . CMbString::toWords(CMbDT::format($date_naiss, "%Y"));
         $heure_naiss_word = CMbString::toWords(CMbDT::format($date_naiss, "%H")) . " heures " . CMbString::toWords(CMbDT::format($date_naiss, "%M")) . " minutes";
         $template->addProperty("Sejour - Accouchement - Date de naissance (lettre)", $date_naiss_word);
         $template->addProperty("Sejour - Accouchement - Heure de naissance (lettre)", $heure_naiss_word);
         $template->addProperty("Sejour - Accouchement - Sexe de l'enfant", $enfant->getFormattedValue("sexe"));
         $template->addProperty("Sejour - Accouchement - Poids (kg)", $constantes_enfant->poids . " kg");
         $template->addProperty("Sejour - Accouchement - Poids (g)", $constantes_enfant->_poids_g . " g");
         $template->addProperty("Sejour - Accouchement - Prénom de l'enfant", $enfant->prenom);
         $template->addProperty("Sejour - Accouchement - Nom de l'enfant", $enfant->nom);
     }
     $this->notify("AfterFillLimitedTemplate", $template);
 }