/**
  * Handle acknowledgment
  *
  * @param string $ack_hl7 HL7 acknowledgment
  *
  * @return DOMDocument
  */
 function handle($ack_hl7)
 {
     $this->message = new CHL7v2Message();
     $this->message->parse($ack_hl7);
     $this->dom_message = $this->message->toXML();
     return $this->dom_message;
 }
Ejemplo n.º 2
0
 /**
  * Build
  *
  * @param CHL7Acknowledgment $object Object
  *
  * @return void
  */
 function build($object)
 {
     // Création du message HL7
     $this->message = new CHL7v2Message();
     $this->message->version = $this->version;
     $this->message->name = $this->msg_codes;
     $message = $this->_exchange_hl7v2->_message;
     $hl7_message_initiator = new CHL7v2Message();
     $hl7_message_initiator->parse($message);
     $this->message->_hl7_message_initiator = $hl7_message_initiator;
     // Message Header
     $this->addMSH();
     // Message Acknowledgment
     $this->addMSA($object);
     // Error
     $trigger_event = $object->event;
     // Validation error
     if ($errors = $trigger_event->message->errors) {
         foreach ($errors as $_error) {
             $this->addERR($object, $_error);
         }
     }
     // ORC
     // OBR
 }
Ejemplo n.º 3
0
 /**
  * @see parent::getValue()
  */
 function getValue($object, $smarty = null, $params = array())
 {
     $value = $object->{$this->fieldName};
     if (isset($params["advanced"]) && $params["advanced"]) {
         $message = new CHL7v2Message();
         $message->parse($value);
         return $message->flatten(true);
     }
     return CHL7v2Message::highlight($value);
 }
 /**
  * Read HL7 file
  * @param $fileName Filename
  */
 function readFile($fileName)
 {
     $message = new CHL7v2Message();
     try {
         $fileContents = file_get_contents($fileName);
         $message->parse($fileContents);
     } catch (Exception $e) {
         exceptionHandler($e);
         return;
     }
     return $message;
 }
 /**
  * Handle event A46
  *
  * @param CHL7Acknowledgment $ack     Acknowledgment
  * @param CPatient           $patient Person
  * @param array              $data    Data
  *
  * @return string
  */
 function handleA46(CHL7Acknowledgment $ack, CPatient $patient, $data)
 {
     $handle_mode = CHL7v2Message::$handle_mode;
     CHL7v2Message::$handle_mode = "simple";
     $msg = $this->handleA47($ack, $patient, $data);
     CHL7v2Message::$handle_mode = $handle_mode;
     return $msg;
 }
/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
$message_string = CValue::post("message");
if (!$message_string) {
    return;
}
$message_string = stripslashes($message_string);
CValue::setSession("message", $message_string);
try {
    $message = new CHL7v2Message();
    $message->parse($message_string);
    $message->_errors_msg = !$message->isOK(CHL7v2Error::E_ERROR);
    $message->_warnings_msg = !$message->isOK(CHL7v2Error::E_WARNING);
    $message->_xml = CMbString::highlightCode("xml", $message->toXML()->saveXML());
} catch (CHL7v2Exception $e) {
    CAppUI::stepMessage(UI_MSG_ERROR, $e->getMessage() . " (" . $e->extraData . ")");
    return;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("message", $message);
$smarty->assign("key", "input");
$smarty->display("inc_display_hl7v2_message.tpl");
Ejemplo n.º 7
0
 /**
  * Get message encoding
  *
  * @return string|void
  */
 function getEncoding()
 {
     return $this->_message_object->getEncoding();
 }
Ejemplo n.º 8
0
$extension = $exchange_source->fileextension;
$ftp = new CFTP();
$ftp->init($exchange_source);
$ftp->connect();
if (!($list = $ftp->getListFiles($ftp->fileprefix))) {
    CAppUI::stepAjax("Le répertoire ne contient aucun fichier", UI_MSG_ERROR);
}
$messages = array();
foreach ($list as $filepath) {
    if (substr($filepath, -strlen($extension)) == $extension) {
        $filename = tempnam("", "hl7");
        $ftp->getFile($filepath, $filename);
        $hl7v2_reader = new CHL7v2Reader();
        $message = $hl7v2_reader->readFile($filename);
        if (!$message) {
            $message = new CHL7v2Message();
        }
        $message->filename = basename($filepath);
        $message->_errors_msg = !$message->isOK(CHL7v2Error::E_ERROR);
        $message->_warnings_msg = !$message->isOK(CHL7v2Error::E_WARNING);
        $message->_xml = CMbString::highlightCode("xml", $message->toXML()->saveXML());
        $messages[] = $message;
        unlink($filename);
    } else {
        // $ftp->delFile($filepath);
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("messages", $messages);
$smarty->display("inc_read_hl7v2_files.tpl");
Ejemplo n.º 9
0
 static function resetHandleMode()
 {
     self::$handle_mode = "normal";
 }
$message = "QBP";
$code = "Q23";
$patient = new CPatient();
$iti_handler = new CITIDelegatedHandler();
if (!$iti_handler->isMessageSupported($transaction, $message, $code, $receiver_hl7v2)) {
    CAppUI::stepAjax("No receiver supports this", UI_MSG_WARNING);
    return;
}
$patient->_receiver = $receiver_hl7v2;
$patient->_patient_identifier_list = array("person_id_number" => $person_id_number, "person_namespace_id" => $person_namespace_id, "person_universal_id" => $person_universal_id, "person_universal_id_type" => $person_universal_id_type, "person_identifier_type_code" => $person_identifier_type_code);
$patient->_domains_returned = array("domains_returned_namespace_id" => $domains_returned_namespace_id, "domains_returned_universal_id" => $domains_returned_universal_id, "domains_returned_universal_id_type" => $domains_returned_universal_id_type);
// Envoi de l'évènement
$ack_data = $iti_handler->sendITI($profil, $transaction, $message, $code, $patient);
$objects = array();
if ($ack_data) {
    $hl7_message = new CHL7v2Message();
    $hl7_message->parse($ack_data);
    $xml = $hl7_message->toXML();
    $xpath = new DOMXPath($xml);
    // Patient
    $_pids = $xpath->query("//PID");
    foreach ($_pids as $_element) {
        $ids = $xpath->query("PID.3", $_element);
        $_ids = array();
        foreach ($ids as $_id) {
            $_domain_parts = array();
            foreach ($xpath->query("CX.4/*", $_id) as $_domain_part) {
                $_domain_parts[] = $_domain_part->nodeValue;
            }
            $_ids[] = array("id" => $xpath->query("CX.1", $_id)->item(0)->nodeValue, "domain" => $_domain_parts);
        }
 /**
  * Send event
  *
  * @param CHL7v2Event $evenement Event type
  * @param CMbObject   $mbObject  Object
  *
  * @return null|string
  *
  * @throws CMbException
  */
 function sendEvent($evenement, CMbObject $mbObject)
 {
     $evenement->_receiver = $this;
     // build_mode = Mode simplifié lors de la génération du message
     $this->loadConfigValues();
     CHL7v2Message::setBuildMode($this->_configs["build_mode"]);
     $evenement->build($mbObject);
     CHL7v2Message::resetBuildMode();
     if (!($msg = $evenement->flatten())) {
         return null;
     }
     $exchange = $evenement->_exchange_hl7v2;
     // Si l'échange est invalide
     if (!$exchange->message_valide) {
         return null;
     }
     // Si on n'est pas en synchrone
     if (!$this->synchronous) {
         return null;
     }
     // Si on n'a pas d'IPP et NDA
     if ($exchange->master_idex_missing) {
         return null;
     }
     $evt = $this->getEventMessage($evenement->profil);
     $source = CExchangeSource::get("{$this->_guid}-{$evt}");
     if (!$source->_id || !$source->active) {
         return null;
     }
     if ($this->_configs["encoding"] == "UTF-8") {
         $msg = utf8_encode($msg);
     }
     $source->setData($msg, null, $exchange);
     try {
         $source->send();
     } catch (Exception $e) {
         throw new CMbException("CExchangeSource-no-response");
     }
     $exchange->date_echange = CMbDT::dateTime();
     $ack_data = $source->getACQ();
     if (!$ack_data) {
         $exchange->store();
         return null;
     }
     $data_format = CIHE::getEvent($exchange);
     $ack = new CHL7v2Acknowledgment($data_format);
     $ack->handle($ack_data);
     $exchange->date_echange = CMbDT::dateTime();
     $exchange->statut_acquittement = $ack->getStatutAcknowledgment();
     $exchange->acquittement_valide = $ack->message->isOK(CHL7v2Error::E_ERROR) ? 1 : 0;
     $exchange->_acquittement = $ack_data;
     $exchange->store();
     return $ack_data;
 }
Ejemplo n.º 12
0
$msg = new CHL7v2Message();
$msg->version = "2.5";
$msg->name = "ADT_A08";
//$msg->fieldSeparator = "a";
//$msg->componentSeparator = "b";
//$msg->subcomponentSeparator = "e";
//$msg->repetitionSeparator = "c";
//$msg->escapeCharacter = "d";
$segment = CHL7v2Segment::create("MSH", $msg);
$data = array(null, null, "Mediboard", "Mediboard_finess", "no_receiver", null, CMbDT::dateTime(), null, null, "Msg ctrl id", "A", null, 15, null, null, null, null, "8859/1", null, null, null);
$segment->fill($data);
$msg->appendChild($segment);
$segment = CHL7v2Segment::create("PID", $msg);
$data = array(0 => 1, 1 => null, 2 => array(0 => array(0 => '323241', 1 => null, 2 => null, 3 => array(0 => 'Mediboard', 1 => '1.2.250.1.2.3.4', 2 => 'OpenXtrem'), 4 => 'RI'), 1 => array(0 => 'fgfg', 1 => null, 2 => null, 3 => array(0 => null, 1 => '1.2.250.1.213.1.4.2', 2 => 'ISO'), 4 => 'INS-C', 5 => null, 6 => '1946-10-17')), 3 => null, 4 => array(0 => array(0 => 'EZZHJ', 1 => 'Rtaso', 2 => 'qldax', 3 => null, 4 => 'dr', 5 => null, 6 => 'D', 7 => 'A'), 1 => array(0 => 'MEBJO', 1 => 'Rtaso', 2 => 'qldax', 3 => null, 4 => 'dr', 5 => null, 6 => 'L', 7 => 'A')), 5 => null, 6 => '1987-09-24', 7 => 'F', 8 => null, 9 => null, 10 => array(0 => array(0 => "adresse test \r\n \\ | & ^ ~", 1 => null, 2 => 'rtckkljfgrw', 3 => null, 4 => '4294967295', 5 => null, 6 => 'H'), 1 => array(0 => null, 1 => null, 2 => 'vlfxif', 3 => null, 4 => '40048', 5 => '000', 6 => 'BR')), 11 => null, 12 => array(0 => array(0 => '43502', 1 => 'PRN', 2 => 'PH'), 1 => array(0 => '42287', 1 => 'ORN', 2 => 'CP'), 2 => array(0 => 'oezym', 1 => 'ORN', 2 => 'PH')), 13 => null, 14 => null, 15 => null, 16 => null, 17 => null, 18 => null, 19 => null, 20 => null, 21 => null, 22 => null, 23 => null, 24 => null, 25 => null, 26 => null, 27 => null, 28 => '1905-05-06', 29 => 'Y');
$segment->fill($data);
$msg->appendChild($segment);
$msg->validate();
foreach ($msg->errors as $error) {
    mbTrace(@$error->entity->getPathString(), CAppUI::tr("CHL7v2Exception-" . $error->code) . " - " . $error->data);
}
echo "Généré";
echo $msg->flatten(true);
$message_str = $msg->flatten();
echo "Parsé";
$msg2 = new CHL7v2Message();
$msg2->parse($message_str);
$msg2->validate();
foreach ($msg2->errors as $error) {
    mbTrace(@$error->entity->getPathString(), CAppUI::tr("CHL7v2Exception-" . $error->code) . " - " . $error->data);
}
echo $msg2->flatten(true);
Ejemplo n.º 13
0
 /**
  * Event
  *
  * @param CExchangeDataFormat $data_format Data format
  *
  * @return null|string
  */
 function event(CExchangeDataFormat $data_format)
 {
     $msg = $data_format->_message;
     /** @var CHL7v2Event $evt */
     $evt = $data_format->_family_message;
     $evt->_data_format = $data_format;
     // Récupération des informations du message
     /** @var CHL7v2MessageXML $dom_evt */
     $dom_evt = $evt->handle($msg);
     $dom_evt->_is_i18n = $evt->_is_i18n;
     try {
         // Création de l'échange
         $exchange_hl7v2 = new CExchangeHL7v2();
         $exchange_hl7v2->load($data_format->_exchange_id);
         // Récupération des données du segment MSH
         $data = $dom_evt->getMSHEvenementXML();
         // Gestion de l'acquittement
         $ack = $dom_evt->getEventACK($evt);
         $ack->message_control_id = $data['identifiantMessage'];
         // Message non supporté pour cet utilisateur
         $evt_class = CHL7Event::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;
             }
             $exchange_hl7v2->populateExchange($data_format, $evt);
             $exchange_hl7v2->loadRefsInteropActor();
             $exchange_hl7v2->populateErrorExchange(null, $evt);
             $ack->_ref_exchange_hl7v2 = $exchange_hl7v2;
             $msgAck = $ack->generateAcknowledgment("AR", "E001", "201");
             $exchange_hl7v2->populateErrorExchange($ack);
             return $msgAck;
         }
         $sender = $data_format->_ref_sender;
         $sender->getConfigs($data_format);
         // Acquittement d'erreur d'un document XML recu non valide
         if (!$sender->_configs["bypass_validating"] && !$evt->message->isOK(CHL7v2Error::E_ERROR)) {
             $exchange_hl7v2->populateExchange($data_format, $evt);
             $exchange_hl7v2->loadRefsInteropActor();
             $exchange_hl7v2->populateErrorExchange(null, $evt);
             $ack->_ref_exchange_hl7v2 = $exchange_hl7v2;
             $msgAck = $ack->generateAcknowledgment("AR", "E002", "207");
             $exchange_hl7v2->populateErrorExchange($ack);
             return $msgAck;
         }
         $exchange_hl7v2->populateExchange($data_format, $evt);
         $exchange_hl7v2->message_valide = 1;
         // Gestion des notifications ?
         if (!$exchange_hl7v2->_id) {
             $exchange_hl7v2->date_production = CMbDT::dateTime();
             $exchange_hl7v2->identifiant_emetteur = $data['identifiantMessage'];
         }
         $exchange_hl7v2->store();
         // Pas de traitement du message
         if (!$data_format->_to_treatment) {
             return;
         }
         $exchange_hl7v2->loadRefsInteropActor();
         // Chargement des configs de l'expéditeur
         $sender = $exchange_hl7v2->_ref_sender;
         $sender->getConfigs($data_format);
         if (!$dom_evt->checkApplicationAndFacility($data, $sender)) {
             return;
         }
         if (!empty($sender->_configs["handle_mode"])) {
             CHL7v2Message::setHandleMode($sender->_configs["handle_mode"]);
         }
         $dom_evt->_ref_exchange_hl7v2 = $exchange_hl7v2;
         $ack->_ref_exchange_hl7v2 = $exchange_hl7v2;
         // Message PAM / DEC / PDQ / SWF
         $msgAck = self::handleEvent($exchange_hl7v2, $dom_evt, $ack, $data);
         CHL7v2Message::resetBuildMode();
     } catch (Exception $e) {
         $exchange_hl7v2->populateExchange($data_format, $evt);
         $exchange_hl7v2->loadRefsInteropActor();
         $exchange_hl7v2->populateErrorExchange(null, $evt);
         $ack = new CHL7v2Acknowledgment($evt);
         $ack->message_control_id = isset($data['identifiantMessage']) ? $data['identifiantMessage'] : "000000000";
         $ack->_ref_exchange_hl7v2 = $exchange_hl7v2;
         $msgAck = $ack->generateAcknowledgment("AR", "E003", "207", "E", $e->getMessage());
         $exchange_hl7v2->populateErrorExchange($ack);
         CHL7v2Message::resetBuildMode();
     }
     return $msgAck;
 }
Ejemplo n.º 14
0
 /**
  * Build
  *
  * @param CHL7Acknowledgment $object Object
  *
  * @return void
  */
 function build($object)
 {
     // Création du message HL7
     $this->message = new CHL7v2Message();
     $this->message->version = $this->version;
     $this->message->name = $this->msg_codes;
     $message = $this->_exchange_hl7v2->_message;
     $hl7_message_initiator = new CHL7v2Message();
     $hl7_message_initiator->parse($message);
     $this->message->_hl7_message_initiator = $hl7_message_initiator;
     // Message Header
     $this->addMSH();
     // Message Acknowledgment
     $this->addMSA($object);
     // Error
     $trigger_event = $object->event;
     // Validation error
     if ($errors = $trigger_event->message->errors) {
         foreach ($errors as $_error) {
             $this->addERR($object, $_error);
         }
     }
     // Error unrecognized domain
     if ($object->QPD8_error) {
         $error = new CHL7v2Error();
         $error->code = CHL7v2Exception::UNKNOWN_DOMAINS_RETURNED;
         $error->location = array("QPD", 1, 8, 1);
         $this->addERR($object, $error);
     }
     // Query Acknowledgment
     $this->addQAK($object->objects);
     // Query Parameter Definition
     $this->addQPD();
     $i = 1;
     if (!$object->objects) {
         return;
     }
     // Results
     foreach ($object->objects as $_object) {
         if ($_object instanceof CPatient) {
             $_object->domains = $object->domains;
             $this->addPID($_object, $i);
             $i++;
         }
         if ($_object instanceof CSejour) {
             $_object->domains = $object->domains;
             $patient = $_object->loadRefPatient();
             $patient->domains = $object->domains;
             $patient->_sejour = $_object;
             $this->addPID($patient, $i);
             $this->addPV1($_object, $i);
             $this->addPV2($_object, $i);
             $i++;
         }
     }
     $last = end($object->objects);
     if ($last && isset($last->_incremental_query)) {
         $last->_pointer = $last->_id;
         $this->addDSC($last);
     }
 }
Ejemplo n.º 15
0
         try {
             $_exchange->reprocessing();
         } catch (CMbException $e) {
             $e->stepAjax(UI_MSG_WARNING);
         }
         if (!$_exchange->_id) {
             CAppUI::stepAjax("CExchangeAny-msg-delete", UI_MSG_ALERT);
         }
         CAppUI::stepAjax("CExchangeDataFormat-reprocessed");
     }
     break;
 case "detect_collision":
     $collisions = array();
     foreach ($exchanges as $_exchange) {
         if ($_exchange instanceof CExchangeHL7v2) {
             $hl7_message = new CHL7v2Message();
             $hl7_message->parse($_exchange->_message);
             $xml = $hl7_message->toXML(null, false);
             $PV1 = $xml->queryNode("PV1");
             $PV2 = $xml->queryNode("PV2");
             $sejour = new CSejour();
             $sejour->load($_exchange->object_id);
             $sejour_hl7 = new CSejour();
             $sejour_hl7->entree_prevue = $xml->queryTextNode("PV2.8/TS.1", $PV2);
             $sejour_hl7->entree_reelle = $xml->queryTextNode("PV1.44/TS.1", $PV1);
             $sejour_hl7->sortie_prevue = $xml->queryTextNode("PV2.9/TS.1", $PV2);
             $sejour_hl7->sortie_reelle = $xml->queryTextNode("PV1.45/TS.1", $PV1);
             $collisions[] = array("hl7" => $sejour_hl7, "mb" => $sejour);
         }
     }
     $smarty->assign("collisions", $collisions);
Ejemplo n.º 16
0
                $result = $dt->{$method}($from, $dummy_field);
            } catch (Exception $e) {
                $result = $e;
            }
            $color = $result === $to || $result instanceof Exception && $to == null ? 'green' : 'red';
            $value = $result instanceof Exception ? $result->getMessage() : var_export($result, true);
            echo "<pre style='text-indent: 3em; color:{$color}'>'{$from}' => {$value} (expected " . var_export($to, true) . ")</pre>\n";
        }
    }
}
echo "<h1>Escape sequences</h1>";
function pre($str)
{
    return "<pre>{$str}</pre>";
}
$message = new CHL7v2Message();
$message->initEscapeSequences();
$escaped = 'START \\F\\ \\S\\ \\T\\ \\E\\ \\R\\ END';
$unescaped = $message->unescape($escaped);
echo pre("escaped: " . $escaped);
echo pre("escaped unescaped: " . $unescaped);
echo pre("escaped unescaped escaped: " . $message->escape($unescaped));
$ascii = 'ASCII escape \\X41\\ ';
echo pre($ascii);
echo pre($message->unescape($ascii));
$unicode = 'Unicode escape \\M2764\\ ';
echo pre($unicode);
echo pre($message->unescape($unicode));
$format = 'test \\H\\I\'m strong\\N\\ test \\.br\\ new line';
echo pre($format);
echo pre($message->format($format));
Ejemplo n.º 17
0
<?php

/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision: 15455 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
$er7 = CValue::post("er7");
$query = CValue::post("query");
$hl7_message = new CHL7v2Message();
$hl7_message->parse($er7);
$xml = $hl7_message->toXML();
if ($query) {
    $xpath = new CMbXPath($xml);
    $results = @$xpath->query("//{$query}");
    $nodes = array();
    // Création du template
    $smarty = new CSmartyDP();
    if ($results) {
        foreach ($results as $result) {
            $nodes[] = CMbString::highlightCode("xml", $xml->saveXML($result));
        }
    }
    $smarty->assign("nodes", $nodes);
    $smarty->display("inc_er7_xml_result.tpl");
} else {
    ob_clean();
    header("Content-Type: text/xml");
Ejemplo n.º 18
0
 public function setQueryParametersParticipantObjectQuery()
 {
     $qpd = $this->hl7_msg->getSegmentByName('QPD');
     $participant_object_query = $this->msg_xml->addElement($this->query_parameters, 'ParticipantObjectQuery', base64_encode($qpd->data));
     $this->query_parameters_participant_object_query = $participant_object_query;
 }
Ejemplo n.º 19
0
 */
$er7 = CValue::post("er7");
$exchange_id = CValue::post("exchange_id");
$exchange = new CExchangeHL7v2();
$exchange->load($exchange_id);
$exchange->loadRefsInteropActor();
if ($exchange->receiver_id) {
    /** @var CInteropReceiver $actor */
    $actor = $exchange->_ref_receiver;
    $actor->loadConfigValues();
} else {
    /** @var CInteropSender $actor */
    $actor = $exchange->_ref_sender;
    $actor->getConfigs($exchange);
}
$hl7_message = new CHL7v2Message();
$hl7_message->parse($er7);
/** @var CHL7v2MessageXML $xml */
$xml = $hl7_message->toXML(null, false);
$MSH = $xml->queryNode("MSH");
$EVN = $xml->queryNode("EVN");
$PID = $xml->queryNode("PID");
$PV1 = $xml->queryNode("PV1");
$PV2 = $xml->queryNode("PV2");
$ZBE = $xml->queryNode("ZBE");
$IPP = $NDA = null;
$data = array();
$data["personIdentifiers"] = $xml->getPersonIdentifiers("PID.3", $PID, $actor);
$data["admitIdentifiers"] = $xml->getAdmitIdentifiers($PV1, $actor);
$names = array("nom" => "", "nom_jeune_fille" => "");
$prenom = null;
Ejemplo n.º 20
0
 $nda = $xml->queryNode("PV1.19", $PV1);
 if (!$ipp || $ipp && $ipp->nodeValue == "waiting" || (!$nda || $nda && $nda->nodeValue == "waiting")) {
     CHL7v2Message::setBuildMode($receiver->_configs["build_mode"]);
     $data_format->build($object);
     CHL7v2Message::resetBuildMode();
     $data_format->flatten();
     if (!$data_format->message->isOK(CHL7v2Error::E_ERROR)) {
         $_exchange->date_echange = "";
         $_exchange->store();
         continue;
     }
 }
 if ($_exchange->code != "A40" && (!$ipp && !$ipp->nodeValue || $ipp->nodeValue == "0" || ($_exchange->sous_type != "ITI30" || $_exchange->sous_type == "ITI30" && $_exchange->code == "A08") && !$nda && empty($nda->nodeValue))) {
     CHL7v2Message::setBuildMode($receiver->_configs["build_mode"]);
     $data_format->build($object);
     CHL7v2Message::resetBuildMode();
     $data_format->flatten();
     if (!$data_format->message->isOK(CHL7v2Error::E_ERROR)) {
         $_exchange->date_echange = "";
         $_exchange->store();
         continue;
     }
 }
 $evt = $receiver->getEventMessage($data_format->profil);
 $source = CExchangeSource::get("{$receiver->_guid}-{$evt}");
 if (!$source->_id || !$source->active) {
     new CMbException("Source inactive");
 }
 $msg = $data_format->msg_hl7 ? $data_format->msg_hl7 : $_exchange->_message;
 if ($receiver->_configs["encoding"] == "UTF-8") {
     $msg = utf8_encode($msg);