/** * Identifiant de dossier médical lié à l'objet fourni. * Crée le dossier médical si nécessaire * * @param integer $object_id Identifiant de l'objet * @param string $object_class Classe de l'objet * * @return integer Id du dossier médical */ static function dossierMedicalId($object_id, $object_class) { $dossier = new CDossierMedical(); $dossier->object_id = $object_id; $dossier->object_class = $object_class; $dossier->loadMatchingObject(); if (!$dossier->_id) { $dossier->store(); } return $dossier->_id; }
/** * @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; }
function addIntervention($elParent, COperation $operation, $referent = null, $light = false) { $identifiant = $this->addElement($elParent, "identifiant"); $this->addElement($identifiant, "emetteur", $operation->_id); $last_idex = $operation->_ref_last_id400; if (isset($last_idex->_id)) { $this->addElement($identifiant, "recepteur", $last_idex->id400); } $sejour = $operation->loadRefSejour(); if (!$operation->plageop_id) { $operation->completeField("date"); } // Calcul du début de l'intervention $mbOpDate = CValue::first($operation->_ref_plageop->date, $operation->date); $time_operation = $operation->time_operation == "00:00:00" ? null : $operation->time_operation; $mbOpHeureDebut = CValue::first($operation->debut_op, $operation->entree_salle, $time_operation, $operation->horaire_voulu, $operation->_ref_plageop->debut); $mbOpDebut = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureDebut}"); // Calcul de la fin de l'intervention $mbOpHeureFin = CValue::first($operation->fin_op, $operation->sortie_salle, CMbDT::addTime($operation->temp_operation, CMbDT::time($mbOpDebut))); $mbOpFin = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureFin}"); $debut = $this->addElement($elParent, "debut"); $this->addElement($debut, "date", CMbDT::date($mbOpDebut)); $this->addElement($debut, "heure", CMbDT::time($mbOpDebut)); $fin = $this->addElement($elParent, "fin"); $this->addElement($fin, "date", CMbDT::date($mbOpFin)); $this->addElement($fin, "heure", CMbDT::time($mbOpFin)); if ($light) { // Ajout des participants $mbParticipants = array(); foreach ($operation->_ref_actes_ccam as $acte_ccam) { $acte_ccam->loadRefExecutant(); $mbParticipant = $acte_ccam->_ref_executant; $mbParticipants[$mbParticipant->user_id] = $mbParticipant; } $participants = $this->addElement($elParent, "participants"); foreach ($mbParticipants as $mbParticipant) { $participant = $this->addElement($participants, "participant"); $medecin = $this->addElement($participant, "medecin"); $this->addProfessionnelSante($medecin, $mbParticipant); } // Libellé de l'opération $this->addTexte($elParent, "libelle", $operation->libelle, 80); } else { $this->addUniteFonctionnelle($elParent, $operation); // Uniquement le responsable de l’'intervention $participants = $this->addElement($elParent, "participants"); $participant = $this->addElement($participants, "participant"); $medecin = $this->addElement($participant, "medecin"); $this->addProfessionnelSante($medecin, $operation->loadRefChir()); // Libellé de l'opération $this->addTexte($elParent, "libelle", $operation->libelle, 4000); // Remarques sur l'opération $this->addTexte($elParent, "commentaire", CMbString::convertHTMLToXMLEntities("{$operation->materiel} - {$operation->rques}"), 4000); // Conventionnée ? $this->addElement($elParent, "convention", $operation->conventionne ? 1 : 0); // TypeAnesthésie : nomemclature externe (idex) if ($operation->type_anesth) { $tag_hprimxml = $this->_ref_receiver->_tag_hprimxml; $idexTypeAnesth = CIdSante400::getMatch("CTypeAnesth", $tag_hprimxml, null, $operation->type_anesth); $this->addElement($elParent, "typeAnesthesie", $idexTypeAnesth->id400); } // Indicateurs $indicateurs = $this->addElement($elParent, "indicateurs"); $dossier_medical = new CDossierMedical(); $dossier_medical->object_class = "CPatient"; $dossier_medical->object_id = $operation->loadRefPatient()->_id; $dossier_medical->loadMatchingObject(); $antecedents = $dossier_medical->loadRefsAntecedents(); foreach ($antecedents as $_antecedent) { $rques = CMbString::htmlspecialchars($_antecedent->rques); $rques = CMbString::convertHTMLToXMLEntities($rques); $this->addCodeLibelle($indicateurs, "indicateur", $_antecedent->_id, $rques); } // Extemporané if ($operation->exam_extempo) { $this->addCodeLibelle($indicateurs, "indicateur", "EXT", "Extemporané"); } // Recours / Durée USCPO $this->addElement($elParent, "recoursUscpo", $operation->duree_uscpo ? 1 : 0); $this->addElement($elParent, "dureeUscpo", $operation->duree_uscpo ? $operation->duree_uscpo : null); // Côté (droit|gauche|bilatéral|total|inconnu) // D - Droit // G - Gauche // B - Bilatéral // T - Total // I - Inconnu $cote = array("droit" => "D", "gauche" => "G", "bilatéral" => "B", "total" => "T", "inconnu" => "I", "haut" => "HT", "bas" => "BS"); $this->addCodeLibelle($elParent, "cote", $cote[$operation->cote], CMbString::capitalize($operation->cote)); } }