$echg_hprim->object_id = $medecin->_id; $echg_hprim->store(); } CAppUI::stepAjax("Médecins utilisés : '{$total}'"); CAppUI::stepAjax("Médecins rapprochés : '{$nouv}'"); if ($total > 0) { CAppUI::stepAjax($nouv * 100 / $total . ", %% de rapprochement de médecins"); } // Gestion des patients $hprimPatient = new CHprim21Patient(); $where = array(); $where["date_derniere_modif"] = ">= '{$date_limite}'"; $where["patient_id"] = "IS NULL"; $order = "date_derniere_modif DESC"; /** @var CHprim21Patient[] $listHprimPatients */ $listHprimPatients = $hprimPatient->loadList($where, $order, $qte_limite); $total = count($listHprimPatients); // Liaison à un patient existant $nouv = $anc = 0; foreach ($listHprimPatients as $_patient) { $_patient->loadRefExchange(); $echg_hprim = $_patient->_ref_echange_hprim21; // Recherche si la liaison a déjà été faite $IPP = new CIdSante400(); $IPP->object_class = "CPatient"; $IPP->tag = $tag_ipp; $IPP->id400 = "{$_patient->external_id}"; $IPP->loadMatchingObject(); if ($IPP->_id) { $_patient->patient_id = $IPP->object_id; $_patient->store();
$where["ville"] = $whereSoundex["ville"] = "LIKE '{$patient_ville}%'"; } if ($patient_cp) { $where["cp"] = $whereSoundex["cp"] = "= '{$patient_cp}'"; } $patients = array(); $patientsSoundex = array(); $order = "nom, prenom, naissance"; $pat = new CHprim21Patient(); // Patient counts $patientsCount = $where ? $pat->countList($where) : 0; $patientsSoundexCount = $whereSoundex ? $pat->countList($whereSoundex) : 0; $patientsSoundexCount -= $patientsCount; // Chargement des patients if ($where) { $patients = $pat->loadList($where, $order, "0, {$showCount}"); } if ($whereSoundex) { $patientsSoundex = $pat->loadList($whereSoundex, $order, "0, {$showCount}"); $patientsSoundex = array_diff_key($patientsSoundex, $patients); } // Sélection du premier de la liste si aucun n'est déjà sélectionné if (!$patient->_id and count($patients) == 1) { $patient = reset($patients); } if ($patient->_id) { $patient->loadRefs(); foreach ($patient->_ref_hprim21_sejours as &$sejour) { $sejour->loadRefs(); $sejour->_ref_sejour->loadRefsFwd(); }
$day = $patient_day ? "{$patient_day}" : "%"; if ($day != "%") { $day = str_pad($day, 2, "0", STR_PAD_LEFT); } $naissance = $year . $month . $day; if ($patient_year || $patient_month || $patient_day) { $where["naissance"] = $whereSoundex["naissance"] = "LIKE '{$naissance}'"; } } $limit = "0, {$showCount}"; $order = "hprim21_patient.nom, hprim21_patient.prenom"; $pat = new CHprim21Patient(); $patients = array(); $patientsSoundex = array(); if ($where) { $patients = $pat->loadList($where, $order, $limit); foreach ($patients as &$curr_pat) { $curr_pat->loadRefs(); } if ($nbExact = $showCount - count($patients)) { $limit = "0, {$nbExact}"; $patientsSoundex = $pat->loadList($whereSoundex, $order, $limit); $patientsSoundex = array_diff_key($patientsSoundex, $patients); foreach ($patientsSoundex as &$curr_pat) { $curr_pat->loadRefs(); } } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("name", $name);