/** * $Id$ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $idex = new CIdSante400(); $idex->object_class = "CPatient"; $idex->tag = CAppUI::conf("dPpatients CPatient tag_conflict_ipp") . CAppUI::conf("dPpatients CPatient tag_ipp"); /** @var CIdSante400[] $ipp_conflicts */ $ipp_conflicts = $idex->loadMatchingList(); $conflicts = array(); foreach ($ipp_conflicts as $_conflict) { $patient_conflict = new CPatient(); $patient_conflict->load($_conflict->object_id); $patient_conflict->loadIPP(); $IPP = new CIdSante400(); $IPP->object_class = "CPatient"; $IPP->tag = CAppUI::conf("dPpatients CPatient tag_ipp"); $IPP->id400 = $_conflict->id400; $IPP->loadMatchingObject(); $patient = new CPatient(); $patient->load($IPP->object_id); $patient->loadIPP(); $conflicts[] = array("patient" => $patient, "patient_conflict" => $patient_conflict); }
/** * Catalogue import */ function importCatalogue($cat, $parent_id = null) { global $remote_name; CApp::setTimeLimit(180); // On rend toutes les analyses du catalogue obsoletes $idAnalyse = new CIdSante400(); $idAnalyse->tag = $remote_name; $idAnalyse->object_class = "CExamenLabo"; $idAnalyses = $idAnalyse->loadMatchingList(); foreach ($idAnalyses as $_id_analyse) { $examenLabo = new CExamenLabo(); $examenLabo->identifiant = $_id_analyse->id400; $examenLabo->loadMatchingObject(); if ($examenLabo->_id) { $examenLabo->obsolete = 1; $examenLabo->store(); } } $idCatalogue = new CIdSante400(); $idCatalogue->tag = $remote_name; $idCatalogue->object_class = "CCatalogueLabo"; $idCatalogues = $idCatalogue->loadMatchingList(); foreach ($idCatalogues as $_id_catalogue) { $catalogueLabo = new CCatalogueLabo(); $catalogueLabo->identifiant = $_id_catalogue->id400; $catalogueLabo->loadMatchingObject(); if ($catalogueLabo->_id) { $catalogueLabo->obsolete = 1; $catalogueLabo->store(); } } $compteur["analyses"] = 0; $compteur["chapitres"] = 0; $compteur["sousChapitre"] = 0; $catalogues = array(); // Creation du catalogue global LABO $catal = new CCatalogueLabo(); $catalogue = new CCatalogueLabo(); $catal->identifiant = substr(hash('md5', $remote_name), 0, 4); // libelle modifié par hash $catal->libelle = $remote_name; $catal->pere_id = $parent_id; // creation de son id400 $idCat = new CIdSante400(); $idCat->tag = $remote_name; $idCat->id400 = $remote_name; $catal->obsolete = 0; $idCat->bindObject($catal); //CAppUI::stepAjax("Catalogue '$catal->libelle' importé", UI_MSG_OK); $path = $remote_name; // on met a jour $catalogues $catalogues[$path] = $catal; //Parcours des analyses foreach ($cat->analyse as $_analyse) { $chapitre = (string) $_analyse->chapitre; $path = "{$remote_name}/{$chapitre}/"; if (!$chapitre) { $path = $remote_name; } $catChapitre = new CCatalogueLabo(); // si le catalogue n'existe pas deja if (!array_key_exists($path, $catalogues)) { // creation du catalogue $catChapitre->identifiant = substr(hash('md5', $chapitre), 0, 4); // libelle modifié par hash; $catChapitre->libelle = $chapitre; $catChapitre->pere_id = $catal->_id; $catChapitre->decodeUtfStrings(); //creation de l'id400 $idCatChapitre = new CIdSante400(); $idCatChapitre->tag = $remote_name; $idCatChapitre->id400 = substr(hash('md5', $chapitre), 0, 4); $catChapitre->obsolete = 0; $idCatChapitre->bindObject($catChapitre); //CAppUI::stepAjax("Catalogue '$catChapitre->libelle' importé", UI_MSG_OK); $compteur["chapitres"]++; // on met a jour $catalogues $catalogues[$path] = $catChapitre; } $catChapitre = $catalogues[$path]; $catalogue = $catChapitre; // si il y a un sous chapitre a creer==> le pere du sous chapitre est $catalogue->_id; $sschapitre = (string) $_analyse->sschapitre; if ($sschapitre) { // modification du path $path .= $sschapitre; $catssChapitre = new CCatalogueLabo(); if (!array_key_exists($path, $catalogues)) { // creation du catalogue $catssChapitre->identifiant = substr(hash('md5', $sschapitre), 0, 4); // libelle modifié par hash; $catssChapitre->libelle = $sschapitre; $catssChapitre->pere_id = $catChapitre->_id; $catssChapitre->decodeUtfStrings(); //creation de l'id400 $idCatssChapitre = new CIdSante400(); $idCatssChapitre->tag = $remote_name; $idCatssChapitre->id400 = substr(hash('md5', $sschapitre), 0, 4); $catssChapitre->obsolete = 0; $idCatssChapitre->bindObject($catssChapitre); //CAppUI::stepAjax("Sous Catalogue '$catssChapitre->libelle' importé", UI_MSG_OK); $compteur["sousChapitre"]++; //on met à jour les catalogues $catalogues[$path] = $catssChapitre; } $catssChapitre = $catalogues[$path]; $catalogue = $catssChapitre; } // Code de l'analyse $catAtt = $_analyse->attributes(); $code = $catAtt["code"]; $idAnalyse = new CIdSante400(); $idAnalyse->tag = $remote_name; $idAnalyse->id400 = (string) $code; $analyse = new CExamenLabo(); $analyse->identifiant = (string) $code; $analyse->libelle = (string) $_analyse->libelle; $analyse->decodeUtfStrings(); $analyse->technique = (string) $_analyse->technique; $analyse->duree_execution = (string) $_analyse->delaitechnique; $materiel = utf8_decode((string) $_analyse->materiel); $materiel = trim($materiel); switch ($materiel) { case "SANG VEINEUX": $analyse->type_prelevement = "sang"; break; case "URINE": $analyse->type_prelevement = "urine"; break; case "BIOPSIE": $analyse->type_prelevement = "biopsie"; break; } //$analyse->applicabilite = (string) $_analyse->applicablesexe; $analyse->execution_lun = (string) $_analyse->joursrealisation->lundi; $analyse->execution_mar = (string) $_analyse->joursrealisation->mardi; $analyse->execution_mer = (string) $_analyse->joursrealisation->mercredi; $analyse->execution_jeu = (string) $_analyse->joursrealisation->jeudi; $analyse->execution_ven = (string) $_analyse->joursrealisation->vendredi; $analyse->execution_sam = (string) $_analyse->joursrealisation->samedi; $analyse->execution_dim = (string) $_analyse->joursrealisation->dimanche; $analyse->catalogue_labo_id = $catalogue->_id; $analyse->type = "num"; $analyse->obsolete = 0; $idAnalyse->bindObject($analyse); //CAppUI::stepAjax("Analyse '$analyse->identifiant' importée", UI_MSG_OK); $compteur["analyses"]++; } // fin du foreach CAppUI::stepAjax("Analyses Importées: " . $compteur["analyses"] . ", Chapitres Importés: " . $compteur["chapitres"] . ", Sous chapitres Importés: " . $compteur["sousChapitre"], UI_MSG_OK); }
/** * Build PID segement * * @param CHL7v2Event $event Event * * @return null */ function build(CHL7v2Event $event) { parent::build($event); $message = $event->message; $sender = $event->_sender; $group = $sender->loadRefGroup(); $domains_returned = $this->domains_returned; $patient = $this->patient; $data = array(); // PID-1: Set ID - PID (SI) (optional) $data[] = $this->set_id; // PID-2: Patient ID (CX) (optional) $data[] = null; $identifiers = array(); if (empty($domains_returned)) { $idex = new CIdSante400(); $idex->object_id = $patient->_id; $idex->object_class = "CPatient"; $ljoin = array(); $ljoin[] = "group_domain AS g1 ON g1.domain_id = domain.domain_id AND g1.object_class = 'CPatient'"; foreach ($idex->loadMatchingList() as $_idex) { $domain = new CDomain(); $where["tag"] = " = '{$_idex->tag}'"; $domain->loadObject($where, null, null, $ljoin); if (!$domain->_id) { continue; } $identifiers[] = array($_idex->id400, null, null, $this->getAssigningAuthority("domain", null, null, $domain), "MR"); } } else { foreach ($domains_returned as $_domain_returned) { $assigning_authority = $this->getAssigningAuthority("domain", null, null, $_domain_returned); $identifiers[] = array(CIdSante400::getValueFor($patient, $_domain_returned->tag), null, null, $assigning_authority, "MR"); } } // PID-3: Patient Identifier List (CX) (repeating) $data[] = $identifiers; // PID-4: Alternate Patient ID - PID (CX) (optional repeating) $data[] = null; // PID-5: Patient Name (XPN) (repeating) $data[] = $this->getXPN($patient); // PID-6: Mother's Maiden Name (XPN) (optional repeating) $data[] = null; // PID-7: Date/Time of Birth (TS) (optional) $data[] = CMbDT::isLunarDate($patient->naissance) ? null : $patient->naissance; // PID-8: Administrative Sex (IS) (optional) // Table - 0001 // F - Female // M - Male // O - Other // U - Unknown // A - Ambiguous // N - Not applicable $data[] = CHL7v2TableEntry::mapTo("1", $patient->sexe); // PID-9: Patient Alias (XPN) (optional repeating) $data[] = null; // PID-10: Race (CE) (optional repeating) $data[] = null; // PID-11: Patient Address (XAD) (optional repeating) $address = array(); if ($patient->adresse || $patient->ville || $patient->cp) { $linesAdress = explode("\n", $patient->adresse, 2); $address[] = array(CValue::read($linesAdress, 0), str_replace("\n", $message->componentSeparator, CValue::read($linesAdress, 1)), $patient->ville, $patient->province, $patient->cp, CPaysInsee::getAlpha3($patient->pays_insee), "H"); } if ($patient->lieu_naissance || $patient->cp_naissance || $patient->pays_naissance_insee) { $address[] = array(null, null, $patient->lieu_naissance, null, $patient->cp_naissance, CPaysInsee::getAlpha3($patient->pays_naissance_insee), "BDL"); } $data[] = $address; // PID-12: County Code (IS) (optional) $data[] = null; // PID-13: Phone Number - Home (XTN) (optional repeating) // Table - 0201 // ASN - Answering Service Number // BPN - Beeper Number // EMR - Emergency Number // NET - Network (email) Address // ORN - Other Residence Number // PRN - Primary Residence Number // VHN - Vacation Home Number // WPN - Work Number // Table - 0202 // BP - Beeper // CP - Cellular Phone // FX - Fax // Internet - Internet Address: Use Only If Telecommunication Use Code Is NET // MD - Modem // PH - Telephone // TDD - Telecommunications Device for the Deaf // TTY - Teletypewriter $phones = array(); if ($patient->tel) { $area_city_code = null; $local_number = null; if ($sender->_configs["send_area_local_number"]) { $area_city_code = substr($patient->tel, 0, 3); $local_number = substr($patient->tel, 3); } $phones[] = array(null, "PRN", "PH", null, null, $area_city_code, $local_number, null, null, null, null, $sender->_configs["send_area_local_number"] ? null : $patient->tel); } $data[] = $phones; // PID-14: Phone Number - Business (XTN) (optional repeating) $data[] = null; // PID-15: Primary Language (CE) (optional) $data[] = null; // PID-16: Marital Status (CE) (optional) $data[] = null; // PID-17: Religion (CE) (optional) $data[] = null; // PID-18: Patient Account Number (CX) (optional) if ($this->sejour) { $sejour = $this->sejour; $sejour->loadNDA($group->_id); $domain = new CDomain(); $domain->tag = $sejour->getTagNDA(); $domain->loadMatchingObject(); $data[] = $sejour->_NDA ? array(array($sejour->_NDA, null, null, $this->getAssigningAuthority("domain", null, null, $domain))) : null; } else { $data[] = null; } // PID-19: SSN Number - Patient (ST) (optional) $data[] = $patient->matricule; // PID-20: Driver's License Number - Patient (DLN) (optional) $data[] = null; // PID-21: Mother's Identifier (CX) (optional repeating) $data[] = null; // PID-22: Ethnic Group (CE) (optional repeating) $data[] = null; // PID-23: Birth Place (ST) (optional) $data[] = null; // PID-24: Multiple Birth Indicator (ID) (optional) $data[] = null; // PID-25: Birth Order (NM) (optional) $data[] = $patient->rang_naissance; // PID-26: Citizenship (CE) (optional repeating) $data[] = null; // PID-27: Veterans Military Status (CE) (optional) $data[] = null; // PID-28: Nationality (CE) (optional) $data[] = null; // PID-29: Patient Death Date and Time (TS) (optional) $data[] = $patient->deces ? $patient->deces : null; // PID-30: Patient Death Indicator (ID) (optional) $data[] = $patient->deces ? "Y" : "N"; // PID-31: Identity Unknown Indicator (ID) (optional) $data[] = null; // PID-32: Identity Reliability Code (IS) (optional repeating) $data[] = null; // PID-33: Last Update Date/Time (TS) (optional) $data[] = null; // PID-34: Last Update Facility (HD) (optional) $data[] = null; // PID-35: Species Code (CE) (optional) $data[] = null; // PID-36: Breed Code (CE) (optional) $data[] = null; // PID-37: Strain (ST) (optional) $data[] = null; // PID-38: Production Class Code (CE) (optional) $data[] = null; // PID-39: Tribal Citizenship (CWE) (optional repeating) $data[] = null; $this->fill($data); }
<?php /** * $Id$ * * @category Admin * @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 */ $id_ext = new CIdSante400(); $id_ext->tag = CAppUI::conf("admin LDAP ldap_tag"); $id_ext->object_class = "CUser"; $list = $id_ext->loadMatchingList(); if (count($list) == 0) { CAppUI::setMsg("Aucun identifiant à convertir"); } $count = 0; foreach ($list as $_id_ext) { if (strpos($_id_ext->id400, "-") !== false) { continue; } $count++; $_id_ext->id400 = CLDAP::convertHexaToRegistry($_id_ext->id400); $_id_ext->last_update = CMbDT::dateTime(); if ($msg = $_id_ext->store()) { CAppUI::setMsg($msg, UI_MSG_WARNING); } else { CAppUI::setMsg("Identifiant converti");
/** * @see parent::onBeforeMerge */ function onBeforeMerge(CMbObject $mbObject) { if (!parent::onBeforeMerge($mbObject)) { return; } // Si pas en mode alternatif if (!CAppUI::conf("alternative_mode")) { throw new CMbException("no_alternative_mode"); } $patient = $mbObject; $patient_elimine = new CPatient(); $patient_elimine->load(reset($mbObject->_merging)); // Si Client if (!CAppUI::conf('sip server')) { $mbObject->_fusion = array(); foreach (CGroups::loadGroups() as $_group) { /** @var CInteropSender $sender */ $sender = $mbObject->_eai_sender_guid ? CMbObject::loadFromGuid($mbObject->_eai_sender_guid) : null; if ($sender && $sender->group_id == $_group->_id) { continue; } $patient->_IPP = null; $patient->loadIPP($_group->_id); $patient1_ipp = $patient->_IPP; $patient_elimine->_IPP = null; $patient_elimine->loadIPP($_group->_id); $patient2_ipp = $patient_elimine->_IPP; // Passage en trash des IPP des patients $tap_IPP = CPatient::getTagIPP($_group->_id); if (!$tap_IPP) { continue; } $idexPatient = new CIdSante400(); $idexPatient->tag = $tap_IPP; $idexPatient->object_class = "CPatient"; $idexPatient->object_id = $patient->_id; $idexsPatient = $idexPatient->loadMatchingList(); $idexPatientElimine = new CIdSante400(); $idexPatientElimine->tag = $tap_IPP; $idexPatientElimine->object_class = "CPatient"; $idexPatientElimine->object_id = $patient_elimine->_id; $idexsPatientElimine = $idexPatientElimine->loadMatchingList(); $idexs = array_merge($idexsPatient, $idexsPatientElimine); $idexs_changed = array(); if (count($idexs) > 1) { foreach ($idexs as $_idex) { // On continue pour ne pas mettre en trash l'IPP du patient que l'on garde if ($_idex->id400 == $patient1_ipp) { continue; } $old_tag = $_idex->tag; $_idex->tag = CAppUI::conf('dPpatients CPatient tag_ipp_trash') . $tap_IPP; $_idex->last_update = CMbDT::dateTime(); if (!($msg = $_idex->store())) { if ($_idex->object_id == $patient_elimine->_id) { $idexs_changed[$_idex->_id] = $old_tag; } } } } if (!$patient1_ipp && !$patient2_ipp) { continue; } $mbObject->_fusion[$_group->_id] = array("patientElimine" => $patient_elimine, "patient1_ipp" => $patient1_ipp, "patient2_ipp" => $patient2_ipp, "idexs_changed" => $idexs_changed); } } $this->sendFormatAction("onBeforeMerge", $mbObject); }
$sip_active = $module->mod_active; $idex_value = CValue::get("id400"); $object_id = CValue::get("object_id"); $idex = new CIdSante400(); $idex->id400 = $idex_value; $idex->object_id = $object_id; $idex->loadMatchingObject(); $group_id = CGroups::loadCurrent()->_id; $idexs = array(); $idex_id = null; if ($idex->_id) { $filter = new CIdSante400(); $filter->object_class = $idex->object_class; $filter->object_id = $idex->object_id; $filter->tag = CSejour::getTagNDA($group_id); $idexs = $filter->loadMatchingList(); $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_trash"); $idexs += $filter->loadMatchingList(); $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_cancel"); $idexs += $filter->loadMatchingList(); $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_pa"); $idexs += $filter->loadMatchingList(); // Chargement de l'objet afin de récupérer l'id400 associé (le latest) $object = new $filter->object_class(); $object->load($filter->object_id); $object->loadNDA($group_id); foreach ($idexs as $key => $_idex) { $_idex->loadRefs(); $_idex->getSpecialType(); if (!$idex_id && $_idex->id400 == $object->_NDA) { $idex_id = $_idex->_id;
/** * Packs import */ function importPacks($packs) { global $m, $remote_name; // Chargement des identifiants externes des packs $idPackExamen = new CIdSante400(); $idPackExamen->tag = $remote_name; $idPackExamen->object_class = "CPackExamensLabo"; $idPackExamens = $idPackExamen->loadMatchingList(); // Parcours des identifiants externes des Packs d'examens foreach ($idPackExamens as $_id_pack_examen) { $packExamen = new CPackExamensLabo(); $packExamen->load($_id_pack_examen->object_id); // Chargement des items de packs $packExamen->loadRefsItemExamenLabo(); // On vide chaque pack foreach ($packExamen->_ref_items_examen_labo as $_packItemExamen) { // Chargement de l'examen labo pour obtenir l'identifiant necessaire pour supprime l'id externe $_packItemExamen->loadRefExamen(); // Suppression de l'id400 du packItem $_id_pack_examen = new CIdSante400(); $_id_pack_examen->tag = $remote_name; $_id_pack_examen->object_class = $_packItemExamen->_class; $_id_pack_examen->object_id = $_packItemExamen->_id; $_id_pack_examen->loadMatchingObject(); if ($_id_pack_examen->_id) { $_id_pack_examen->delete(); } // Suppression du pack item $_packItemExamen->delete(); } if ($packExamen->_id) { $packExamen->obsolete = 1; $packExamen->store(); } } // Nombre de packs et d'analyses $nb["packs"] = 0; $nb["analysesOK"] = 0; $nb["analysesKO"] = 0; // Liste des analyses nono trouvees $erreurs = array(); // On crée chaque pack ainsi qu'un id400 associé foreach ($packs->bilan as $_pack) { $pack = new CPackExamensLabo(); $pack->function_id = ""; $pack->libelle = utf8_decode((string) $_pack->libelle); $pack->code = (int) $_pack->code; // Sauvegarde du pack $idPack = new CIdSante400(); // tag des id externe des packs => nom du laboatoire ==> LABO $idPack->tag = $remote_name; $idPack->id400 = (int) $_pack->code; $pack->obsolete = 0; $idPack->bindObject($pack); // On crée les analyses correspondantes foreach ($_pack->analyses->cana as $_analyse) { // Creation de l'analyse $analyse = new CPackItemExamenLabo(); // Chargement de l'analyse $examLabo = new CExamenLabo(); $whereExam = array(); $whereExam['identifiant'] = (string) " = '{$_analyse}'"; $examLabo->loadObject($whereExam); if ($examLabo->_id) { $analyse->pack_examens_labo_id = $pack->_id; $analyse->examen_labo_id = $examLabo->examen_labo_id; // Sauvegarde de l'analyse et de son id400 $idExamen = new CIdSante400(); $idExamen->tag = $remote_name; $idExamen->id400 = (string) $_analyse; $idExamen->bindObject($analyse); $nb["analysesOK"]++; } else { $erreurs[][(string) $_pack->libelle] = (string) $_analyse; $nb["analysesKO"]++; } } $nb["packs"]++; } // Recapitulatif des importations CAppUI::stepAjax("Packs Importés: " . $nb["packs"], UI_MSG_OK); CAppUI::stepAjax("Analyses Importées: " . $nb["analysesOK"], UI_MSG_OK); CAppUI::stepAjax("Analyses non importées: " . $nb["analysesKO"], UI_MSG_WARNING); foreach ($erreurs as $erreur) { foreach ($erreur as $_key => $_erreur) { CAppUI::stepAjax("Analyse non trouvée: " . $_erreur . " dans le pack " . utf8_decode($_key), UI_MSG_WARNING); } } }
// Chargement de la liste des id4Sante400 pour le filtre $filter = new CIdSante400(); $filter->object_id = $object_id; $filter->object_class = $object_class; $filter->tag = $tag; $filter->id400 = $id400; $filter->nullifyEmptyFields(); // Chargement de la cible si objet unique $target = null; if ($filter->object_id && $filter->object_class) { $target = new $filter->object_class(); $target->load($filter->object_id); } // Requête du filtre $step = 25; $idexs = $filter->loadMatchingList(null, "{$page}, {$step}"); foreach ($idexs as $_idex) { $_idex->loadRefs(); $_idex->getSpecialType(); } $total_idexs = $filter->countMatchingList(); // Création du template $smarty = new CSmartyDP(); $smarty->assign("idexs", $idexs); $smarty->assign("total_idexs", $total_idexs); $smarty->assign("filter", $filter); $smarty->assign("idex_id", $idex_id); $smarty->assign("dialog", $dialog); $smarty->assign("page", $page); $smarty->assign("target", $target); $smarty->display("inc_list_identifiants.tpl");
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $pratId = CValue::getOrSession("object_id"); $pratId400 = CValue::getOrSession("id400"); $date = CMbDT::dateTime(); //Création d'un nouvel id400 pour le laboratoire $new_idex = new CIdSante400(); $prat = new CMediusers(); $listPrat = $prat->loadPraticiens(); $remote_name = CAppUI::conf("dPlabo CCatalogueLabo remote_name"); $idex = new CIdSante400(); $idex->object_class = "CMediusers"; $idex->tag = $remote_name; $idexs = $idex->loadMatchingList(); foreach ($idexs as $_idex) { $_idex->loadRefs(); } $prescriptionlabo_source = CExchangeSource::get("prescriptionlabo", "ftp", true, null, false); $get_id_prescriptionlabo_source = CExchangeSource::get("get_id_prescriptionlabo", "soap", true, null, false); // Création du template $smarty = new CSmartyDP(); $smarty->assign("prescriptionlabo_source", $prescriptionlabo_source); $smarty->assign("get_id_prescriptionlabo_source", $get_id_prescriptionlabo_source); $smarty->assign("listPrat", $listPrat); $smarty->assign("date", $date); $smarty->assign("remote_name", $remote_name); $smarty->assign("newId400", $new_idex); $smarty->assign("list_idSante400", $idexs); $smarty->display("configure.tpl");
/* $Id: $ */ /** * @package Mediboard * @subpackage dPsante400 * @version $Revision: $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ $idex_id = CValue::get("idex_id"); $idex = new CIdSante400(); $idex->load($idex_id); $filter = new CIdSante400(); $filter->object_class = $idex->object_class; $filter->object_id = $idex->object_id; $filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id); $idexs = $filter->loadMatchingList(CGroups::loadCurrent()->_id); $filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_cancel"); $idexs = array_merge($idexs, $filter->loadMatchingList()); $filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_trash"); $idexs = array_merge($idexs, $filter->loadMatchingList()); $filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_pa"); $idexs = array_merge($idexs, $filter->loadMatchingList()); $tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id); // Chargement de l'objet afin de récupérer l'id400 associé $object = new $filter->object_class(); $object->load($filter->object_id); $object->loadNDA(CGroups::loadCurrent()->_id); foreach ($idexs as $_idex) { // L'identifiant 400 coché if ($_idex->_id == $idex_id) { $_idex->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id);
/** * Trigger before event merge * * @param CMbObject $mbObject Object * * @throws CMbException * * @return bool */ function onBeforeMerge(CMbObject $mbObject) { if (!parent::onBeforeMerge($mbObject)) { return false; } // Si pas en mode alternatif if (!CAppUI::conf("alternative_mode")) { throw new CMbException("no_alternative_mode"); } $sejour = $mbObject; $sejour_elimine = new CSejour(); $sejour_elimine->load(reset($mbObject->_merging)); // Si Client if (!CAppUI::conf('smp server')) { $mbObject->_fusion = array(); foreach (CGroups::loadGroups() as $_group) { $sender = CMbObject::loadFromGuid($mbObject->_eai_sender_guid); if ($sender && $sender->group_id == $_group->_id) { continue; } $sejour->_NDA = null; $sejour->loadNDA($_group->_id); $sejour1_nda = $sejour->_NDA; $sejour_elimine->_NDA = null; $sejour_elimine->loadNDA($_group->_id); $sejour2_nda = $sejour_elimine->_NDA; // Passage en trash des NDA des séjours $tag_NDA = CSejour::getTagNDA($_group->_id); if (!$tag_NDA) { continue; } $idexSejour = new CIdSante400(); $idexSejour->tag = $tag_NDA; $idexSejour->object_class = "CSejour"; $idexSejour->object_id = $sejour->_id; $idexsSejour = $idexSejour->loadMatchingList(); $idexSejourElimine = new CIdSante400(); $idexSejourElimine->tag = $tag_NDA; $idexSejourElimine->object_class = "CSejour"; $idexSejourElimine->object_id = $sejour_elimine->_id; $idexsSejourElimine = $idexSejourElimine->loadMatchingList(); /** @var CIdSante400[] $idexs */ $idexs = array_merge($idexsSejour, $idexsSejourElimine); $idexs_changed = array(); if (count($idexs) > 1) { foreach ($idexs as $_idex) { // On continue pour ne pas mettre en trash le NDA du séjour que l'on garde if ($_idex->id400 == $sejour1_nda) { continue; } $old_tag = $_idex->tag; $_idex->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_trash') . $tag_NDA; $_idex->last_update = CMbDT::dateTime(); if (!($msg = $_idex->store())) { if ($_idex->object_id == $sejour_elimine->_id) { $idexs_changed[$_idex->_id] = $old_tag; } } } } if (!$sejour1_nda && !$sejour2_nda) { continue; } $mbObject->_fusion[$_group->_id] = array("sejourElimine" => $sejour_elimine, "sejour1_nda" => $sejour1_nda, "sejour2_nda" => $sejour2_nda, "idexs_changed" => $idexs_changed); } } $this->sendFormatAction("onBeforeMerge", $mbObject); return true; }