/** * Update soundex data * * @return bool */ protected function createSoundex() { $where = array("nom_soundex2" => "IS NULL", "nom" => "!= ''"); $limit = "0,1000"; $pat = new CPatient(); $listPat = $pat->loadList($where, null, $limit); while (count($listPat)) { foreach ($listPat as &$pat) { if ($msg = $pat->store()) { trigger_error("Erreur store [{$pat->_id}] : {$msg}"); return false; } } $listPat = $pat->loadList($where, null, $limit); } return true; }
$where["nom"] = "LIKE '{$nom}%'"; if ($sexe != "") { $where["sexe"] = "= '{$sexe}'"; } /*if ($IPP) { /*$patient = new CPatient; $patient->_IPP = $patient_ipp; $patient->loadFromIPP(); }*/ $order = "nom, prenom, naissance"; $step = 30; $limit = "{$page}, {$step}"; $patient = new CPatient(); $patient->nom = $nom; $patient->prenom = $prenom; $patient->nom_jeune_fille = $nom_jeune_fille; $patient->sexe = $sexe; //$patient->_IPP = $IPP; $nb_pat = $patient->countList($where); /** @var CPatient[] $patients CPatient[] */ $patients = $patient->loadList($where, $order, $limit); CPatient::massLoadIPP($patients); foreach ($patients as $_patient) { $_patient->loadFirstLog()->loadRefUser(); } $smarty = new CSmartyDP(); $smarty->assign("patient", $patient); $smarty->assign("patients", $patients); $smarty->assign("nb_pat", $nb_pat); $smarty->assign("page", $page); $smarty->display("inc_list_demographic.tpl");
/** @var CPatient[] $patients */ $where["status"] = " = '{$state}'"; if ($state != "vali") { $where["vip"] = "= '0'"; } if ($state == "cach") { $where["vip"] = "= '1'"; $where["status"] = "!= 'VALI'"; } if ($state == "dpot") { $patient_link = new CPatientLink(); $patient_links = $patient_link->loadList(null, null, "{$page}, 30"); $patient_ids1 = CMbArray::pluck($patient_links, "patient_id1"); $patient_ids2 = CMbArray::pluck($patient_links, "patient_id2"); $where = array("patient_id" => CSQLDataSource::prepareIn(array_merge($patient_ids1, $patient_ids2))); $patients = $patient->loadList($where); } else { $patients = $patient->loadList($where, "nom, prenom", "{$page}, 30", null, $leftjoin); } CPatient::massLoadIPP($patients); /** @var CPatientState $patients_state */ $patients_state = CPatient::massLoadBackRefs($patients, "patient_state", "datetime DESC"); $mediusers = CPatientState::massLoadFwdRef($patients_state, "mediuser_id"); /** @var CPatientLink[] $link1 */ $link1 = CPatient::massLoadBackRefs($patients, "patient_link1"); /** @var CPatientLink[] $link2 */ $link2 = CPatient::massLoadBackRefs($patients, "patient_link2"); $patient_link1 = CPatientLink::massLoadFwdRef($link1, "patient_id2"); $patient_link2 = CPatientLink::massLoadFwdRef($link2, "patient_id1"); $patient_link = $patient_link1 + $patient_link2; CPatient::massLoadIPP($patient_link);
$ljoin["plageconsult"] = "`plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`"; $ljoin["sejour"] = "`sejour`.`patient_id` = `patients`.`patient_id`"; $where[] = "plageconsult.chir_id = '{$prat_id}' OR sejour.praticien_id = '{$prat_id}'"; $whereSoundex[] = "plageconsult.chir_id = '{$prat_id}' OR sejour.praticien_id = '{$prat_id}'"; } if ($patient_nda) { $ljoin["sejour"] = "`sejour`.`patient_id` = `patients`.`patient_id`"; $ljoin["id_sante400"] = "`id_sante400`.`object_id` = `sejour`.`sejour_id`"; $where[] = "`id_sante400`.`object_class` = 'CSejour'"; $where["id_sante400.id400"] = " = '{$patient_nda}'"; } $patients = array(); $patientsSoundex = array(); $pat = new CPatient(); if ($where) { $patients = $pat->loadList($where, "nom, prenom, naissance", "0, 100", null, $ljoin); } if ($whereSoundex && ($nbExact = 100 - count($patients))) { $patientsSoundex = $pat->loadList($whereSoundex, "nom, prenom, naissance", "0, {$nbExact}", null, $ljoin); $patientsSoundex = array_diff_key($patientsSoundex, $patients); } } // Liste des praticiens $prats = $mediuser->loadPraticiens(); // Création du template $smarty = new CSmartyDP(); $smarty->assign("dPsanteInstalled", CModule::getInstalled("dPsante400")); $smarty->assign("patient_ipp", $patient_ipp); $smarty->assign("patient_nda", $patient_nda); $smarty->assign("board", $board); $smarty->assign("nom", $patient_nom);
} if ($export_id_max = $sip_config["export_id_max"]) { $where[] = $patient->_spec->key . " <= '{$export_id_max}'"; } // Comptage $count = $patient->countList($where); $max = $sip_config["export_segment"]; $max = min($max, $count); CAppUI::stepAjax("Export de {$max} sur {$count} objets de type 'CPatient' à partir de l'ID '{$idMin}'", UI_MSG_OK); // Time limit $seconds = max($max / 20, 120); CAppUI::stepAjax("Limite de temps du script positionné à '{$seconds}' secondes", UI_MSG_OK); CApp::setTimeLimit($seconds); // Export réel $errors = 0; $patients = $patient->loadList($where, $patient->_spec->key, "0, {$max}"); $echange = 0; foreach ($patients as $patient) { $patient->loadIPP(); $patient->loadRefsSejours(); $patient->_ref_last_log->type = "create"; $receiver = new CDestinataireHprim(); $receiver->load(CAppUI::conf("sip export_dest")); $receiver->loadConfigValues(); if (!$patient->_IPP) { $IPP = new CIdSante400(); //Paramétrage de l'id 400 $IPP->object_class = "CPatient"; $IPP->object_id = $patient->_id; $IPP->tag = $receiver->_tag_patient; $IPP->loadMatchingObject();
CValue::setSession("start", $start); CValue::setSession("directory", $directory); CValue::setSession("ignore_files", $ignore_files); CValue::setSession("generate_pdfpreviews", $generate_pdfpreviews); CValue::setSession("date_min", $date_min); $step = min($step, 1000); CStoredObject::$useObjectCache = false; $backrefs_tree = array("CPatient" => array("identifiants", "notes", "files", "documents", "permissions", "observation_result_sets", "constantes", "contextes_constante", "consultations", "correspondants", "correspondants_patient", "sejours", "dossier_medical", "correspondants_courrier", "grossesses", "allaitements", "patient_observation_result_sets", "patient_links", 'arret_travail', "facture_patient_consult", "facture_patient_sejour"), "CConsultation" => array("files", "documents", "notes", "consult_anesth", "examaudio", "examcomp", "examnyha", "exampossum", "sejours_lies", "intervs_liees", "consults_liees", "facturable", "actes_ngap", "actes_ccam", "codages_ccam", "actes_caisse"), "CConsultAnesth" => array("files", "documents", "notes", "techniques"), "CSejour" => array("identifiants", "files", "documents", "notes", "dossier_medical", "operations", "facturable", "actes_ngap", "actes_ccam", "codages_ccam", "actes_caisse"), "COperation" => array("files", "documents", "notes", "anesth_perops", "facturable", "actes_ngap", "actes_ccam", "actes_caisse"), "CCompteRendu" => array("files"), "CDossierMedical" => array("antecedents", "traitements", "etats_dent"), "CFactureCabinet" => array("items", "reglements"), "CFactureEtablissement" => array("items", "reglements")); $fwdrefs_tree = array("CPatient" => array("medecin_traitant"), "CConstantesMedicales" => array("context_id", "patient_id", "user_id"), "CConsultation" => array("plageconsult_id", "sejour_id", "grossesse_id", "patient_id", "consult_related_id"), "CConsultAnesth" => array("consultation_id", "operation_id", "sejour_id", "chir_id"), "CPlageconsult" => array("chir_id"), "CSejour" => array("patient_id", "praticien_id", "service_id", "group_id", "grossesse_id"), "COperation" => array("sejour_id", "chir_id", "anesth_id", "plageop_id", "salle_id", "type_anesth", "consult_related_id", "prat_visite_anesth_id"), "CGrossesse" => array("group_id", "parturiente_id"), "CCorrespondant" => array("patient_id", "medecin_id"), "CMediusers" => array("user_id"), "CPlageOp" => array("chir_id", "anesth_id", "spec_id", "salle_id"), "CActeCCAM" => array("executant_id"), "CActeNGAP" => array("executant_id"), "CActeCaisse" => array("executant_id"), "CFraidDivers" => array("executant_id"), "CFactureItem" => array("object_id"), "CFactureLiaison" => array("facture_id", "object_id"), "CFactureCabinet" => array("group_id", "patient_id", "praticien_id"), "CFactureEtablissement" => array("group_id", "patient_id", "praticien_id"), "CTypeAnesth" => array("group_id"), "CFile" => array("object_id", "author_id"), "CCompteRendu" => array("object_id", "author_id", "user_id", "function_id", "group_id", "content_id", "locker_id")); $patient = new CPatient(); $ds = $patient->getDS(); $order = array("patients.nom", "patients.nom_jeune_fille", "patients.prenom", "patients.naissance", "patients.patient_id"); if ($all_prats && !$date_min) { $limit = "{$start}, {$step}"; /** @var CPatient[] $patients */ $patients = $patient->loadList(null, $order, $limit); $patient_count = count($patients); $patient_total = $patient->countList(); } else { $ljoin_consult = array("consultation" => "consultation.patient_id = patients.patient_id", "plageconsult" => "plageconsult.plageconsult_id = consultation.plageconsult_id"); $where_consult = array(); if (!$all_prats) { $where_consult["plageconsult.chir_id"] = $ds->prepareIn($praticien_id); } if ($date_min) { $where_consult["plageconsult.date"] = $ds->prepare(">= ?", $date_min); } $patient_ids_consult = $patient->loadIds($where_consult, $order, null, "patients.patient_id", $ljoin_consult); $ljoin_sejour = array("sejour" => "sejour.patient_id = patients.patient_id"); $where_sejour = array(); if (!$all_prats) {
/** * @see parent::loadRefs() */ function loadRefs() { // Backward references $obj = new CPatient(); $this->_ref_patients = $obj->loadList("medecin_traitant = '{$this->medecin_id}'"); }
/** * Handle event * * @param CHL7v2PatientDemographicsAndVisitResponse $ack Acknowledgement * @param CPatient $patient Person * @param array $data Nodes data * * @return null|string */ function handle(CHL7v2PatientDemographicsAndVisitResponse $ack, CPatient $patient, $data) { $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $sender = $exchange_hl7v2->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; $ds = $patient->getDS(); $where = array(); foreach ($this->getRequestPatient($data["QPD"]) as $field => $value) { if ($value == "") { continue; } if (!in_array($field, array("naissance", "cp"))) { $value = preg_replace("/[^a-z\\d\\*]/i", "_", $value); $value = preg_replace("/\\*+/", "%", $value); } $where["patients.{$field}"] = $ds->prepare("LIKE %", $value); } $ljoin = null; $identifier_list = $this->getRequestPatientIdentifierList($data["QPD"]); if (count(array_filter($identifier_list)) > 0) { $ljoin[10] = "id_sante400 AS id_pat_list ON id_pat_list.object_id = patients.patient_id"; $where[] = "`id_pat_list`.`object_class` = 'CPatient'"; // Requête sur un IPP if (!empty($identifier_list["id_number"]) && empty($identifier_list["namespace_id"]) && empty($identifier_list["universal_id"]) && empty($identifier_list["universal_id_type"])) { $where[] = $ds->prepare("id_pat_list.id400 = %", $identifier_list["id_number"]); } if (!empty($identifier_list["id_number"]) && (!empty($identifier_list["namespace_id"]) || !empty($identifier_list["universal_id"]))) { $namespace_id = $identifier_list["namespace_id"]; $universal_id = $identifier_list["universal_id"]; $domain = new CDomain(); if ($namespace_id) { $domain->namespace_id = $namespace_id; } if ($universal_id) { $domain->OID = $universal_id; } if ($domain->tag || $domain->OID) { $domain->loadMatchingObject(); } $where[] = $ds->prepare("id_pat_list.id400 = %", $identifier_list["id_number"]); $where[] = $ds->prepare("id_pat_list.tag = %", $domain->tag); } if (empty($identifier_list["id_number"]) && (!empty($identifier_list["namespace_id"]) || !empty($identifier_list["universal_id"]))) { $namespace_id = $identifier_list["namespace_id"]; $universal_id = $identifier_list["universal_id"]; $domain = new CDomain(); if ($namespace_id) { $domain->namespace_id = $namespace_id; } if ($universal_id) { $domain->OID = $universal_id; } if ($domain->namespace_id || $domain->OID) { $domain->loadMatchingObject(); $where[] = $ds->prepare("id_pat_list.tag = %", $domain->tag); } } } $request_admit = false; // Requête sur un NDA $identifier_list = $this->getRequestSejourIdentifierList($data["QPD"]); if (count(array_filter($identifier_list)) > 0) { $ljoin[100] = "sejour ON `patients`.`patient_id` = `sejour`.`patient_id`"; $ljoin[10] = "id_sante400 AS id_sej_list ON id_sej_list.object_id = sejour.sejour_id"; $where[] = "`id_sej_list`.`object_class` = 'CSejour'"; // Requête sur un IPP if (!empty($identifier_list["id_number"]) && empty($identifier_list["namespace_id"]) && empty($identifier_list["universal_id"]) && empty($identifier_list["universal_id_type"])) { $where[] = $ds->prepare("id_sej_list.id400 = %", $identifier_list["id_number"]); } if (!empty($identifier_list["id_number"]) && (!empty($identifier_list["namespace_id"]) || !empty($identifier_list["universal_id"]))) { $namespace_id = $identifier_list["namespace_id"]; $universal_id = $identifier_list["universal_id"]; $domain = new CDomain(); if ($namespace_id) { $domain->namespace_id = $namespace_id; } if ($universal_id) { $domain->OID = $universal_id; } if ($domain->namespace_id || $domain->OID) { $domain->loadMatchingObject(); } $where[] = $ds->prepare("id_sej_list.id400 = %", $identifier_list["id_number"]); $where[] = $ds->prepare("id_sej_list.tag = %", $domain->tag); } if (empty($identifier_list["id_number"]) && (!empty($identifier_list["namespace_id"]) || !empty($identifier_list["universal_id"]))) { $namespace_id = $identifier_list["namespace_id"]; $universal_id = $identifier_list["universal_id"]; $domain = new CDomain(); if ($namespace_id) { $domain->namespace_id = $namespace_id; } if ($universal_id) { $domain->OID = $universal_id; } if ($domain->namespace_id || $domain->OID) { $domain->loadMatchingObject(); $where[] = $ds->prepare("id_sej_list.tag = %", $domain->tag); } } } foreach ($this->getRequestSejour($data["QPD"]) as $field => $value) { if ($value == "") { continue; } $value = preg_replace("/[^a-z\\*]/i", "_", $value); $value = preg_replace("/\\*+/", "%", $value); $where["sejour.{$field}"] = $ds->prepare("LIKE %", $value); $request_admit = true; } if ($other_request = $this->getOtherRequestSejour($data["QPD"])) { $where = array_merge($other_request, $where); $request_admit = true; } $i = 1; $domains = array(); foreach ($this->getQPD8s($data["QPD"]) as $_QPD8) { // Requête sur un domaine particulier $domains_returned_namespace_id = $_QPD8["domains_returned_namespace_id"]; // Requête sur un OID particulier $domains_returned_universal_id = $_QPD8["domains_returned_universal_id"]; $domain = new CDomain(); if ($domains_returned_namespace_id) { $domain->namespace_id = $domains_returned_namespace_id; } if ($domains_returned_universal_id) { $domain->OID = $domains_returned_universal_id; } if ($domain->namespace_id || $domain->OID) { $domain->loadMatchingObject(); } $value = $domain->OID ? $domain->OID : $domain->tag; // Cas où le domaine n'est pas retrouvé if (!$domain->_id) { return $exchange_hl7v2->setPDRAE($ack, null, $value); } $domains[] = $domain; if ($domains_returned_namespace_id) { $ljoin[20 + $i] = "id_sante400 AS id{$i} ON id{$i}.object_id = patients.patient_id"; $where[] = $ds->prepare("id{$i}.tag = %", $domain->tag); $i++; } } $quantity_limited_request = $this->getQuantityLimitedRequest($data["RCP"]); $limit_quantity = !!$quantity_limited_request; $quantity_limited_request = $quantity_limited_request ? $quantity_limited_request : 100; $pointer = null; if (isset($data["DSC"])) { $pointer = $this->getContinuationPointer($data["DSC"]); } $objects = array(); if (!$request_admit) { // Pointeur pour continuer if ($pointer) { $patient->_pointer = $pointer; // is_numeric $where["patients.patient_id"] = $ds->prepare(" > %", $pointer); } $order = "patients.patient_id ASC"; if (!empty($where)) { $objects = $patient->loadList($where, $order, $quantity_limited_request, "patients.patient_id", $ljoin); // If we have no next match, we won't have to add a DSC segment if ($limit_quantity) { $next_one = $patient->loadList($where, $order, "{$quantity_limited_request},1", "patients.patient_id", $ljoin); if (count($next_one) == 0) { $limit_quantity = false; } } } } else { $ljoin[100] = "patients ON `patients`.`patient_id` = `sejour`.`patient_id`"; /** @var $sejour CSejour */ $sejour = new CSejour(); if (!empty($where)) { $objects = $sejour->loadList($where, null, $quantity_limited_request, "sejour.sejour_id", $ljoin); } } // Save information indicating that we are doing an incremental query $last = end($objects); if ($last && $limit_quantity) { $last->_incremental_query = true; } return $exchange_hl7v2->setPDRAA($ack, $objects, null, $domains); }
$limit = "0, {$showCount}"; $order = "patients.nom, patients.prenom"; $pat = new CPatient(); /** @var CPatient[] $patients */ $patients = array(); /** @var CPatient[] $patientsSoundex */ $patientsSoundex = array(); /** @var CPatient[] $patientsLimited */ $patientsLimited = array(); if ($where) { // Séparation des patients par fonction if (CAppUI::conf('dPpatients CPatient function_distinct') && !CMediusers::get()->isAdmin()) { $function_id = CMediusers::get()->function_id; $where["function_id"] = $whereLimited["function_id"] = $whereSoundex["function_id"] = "= '{$function_id}'"; } $patients = $pat->loadList($where, $order, $limit); if ($nbExact = $showCount - count($patients)) { $limit = "0, {$nbExact}"; $patientsSoundex = $pat->loadList($whereSoundex, $order, $limit); $patientsSoundex = array_diff_key($patientsSoundex, $patients); } //par recherche limitée if ($whereLimited && $limit_char_search && !$lenSearchConfig) { $patientsLimited = $pat->loadList($whereLimited, $order, $limit); $patientsLimited = array_diff_key($patientsLimited, $patients); } } /** * Chargement des consultations du jour pour une liste de patients donnés * * @param CPatient[] &$patients Liste des patients
/** * $Id$ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $patient = new CPatient(); // Supression de patients $suppr = 0; $error = 0; $qte = CValue::get("qte", 1); $listPatients = $patient->loadList(null, null, $qte); foreach ($listPatients as $_patient) { CAppUI::setMsg($_patient->_view, UI_MSG_OK); if ($msg = $_patient->purge()) { CAppUI::setMsg($msg, UI_MSG_ALERT); $error++; continue; } CAppUI::setMsg("patient supprimé", UI_MSG_OK); $suppr++; } // Nombre de patients $nb_patients = $patient->countList(); // Création du template $smarty = new CSmartyDP(); $smarty->assign("resultsMsg", CAppUI::getMsg());
switch ($mode = CValue::get("mode")) { case "check": $ds = $patient->_spec->ds; $query = "SELECT `{$_field}`, COUNT( * ) AS `counts`\r\n FROM `patients`\r\n GROUP BY `{$_field}`"; foreach ($ds->loadHashList($query) as $value => $count) { $msgType = $value ? UI_MSG_OK : UI_MSG_WARNING; CAppUI::stepAjax("Nombre d'occurences pour '%s' valant '%s' : '%s'", $msgType, CAppUI::tr("CPatient-{$_field}-desc"), CAppUI::tr("CPatient.{$_field}.{$value}"), $count); } break; case "repair": $where = array(); $where["{$_field}"] = "IS NULL"; $repaired = 0; $max = CValue::get("max", 1000); $limit = "0, {$max}"; CAppUI::stepAjax("Patients détectés pour une correction de '%s' : %s trouvés.", UI_MSG_OK, CAppUI::tr("CPatient-{$_field}-desc"), $patient->countList($where)); foreach ($patient->loadList($where, null, $limit) as $_patient) { $_patient->{$_field} = "guess"; if ($msg = $_patient->store()) { CAppUI::stepAjax("Echec de la correction de %s pour le patient '%s' : %s", UI_MSG_WARNING, CAppUI::tr("CPatient-{$_field}-desc"), $_patient, $msg); continue; } $repaired++; } CAppUI::stepAjax("%s patients corrigés", UI_MSG_OK, $repaired); break; default: CAppUI::stepAjax("Mode '{$mode}' non pris en charge", UI_MSG_ERROR); break; } }
/** @var CPatient[] $patients */ $patients = array(); /** @var CPatient[] $patientsSoundex */ $patientsSoundex = array(); /** @var CPatient[] $patientsLimited */ $patientsLimited = array(); $order = "nom, prenom, naissance"; $pat = new CPatient(); // Chargement des patients if ($where) { // Séparation des patients par fonction if (CAppUI::conf('dPpatients CPatient function_distinct') && !CMediusers::get()->isAdmin()) { $function_id = CMediusers::get()->function_id; $where["function_id"] = $whereLimited["function_id"] = $whereSoundex["function_id"] = "= '{$function_id}'"; } $patients = $pat->loadList($where, $order, $showCount, $group_by, $ljoin); } // par soundex if ($whereSoundex) { $patientsSoundex = $pat->loadList($whereSoundex, $order, $showCount, $group_by, $ljoin); $patientsSoundex = array_diff_key($patientsSoundex, $patients); } //par recherche limitée if ($whereLimited && $limit_char_search && !$lenSearchConfig) { $patientsLimited = $pat->loadList($whereLimited, $order, $showCount, $group_by, $ljoin); $patientsLimited = array_diff_key($patientsLimited, $patients); } // Sélection du premier de la liste si aucun n'est déjà sélectionné if (!$patient->_id && count($patients) == 1) { $patient = reset($patients); }