trigger_error("Not a main <tr> DOM Node", E_USER_WARNING); $xpath_screwed = true; break; } // Création du médecin if (!array_key_exists($ndx, $medecins)) { $medecins[$ndx] = new CMedecin(); } $medecin =& $medecins[$ndx]; $medecin->type = "medecin"; $xpath2 = new CMbXPath($doc); switch ($mod) { case 0: // Nom du médecin $query = "td[2]/span[1]"; $nom_prenom = $xpath2->queryTextNode($query, $nodeMainTr); preg_match('/^\\s*(.+)\\s+([^\\s]+)\\s*$/', $nom_prenom, $matches); $medecin->nom = $matches[1]; $medecin->prenom = $matches[2]; // RPPS $query = "td[2]/strong[1]"; $medecin->rpps = $xpath2->queryTextNode($query, $nodeMainTr); break; case 1: // Disciplines qualifiantes // Le champ discipline exercée peut ne pas être renseigné. $query = "td[2]/strong"; $medecin->disciplines = $xpath2->query($query, $nodeMainTr)->item(0)->nextSibling ? $xpath2->query($query, $nodeMainTr)->item(0)->nextSibling->nodeValue : ""; break; case 2: $query = "td[2]";
/** * Query text node * * @param string $query Query * @param CHL7v2DOMElement $contextNode Context * * @return string */ function queryTextNode($query, CHL7v2DOMElement $contextNode = null) { $xpath = new CMbXPath($this); return $xpath->queryTextNode($query, $contextNode); }
/** * 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); } } }
/** * Fonction de création des classes voc * * @return string */ static function createClass() { //On charge le XSD contenant le vocabulaire $dom = new CMbXMLDocument("UTF-8"); $dom->load("modules/cda/resources/voc.xsd"); //On enregistre le namespace utiliser dans le XSD $xpath = new CMbXPath($dom); $xpath->registerNamespace("xs", "http://www.w3.org/2001/XMLSchema"); //On recherche tous les simpleTypes et les complexTypes $nodeList = $xpath->query("//xs:complexType|xs:simpleType"); $listvoc = array(); //On parcours la liste que retourne la requête XPATH foreach ($nodeList as $_node) { //On récupère le nom du type $name = $xpath->queryAttributNode(".", $_node, "name"); //On récupère la documentation lié au type $documentation = $xpath->queryTextNode(".//xs:documentation", $_node); //On récupère les unions du type $union = $xpath->queryUniqueNode(".//xs:union", $_node); //On vérifie l'existence d'union if ($union) { $union = $xpath->queryAttributNode(".", $union, "memberTypes"); } //on récupère les énumérations $enumeration = $xpath->query(".//xs:enumeration", $_node); $listEnumeration = array(); //on met chaque enumeration dans un tableau foreach ($enumeration as $_enumeration) { array_push($listEnumeration, $xpath->queryAttributNode(".", $_enumeration, "value")); } //On créé un tableau rassemblant toutes les informations concernant un voc $listvoc[] = array("name" => $name, "documentation" => $documentation, "union" => $union, "enumeration" => $listEnumeration); } //On met le lien du dossier contenant les voc $cheminBase = "modules/cda/classes/datatypes/voc/"; //On parcours les voc foreach ($listvoc as $_voc) { //On affecte comme nom de fichier CCDA et le nom du voc $nameFichier = "CCDA" . $_voc["name"] . ".class.php"; $smarty = new CSmartyDP(); $smarty->assign("documentation", $_voc["documentation"]); $smarty->assign("name", $_voc["name"]); $smarty->assign("enumeration", self::formatArray($_voc["enumeration"])); $union = self::formatArray(array()); //on vérifie la présence d'union if (CMbArray::get($_voc, "union")) { $union = self::formatArray(explode(" ", $_voc["union"])); } $smarty->assign("union", $union); //on récupère la classe former $data = $smarty->fetch("defaultClassVoc.tpl"); //on créé le fichier file_put_contents($cheminBase . $nameFichier, str_replace("\r\n", "\n", $data)); } return true; }
function queryTextNode($query) { $xpath = new CMbXPath($this->ownerDocument); return $xpath->queryTextNode($query, $this); }