/**
  * Handle event
  *
  * @param string $msg_hl7 HL7 message
  *
  * @return DOMDocument|void
  */
 function handle($msg_hl7)
 {
     $this->message = new CHL7v2Message();
     $ignored_fields = array();
     if ($this->_data_format) {
         $configs_format = $this->_data_format->_configs_format;
         if ($configs_format->ignore_fields) {
             $ignored_fields = preg_split("/\\s*,\\s*/", $configs_format->ignore_fields);
         }
         $strict = $configs_format->strict_segment_terminator;
         $this->message->strict_segment_terminator = $strict;
         if ($strict) {
             $terminator = $this->getSegmentTerminator($configs_format->segment_terminator);
             $this->message->segmentTerminator = $terminator;
         }
     }
     $this->message->ignored_fields = $ignored_fields;
     $this->message->parse($msg_hl7);
     $dom = $this->message->toXML(get_class($this), false, CApp::$encoding);
     $xpath = new CHL7v2MessageXPath($dom);
     foreach ($ignored_fields as $_ignore_field) {
         $query = "//{$_ignore_field}";
         $nodes = $xpath->query($query);
         foreach ($nodes as $_node) {
             $_node->parentNode->removeChild($_node);
         }
     }
     return $dom;
 }
 /**
  * Get the text of a node corresponding to an XPath
  *
  * @param string       $nodeName    The XPath to the node
  * @param DOMNode|null $contextNode The context node from which the XPath starts
  * @param boolean      $root        Is root node ?
  *
  * @return string
  */
 function queryTextNode($nodeName, DOMNode $contextNode, $root = false)
 {
     $xpath = new CHL7v2MessageXPath($contextNode ? $contextNode->ownerDocument : $this);
     return $xpath->queryTextNode($nodeName, $contextNode);
 }
 /**
  * Get acknowledgment status
  *
  * @return string
  */
 function getStatutAcknowledgment()
 {
     $xpath = new CHL7v2MessageXPath($this->dom_message);
     return $xpath->queryTextNode("//MSA/MSA.1");
 }
 /**
  * Get fields tree
  *
  * @param array  &$_datatypes        Datatypes
  * @param string $datatype_name      Datatype name
  * @param string $fullpath_component Fullpath
  *
  * @return array
  */
 function readDataTypeSchema(&$_datatypes, $datatype_name, $fullpath_component)
 {
     if (array_key_exists($datatype_name, CHDataType::$typesMap)) {
         return array();
     }
     $datatype_schema = $this->message->getSchema("composite", $datatype_name);
     $datatype_xpath = new CHL7v2MessageXPath($datatype_schema);
     $fields = $datatype_xpath->query("//field");
     foreach ($fields as $_field) {
         $_component_datatype = $datatype_xpath->queryTextNode("datatype", $_field);
         $children = array();
         $this->readDataTypeSchema($children, $_component_datatype, $fullpath_component);
         $_datatypes[] = array("name" => $_component_datatype, "fullpath" => "{$fullpath_component}/{$_component_datatype}", "datatype" => $_component_datatype, "children" => $children);
     }
 }