/**
  * Récupération des éléments Reponses de l'acquittement
  *
  * @return array
  */
 function getAcquittementReponsesServeurActivitePmsi()
 {
     $xpath = new CHPrimXPath($this);
     $statut = $xpath->queryAttributNode("/hprim:a{$this->acquittement}/hprim:enteteMessage", null, "statut");
     $query = "/hprim:{$this->evenement}/hprim:enteteMessageAcquittement";
     $enteteMessageAcquittement = $xpath->queryUniqueNode($query);
     $observations = array();
     if ($statut == "ok") {
         $d = array();
         $observations[] =& $d;
         $observation = $xpath->queryUniqueNode("hprim:observation", $enteteMessageAcquittement);
         $d['code'] = chunk_split($xpath->queryTextNode("hprim:code", $observation, "", false), 4, ' ');
         $d['libelle'] = $xpath->queryTextNode("hprim:libelle", $observation, "", false);
         $d['commentaire'] = $xpath->queryTextNode("hprim:commentaire", $observation, "", false);
     } else {
         $query = "/hprim:{$this->evenements}/hprim:reponses/*";
         $reponses = $xpath->query($query);
         foreach ($reponses as $_reponse) {
             $d = array();
             $observation = $xpath->queryUniqueNode("hprim:observations/hprim:observation", $_reponse);
             $d['code'] = chunk_split($xpath->queryTextNode("hprim:code", $observation, "", false), 4, ' ');
             $d['libelle'] = $xpath->queryTextNode("hprim:libelle", $observation, "", false);
             $d['commentaire'] = $xpath->queryTextNode("hprim:commentaire", $observation, "", false);
             $observations[] = $d;
         }
     }
     return $observations;
 }
 /**
  * Récupération de l'assuré
  *
  * @param DOMNode  $node      Node
  * @param CPatient $mbPatient Patient
  *
  * @return CPatient
  */
 static function getAssure(DOMNode $node, CPatient $mbPatient)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $immatriculation = $xpath->queryTextNode("hprim:immatriculation", $node);
     $mbPatient->matricule = $immatriculation;
     $mbPatient->assure_matricule = $immatriculation;
     $personne = $xpath->queryUniqueNode("hprim:personne", $node);
     if (!$personne) {
         return $mbPatient;
     }
     $sexe = $xpath->queryAttributNode("hprim:personne", $node, "sexe");
     $sexeConversion = array("M" => "m", "F" => "f");
     $mbPatient->assure_sexe = $sexeConversion[$sexe];
     $mbPatient->assure_nom = $xpath->queryTextNode("hprim:nomUsuel", $personne);
     $prenoms = $xpath->getMultipleTextNodes("hprim:prenoms/*", $personne);
     $mbPatient->assure_prenom = CMbArray::get($prenoms, 0);
     $mbPatient->assure_prenom_2 = CMbArray::get($prenoms, 1);
     $mbPatient->assure_prenom_3 = CMbArray::get($prenoms, 2);
     $mbPatient->assure_naissance = $xpath->queryTextNode("hprim:naissance", $personne);
     $elementDateNaissance = $xpath->queryUniqueNode("hprim:dateNaissance", $personne);
     $mbPatient->assure_naissance = $xpath->queryTextNode("hprim:date", $elementDateNaissance);
     $mbPatient->rang_beneficiaire = $xpath->queryTextNode("hprim:lienAssure", $node);
     $mbPatient->qual_beneficiaire = CValue::read(CPatient::$rangToQualBenef, $mbPatient->rang_beneficiaire);
     return $mbPatient;
 }
 /**
  * Mapping des actes NGAP
  *
  * @param DOMNode $node Node
  * @param array   $data Datas
  *
  * @return array
  */
 function mappingActeNGAP(DOMNode $node, $data)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $acteNGAP = array();
     $acteNGAP["code"] = $xpath->queryTextNode("hprim:lettreCle", $node);
     $acteNGAP["coefficient"] = $xpath->queryTextNode("hprim:coefficient", $node);
     $acteNGAP["quantite"] = $xpath->queryTextNode("hprim:quantite", $node);
     $acteNGAP["date"] = $xpath->queryTextNode("hprim:execute/hprim:date", $node);
     $acteNGAP["heure"] = $xpath->queryTextNode("hprim:execute/hprim:heure", $node);
     $acteNGAP["numero_dent"] = $xpath->queryTextNode("hprim:positionDentaire", $node);
     $acteNGAP["comment"] = $xpath->queryTextNode("hprim:commentaire", $node);
     $acteNGAP = array_merge($acteNGAP, $this->getMontant($node));
     $minoration = $xpath->queryUniqueNode("hprim:minorMajor/hprim:minoration", $node);
     $acteNGAP["minor_pct"] = $xpath->queryTextNode("hprim:pourcentage", $minoration);
     $acteNGAP["minor_coef"] = $xpath->queryTextNode("hprim:coefficient", $minoration);
     $majoration = $xpath->queryUniqueNode("hprim:minorMajor/hprim:majoration", $node);
     $acteNGAP["major_pct"] = $xpath->queryTextNode("hprim:pourcentage", $majoration);
     $acteNGAP["major_coef"] = $xpath->queryTextNode("hprim:coefficient", $majoration);
     $acteNGAP["facturable"] = $xpath->queryAttributNode(".", $node, "facturable");
     $acteNGAP["rapportExoneration"] = $xpath->queryAttributNode(".", $node, "rapportExoneration");
     $acteNGAP["executionNuit"] = $xpath->queryAttributNode(".", $node, "executionNuit");
     $acteNGAP["executionDimancheJourFerie"] = $xpath->queryAttributNode(".", $node, "executionDimancheJourFerie");
     $medecin = $xpath->query("hprim:prestataire/hprim:medecins/hprim:medecin", $node);
     $mediuser_id = $this->getMedecin($medecin->item(0));
     $idSourceActeNGAP = $this->getIdSource($node, false);
     $idCibleActeNGAP = $this->getIdCible($node, false);
     $action = $xpath->queryAttributNode(".", $node, "action");
     return array("idSourceIntervention" => $data['idSourceIntervention'], "idCibleIntervention" => $data['idCibleIntervention'], "idSourceActeNGAP" => $idSourceActeNGAP, "idCibleActeNGAP" => $idCibleActeNGAP, "action" => $action, "acteNGAP" => $acteNGAP, "executant_id" => $mediuser_id);
 }
 /**
  * Récupération des observations de l'acquittement patient
  *
  * @return array
  */
 function getAcquittementObservationPatients()
 {
     $xpath = new CHPrimXPath($this);
     $statut = $xpath->queryAttributNode("/hprim:acquittementsPatients/hprim:enteteMessageAcquittement", null, "statut");
     $query = "/hprim:acquittementsPatients/hprim:enteteMessageAcquittement";
     $enteteMessageAcquittement = $xpath->queryUniqueNode($query);
     $observations = array();
     if ($statut == "OK") {
         $d = array();
         $observations[] =& $d;
         $observation = $xpath->queryUniqueNode("hprim:observation", $enteteMessageAcquittement);
         $d['code'] = chunk_split($xpath->queryTextNode("hprim:code", $observation, "", false), 4, ' ');
         $d['libelle'] = $xpath->queryTextNode("hprim:libelle", $observation, "", false);
         $d['commentaire'] = $xpath->queryTextNode("hprim:commentaire", $observation, "", false);
     } else {
         $query = "/hprim:acquittementsPatients/hprim:erreursAvertissements/*";
         $erreursAvertissements = $xpath->query($query);
         foreach ($erreursAvertissements as $erreurAvertissement) {
             $d = array();
             $observation = $xpath->queryUniqueNode("hprim:observations/hprim:observation", $erreurAvertissement);
             $d['code'] = chunk_split($xpath->queryTextNode("hprim:code", $observation, "", false), 4, ' ');
             $d['libelle'] = $xpath->queryTextNode("hprim:libelle", $observation, "", false);
             $d['commentaire'] = $xpath->queryTextNode("hprim:commentaire", $observation, "", false);
             $observations[] = $d;
         }
     }
     return $observations;
 }
 /**
  * Return person
  *
  * @param DOMNode   $node       Node
  * @param CMbObject $mbPersonne Person
  *
  * @return CMbObject|CMediusers|CPatient
  */
 static function getPersonne(DOMNode $node, CMbObject $mbPersonne)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $civilite = $xpath->queryAttributNode("hprim:civiliteHprim", $node, "valeur");
     $civiliteHprimConversion = array("mme" => "mme", "mlle" => "mlle", "mr" => "m", "dr" => "dr", "pr" => "pr", "bb" => "enf", "enf" => "enf");
     $nom = $xpath->queryTextNode("hprim:nomUsuel", $node);
     $prenoms = $xpath->getMultipleTextNodes("hprim:prenoms/*", $node);
     $adresses = $xpath->queryUniqueNode("hprim:adresses", $node);
     $adresse = $xpath->queryUniqueNode("hprim:adresse", $adresses);
     $ligne = $xpath->getMultipleTextNodes("hprim:ligne", $adresse, true);
     $ville = $xpath->queryTextNode("hprim:ville", $adresse);
     $cp = $xpath->queryTextNode("hprim:codePostal", $adresse);
     if ($cp) {
         $cp = preg_replace("/[^0-9]/", "", $cp);
     }
     $telephones = $xpath->getMultipleTextNodes("hprim:telephones/*", $node);
     $email = $xpath->getFirstTextNode("hprim:emails/*", $node);
     if ($mbPersonne instanceof CPatient) {
         if ($civilite) {
             $mbPersonne->civilite = $civiliteHprimConversion[$civilite];
         } else {
             if ($mbPersonne->civilite == null) {
                 $mbPersonne->civilite = "guess";
             }
         }
         $mbPersonne->nom = $nom;
         $mbPersonne->nom_jeune_fille = $xpath->queryTextNode("hprim:nomNaissance", $node);
         $mbPersonne->prenom = CMbArray::get($prenoms, 0);
         $mbPersonne->prenom_2 = CMbArray::get($prenoms, 1);
         $mbPersonne->prenom_3 = CMbArray::get($prenoms, 2);
         $mbPersonne->adresse = $ligne;
         $mbPersonne->ville = $ville;
         $mbPersonne->pays_insee = $xpath->queryTextNode("hprim:pays", $adresse);
         $pays = new CPaysInsee();
         $pays->numerique = $mbPersonne->pays_insee;
         $pays->loadMatchingObject();
         $mbPersonne->pays = $pays->nom_fr;
         $mbPersonne->cp = $cp;
         $tel1 = $tel2 = null;
         if (isset($telephones[0])) {
             $tel1 = $telephones[0];
         }
         if (isset($telephones[1])) {
             $tel2 = $telephones[1];
         }
         $mbPersonne->tel = $tel1 != $mbPersonne->tel2 && strlen($tel1) <= 10 ? $tel1 : null;
         $mbPersonne->tel2 = $tel2 != $mbPersonne->tel && strlen($tel2) <= 10 ? $tel2 : null;
         if (strlen($tel1) > 10) {
             $mbPersonne->tel_autre = $tel1;
         }
         if (strlen($tel2) > 10) {
             $mbPersonne->tel_autre = $tel2;
         }
         $mbPersonne->email = $email;
     } elseif ($mbPersonne instanceof CMediusers) {
         $mbPersonne->_user_last_name = $nom;
         $mbPersonne->_user_first_name = CMbArray::get($prenoms, 0);
         $mbPersonne->_user_email = $email;
         $mbPersonne->_user_phone = CMbArray::get($telephones, 0);
         $mbPersonne->_user_adresse = $ligne;
         $mbPersonne->_user_cp = $cp;
         $mbPersonne->_user_ville = $ville;
     }
     return $mbPersonne;
 }