/**
  * @see parent::getAcknowledgment
  */
 function getAcknowledgment()
 {
     $dom = new CMbXMLDocument("UTF-8");
     $dom->loadXMLSafe($this->ack_data);
     $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("rs", "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0");
     $xpath->registerNamespace("rim", "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0");
     $status = $xpath->queryAttributNode(".", null, "status");
     if ($status === "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure") {
         $nodes = $xpath->query("//rs:RegistryErrorList/rs:RegistryError");
         $ack = array();
         foreach ($nodes as $_node) {
             $ack[] = array("status" => $xpath->queryAttributNode(".", $_node, "codeContext"), "context" => $xpath->queryAttributNode(".", $_node, "errorCode"));
         }
     } else {
         $nodes = $xpath->query("//rim:RegistryObjectList/rim:ObjectRef");
         $ack = array();
         foreach ($nodes as $_node) {
             $ack[] = array("status" => $xpath->queryAttributNode(".", $_node, "id"), "context" => "");
         }
     }
     return $ack;
 }
 /**
  * Execute the request
  *
  * @param string $request  Request to execute
  * @param string $location Webservice URL
  * @param string $action   Action
  * @param int    $version  SOAP version
  * @param int    $one_way  One way
  *
  * @see parent::__doRequest
  *
  * @return null|string
  * @throws CMbException
  */
 public function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     $ca_file = $this->ca_info;
     if ($this->use_tunnel) {
         $tunnel_exist = false;
         $tunnel_pass = CAppUI::conf("eai tunnel_pass");
         $tunnel_object = new CHTTPTunnelObject();
         $tunnels = $tunnel_object->loadActiveTunnel();
         foreach ($tunnels as $_tunnel) {
             if ($_tunnel->checkStatus()) {
                 $location = preg_replace("#[^/]*//[^/]*#", $_tunnel->address, $location);
                 $ca_file = $_tunnel->ca_file;
                 $tunnel_exist = true;
                 break;
             }
         }
         if (!$tunnel_exist && $tunnel_pass === "0") {
             throw new CMbException("Pas de tunnel actif");
         }
     }
     $response = null;
     if ($this->return_mode == "file") {
         $this->doRequestToFile($request, $location, $action, $ca_file);
         return "";
     } elseif ($this->xop_mode) {
         $response = $this->doRequestXOP($request, $location, $action, $ca_file);
     } else {
         $response = parent::__doRequest($request, $location, $action, $version, $one_way);
     }
     if ($this->return_mode == "normal") {
         return $response;
     }
     if (!$response) {
         return null;
     }
     $document = new CMbXMLDocument();
     $document->loadXMLSafe($response, null, true);
     $xpath = new CMbXPath($document);
     $documentElement = $document->documentElement;
     $xpath->registerNamespace($documentElement->prefix, $documentElement->namespaceURI);
     $body = $xpath->queryUniqueNode("/{$documentElement->prefix}:Envelope/{$documentElement->prefix}:Body");
     $new_document = new CMbXMLDocument("UTF-8");
     $new_document->appendChild($new_document->importNode($body->firstChild, true));
     $this->response_body = $new_document->saveXML();
     return $response;
 }
예제 #3
0
 /**
  * Valide le xml avec le schématron
  *
  * @param String $xml String
  *
  * @return String[]
  */
 static function validateSchematron($xml)
 {
     $baseDir = dirname(__FILE__) . "/../resources";
     $cmd = escapeshellarg("java");
     $styleSheet = "{$baseDir}/schematron/CI-SIS_StructurationCommuneCDAr2.xsl";
     $temp = tempnam("temp", "xml");
     file_put_contents($temp, $xml);
     $cmd = $cmd . " -jar {$baseDir}/saxon9he.jar -s:{$temp} -xsl:{$styleSheet}";
     $processorInstance = proc_open($cmd, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
     $processorResult = stream_get_contents($pipes[1]);
     $processorErrors = stream_get_contents($pipes[2]);
     proc_close($processorInstance);
     unlink($temp);
     $dom = new CMbXMLDocument();
     $dom->loadXMLSafe($processorResult);
     $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("svrl", "http://purl.oclc.org/dsdl/svrl");
     $nodeList = $xpath->query("//svrl:failed-assert");
     $tabErrors = array();
     if ($processorErrors) {
         $tabErrors[] = array("error" => $processorErrors, "location" => "System");
     }
     foreach ($nodeList as $_node) {
         $tabErrors[] = array("error" => utf8_decode($_node->textContent), "location" => $xpath->queryAttributNode(".", $_node, "location"));
     }
     return $tabErrors;
 }
 /**
  * Lecture du fichier XML associé au rejet
  *
  * @param string $content_file contenu du fichier
  * @param bool   $details      enregistrement des informations
  *
  * @return null
  */
 function readXML($content_file = null, $details = false)
 {
     if (!$content_file) {
         $file = $this->loadRefFile();
         $file->updateFormFields();
         $content_file = file_get_contents($file->_file_path);
     }
     $doc = new CMbXMLDocument("UTF-8");
     $doc->loadXMLSafe($content_file);
     $xpath = new CMbXPath($doc);
     $xpath->registerNamespace("invoice", "http://www.forum-datenaustausch.ch/invoice");
     $payload = $xpath->queryUniqueNode("//invoice:payload");
     $timestamp = $xpath->getValueAttributNode($payload, "response_timestamp");
     $this->date = strftime('%Y-%m-%d', $timestamp);
     $invoice = $xpath->queryUniqueNode("//invoice:invoice");
     $this->num_facture = $xpath->getValueAttributNode($invoice, "request_id");
     $this->_date_facture = $xpath->getValueAttributNode($invoice, "request_date");
     $insurance = $xpath->queryUniqueNode("//invoice:insurance");
     $ean_party = $xpath->getValueAttributNode($insurance, "ean_party");
     $corr = new CCorrespondantPatient();
     $corr->ean = $ean_party;
     $corr->loadMatchingObject();
     $this->name_assurance = $corr->nom;
     $patient = $xpath->queryUniqueNode("//invoice:patient");
     $this->_avs = $xpath->getValueAttributNode($patient, "ssn");
     if ($company = $xpath->queryUniqueNode("//invoice:contact/invoice:company")) {
         $this->_contact[] = $xpath->queryTextNode("invoice:companyname", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:department", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:subaddressing", $company);
         $postal = $xpath->queryUniqueNode("invoice:postal", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $company));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $company));
     }
     if ($employee = $xpath->queryUniqueNode("//invoice:contact/invoice:employee")) {
         $this->_contact[] = $xpath->getValueAttributNode($employee, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $employee) . " " . $xpath->queryTextNode("invoice:familyname", $employee);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $employee));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $employee));
     }
     if ($person = $xpath->queryUniqueNode("//invoice:contact/invoice:person")) {
         $this->_contact[] = $xpath->getValueAttributNode($person, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $person) . " " . $xpath->queryTextNode("invoice:familyname", $person);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:subaddressing", $person));
         $postal = $xpath->queryUniqueNode("invoice:postal", $person);
         $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $person));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $person));
     }
     $this->_contact = array_filter($this->_contact);
     $pending = $xpath->query("//invoice:pending");
     foreach ($pending as $_pending) {
         $explanation = $xpath->queryTextNode("invoice:explanation", $_pending);
         $this->motif_rejet = "{$explanation} \r\n";
         $this->_commentaire = $explanation;
         $this->_status_in = $xpath->getValueAttributNode($_pending, "status_in");
         $this->_status_out = $xpath->getValueAttributNode($_pending, "status_out");
         $nb_message = 0;
         $messages = $xpath->query("//invoice:message");
         foreach ($messages as $_message) {
             $code = $xpath->getValueAttributNode($_message, "code");
             $text = $xpath->getValueAttributNode($_message, "text");
             if (!$details) {
                 $this->motif_rejet .= "{$code}: {$text} \r\n";
             } else {
                 $this->_erreurs[$nb_message]['code'] = $code;
                 $this->_erreurs[$nb_message]['text'] = $text;
             }
             $nb_message++;
         }
         $this->_pending = 1;
     }
     $rejected = $xpath->query("//invoice:rejected");
     foreach ($rejected as $_rejected) {
         $explanation = $xpath->queryTextNode("invoice:explanation", $_rejected);
         $this->motif_rejet = "{$explanation} \r\n";
         $this->_commentaire = $explanation;
         $this->_status_in = $xpath->getValueAttributNode($_rejected, "status_in");
         $this->_status_out = $xpath->getValueAttributNode($_rejected, "status_out");
         $nb_message = 0;
         $messages = $xpath->query("//invoice:error");
         foreach ($messages as $_message) {
             $code = $xpath->getValueAttributNode($_message, "code");
             $text = $xpath->getValueAttributNode($_message, "text");
             if (!$details) {
                 $this->motif_rejet .= "{$code}: {$text} \r\n";
             } else {
                 $this->_erreurs[$nb_message]['code'] = $code;
                 $this->_erreurs[$nb_message]['text'] = $text;
             }
             if ($error_value = $xpath->getValueAttributNode($_message, "error_value")) {
                 $valid_value = $xpath->getValueAttributNode($_message, "valid_value");
                 if (!$details) {
                     $this->motif_rejet .= "({$error_value}/{$valid_value})";
                 } else {
                     $this->_erreurs[$nb_message]['error_value'] = $error_value;
                     $this->_erreurs[$nb_message]['valid_value'] = $valid_value;
                     $this->_erreurs[$nb_message]['record_id'] = $xpath->getValueAttributNode($_message, "record_id");
                 }
             }
             $nb_message++;
         }
     }
     if (!$details) {
         if ($msg = $this->store()) {
             mbTrace($msg);
         }
     }
 }