/** * Event method * * @param string $message Message * @param int $actor_id Actor id * * @return string ACK */ function event($message, $actor_id = null) { $actor = null; $sender_soap = new CSenderSOAP(); if ($actor_id) { $sender_soap->load($actor_id); } else { $sender_soap->user_id = CUser::get()->_id; $sender_soap->loadMatchingObject(); } if ($sender_soap->_id) { $actor = $sender_soap; } // Dispatch EAI if (!($acq = CEAIDispatcher::dispatch($message, $actor))) { return utf8_encode(CEAIDispatcher::$xml_error); } return $acq; }
/** * The action DT-2 * * Decode the P-DATA-TF PDU * * @param mixed $datas The datas * * @return string * * @see DICOM Standard PS 3.8 Section 9.2 */ protected function doDT2($datas) { $ack = CEAIDispatcher::dispatch(array("msg" => $datas, "pres_contexts" => $this->_presentation_contexts), $this->_ref_actor, $this->dicom_exchange_id); if (is_array($ack) && array_key_exists("exchange_id", $ack)) { if (!$this->dicom_exchange_id) { $this->dicom_exchange_id = $ack["exchange_id"]; } if (array_key_exists("event", $ack) && array_key_exists("datas", $ack)) { return $this->handleEvent($ack["event"], $ack["datas"]); } } return ''; }
$source->renameFile($_old_filepath, $_filepath); try { $message = $source->getData($_filepath); if (!$message) { continue; } } catch (CMbException $e) { $source->renameFile($_filepath, $_old_filepath); $e->stepAjax(UI_MSG_WARNING); continue; } $source->_receive_filename = $path_info["filename"]; // Dispatch EAI if ($acq = CEAIDispatcher::dispatch($message, $sender, null, $to_treatment)) { try { CEAIDispatcher::createFileACK($acq, $sender); } catch (Exception $e) { if ($sender->_delete_file !== false) { $source->delFile($_filepath); if ($fileextension_write_end) { $source->delFile("{$_filepath_no_ext}.{$fileextension_write_end}"); } } else { CAppUI::stepAjax("CEAIDispatcher-error_deleting_file", UI_MSG_WARNING); } CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR); } } if (!$sender->delete_file) { // Rename file $source->renameFile($_filepath, $_old_filepath);
/** * 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); } }
$ERR->build($error); $message->appendChild($ERR);*/ $now = CMbDT::format(null, "%Y%m%d%H%M%S"); $ACK = "MSH|^~\\&|" . CAppUI::conf("hl7 sending_application") . "|" . CAppUI::conf("hl7 sending_facility") . "|||{$now}||ACK|{$now}|P|2.5||||||" . CHL7v2TableEntry::mapTo("211", CApp::$encoding); $ACK .= "\r" . "MSA|AR|{$now}"; $ACK .= "\r" . "ERR||0^0|207|E|E200^Acteur inconnu|||||||"; ob_clean(); echo $ACK; CApp::rip(); } /** @var CSenderMLLP $sender_mllp */ $sender_mllp = CMbObject::loadFromGuid($source_mllp->name); // Dispatch EAI try { $ack = CEAIDispatcher::dispatch($message, $sender_mllp); } catch (CHL7v2Exception $e) { $sender_mllp->getConfigs(new CExchangeHL7v2()); $configs = $sender_mllp->_configs; $now = CMbDT::format(null, "%Y%m%d%H%M%S"); $sending_app = CAppUI::conf("hl7 sending_application"); $sending_fac = CAppUI::conf("hl7 sending_facility"); $recv_app = isset($configs["receiving_application"]) ? $configs["receiving_application"] : $sender_mllp->nom; $recv_fac = isset($configs["receiving_facility"]) ? $configs["receiving_facility"] : $sender_mllp->nom; $ack = "MSH|^~\\&|{$sending_app}|{$sending_fac}|{$recv_app}|{$recv_fac}|{$now}||ACK^R01^ACK|{$now}|P|2.6||||||" . CHL7v2TableEntry::mapTo("211", CApp::$encoding); $ack .= "\r\n" . "MSA|CR|{$now}"; $ack .= "\r\n" . "ERR||0^0|207|E|E200^" . $e->getMessage() . "|||||||"; } ob_clean(); echo $ack; CApp::rip();
/** * Dispatch error * * @param string $data Data * @param CInteropSender $actor Actor data * * @return bool Always false */ static function dispatchError($data, $actor = null) { foreach (self::$errors as $_error) { CAppUI::stepAjax($_error, UI_MSG_WARNING); } // Création d'un échange Any $exchange_any = new CExchangeAny(); $exchange_any->date_production = CMbDT::dateTime(); if ($actor) { $exchange_any->sender_id = $actor->_id; $exchange_any->sender_class = $actor->_class; $exchange_any->group_id = $actor->group_id; } $exchange_any->type = "None"; $exchange_any->_message = $data; $exchange_any->store(); // Création d'un message de retour $dom = new CMbXMLDocument(); $mb_errors = $dom->addElement($dom, "MB_Dispatch_Errors"); foreach (self::$errors as $_error) { $dom->addElement($mb_errors, "MB_Dispatch_Error", $_error); } self::$xml_error = $dom->saveXML(); return false; }