/** * @see parent::importObject() */ function importObject(DOMElement $element) { $id = $element->getAttribute("id"); if (isset($this->imported[$id])) { return; } $this->name_suffix = " (import du " . CMbDT::dateTime() . ")"; $_class = $element->getAttribute("class"); $imported_object = null; $idex = self::lookupObject($id); if ($idex->_id) { $this->imported[$id] = true; $this->map[$id] = $idex->loadTargetObject()->_guid; return; } switch ($_class) { // COperation = Intervention: Données incorrectes, Le code CCAM 'QZEA024 + R + J' n'est pas valide case "CPatient": /** @var CPatient $_patient */ $_patient = $this->getObjectFromElement($element); if ($_patient->naissance == "0000-00-00") { $_patient->naissance = "1850-01-01"; } $_patient->loadMatchingPatient(); $is_new = !$_patient->_id; $_patient->_merging = true; // TODO a supprimer if ($msg = $_patient->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } if ($is_new) { CAppUI::stepAjax("Patient '%s' créé", UI_MSG_OK, $_patient->_view); } else { CAppUI::stepAjax("Patient '%s' retrouvé", UI_MSG_OK, $_patient->_view); } $imported_object = $_patient; break; case "CDossierMedical": /** @var CDossierMedical $_object */ $_object = $this->getObjectFromElement($element); $_dossier = new CDossierMedical(); $_dossier->object_id = $_object->object_id; $_dossier->object_class = $_object->object_class; $_dossier->loadMatchingObject(); if (!$_dossier->_id) { if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); $imported_object = $_object; } else { $imported_object = $_dossier; } break; case "CAntecedent": /** @var CAntecedent $_new_atcd */ $_new_atcd = $this->getObjectFromElement($element); // On cherche un ATCD similaire $_empty_atcd = new CAntecedent(); $_empty_atcd->dossier_medical_id = $_new_atcd->dossier_medical_id; $_empty_atcd->type = $_new_atcd->type ?: null; $_empty_atcd->appareil = $_new_atcd->appareil ?: null; $_empty_atcd->annule = $_new_atcd->annule ?: null; $_empty_atcd->date = $_new_atcd->date ?: null; $_empty_atcd->rques = $_new_atcd->rques ?: null; $_empty_atcd->loadMatchingObject(); if (!$_empty_atcd->_id) { $_new_atcd->_forwardRefMerging = true; // To accept any ATCD type if ($msg = $_new_atcd->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax("Antécédent '%s' créé", UI_MSG_OK, $_new_atcd->_view); } $imported_object = $_new_atcd; break; case "CPlageOp": case "CPlageconsult": /** @var CPlageOp|CPlageconsult $_plage */ $_plage = $this->getObjectFromElement($element); $_plage->hasCollisions(); if (count($_plage->_colliding_plages)) { $_plage = reset($_plage->_colliding_plages); CAppUI::stepAjax("%s '%s' retrouvée", UI_MSG_OK, CAppUI::tr($_plage->_class), $_plage->_view); } else { if ($msg = $_plage->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax("%s '%s' créée", UI_MSG_OK, CAppUI::tr($_plage->_class), $_plage->_view); } $imported_object = $_plage; break; case "CFile": /** @var CFile $_file */ $_file = $this->getObjectFromElement($element); $_filedir = $this->getCFileDirectory($element); if (!$_file->moveFile($_filedir)) { CAppUI::stepAjax("Fichier '%s' non trouvé dans '%s'", UI_MSG_WARNING, $_file->_view, $_filedir); } else { if ($msg = $_file->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax("Fichier '%s' créé", UI_MSG_OK, $_file->_view); } $imported_object = $_file; break; case "CConsultation": /** @var CConsultation $_object */ $_object = $this->getObjectFromElement($element); $_new_consult = new CConsultation(); $_new_consult->patient_id = $_object->patient_id; $_new_consult->plageconsult_id = $_object->plageconsult_id; $_new_consult->loadMatchingObject(); if ($_new_consult->_id) { $_object = $_new_consult; CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' retrouvé", UI_MSG_OK, $_object); } else { if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); } $imported_object = $_object; break; case "CSejour": /** @var CSejour $_object */ $_object = $this->getObjectFromElement($element); $_collisions = $_object->getCollisions(); if (count($_collisions)) { $_object = reset($_collisions); CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' retrouvé", UI_MSG_OK, $_object); } else { if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); } $imported_object = $_object; break; case "COperation": /** @var COperation $_interv */ $_interv = $this->getObjectFromElement($element); $_ds = $_interv->getDS(); $where = array("sejour_id" => $_ds->prepare("= ?", $_interv->sejour_id), "chir_id" => $_ds->prepare("= ?", $_interv->chir_id), "date" => $_ds->prepare("= ?", $_interv->date), "cote" => $_ds->prepare("= ?", $_interv->cote), "id_sante400.id_sante400_id" => "IS NULL"); $ljoin = array("id_sante400" => "id_sante400.object_id = operations.operation_id AND\n id_sante400.object_class = 'COperation' AND\n id_sante400.tag = 'migration'"); $_matching = $_interv->loadList($where, null, null, null, $ljoin); if (count($_matching)) { $_interv = reset($_matching); CAppUI::stepAjax("%s '%s' retrouvée", UI_MSG_OK, CAppUI::tr($_interv->_class), $_interv->_view); } else { if ($msg = $_interv->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax("%s '%s' créée", UI_MSG_OK, CAppUI::tr($_interv->_class), $_interv->_view); } $imported_object = $_interv; break; case "CContentHTML": /** @var CContentHTML $_object */ $_object = $this->getObjectFromElement($element); $_object->content = stripslashes($_object->content); if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); $imported_object = $_object; break; default: // Ignored classes if (in_array($_class, self::$_ignored_classes)) { break; } $_object = $this->getObjectFromElement($element); if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); $imported_object = $_object; break; } // Store idex on new object if ($imported_object && $imported_object->_id) { $idex->setObject($imported_object); $idex->id400 = $id; if ($msg = $idex->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); } } else { if (!in_array($_class, self::$_ignored_classes)) { CAppUI::stepAjax("{$id} sans objet", UI_MSG_WARNING); } } if ($imported_object) { $this->map[$id] = $imported_object->_guid; } $this->imported[$id] = true; }
/** * Charge l'observation d'entrée du séjour * * @return CConsultation */ function loadRefObsEntree() { $consult = new CConsultation(); if ($this->_id) { $consult->sejour_id = $this->_id; $consult->type = "entree"; $consult->annule = 0; $consult->loadMatchingObject(); } return $this->_ref_obs_entree = $consult; }