/**
  * 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::getHPrimXMLEvenements
  */
 static function getHPrimXMLEvenements($messageServeurActivitePmsi)
 {
     $hprimxmldoc = new CMbXMLDocument();
     $hprimxmldoc->loadXML($messageServeurActivitePmsi);
     $xpath = new CMbXPath($hprimxmldoc);
     $event = $xpath->queryUniqueNode("/*/*[2]");
     $dom_evt = new CHPrimXMLEvenementsServeurActivitePmsi();
     if ($nodeName = $event->nodeName) {
         $dom_evt = new CHPrimXMLEventServeurActivitePmsi::$evenements[$nodeName]();
     }
     $dom_evt->loadXML($messageServeurActivitePmsi);
     return $dom_evt;
 }
Beispiel #3
0
 /**
  * @see parent::getMultipleTextNodes
  */
 function getMultipleTextNodes($query, DOMNode $contextNode = null, $implode = false)
 {
     $array = array();
     $query = utf8_encode($query);
     $nodeList = $contextNode ? parent::query($query, $contextNode) : parent::query($query);
     foreach ($nodeList as $n) {
         $array[] = utf8_decode($n->nodeValue);
     }
     return $implode ? implode("\n", $array) : $array;
 }
 /**
  * @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;
 }
 function __construct(DOMDocument $dom)
 {
     parent::__construct($dom);
     $this->registerNamespace("hpr", "urn:hpr-org:v2xml");
 }
 /**
  * Query unique node
  *
  * @param string           $query       Query
  * @param CHL7v2DOMElement $contextNode Context
  *
  * @return CHL7v2DOMElement
  */
 function queryUniqueNode($query, CHL7v2DOMElement $contextNode = null)
 {
     $xpath = new CMbXPath($this);
     return $xpath->queryUniqueNode($query, $contextNode);
 }
Beispiel #7
0
 /**
  * Retourne une entrée dans un jeux de valeur
  *
  * @param String $name Nom du jeux de valeur
  * @param String $code Identifiant de la valeur voulut
  *
  * @return array
  */
 static function loadEntryJV($name, $code)
 {
     $path = "modules/xds/resources/jeux_de_valeurs/{$name}";
     $dom = new CMbXMLDocument();
     $dom->load($path);
     $xpath = new CMbXPath($dom);
     $node = $xpath->queryUniqueNode("//line[@id='{$code}']");
     $valeur = array("id" => $xpath->queryAttributNode(".", $node, "id"), "oid" => $xpath->queryAttributNode(".", $node, "oid"), "name" => $xpath->queryAttributNode(".", $node, "name"));
     return $valeur;
 }
Beispiel #8
0
if (!empty($file) && ($contents = file_get_contents($file['tmp_name']))) {
    $actor = CMbObject::loadFromGuid($actor_guid);
    $format_config = CMbObject::loadFromGuid($format_config_guid);
    if (!$format_config->sender_class || !$format_config->sender_id) {
        $format_config->sender_class = $actor->_class;
        $format_config->sender_id = $actor->_id;
    }
    $dom = new CMbXMLDocument();
    $dom->loadXML($contents);
    $root_name = $dom->documentElement->nodeName;
    $fields = $format_config->getPlainFields();
    unset($fields[$format_config->_spec->key]);
    unset($fields["sender_id"]);
    unset($fields["sender_class"]);
    if ($root_name == $format_config->_class) {
        $xpath = new CMbXPath($dom);
        $nodeList = $xpath->query("//{$root_name}/*");
        $array_configs = array();
        foreach ($nodeList as $_node) {
            $config = $xpath->getValueAttributNode($_node, "config");
            $value = $xpath->getValueAttributNode($_node, "value");
            $array_configs[$config] = $value;
        }
        if ($count = array_diff_key($array_configs, $fields)) {
            CAppUI::setMsg("Trop de données ('" . count($array_configs) . "') par rapport aux \n        champs de l'objet ('" . count($fields) . "')", UI_MSG_ERROR);
        } else {
            foreach ($array_configs as $key => $value) {
                $format_config->{$key} = $value;
                if ($msg = $format_config->store()) {
                    CAppUI::setMsg("Erreur lors de l'import de la configuration : " . $msg, UI_MSG_ERROR);
                } else {
 /**
  * Return the result count
  *
  * @return string
  */
 function getResultCount()
 {
     return $this->xpath->queryAttributNode(".", null, "totalResultCount");
 }
 /**
  * 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>");
             }
         }
     }
 }
 function queryTextNode($query)
 {
     $xpath = new CMbXPath($this->ownerDocument);
     return $xpath->queryTextNode($query, $this);
 }
 /**
  * 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;
 }
Beispiel #13
0
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @link     http://www.mediboard.org */
CApp::setTimeLimit(360);
// Récupération du fichier
$file = CValue::files('datafile');
$passphrase = CValue::post('passphrase');
if (!$passphrase || !$file) {
    $msg = "Le fichier et la phrase de passe doivent être saisis.";
    CAppUI::stepAjax($msg, UI_MSG_ERROR);
}
$user = CMediusers::get();
$dom = new CMbXMLDocument();
if (!$dom->load($file['tmp_name'])) {
    CAppUI::redirect('m=passwordKeeper&a=vw_import_keeper&dialog=1');
}
$xpath = new CMbXPath($dom);
$keeperNode = $xpath->queryUniqueNode("/keeper");
$keeperName = $keeperNode->getAttribute("name");
if ($keeperNode->nodeName != "keeper") {
    CAppUI::redirect('m=passwordKeeper&a=vw_import_keeper&dialog=1');
}
$keeper = new CPasswordKeeper();
$keeper->keeper_name = $keeperName;
$keeper->_passphrase = $passphrase;
$keeper->user_id = $user->_id;
$keeper->store();
$categoryNodes = $xpath->query("//category");
foreach ($categoryNodes as $_categoryNode) {
    $category = new CPasswordCategory();
    $category->category_name = $_categoryNode->getAttribute("name");
    $category->password_keeper_id = $keeper->_id;
Beispiel #14
0
 /**
  * @see parent::__construct()
  */
 function __construct($xml)
 {
     parent::__construct($xml);
     $this->registerNamespace("rim", "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0");
     $this->registerNamespace("xds", "urn:ihe:iti:xds-b:2007");
 }
Beispiel #15
0
 /**
  * @see parent::__construct()
  */
 function __construct($xml)
 {
     parent::__construct($xml);
     $this->registerNamespace("cda", "urn:hl7-org:v3");
 }
Beispiel #16
0
/* $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");
    echo $xml->saveXML();
 /**
  * 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);
         }
     }
 }
 /**
  * Construct
  *
  * @param DOMDocument $dom DOM
  *
  * @retun CHL7v2MessageXPath
  */
 function __construct(DOMDocument $dom)
 {
     parent::__construct($dom);
     $this->registerNamespace("hl7", "urn:hl7-org:v3");
 }
Beispiel #19
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;
 }
Beispiel #20
0
 $medecins = array();
 foreach ($xpath->query($query) as $key => $nodeMainTr) {
     $ndx = intval($key / 4);
     $mod = intval($key % 4);
     if ($nodeMainTr->nodeName != "tr") {
         trigger_error("Not a main &lt;tr&gt; 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é.
 /**
  * @see parent::createExtrinsicObject
  */
 function createExtrinsicObject($id, $lid = null)
 {
     /** @var CCDAFactory $factory */
     $factory = $this->mbObject;
     $cla_id =& $this->id_classification;
     $ei_id =& $this->id_external;
     $patient_id = $this->patient_id;
     $ins = $this->ins_patient;
     $hide_patient = $this->hide_patient;
     $hide_ps = $this->hide_ps;
     $service = $factory->service_event;
     $industry = $factory->industry_code;
     $praticien = $factory->practicien;
     $this->appendNameDocument($id);
     $extrinsic = new CXDSExtrinsicObject($id, "text/xml", $lid);
     //effectiveTime en UTC
     if ($factory->date_creation) {
         $extrinsic->setSlot("creationTime", array(CXDSTools::getTimeUtc($factory->date_creation)));
     }
     //languageCode
     $extrinsic->setSlot("languageCode", array($factory->langage));
     //legalAuthenticator XCN
     $legalAuthenticator = $this->getPerson($praticien);
     $extrinsic->setSlot("legalAuthenticator", array($legalAuthenticator));
     //documentationOf/serviceEvent/effectiveTime/low en UTC
     if ($service["time_start"]) {
         $extrinsic->setSlot("serviceStartTime", array(CXDSTools::getTimeUtc($service["time_start"])));
     }
     //documentationOf/serviceEvent/effectiveTime/high en UTC
     if ($service["time_stop"]) {
         $extrinsic->setSlot("serviceStopTime", array(CXDSTools::getTimeUtc($service["time_stop"])));
     }
     //recordTarget/patientRole/id
     $extrinsic->setSlot("sourcePatientId", array($patient_id));
     //recordtarget/patientRole
     $extrinsic->setSlot("sourcePatientInfo", $this->getSourcepatientInfo($factory->patient));
     //title
     $extrinsic->setTitle($factory->nom);
     //Auteur du document
     $document = new CXDSDocumentEntryAuthor("cla{$cla_id}", $id);
     $this->setClaId();
     //author/assignedAuthor
     $author = $this->getPerson($praticien);
     $document->setAuthorPerson(array($author));
     //author/assignedAuthor/code
     $spec = $praticien->loadRefOtherSpec();
     if ($spec->libelle) {
         $document->setAuthorSpecialty(array("{$spec->code}^{$spec->libelle}^{$spec->oid}"));
     }
     //author/assignedAuthor/representedOrganization - si absent, ne pas renseigner
     //si nom pas présent - champ vide
     //si id nullflavor alors 6-7-10 vide
     $author_organization = $praticien->loadRefFunction()->loadRefGroup();
     if ($author_organization->_id) {
         $institution = CXDSTools::getXONetablissement($author_organization->text, CXDSTools::getIdEtablissement(false, $author_organization));
         $document->setAuthorInstitution(array($institution));
     }
     $extrinsic->appendDocumentEntryAuthor($document);
     //confidentialityCode
     $confidentialite = $factory->confidentialite;
     $confid = new CXDSConfidentiality("cla{$cla_id}", $id, $confidentialite["code"]);
     $confid->setCodingScheme(array($confidentialite["codeSystem"]));
     $confid->setName($confidentialite["displayName"]);
     $extrinsic->appendConfidentiality($confid);
     if ($hide_ps) {
         $confid2 = CXDSConfidentiality::getMasquagePS("cla{$cla_id}", $id);
         $this->setClaId();
         $extrinsic->appendConfidentiality($confid2);
     }
     if ($hide_patient) {
         $confid3 = CXDSConfidentiality::getMasquagePatient("cla{$cla_id}", $id);
         $this->setClaId();
         $extrinsic->appendConfidentiality($confid3);
     }
     //documentationOf/serviceEvent/code - table de correspondance
     if (!$service["nullflavor"]) {
         $eventSystem = $service["oid"];
         $eventCode = $service["code"];
         switch ($service["type_code"]) {
             case "cim10":
                 $cim10 = CCodeCIM10::get($eventCode);
                 $libelle = $cim10->libelle;
                 break;
             case "ccam":
                 $ccam = CDatedCodeCCAM::get($eventCode);
                 $libelle = $ccam->libelleCourt;
                 break;
             default:
         }
         $event = new CXDSEventCodeList("cla{$cla_id}", $id, $eventCode);
         $this->setClaId();
         $event->setCodingScheme(array($eventSystem));
         $event->setName($libelle);
         $extrinsic->appendEventCodeList($event);
     }
     //En fonction d'un corps structuré
     $type = $factory->mediaType;
     $codingScheme = "";
     $name = "";
     $formatCode = "";
     if ($type) {
         $entry = CXDSTools::loadEntryDocument("Document_non_structure.xml", $type);
         $codingScheme = $entry["codingScheme"];
         $name = $entry["contenu"];
         $formatCode = $entry["formatCode"];
     } else {
         $correspondance = new DOMDocument();
         $correspondance->load("modules/xds/resources/Document_structure.xml");
         $correspondanceXpath = new CMbXPath($correspondance);
         $type = $factory->templateId;
         foreach ($type as $_type) {
             $type_id = $correspondanceXpath->queryAttributNode(".", $_type, "root");
             $node = $correspondanceXpath->queryUniqueNode("/mappage/line[@id='{$type_id}']");
             if (!$node) {
                 continue;
             }
             $codingScheme = $correspondanceXpath->queryAttributNode("./xds", $node, "codingScheme");
             $name = $correspondanceXpath->queryAttributNode("./mediaType", $node, "contenu");
             $formatCode = $correspondanceXpath->queryAttributNode("./xds", $node, "formatCode");
         }
         if (!$codingScheme) {
             $node = $correspondanceXpath->queryUniqueNode("/mappage/line[@id='*']");
             $codingScheme = $correspondanceXpath->queryAttributNode("./xds", $node, "codingScheme");
             $name = $correspondanceXpath->queryAttributNode("./mediaType", $node, "contenu");
             $formatCode = $correspondanceXpath->queryAttributNode("./xds", $node, "formatCode");
         }
     }
     $format = new CXDSFormat("cla{$cla_id}", $id, $formatCode);
     $this->setClaId();
     $format->setCodingScheme(array($codingScheme));
     $format->setName($name);
     $extrinsic->setFormat($format);
     //componentOf/encompassingEncounter/location/healthCareFacility/code
     $healtcare = $factory->healt_care;
     $healt = new CXDSHealthcareFacilityType("cla{$cla_id}", $id, $healtcare["code"]);
     $this->setClaId();
     $healt->setCodingScheme(array($healtcare["codeSystem"]));
     $healt->setName($healtcare["displayName"]);
     $extrinsic->setHealthcareFacilityType($healt);
     $this->health_care_facility = $this->health_care_facility ? $this->health_care_facility : $healtcare;
     //documentationOf/serviceEvent/performer/assignedEntity/representedOrganization/standardIndustryClassCode
     $pratice = new CXDSPracticeSetting("cla{$cla_id}", $id, $industry["code"]);
     $this->setClaId();
     $pratice->setCodingScheme(array($industry["codeSystem"]));
     $pratice->setName($industry["displayName"]);
     $this->practice_setting = $this->practice_setting ? $this->practice_setting : $industry;
     $extrinsic->setPracticeSetting($pratice);
     //code
     $code = $factory->code;
     $type = new CXDSType("cla{$cla_id}", $id, $code["code"]);
     $this->setClaId();
     $type->setCodingScheme(array($code["codeSystem"]));
     $type->setName($code["displayName"]);
     $extrinsic->setType($type);
     //code - table de correspondance X04
     list($classCode, $oid, $name) = $this->getClassCodeFromCode($code["code"]);
     $classification = new CXDSClass("cla{$cla_id}", $id, $classCode);
     $this->setClaId();
     $classification->setCodingScheme(array($oid));
     $classification->setName($name);
     $extrinsic->setClass($classification);
     //recordTarget/patientRole/id
     $extrinsic->setPatientId("ei{$ei_id}", $id, $ins);
     $this->setEiId();
     //id - root
     $root = $factory->id_cda;
     $this->oid["extrinsic"] = $root;
     $extrinsic->setUniqueId("ei{$ei_id}", $id, $root);
     $this->setEiId();
     return $extrinsic;
 }