if (!$sejour_id) { CAppUI::stepMessage(UI_MSG_WARNING, "Veuillez sélectionner un sejour pour visualiser le dossier complet"); return; } $fiches_anesthesies = array(); $formulaires = null; global $atc_classes; $atc_classes = array(); $datetime_min = ""; if ($period) { $datetime_min = CMbDT::dateTime("- {$period} HOURS"); } // Chargement du sejour $sejour = new CSejour(); $sejour->load($sejour_id); $sejour->loadNDA(); $sejour->loadExtDiagnostics(); $sejour->loadRefsConsultAnesth(); $sejour->_ref_consult_anesth->loadRefConsultation(); $sejour->canRead(); // Chargement des affectations $sejour->loadRefCurrAffectation()->loadRefLit(); foreach ($sejour->loadRefsAffectations() as $_affectation) { $_affectation->loadRefLit(); } // Chargement des tâches foreach ($sejour->loadRefsTasks() as $_task) { $_task->loadRefPrescriptionLineElement(); $_task->setDateAndAuthor(); $_task->loadRefAuthor(); $_task->loadRefAuthorRealise();
if (isset($_POST["cmca_uf_code"])) { $object->code_uf = $_POST["cmca_uf_code"]; } if (isset($_POST["cmca_uf_libelle"])) { $object->libelle_uf = $_POST["cmca_uf_libelle"]; } } break; case "CSejour": $object = new CSejour(); // Chargement du séjour et génération du document $sejour_id = CValue::post("mb_sejour_id", CValue::getOrSession("object_id")); if ($object->load($sejour_id)) { $object->loadRefs(); $object->loadRefDossierMedical(); $object->loadNDA(); $NDA = $object->_NDA; $object->_ref_patient->loadIPP(); $IPP = $object->_ref_patient->_IPP; if (isset($_POST["sc_patient_id"])) { $object->_ref_patient->_IPP = $_POST["sc_patient_id"]; } if (isset($_POST["sc_venue_id"])) { $object->_NDA = $_POST["sc_venue_id"]; } } break; } // Facturation de l'opération où du séjour $object->facture = 1; if ($unlock_dossier) {
/** * Prepare the data to send from the given sejour * * @param CSejour $sejour The sejour * @param string $encoding The encoding * @param string $modality The target modality * @param string $calling_ae_title The AE title who requested the worklist * @param CDicomConfig $dicom_config The Exchange Dicom * * @return array */ protected function getDataFromSejour($sejour, $encoding, $modality, $calling_ae_title, $dicom_config) { $libelle = ''; $date = ''; $time = ''; $patient = $sejour->loadRefPatient(); $sejour->updateFormFields(); $operation = $sejour->loadRefCurrOperation(CMbDT::dateTime()); if ($operation->_id) { $operation->updateFormFields(); $operation->loadRefPlageOp(); if ($operation->libelle) { $libelle = substr($operation->libelle, 0, 64); } else { $libelle = 'Pas de libellé'; } if ($operation->date) { $date = str_replace('-', '', $operation->date); } else { $date = str_replace('-', '', $operation->_ref_plageop->date); } if ($operation->time_operation) { $time = str_replace(':', '', $operation->time_operation) . '.000000'; } else { $time = str_replace(':', '', CMbDT::time()) . '.000000'; } } else { $libelle = "Pas de libellé"; $date = str_replace('-', '', CMBDT::date()); $time = str_replace(':', '', CMbDT::time()) . '.000000'; } $chir = $sejour->loadRefPraticien(); $patient->loadIPP(); $sejour->loadNDA(); $sejour_id = $sejour->_id; if ($sejour->_NDA) { $sejour_id = $sejour->_NDA; } $patient_id = $patient->_id; if ($patient->_IPP) { $patient_id = $patient->_IPP; } $age = intval(substr(trim($patient->_age), 0, 2)); $chir_name = "{$chir->_user_last_name} {$chir->_user_first_name}"; $data = array(0x8 => array(0x50 => self::encodeValue($sejour_id, $encoding)), 0x10 => array(0x10 => self::encodeValue("{$patient->nom}^{$patient->prenom}", $encoding), 0x20 => self::encodeValue("{$patient_id}", $encoding), 0x30 => self::encodeValue(str_replace("-", "", $patient->naissance), $encoding), 0x40 => self::encodeValue(strtoupper($patient->sexe), $encoding)), 0x20 => array(0xd => self::encodeValue($sejour_id, $encoding)), 0x38 => array(0x10 => self::encodeValue($sejour_id, $encoding)), 0x40 => array(0x100 => array(array(array("group_number" => 0x8, "element_number" => 0x60, "value" => self::encodeValue($modality, $encoding)), array("group_number" => 0x40, "element_number" => 0x1, "value" => self::encodeValue($calling_ae_title, $encoding)), array("group_number" => 0x40, "element_number" => 0x2, "value" => self::encodeValue($date, $encoding)), array("group_number" => 0x40, "element_number" => 0x3, "value" => self::encodeValue($time, $encoding)), array("group_number" => 0x40, "element_number" => 0x6, "value" => self::encodeValue($chir_name, $encoding)), array("group_number" => 0x40, "element_number" => 0x7, "value" => self::encodeValue($libelle, $encoding)), array("group_number" => 0x40, "element_number" => 0x9, "value" => self::encodeValue($sejour_id, $encoding)))), 0x1001 => self::encodeValue($sejour_id, $encoding))); /* We add the field 0x0032,0x1032 if it's configured */ if ($dicom_config->send_0032_1032) { if (!array_key_exists(0x32, $data)) { $data[0x32] = array(); } $data[0x32][0x1032] = self::encodeValue($chir_name, $encoding); /* Add the field into the sequence of item 0x0040,0x0100 */ /*$data[0x0040][0x0100][0][] = array( "group_number" => 0x0032, "element_number" => 0x1032, "value" => self::encodeValue($chir_name, $encoding) );*/ } return $data; }
/** * Recording NDA * * @param CIdSante400 $NDA Object id400 * @param CSejour $sejour Admit * @param CInteropSender $sender Sender * * @return null|string null if successful otherwise returns and error message */ static function storeNDA(CIdSante400 $NDA, CSejour $sejour, CInteropSender $sender) { /* Gestion du numéroteur */ $group = new CGroups(); $group->load($sender->group_id); $group->loadConfigValues(); // Purge du NDA existant sur le séjour et on le remplace par le nouveau if ($sender->_configs["purge_idex_movements"]) { // On charge le NDA courant du séjour $sejour->loadNDA($sender->group_id); $ref_NDA = $sejour->_ref_NDA; if ($ref_NDA) { // Si le NDA actuel est identique à celui qu'on reçoit on ne fait rien if ($ref_NDA->id400 == $NDA->id400) { return; } // On passe le NDA courant en trash $ref_NDA->tag = CAppUI::conf("dPplanningOp CSejour tag_dossier_trash") . $ref_NDA->tag; $ref_NDA->_eai_sender_guid = $sender->_guid; $ref_NDA->store(); } // On sauvegarde le nouveau $NDA->tag = $sender->_tag_sejour; $NDA->object_class = "CSejour"; $NDA->object_id = $sejour->_id; $NDA->last_update = CMbDT::dateTime(); $NDA->_eai_sender_guid = $sender->_guid; return $NDA->store(); } // Génération du NDA ? // Non if (!$group->_configs["smp_idex_generator"]) { if (!$NDA->id400) { return null; } if ($sejour) { $NDA->object_id = $sejour->_id; } $NDA->last_update = CMbDT::dateTime(); $NDA->_eai_sender_guid = $sender->_guid; return $NDA->store(); } else { $NDA_temp = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, null, $sejour->_id); if ($NDA_temp->_id) { return; } // Pas de NDA passé if (!$NDA->id400) { if (!CIncrementer::generateIdex($sejour, $sender->_tag_sejour, $sender->group_id)) { return CAppUI::tr("CEAISejour-error-generate-idex"); } return null; } else { $incrementer = $sender->loadRefGroup()->loadDomainSupplier("CSejour"); if ($incrementer && $NDA->id400 < $incrementer->range_min || $NDA->id400 > $incrementer->range_max) { return CAppUI::tr("CEAISejour-idex-not-in-the-range"); } $NDA->object_id = $sejour->_id; $NDA->last_update = CMbDT::dateTime(); $NDA->_eai_sender_guid = $sender->_guid; return $NDA->store(); } } }
/** * 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; }