/**
  * Get NK1 segment
  *
  * @param DOMNode  $node       Node
  * @param CPatient $newPatient Person
  *
  * @return void
  */
 function getNK1(DOMNode $node, CPatient $newPatient)
 {
     $sender = $this->_ref_sender;
     $NK1_2 = $this->queryNode("NK1.2", $node);
     $nom = $this->queryTextNode("XPN.1/FN.1", $NK1_2);
     $prenom = $this->queryTextNode("XPN.2", $NK1_2);
     if ($prenom == "") {
         $prenom = null;
     }
     $parente = $this->queryTextNode("NK1.3/CE.1", $node);
     $parente_autre = null;
     if ($parente == "OTH") {
         $parente_autre = $this->queryTextNode("NK1.3/CE.2", $node);
     }
     $NK1_4 = $this->queryNode("NK1.4", $node);
     $adresse = $this->queryTextNode("XAD.1/SAD.1", $NK1_4);
     $cp = $this->queryTextNode("XAD.5", $NK1_4);
     $ville = $this->queryTextNode("XAD.3", $NK1_4);
     $NK1_5 = $this->queryNodes("NK1.5", $node)->item(0);
     $tel = null;
     if ($NK1_5) {
         $tel = $this->queryTextNode("XTN.12", $NK1_5);
         if (!$tel) {
             $tel = $this->queryTextNode("XTN.1", $NK1_5);
         }
     }
     $relation = $this->queryTextNode("NK1.7/CE.1", $node);
     $relation_autre = null;
     if ($relation == "O") {
         $relation_autre = $this->queryTextNode("NK1.7/CE.2", $node);
     }
     $corres_patient = new CCorrespondantPatient();
     $corres_patient->patient_id = $newPatient->_id;
     $corres_patient->nom = $nom;
     $corres_patient->prenom = $prenom;
     $corres_patient->loadMatchingObjectEsc();
     $corres_patient->adresse = $adresse;
     $corres_patient->cp = $cp;
     $corres_patient->ville = $ville;
     $corres_patient->tel = $tel;
     $corres_patient->parente = CHL7v2TableEntry::mapFrom("63", $parente);
     $corres_patient->parente_autre = $parente_autre;
     $corres_patient->relation = CHL7v2TableEntry::mapFrom("131", $relation);
     $corres_patient->relation_autre = $relation_autre;
     // Notifier les autres destinataires autre que le sender
     $corres_patient->_eai_sender_guid = $sender->_guid;
     $corres_patient->store();
 }
 /**
  * Récupération du segment GT1
  *
  * @param DOMNode $node     Node
  * @param CSejour $newVenue Admit
  *
  * @return void
  */
 function getGT1(DOMNode $node, CSejour $newVenue)
 {
     if (!$newVenue->_id) {
         return;
     }
     $patient = $newVenue->_ref_patient;
     if (!$patient->_id) {
         return;
     }
     $GT1_2 = $this->queryTextNode("GT1.2/CX.1", $node);
     $GT1_3 = $this->queryNode("GT1.3", $node);
     $nom = $this->queryTextNode("XPN.1/FN.1", $GT1_3);
     $prenom = $this->queryTextNode("XPN.2", $GT1_3);
     if ($prenom == "") {
         $prenom = null;
     }
     $GT1_5 = $this->queryNode("GT1.5", $node);
     $adresse = $this->queryTextNode("XAD.1/SAD.1", $GT1_5);
     $ville = $this->queryTextNode("XAD.3", $GT1_5);
     $cp = $this->queryTextNode("XAD.5", $GT1_5);
     $GT1_6 = $this->queryNodes("GT1.6", $node);
     $tel = null;
     $ean = null;
     $ean_base = null;
     foreach ($GT1_6 as $_GT1_6) {
         if (!$tel) {
             $tel = $this->queryTextNode("XTN.12", $_GT1_6);
         }
         if (!$tel) {
             $tel = $this->queryTextNode("XTN.1", $_GT1_6);
         }
         $XTN_4 = $this->queryTextNode("XTN.4", $_GT1_6);
         // EAN base => Ean Dest
         if (preg_match('/^Ean Dest=(\\d+)$/', $XTN_4, $matches) === 1) {
             $ean_base = CMbArray::get($matches, 1);
         }
         // EAN => Code Ean
         if (preg_match('/^Code Ean=(\\d+)$/', $XTN_4, $matches) === 1) {
             $ean = CMbArray::get($matches, 1);
         }
     }
     $GT1_13 = $this->queryTextNode("GT1.13", $node);
     $GT1_14 = $this->queryTextNode("GT1.14", $node);
     $corres_patient = new CCorrespondantPatient();
     $where = array();
     $where["patient_id"] = " = '{$patient->_id}'";
     if ($nom) {
         $where["nom"] = " = '{$nom}'";
     }
     if ($prenom) {
         $where["prenom"] = " = '{$prenom}'";
     }
     $where["relation"] = " = 'assurance'";
     $now = CMbDT::date();
     $next = CMbDT::date("+ 1 DAY");
     $where["date_debut"] = " <= '{$now}' AND IFNULL(date_fin, '{$next}') >= '{$now}'";
     $corres_patient->loadObject($where);
     if (!$corres_patient->_id) {
         $corres_patient->patient_id = $patient->_id;
         $corres_patient->nom = $nom;
         $corres_patient->relation = "assurance";
     }
     $corres_patient->prenom = $prenom;
     $corres_patient->adresse = $adresse;
     $corres_patient->cp = $cp;
     $corres_patient->ville = $ville;
     $corres_patient->tel = $tel;
     $corres_patient->ean = $ean;
     $corres_patient->ean_base = $ean_base;
     if ($ean) {
         $where = array("patient_id" => "IS NULL", "relation" => "= 'assurance'", "ean" => "= '{$ean}'");
         $assurance = new CCorrespondantPatient();
         $assurance->loadObject($where);
         $corres_patient->type_pec = $assurance->type_pec;
     }
     if ($GT1_13) {
         $corres_patient->date_debut = CMbDT::date($GT1_13);
     }
     if ($GT1_14) {
         $corres_patient->date_fin = CMbDT::date($GT1_14);
     }
     $sender = $this->_ref_sender;
     // Notifier les autres destinataires autre que le sender
     $corres_patient->_eai_sender_guid = $sender->_guid;
     if ($msg = $corres_patient->store()) {
         $corres_patient->repair();
         $corres_patient->_eai_sender_guid = $sender->_guid;
         $corres_patient->store();
     }
 }
Ejemplo n.º 3
0
 $corres->relation = "assurance";
 $corres->loadMatchingObject();
 if ($corres->_id) {
     //update
     $corres->nom = stripslashes($results[$i]["nom"]);
     $corres->adresse = $results[$i]["rue"];
     $corres->cp = $results[$i]["cp"];
     $corres->ville = $results[$i]["localite"];
     $corres->type_pec = $results[$i]["pec"];
     $corres->surnom = $results[$i]["surnom"];
     $corres->parente = "autre";
     $corres->parente_autre = "assurance";
     if ($corres->ean == "" || $corres->nom == "") {
         $msg = "CCorrespondant-import-missing1";
     } else {
         $msg = $corres->store();
         if (!$msg) {
             $msg = "update";
         }
     }
     if ($msg) {
         CAppUI::setMsg($msg, UI_MSG_WARNING);
         $results[$i]["error"] = $msg;
         $i++;
         continue;
     }
 } else {
     // create
     $corres->nom = stripslashes($results[$i]["nom"]);
     $corres->adresse = $results[$i]["rue"];
     $corres->cp = $results[$i]["cp"];