function event(CExchangeDataFormat $data_format) { $msg = $data_format->_message; /** @var CHPREvent $evt */ $evt = $data_format->_family_message; $evt->_data_format = $data_format; // Récupération des informations du message $dom_evt = $evt->handle($msg); try { // Création de l'échange $exchange_hpr = new CEchangeHprim21(); $exchange_hpr->load($data_format->_exchange_id); // Récupération des données du segment H $data = $dom_evt->getHEvenementXML(); // Gestion de l'acquittement $ack = new CHPrim21Acknowledgment($evt); $evt_class = CHPREvent::getEventClass($evt); if (!in_array($evt_class, $data_format->_messages_supported_class)) { $data_format->_ref_sender->_delete_file = false; // Pas de création d'échange dans le cas : // * où l'on ne souhaite pas traiter le message // * où le sender n'enregistre pas les messages non pris en charge if (!$data_format->_to_treatment || !$data_format->_ref_sender->save_unsupported_message) { return null; } $exchange_hpr->populateExchange($data_format, $evt); $exchange_hpr->loadRefsInteropActor(); $exchange_hpr->populateErrorExchange(null, $evt); $ack->_ref_exchange_hpr = $exchange_hpr; $msgAck = $ack->generateAcknowledgment("AR", "E001", "201"); $exchange_hpr->populateErrorExchange($ack); return $msgAck; } // Acquittement d'erreur d'un document XML recu non valide $exchange_hpr->populateExchange($data_format, $evt); $exchange_hpr->message_valide = 1; // Gestion des notifications ? if (!$exchange_hpr->_id) { $exchange_hpr->date_production = $data['dateHeureProduction']; $exchange_hpr->nom_fichier = $data['filename']; } $exchange_hpr->store(); // Pas de traitement du message if (!$data_format->_to_treatment) { return null; } $exchange_hpr->loadRefsInteropActor(); // Chargement des configs de l'expéditeur $sender = $exchange_hpr->_ref_sender; $sender->getConfigs($data_format); $dom_evt->_ref_exchange_hpr = $exchange_hpr; $ack->_ref_exchange_hpr = $exchange_hpr; // Message ADM / REG $msgAck = self::handleEvent($data, $exchange_hpr, $dom_evt, $ack); } catch (Exception $e) { } return $msgAck; }
/** * Reprocessing exchange * * @throws CMbException * * @return void */ function reprocessing() { if ($this->reprocess >= CAppUI::conf("eai max_reprocess_retries")) { throw new CMbException("CExchangeDataFormat-too_many_retries", $this->reprocess); } $sender = new $this->sender_class(); $sender->load($this->sender_id); // Suppression de l'identifiant dans le cas où l'échange repasse pour éviter un autre échange avec // un identifiant forcé if ($this instanceof CExchangeAny) { $exchange_id = $this->_id; $this->_id = null; } if (!($ack_data = CEAIDispatcher::dispatch($this->_message, $sender, $this->_id))) { // Dans le cas d'un échange générique on le supprime if ($this instanceof CExchangeAny) { $this->_id = $exchange_id; if ($msg = $this->delete()) { throw new CMbException("CMbObject-msg-delete-failed", $msg); } } } $this->load($this->_id); // Dans le cas d'un échange générique on le supprime if ($this instanceof CExchangeAny) { $this->_id = $exchange_id; if ($msg = $this->delete()) { throw new CMbException("CMbObject-msg-delete-failed", $msg); } } if (!$ack_data) { return; } $ack_valid = 0; if ($this instanceof CEchangeHprim) { $dom_evt = $sender->_data_format->_family_message->getHPrimXMLEvenements($this->_message); $ack = CHPrimXMLAcquittements::getAcquittementEvenementXML($dom_evt); $ack->loadXML($ack_data); $ack_valid = $ack->schemaValidate(null, false, false); if ($ack_valid) { $this->statut_acquittement = $ack->getStatutAcquittement(); } } if ($this instanceof CEchangeHprim21) { $ack = new CHPrim21Acknowledgment($sender->_data_format->_family_message); $ack->handle($ack_data); $this->statut_acquittement = $ack->getStatutAcknowledgment(); $ack_valid = $ack->message->isOK(CHL7v2Error::E_ERROR); } if ($this instanceof CExchangeHL7v2) { $evt = $sender->_data_format->_family_message; $evt->_data_format = $sender->_data_format; // Récupération des informations du message - CHL7v2MessageXML $dom_evt = $evt->handle($this->_message); $dom_evt->_is_i18n = $evt->_is_i18n; $ack = $dom_evt->getEventACK($evt); $ack->handle($ack_data); $this->statut_acquittement = $ack->getStatutAcknowledgment(); $ack_valid = $ack->message->isOK(CHL7v2Error::E_ERROR); } $this->date_echange = CMbDT::dateTime(); $this->acquittement_valide = $ack_valid ? 1 : 0; $this->_acquittement = $ack_data; $this->reprocess++; if ($msg = $this->store()) { throw new CMbException("CMbObject-msg-store-failed", $msg); } }
function setAckP(CHPrim21Acknowledgment $ack, $errors, CMbObject $object = null) { $ack->generateAcknowledgment("P", $errors, $object); return $this->populateExchangeACK($ack, $object); }