/**
  * @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;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
Exemple #4
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;
 }
Exemple #5
0
 /**
  * Permet de de retourner la portion xml du noeud choisi par le nom dans le schéma spécifié
  *
  * @param String $name   String
  * @param String $schema String
  *
  * @return string
  */
 static function showNodeXSD($name, $schema)
 {
     $dom = new CMbXMLDocument();
     $dom->load($schema);
     $xpath = new CMbXPath($dom);
     $xpath->registerNamespace("xs", "http://www.w3.org/2001/XMLSchema");
     $node = $xpath->queryUniqueNode("//xs:simpleType[@name='" . $name . "']|//xs:complexType[@name='" . $name . "']");
     return $dom->saveXML($node);
 }
 /**
  * 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;
 }
 * @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;
    $category->store();
 /**
  * @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;
 }