/**
  * Get acknowledgment status
  *
  * @return string
  */
 function getStatutAcknowledgment()
 {
     $dom = $this->dom;
     $this->xpath = $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");
     $this->status = substr($status, strrpos($status, ":") + 1);
     return $this->status;
 }
 /**
  * Get acknowledgment status
  *
  * @return string
  */
 function getStatutAcknowledgment()
 {
     $dom = $this->dom;
     $this->xpath = $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("rs", "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0");
     $xpath->registerNamespace("xds", "urn:ihe:iti:xds-b:2007");
     $xpath->registerNamespace("xop", "http://www.w3.org/2004/08/xop/include");
     $status = $xpath->queryAttributNode("/rs:RegistryResponse", null, "status");
     $this->status = substr($status, strrpos($status, ":") + 1);
     return $this->status;
 }
 /**
  * @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;
 }
 /**
  * Check service availability
  *
  * @throws CMbException
  *
  * @return void
  */
 public function checkServiceAvailability()
 {
     $url = $this->wsdl_url;
     if ($this->wsdl_original) {
         $url = $this->wsdl_original;
     }
     $xml = file_get_contents($url);
     $dom = new CMbXMLDocument();
     $dom->loadXML($xml);
     $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
     $xpath->registerNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
     $xpath->registerNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12");
     $login = CMbArray::get($this->options, "login");
     $password = CMbArray::get($this->options, "password");
     $service_nodes = $xpath->query("//wsdl:service");
     foreach ($service_nodes as $_service_node) {
         $service_name = $_service_node->getAttribute("name");
         $port_nodes = $xpath->query("wsdl:port", $_service_node);
         foreach ($port_nodes as $_port_node) {
             $address = $xpath->queryAttributNode("soap:address|soap12:address", $_port_node, "location");
             if (!$address) {
                 continue;
             }
             if ($login && $password) {
                 $address = str_replace("://", "://{$login}:{$password}@", $address);
             }
             // Url exist
             $url_exist = CHTTPClient::checkUrl($address, $this->check_option);
             if (!$url_exist) {
                 throw new CMbException("Service '{$service_name}' injoignable à l'adresse : <em>{$address}</em>");
             }
         }
     }
 }
Exemple #5
0
 /**
  * fonction permettant de créér la structure principal des classes d'un XSD
  *
  * @return bool
  */
 static function createClassFromXSD()
 {
     $pathXSD = "modules/cda/resources/POCD_MT000040.xsd";
     $pathDir = "modules/cda/classes/classesCDA/classesGenerate/";
     $dom = new CMbXMLDocument("UTF-8");
     $dom->load($pathXSD);
     $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("xs", "http://www.w3.org/2001/XMLSchema");
     $nodeList = $xpath->query("//xs:complexType[@name] | //xs:simpleType[@name]");
     foreach ($nodeList as $_node) {
         $tabVariable = array();
         $tabProps = array();
         /** @var DOMElement $_node */
         $elements = $_node->getElementsByTagName("element");
         $nodeAttributes = $_node->getElementsByTagName("attribute");
         $nameNode = $xpath->queryAttributNode(".", $_node, "name");
         $nameNode = str_replace(".", "_", $nameNode);
         list($tabVariable, $tabProps) = self::createPropsForElement($elements, $tabVariable, $tabProps);
         list($tabVariable, $tabProps) = self::createPropsForElement($nodeAttributes, $tabVariable, $tabProps);
         $smarty = new CSmartyDP();
         $smarty->assign("name", $nameNode);
         $smarty->assign("variables", $tabVariable);
         $smarty->assign("props", $tabProps);
         $data = $smarty->fetch("defaultClassCDA.tpl");
         file_put_contents($pathDir . "CCDA" . $nameNode . ".class.php", $data);
     }
     return true;
 }
 /**
  * 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);
         }
     }
 }
 /**
  * Transforme la classe en document XML
  *
  * @param null $nameParent String
  * @param null $namespace  String
  *
  * @return CCDADomDocument
  */
 function toXML($nameParent = null, $namespace = null)
 {
     $dom = new CCDADomDocument();
     //on affecte le nom de la classe comme noeud racine
     $name = $this->getNameClass();
     /**
      * Si le nom parent est spécifié, on utilisera ce nom pour le noeud racine
      */
     if (!empty($nameParent)) {
         $name = $nameParent;
     }
     //on créé le nom racine
     $baseXML = $dom->addElement($dom, $name, null, $namespace);
     //on récupère les specifications définie dans les props
     $spec = $this->getSpecs();
     //On parcours les specs
     foreach ($spec as $key => $value) {
         //on récupère une instance d'une classe stocké dans la variable
         /** @var CCDA_Datatype $classInstance */
         $classInstance = $this->{$key};
         //on effectue différente action selon ce qui est définir dans la prop XML
         switch ($value["xml"]) {
             case "attribute":
                 //On vérifie la présence d'une instance
                 if (empty($classInstance)) {
                     continue;
                 }
                 if ($key === "identifier") {
                     $key = "ID";
                 }
                 //On créé l'attribut
                 $dom->addAttribute($baseXML, $key, $classInstance->getData());
                 break;
             case "data":
                 //on insert la donnée avant tous les éléments
                 $dom->insertTextFirst($baseXML, $this->getData());
                 break;
             case "element":
                 //on vérifie l'existence d'une instance
                 if (empty($classInstance)) {
                     continue;
                 }
                 //on vérifie si l'instance est un tableau
                 if (is_array($classInstance)) {
                     //on parcours les différentes instance
                     /** @var CCDA_Datatype[] $classInstance */
                     foreach ($classInstance as $_class) {
                         //on récupère le code xml de l'instance en spécifiant le nom du noeud racine
                         $xmlClass = $_class->toXML($key, $namespace);
                         //on ajoute à notre document notre instance
                         $dom->importDOMDocument($baseXML, $xmlClass);
                     }
                 } else {
                     //on récupère le code xml de l'instance en spécifiant le nom du noeud racine
                     $xmlClass = $classInstance->toXML($key, $namespace);
                     //on ajoute à notre document notre instance
                     $dom->importDOMDocument($baseXML, $xmlClass);
                 }
                 break;
         }
         //si la propriété abstract est spécifié
         if (CMbArray::get($value, "abstract")) {
             //on vérifie l'existence d'une instance
             if (empty($classInstance)) {
                 continue;
             }
             //on cherche le noeud XML dans notre document
             $xpath = new CMbXPath($dom);
             if (!empty($namespace)) {
                 $xpath->registerNamespace("cda", $namespace);
                 $nodeKey = $xpath->queryUniqueNode("//cda:" . $key);
             } else {
                 $nodeKey = $xpath->queryUniqueNode("//" . $key);
             }
             if (is_array($classInstance)) {
                 foreach ($classInstance as $_class) {
                     /**
                      * on spécifie le type de l'élément (on cast)
                      */
                     $dom->castElement($nodeKey, $_class->getNameClass());
                 }
             } else {
                 /**
                  * on spécifie le type de l'élément (on cast)
                  */
                 $dom->castElement($nodeKey, $classInstance->getNameClass());
             }
         }
     }
     return $dom;
 }