/**
  * Check similar person
  *
  * @param CPatient $recoveredPatient Person recovered
  * @param CPatient $newPatient       Person
  *
  * @return bool
  */
 function checkSimilarPatient(CPatient $recoveredPatient, CPatient $newPatient)
 {
     return $recoveredPatient->checkSimilar($newPatient->nom, $newPatient->prenom, false);
 }
 /**
  * Vérifier si les patients sont similaires
  *
  * @param CPatient $mbPatient  Patient
  * @param DOMNode  $xmlPatient Patient provenant des données XML
  *
  * @return string
  */
 function checkSimilarPatient(CPatient $mbPatient, $xmlPatient)
 {
     $sender = $this->_ref_sender;
     if (!$sender->_configs || isset($sender->_configs) && array_key_exists("check_similar", $sender->_configs) && !$sender->_configs["check_similar"]) {
         return null;
     }
     $xpath = new CHPrimXPath($xmlPatient->ownerDocument);
     // Création de l'element personnePhysique
     $personnePhysique = $xpath->queryUniqueNode("hprim:personnePhysique", $xmlPatient);
     $nom = $xpath->queryTextNode("hprim:nomUsuel", $personnePhysique);
     $prenoms = $xpath->getMultipleTextNodes("hprim:prenoms/*", $personnePhysique);
     $prenom = CMbArray::get($prenoms, 0);
     $commentaire = null;
     if (!$mbPatient->checkSimilar($nom, $prenom)) {
         $commentaire = "Le nom ({$nom}/{$mbPatient->nom}) et/ou le prénom ({$prenom}/{$mbPatient->prenom}) sont très différents.";
     }
     return $commentaire;
 }
CCanDo::checkRead();
$patient_id = CValue::get("patient_id");
$nom = CValue::get("nom");
$nom_jeune_fille = CValue::get("nom_jeune_fille");
$prenom = CValue::get("prenom");
$prenom_2 = CValue::get("prenom_2");
$prenom_3 = CValue::get("prenom_3");
$prenom_4 = CValue::get("prenom_4");
$naissance = CValue::get("naissance", "0000-00-00");
$submit = CValue::get("submit", 0);
$json_result = CValue::get("json_result");
$similar = true;
$old_patient = new CPatient();
$old_patient->load($patient_id);
if ($patient_id && $nom && $prenom) {
    $similar = $old_patient->checkSimilar($nom, $prenom);
}
$patientMatch = new CPatient();
$patientMatch->patient_id = $patient_id;
if (CAppUI::conf('dPpatients CPatient function_distinct')) {
    $function_id = CMediusers::get()->function_id;
    $patientMatch->function_id = $function_id;
}
$patientMatch->nom = $nom;
$patientMatch->nom_jeune_fille = $nom_jeune_fille;
$patientMatch->prenom = $prenom;
$patientMatch->prenom_2 = $prenom_2;
$patientMatch->prenom_3 = $prenom_3;
$patientMatch->prenom_4 = $prenom_4;
$patientMatch->naissance = $naissance;
$doubloon = implode("|", $patientMatch->getDoubloonIds());