} if (!in_array($order_col, array("_entree", "ccmu", "_patient_id"))) { $order_col = "ccmu"; } switch ($order_col) { case "_entree": $order = "entree {$order_way}, rpu.ccmu {$order_way}"; break; case "ccmu": $order = "rpu.ccmu {$order_way}, entree {$order_way}"; break; case "_patient_id": $order = "patients.nom {$order_way}, ccmu {$order_way}"; } /** @var CSejour[] $listSejours */ $listSejours = $sejour->loadList($where, $order, null, "`sejour`.sejour_id", $ljoin); if ($service_id) { foreach ($listSejours as $key => $sejour) { $curr_aff = $sejour->getCurrAffectation(); if (!$curr_aff->_id && (!$sejour->service_id || $sejour->service_id != $service_id) || $curr_aff->service_id != $service_id) { unset($listSejours[$key]); } } } CMbObject::massLoadFwdRef($listSejours, "patient_id"); CMbObject::massLoadFwdRef($listSejours, "group_id"); $prats = CMbObject::massLoadFwdRef($listSejours, "praticien_id"); CMbObject::massLoadFwdRef($prats, "function_id"); CMbObject::massCountBackRefs($listSejours, "notes"); CMbObject::massCountBackRefs($listSejours, "rpu"); CMbObject::massCountBackRefs($listSejours, "consultations");
/** * Charge les séjours du patient * * @param array $where SQL where clauses * * @return CSejour[]n loadRef */ function loadRefsSejours($where = array()) { if (!$this->_id) { return $this->_ref_sejours = array(); } $sejour = new CSejour(); $group_id = CGroups::loadCurrent()->_id; $where["patient_id"] = "= '{$this->_id}'"; if (CAppUI::conf("dPpatients CPatient multi_group") == "hidden") { $where["sejour.group_id"] = "= '{$group_id}'"; } $order = "entree DESC"; return $this->_ref_sejours = $sejour->loadList($where, $order); }
ob_clean(); CApp::setMemoryLimit("1024M"); CApp::setTimeLimit(240); $service_id = CValue::get("service_id"); $date = CValue::get("date", CMbDT::date()); $service = new CService(); $service->load($service_id); $datetime_min = "{$date} 00:00:00"; $datetime_max = "{$date} 23:59:59"; $datetime_avg = "{$date} " . CMbDT::time(); $sejour = new CSejour(); $where = array(); $ljoin = array(); $ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id"; $where["sejour.entree"] = "<= '{$datetime_max}'"; $where["sejour.sortie"] = " >= '{$datetime_min}'"; $where["affectation.entree"] = "<= '{$datetime_max}'"; $where["affectation.sortie"] = ">= '{$datetime_min}'"; $where["affectation.service_id"] = " = '{$service_id}'"; /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where, null, null, "sejour.sejour_id", $ljoin); $ordonnances = array(); foreach ($sejours as $_sejour) { $_prescription = $_sejour->loadRefPrescriptionSejour(); $_patient = $_sejour->loadRefPatient(); $params = array("prescription_id" => $_prescription->_id ?: "", "in_progress" => 1, "multipart" => 1); $_content = CApp::fetch("dPprescription", "print_prescription_fr", $params); $_naissance = str_replace("/", "-", $_patient->getFormattedValue("naissance")); $ordonnances[] = array("title" => base64_encode($_patient->_view . " - " . $_naissance), "content" => base64_encode($_content), "extension" => "pdf"); } CApp::json($ordonnances);
$page = CValue::get("page", 0); $next = CMbDT::date("+1 day", $date); $sejour = new CSejour(); $where = array(); $where["entree"] = "< '{$next}'"; $where["sortie"] = "> '{$date}'"; $where["group_id"] = "= '{$group->_id}'"; $where["annule"] = "= '0'"; $order = array(); $order[] = "sortie"; $order[] = "entree"; $step = 30; $limit = "{$page},{$step}"; /** @var CSejour[] $listSejours */ $count = $sejour->countList($where); $listSejours = $sejour->loadList($where, $order, $limit); $patients = CSejour::massLoadFwdRef($listSejours, "patient_id"); $ipps = CPatient::massLoadIPP($patients); $ndas = CSejour::massLoadNDA($listSejours); $praticiens = CSejour::massLoadFwdRef($listSejours, "praticien_id"); CMediusers::massLoadFwdRef($praticiens, "function_id"); CSejour::massLoadFwdRef($listSejours, "group_id"); CSejour::massLoadFwdRef($listSejours, "etablissement_sortie_id"); CSejour::massLoadFwdRef($listSejours, "service_sortie_id"); CSejour::massLoadFwdRef($listSejours, "service_sortie_id"); foreach ($listSejours as $_sejour) { $_sejour->_ref_patient = $patients[$_sejour->patient_id]; $_sejour->loadRefPraticien(); $_sejour->loadExtCodesCCAM(); $_sejour->loadRefsFactureEtablissement(); $_sejour->countActes();
$where["isolement"] = "= '1'"; } $items_prestation = array(); if ($prestation_id) { $prestation = new CPrestationJournaliere(); $prestation->load($prestation_id); $items_prestation = $prestation->loadBackRefs("items", "rank asc"); } if ($item_prestation_id && $prestation_id) { // L'axe de prestation a pu changer, donc ne pas appliquer l'item de prestation s'il ne fait pas partie de l'axe choisi if (isset($items_prestation[$item_prestation_id])) { $ljoin["item_liaison"] = "sejour.sejour_id = item_liaison.sejour_id"; $where["item_liaison.item_souhait_id"] = " = '{$item_prestation_id}'"; } } $sejours = $sejour->loadList($where, $order, null, null, $ljoin); $praticiens = CStoredObject::massLoadFwdRef($sejours, "praticien_id"); CStoredObject::massLoadFwdRef($sejours, "prestation_id"); CStoredObject::massLoadFwdRef($praticiens, "function_id"); CStoredObject::massLoadFwdRef($sejours, "patient_id"); $services = CStoredObject::massLoadFwdRef($sejours, "service_id"); foreach ($sejours as $_sejour_imc) { /* @var CAffectation $_affectation_imc*/ $conf_imc = $_sejour_imc->service_id ? "CService-" . $_sejour_imc->service_id : CGroups::loadCurrent(); if (CAppUI::conf("dPhospi vue_temporelle show_imc_patient", $conf_imc)) { $_sejour_imc->loadRefPatient()->loadRefLatestConstantes(null, array("poids", "taille")); } } $sejours_non_affectes = array(); $functions_filter = array(); $operations = array();
} } /** * Comptage des séjours */ $group = CGroups::loadCurrent(); $next = CMbDT::date("+1 day", $date); $sejour = new CSejour(); $where = array(); $where["entree"] = "< '{$next}'"; $where["sortie"] = "> '{$date}'"; $where["group_id"] = "= '{$group->_id}'"; $where["annule"] = "= '0'"; $order = array(); $order[] = "sortie"; $order[] = "entree"; /** @var CSejour[] $listSejours */ $count = $sejour->countList($where); $listSejours = $sejour->loadList($where, $order); foreach ($listSejours as $_sejour) { $counts["sejours"]["total"]++; if ($_sejour->facture) { $counts["sejours"]["facturees"]++; } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("date", $date); $smarty->assign("counts", $counts); $smarty->assign("totalOp", $totalOp); $smarty->display("current_dossiers/inc_current_dossiers.tpl");
if ($mode == "count" || $mode == "referenced") { $join = array(); $join["patients"] = "patients.patient_id = sejour.patient_id"; $order = "nom, prenom"; $join["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id"; $join["technicien"] = "technicien.technicien_id = bilan_ssr.technicien_id"; $where = array(); $where["sejour.type"] = "= 'ssr'"; $where["sejour.entree"] = "<= '{$planning->date_max}'"; $where["sejour.sortie"] = ">= '{$planning->date_min}'"; $where["sejour.annule"] = "= '0'"; $where["technicien.kine_id"] = "= '{$kine_id}'"; if ($mode == "count") { $counts["referenced"] = $sejour->countList($where, null, $join); } else { $sejours = $sejour->loadList($where, $order, null, null, $join); } } // Sejours pour lesquels le kine est remplaçant if ($mode == "count" || $mode == "replaced") { $order = "nom, prenom"; $join = array(); $join["patients"] = "patients.patient_id = sejour.patient_id"; $join["replacement"] = "replacement.sejour_id = sejour.sejour_id"; $join["plageconge"] = "plageconge.plage_id = replacement.conge_id"; $where = array(); $where["sejour.type"] = "= 'ssr'"; $where["sejour.entree"] = "<= '{$planning->date_max}'"; $where["sejour.sortie"] = ">= '{$planning->date_min}'"; $where["sejour.annule"] = "= '0'"; $where["replacement.replacement_id"] = "IS NOT NULL";
if ($service_id == "NP") { $ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id"; $where["affectation.affectation_id"] = "IS NULL"; $where["sejour.group_id"] = "= '{$group->_id}'"; } else { $ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id"; $where["affectation.entree"] = "<= '{$dateTime_max}'"; $where["affectation.sortie"] = ">= '{$dateTime_min}'"; $where["affectation.service_id"] = " = '{$service_id}'"; } } if ($_present_only) { $where["sejour.sortie_reelle"] = 'IS NULL'; } /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where, $order_by, null, "sejour.sejour_id", $ljoin); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massCountBackRefs($sejours, "operations"); foreach ($sejours as $_sejour) { $_sejour->loadRefPatient()->loadRefLatestConstantes(); $_sejour->loadRefsOperations(); $last_op = $_sejour->_ref_last_operation; $last_op->loadRefPlageOp(); $last_op->loadRefChir(); $last_op->loadExtCodesCCAM(); $affectations = $_sejour->loadRefsAffectations(); $_lits = CMbObject::massLoadFwdRef($affectations, "lit_id"); CMbObject::massLoadFwdRef($_lits, "chambre_id"); } $sorter_affectation = CMbArray::pluck($sejours, "_ref_last_affectation", "_view"); $sorter_patient = CMbArray::pluck($sejours, "_ref_patient", "nom");
$where["rpu.box_id"] = CSQLDataSource::prepareIn(array_keys($lits)); } if (!CAppUI::conf("dPurgences create_sejour_hospit")) { $where[] = "rpu.mutation_sejour_id IS NULL"; } if (!CAppUI::conf("dPurgences view_rpu_uhcd")) { $where["sejour.uhcd"] = " = '0'"; } $where_temp = $where; if ($temp != "") { $where_temp[] = $temp; } $sejours_chambre = array(); $sejour = new CSejour(); /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where_temp, null, null, "sejour_id", $ljoin, "entree"); if (!CAppUI::conf("dPurgences view_rpu_uhcd")) { $where["sejour.uhcd"] = " = '1'"; $sejours_uhcd = $sejour->loadList($where, null, null, "sejour_id", $ljoin, "entree"); foreach ($sejours_uhcd as $sejour_uhcd) { $sejours[$sejour_uhcd->_id] = $sejour_uhcd; } } foreach ($sejours as $sejour) { $sejour->loadRefPatient(); $sejour->loadRefPraticien(); $sejour->loadRefCurrAffectation()->loadRefService(); if (!$sejour->loadRefRPU()->_id) { $sejour->_ref_rpu = $sejour->loadUniqueBackRef("rpu_mute"); if (!$sejour->_ref_rpu) { $sejour->_ref_rpu = new CRPU();
$echg_hprim->object_id = $nda->object_id; $echg_hprim->id_permanent = $nda->id400; $echg_hprim->store(); $anc++; continue; } // Sinon rattachement à un sejour existant $sejour = new CSejour(); $where = array(); $where["patient_id"] = "= '{$hprimPatient->patient_id}'"; $date_min = CMbDT::date("-2 day", $_sejour->date_mouvement); $date_max = CMbDT::date("+2 day", $_sejour->date_mouvement); $where["entree"] = "BETWEEN '{$date_min}' AND '{$date_max}'"; $where["type"] = "!= 'consult'"; $where["annule"] = "= '0'"; $listSej = $sejour->loadList($where); if (count($listSej) > 1) { $moresej++; continue; } if (!count($listSej)) { continue; } $sejour = reset($listSej); if ($sejour->_id) { $nda->object_id = $sejour->_id; $nda->last_update = CMbDT::dateTime(); $nda->store(); $_sejour->sejour_id = $sejour->_id; $_sejour->store(); $echg_hprim->object_class = $nda->object_class;
* @subpackage PlanningOp * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $sejour = new CSejour(); $group = CGroups::loadCurrent(); // Supression de patients $suppr = 0; $error = 0; $qte = CValue::get("qte", 1); $date_min = CValue::get("date_min", CMbDT::date()); $date_min = $date_min ? $date_min : CMbDT::date(); $where = array("entree" => ">= '{$date_min} 00:00:00'", "group_id" => "= '{$group->_id}'"); $listSejours = $sejour->loadList($where, null, $qte); foreach ($listSejours as $_sejour) { CAppUI::setMsg($_sejour->_view, UI_MSG_OK); if ($msg = $_sejour->purge()) { CAppUI::setMsg($msg, UI_MSG_ALERT); $error++; continue; } CAppUI::setMsg("séjour supprimé", UI_MSG_OK); $suppr++; } // Nombre de patients $nb_sejours = $sejour->countList($where); // Création du template $smarty = new CSmartyDP(); $smarty->assign("resultsMsg", CAppUI::getMsg());
CSejour::massLoadNDA($sejours); break; case "A11": $where = array(); if ($event_type == "register_outpatient") { $where["type"] = "= 'urg'"; } $sejours = $patient->loadRefsSejours($where); CSejour::massLoadNDA($sejours); break; case "A12": $leftjoin = array("affectation" => "affectation.sejour_id = sejour.sejour_id"); $where = array("patient_id" => "= '{$patient->_id}'", "entree_reelle" => "IS NOT NULL", "affectation_id" => "IS NOT NULL"); $sejour = new CSejour(); /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where, "entree DESC", null, null, $leftjoin); $patient->_ref_sejours = $sejours; CSejour::massLoadNDA($sejours); CSejour::massLoadBackRefs($sejours, "affectations"); foreach ($sejours as $_sejour) { $_sejour->_ref_affectations = $_sejour->_back["affectations"]; } break; case "A13": $sejours = $patient->loadRefsSejours(array("sortie_reelle" => "IS NOT NULL")); CSejour::massLoadNDA($sejours); break; case "A38": $sejours = $patient->loadRefsSejours(array("sortie_reelle" => "IS NULL", "entree_reelle" => "IS NULL")); CSejour::massLoadNDA($sejours); break;
/** * 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); }
$where = array(); $where["lit_id"] = "= '{$lit_id}'"; $where["entree"] = "<= '{$date_max}'"; $where["sortie"] = ">= '{$date_min}'"; $affectation = new CAffectation(); $affectations = $affectation->loadList($where, "parent_affectation_id ASC"); // Ajout des prolongations anormales // (séjours avec entrée réelle et sortie non confirmée et sortie < maintenant $nb_days_prolongation = CAppUI::conf("dPhospi nb_days_prolongation"); if ($nb_days_prolongation) { $sejour = new CSejour(); $max = CMbDT::dateTime(); $min = CMbDT::date("-{$nb_days_prolongation} days", $max) . " 00:00:00"; $where = array("entree_reelle" => "IS NOT NULL", "sortie_reelle" => "IS NULL", "sortie_prevue" => "BETWEEN '{$min}' AND '{$max}'", "sejour.confirme" => "IS NULL", "group_id" => "= '{$group_id}'"); /** @var CSejour[] $sejours_prolonges */ $sejours_prolonges = $sejour->loadList($where); $affectations_prolong = array(); foreach ($sejours_prolonges as $_sejour) { $aff = $_sejour->getCurrAffectation($_sejour->sortie); if (!$aff->_id || $aff->lit_id != $lit_id) { continue; } $aff->_is_prolong = true; $affectations[$aff->_id] = $aff; } } $sejours = CStoredObject::massLoadFwdRef($affectations, "sejour_id"); $patients = CStoredObject::massLoadFwdRef($sejours, "patient_id"); $praticiens = CStoredObject::massLoadFwdRef($sejours, "praticien_id"); CStoredObject::massLoadFwdRef($praticiens, "function_id"); CStoredObject::massLoadBackRefs($patients, "dossier_medical");
// Chargement du patient $patient = $consult->_ref_patient; $patient->countBackRefs("consultations"); $patient->countBackRefs("sejours"); $patient->loadRefs(); $patient->loadRefsNotes(); $patient->loadRefPhotoIdentite(); $sejour = new CSejour(); $group_id = CGroups::loadCurrent()->_id; $where = array(); $where["patient_id"] = "= '{$patient->_id}'"; if (CAppUI::conf("dPpatients CPatient multi_group") == "hidden") { $where["sejour.group_id"] = "= '{$group_id}'"; } $order = "entree ASC"; $patient->_ref_sejours = $sejour->loadList($where, $order); $date_consult = $consult->_ref_plageconsult->date; $ops_sans_dossier_anesth = array(); $ops_annulees = array(); // Chargement de ses séjours foreach ($patient->_ref_sejours as $_key => $_sejour) { if ($date_consult > $_sejour->entree_prevue && $date_consult > $_sejour->sortie_prevue) { unset($patient->_ref_sejours[$_sejour->_id]); continue; } $_sejour->loadRefsOperations(); $_sejour->loadRefsFwd(); foreach ($_sejour->_ref_operations as $_operation) { $_operation->loadRefsFwd(); $_operation->_ref_chir->loadRefFunction()->loadRefGroup(); $day = CMbDT::daysRelative($consult->_ref_plageconsult->date, $_operation->_ref_plageop->date);
/** * Chargement de tous les séjours de la facture * * @return object **/ function loadRefsSejour() { if (count($this->_ref_sejours)) { return $this->_ref_sejours; } if (CModule::getActive("dPfacturation")) { $ljoin = array(); $ljoin["facture_liaison"] = "facture_liaison.object_id = sejour.sejour_id"; $where = array(); $where["facture_liaison.facture_id"] = " = '{$this->_id}'"; $where["facture_liaison.facture_class"] = " = '{$this->_class}'"; $where["facture_liaison.object_class"] = " = 'CSejour'"; $sejour = new CSejour(); $this->_ref_sejours = $sejour->loadList($where, "sejour_id", null, "sejour_id", $ljoin); // Chargement des actes de séjour foreach ($this->_ref_sejours as $sejour) { /** @var CSejour $sejour*/ $sejour->loadRefsOperations(); foreach ($sejour->_ref_operations as $op) { $op->loadRefsActes($this->numero, 1); $this->rangeActes($op); } $sejour->loadRefsActes($this->numero, 1); $this->rangeActes($sejour); } } if (count($this->_ref_sejours) > 0) { $this->_ref_last_sejour = end($this->_ref_sejours); $this->_ref_first_sejour = reset($this->_ref_sejours); $this->_ref_last_sejour->loadRefLastOperation(); $this->_ref_last_sejour->_ref_last_operation->loadRefAnesth(); } else { $this->_ref_last_sejour = new CSejour(); $this->_ref_first_sejour = new CSejour(); } return $this->_ref_sejours; }
$dossier_anesth_id = CValue::get("dossier_anesth_id"); $patient = new CPatient(); $patient->load($patient_id); // Chargement du dossier medical du patient $patient->loadRefDossierMedical(); $dossier_medical =& $patient->_ref_dossier_medical; $dossier_medical->needsRead(); $sejour = new CSejour(); $sejour->load($sejour_id); $date_sejour = $sejour->_id ? $sejour->entree_prevue : CMbDT::dateTime(); $where = array(); $where["patient_id"] = " = '{$patient_id}'"; $where[] = "sortie_prevue < '{$date_sejour}' OR sortie < '{$date_sejour}'"; $_sejour = new CSejour(); /* @var CSejour[] $sejours*/ $sejours = $_sejour->loadList($where, 'entree DESC'); foreach ($sejours as $_sejour) { $_sejour->loadRefsOperations(); if (!$_sejour->_motif_complet || $_sejour->annule) { unset($sejours[$_sejour->_id]); continue; } } $prescription_sejour = $sejour->loadRefPrescriptionSejour(); if ($prescription_sejour) { $prescription_sejour->countLinesTP(); } // Chargements des antecedents et traitements du dossier_medical if ($dossier_medical->_id) { $dossier_medical->loadRefsAntecedents(true, $sort_by_date); // On doit charger TOUS les antecedents, meme les annulés (argument true)
$sejour->checkDaysRelative($date); $sejour->loadRefPatient()->loadRefDossierMedical(false); $sejour->loadRefPrestation(); } $dossiers = CMbArray::pluck($listAff, "_ref_sejour", "_ref_patient", "_ref_dossier_medical"); CDossierMedical::massCountAntecedentsByType($dossiers, "deficience"); $listNotAff = array("Non placés" => array(), "Couloir" => array()); $group = CGroups::loadCurrent(); // Chargement des sejours n'ayant pas d'affectation pour cette période $sejour = new CSejour(); $where = array(); $where["entree_prevue"] = "<= '{$date_max}'"; $where["sortie_prevue"] = ">= '{$date_min}'"; $where["annule"] = " = '0' "; $where["group_id"] = "= '{$group->_id}'"; $listNotAff["Non placés"] = $sejour->loadList($where); foreach ($listNotAff["Non placés"] as $key => $_sejour) { /* @var CSejour $_sejour*/ $_sejour->loadRefsAffectations(); if (!empty($_sejour->_ref_affectations) || $_sejour->service_id && !in_array($_sejour->service_id, $services_ids)) { unset($listNotAff["Non placés"][$key]); } else { $_sejour->loadRefPatient()->loadRefDossierMedical(false); $_sejour->checkDaysRelative($date); } $_sejour->loadRefPrestation(); } $dossiers = CMbArray::pluck($listNotAff["Non placés"], "_ref_patient", "_ref_dossier_medical"); CDossierMedical::massCountAntecedentsByType($dossiers, "deficience"); // Chargement des affectations dans les couloirs (sans lit_id) $where = array();
$where_convalescence = "`convalescence` LIKE '%{$convalescence_sejour}%'"; $where_sejour[] = $where_convalescence; } if ($remarque_sejour) { $where_remarque = "`rques` LIKE '%{$remarque_sejour}%'"; $where_sejour[] = $where_remarque; } if ($where_sejour) { $where_sejour = implode(" OR ", $where_sejour); } } $order_sejour = "patient_id"; $total_sejours = null; if ($where_sejour) { $total_sejours = $sejour->countList($where_sejour); $sejours = $sejour->loadList($where_sejour, $order_sejour, "{$page_sejour}, 30"); } foreach ($sejours as $value) { $value->loadRefPatient(); } // Recherches sur les Interventions /** @var COperation[] $interventions */ $interventions = array(); $intervention = new COperation(); $patients_intervention = array(); $where_intervention = null; if ($recherche_intervention == "and") { if ($materiel_intervention) { $where_intervention["materiel"] = "LIKE '%{$materiel_intervention}%'"; } if ($examen_per_op) {
/** * Trigger after event store * * @param CMbObject $mbObject Object * * @throws CMbException * * @return bool */ function onAfterStore(CMbObject $mbObject) { if (!$this->isHandled($mbObject)) { return false; } $receiver = $mbObject->_receiver; if ($mbObject instanceof CCorrespondantPatient) { $patient = $mbObject->loadRefPatient(); $patient->_receiver = $receiver; } else { $patient = $mbObject; } // Si Serveur if (CAppUI::conf('sip server')) { $echange_hprim = new CEchangeHprim(); if (isset($patient->_eai_exchange_initiator_id)) { $echange_hprim->load($patient->_eai_exchange_initiator_id); } $initiateur = $receiver->_id == $echange_hprim->sender_id ? $echange_hprim->_id : null; $group = new CGroups(); $group->load($receiver->group_id); $group->loadConfigValues(); if (!$initiateur && !$group->_configs["sip_notify_all_actors"]) { return false; } $patient->_id400 = null; $idexPatient = new CIdSante400(); $idexPatient->loadLatestFor($patient, $receiver->_tag_patient); $patient->_id400 = $idexPatient->id400; $this->generateTypeEvenement("CHPrimXMLEnregistrementPatient", $patient, true, $initiateur); } else { if (!$receiver->isMessageSupported("CHPrimXMLEnregistrementPatient")) { return false; } if (!$patient->_IPP) { // Génération de l'IPP dans le cas de la création, ce dernier n'était pas créé if ($msg = $patient->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $IPP = new CIdSante400(); $IPP->loadLatestFor($patient, $receiver->_tag_patient); $patient->_IPP = $IPP->id400; } // Envoi pas les patients qui n'ont pas d'IPP if (!$receiver->_configs["send_all_patients"] && !$patient->_IPP) { return false; } $this->sendEvenementPatient("CHPrimXMLEnregistrementPatient", $patient); if ($receiver->_configs["send_insured_without_admit"]) { if (!$receiver->isMessageSupported("CHPrimXMLDebiteursVenue")) { return false; } $sejour = new CSejour(); $where = array(); $where["patient_id"] = "= '{$patient->_id}'"; $where["group_id"] = "= '{$receiver->group_id}'"; $datetime = CMbDT::dateTime(); $where["sortie"] = ">= '{$datetime}'"; /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where); // On va transmettre les informations sur le débiteur pour le séjour en cours, et ceux à venir foreach ($sejours as $_sejour) { if (!$patient->code_regime) { continue; } $_sejour->_receiver = $receiver; $_sejour->loadLastLog(); $_sejour->loadRefPatient(); if (!$_sejour->_NDA) { // Génération du NDA dans le cas de la création, ce dernier n'était pas créé if ($msg = $_sejour->generateNDA()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $NDA = new CIdSante400(); $NDA->loadLatestFor($_sejour, $receiver->_tag_sejour); $sejour->_NDA = $NDA->id400; } if ($receiver->isMessageSupported("CHPrimXMLDebiteursVenue")) { $this->sendEvenementPatient("CHPrimXMLDebiteursVenue", $_sejour); } } } $patient->_IPP = null; } return true; }
$sejour = new CSejour(); $sejour->type_pec = "O"; $ljoin = array(); $ljoin["patients"] = "sejour.patient_id = patients.patient_id"; $where = array(); $where["entree"] = "BETWEEN '{$date}' AND '{$next}'"; $where["sejour.annule"] = "= '0'"; $where["group_id"] = "= '{$group->_id}'"; $where["type_pec"] = "= 'O'"; if ($view == "non_eff") { $where[] = "(entree_reelle IS NULL OR entree_reelle = '0000-00-00 00:00:00')"; } if ($view == "non_prep") { $where["sejour.entree_preparee"] = "= '0'"; } $sejours = $sejour->loadList($where, "patients.nom ASC", null, null, $ljoin); CMbObject::massLoadFwdRef($sejours, "patient_id"); CMbObject::massLoadFwdRef($sejours, "grossesse_id"); CMbObject::massCountBackRefs($sejours, "operations"); /** @var $sejours CSejour[] */ foreach ($sejours as $_sejour) { $_sejour->loadRefPatient(); $_sejour->loadRefsOperations(); $grossesse = $_sejour->loadRefGrossesse(); $grossesse->_praticiens = CMbObject::massLoadFwdRef($grossesse->loadRefsSejours(), "praticien_id"); $grossesse->_praticiens += CMbObject::massLoadFwdRef($grossesse->loadRefsConsultations(), "_prat_id"); $naissances = $grossesse->loadRefsNaissances(); $sejours_enfant = CMbObject::massLoadFwdRef($naissances, "sejour_enfant_id"); CMbObject::massLoadFwdRef($sejours_enfant, "patient_id"); foreach ($naissances as $_naissance) { $_naissance->loadRefSejourEnfant()->loadRefPatient();
$_aff->loadView(); $_aff->loadRefSejour(); $_aff->_ref_sejour->loadRefPatient(); $_aff->_ref_sejour->_ref_praticien = $listPrat[$_aff->_ref_sejour->praticien_id]; $_aff->loadRefLit(); $_aff->_ref_lit->loadCompleteView(); foreach ($_aff->_ref_sejour->_ref_operations as $_operation) { $_operation->loadExtCodesCCAM(); } } } else { // Qui n'ont pas d'affectation $sejour = new CSejour(); $where = array("sejour.entree" => "< '{$date_recherche}'", "sejour.sortie" => "> '{$date_recherche}'", "sejour.praticien_id" => CSQLDataSource::prepareIn(array_keys($listPrat), $selPrat), "sejour.group_id" => "= '{$group->_id}'"); $order = "sejour.entree, sejour.sortie, sejour.praticien_id"; $listAff["NotAff"] = $sejour->loadList($where, $order); foreach ($listAff["NotAff"] as $_sejour) { /** @var CSejour $_sejour */ $_sejour->loadRefPatient(); $_sejour->_ref_praticien = $listPrat[$_sejour->praticien_id]; } } } else { if ($typeVue == 2) { // Recherche de tous les lits bloques pour urgences $ljoin = array(); $ljoin["lit"] = "lit.lit_id = affectation.lit_id"; $ljoin["chambre"] = "lit.chambre_id = chambre.chambre_id"; $where = array(); $where["chambre.annule"] = " = '0'"; $where["lit.annule"] = " = '0'";
} else { $where[] = "('{$datetime_check}' BETWEEN affectation.entree AND affectation.sortie) AND affectation.effectue = '0'"; } if ($vue) { $where["sejour.confirme"] = " IS NULL"; } /** @var CAffectation[] $presents */ $presents = $affectation->loadList($where, $order, null, "affectation_id", $ljoin); // Patients non placés if ($mode) { $whereNP[] = "'{$date}' BETWEEN DATE(sejour.entree) AND DATE(sejour.sortie)"; } else { $whereNP[] = "'{$datetime_check}' BETWEEN sejour.entree AND sejour.sortie"; } /** @var CSejour[] $presentsNP */ $presentsNP = $sejour->loadList($whereNP, $orderNP, null, "sejour.sejour_id", $ljoinNP); $update_count = count($presents) . "/" . count($presentsNP); // Chargements des détails des séjours foreach ($presents as $key => $_present) { $_present->loadRefsFwd(); $sejour = $_present->_ref_sejour; $sejour->loadRefPatient(1); $sejour->loadRefPraticien(1); $sejour->checkDaysRelative($date); $sejour->loadRefsOperations(); $sejour->loadNDA(); if ($show_duree_preop || $show_hour_anesth) { $op = $sejour->loadRefCurrOperation($date); if ($show_duree_preop) { $op->updateHeureUS(); }
$sejour_rpu = $rpu->loadRefSejour(); $patient = $sejour_rpu->loadRefPatient(); $sejour_rpu->type = "comp"; $collisions = $sejour_rpu->getCollisions(); $check_merge = ""; $sejours_futur = array(); $count_collision = count($collisions); $sejour_collision = ""; if ($count_collision == 1) { $sejour_collision = current($collisions); $sejour_collision->loadRefPraticien(); $check_merge = $sejour_rpu->checkMerge($collisions); } else { if (!$count_collision) { $sejour = new CSejour(); $where = array("entree" => "BETWEEN '{$now}' AND '{$after}'", "sejour_id" => "!= '{$sejour->_id}'", "patient_id" => "= '{$patient->_id}'", "annule" => "= '0'"); /** @var CSejour[] $sejours_futur */ $sejours_futur = $sejour->loadList($where, "entree DESC", null, "type"); foreach ($sejours_futur as $_sejour_futur) { $_sejour_futur->loadRefPraticien()->loadRefFunction(); } } } $smarty = new CSmartyDP(); $smarty->assign("count_collision", $count_collision); $smarty->assign("rpu", $rpu); $smarty->assign("sejour", $sejour_rpu); $smarty->assign("sejours_futur", $sejours_futur); $smarty->assign("sejour_collision", $sejour_collision); $smarty->assign("check_merge", $check_merge); $smarty->display("inc_hospitalization_rpu.tpl");
$ljoin = array(); if ($praticien->isAnesth()) { $ljoin = array(); $ljoin["operations"] = "operations.sejour_id = sejour.sejour_id"; $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where[] = "operations.anesth_id = '{$chirSel}' OR (operations.anesth_id IS NULL AND plagesop.anesth_id = '{$chirSel}')"; } else { $where["sejour.praticien_id"] = "= '{$chirSel}'"; } $where["sejour.entree"] = "<= '{$date} 23:59:59'"; $where["sejour.sortie"] = ">= '{$date} 00:00:00'"; $where["sejour.annule"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $sejour = new CSejour(); /** @var CSejour[] $listSejours */ $listSejours = $sejour->loadList($where, null, null, null, $ljoin); CStoredObject::massLoadFwdRef($listSejours, "patient_id"); foreach ($listSejours as $_sejour) { $_sejour->loadRefPraticien(); $_sejour->loadRefPatient(); $_sejour->loadRefsOperations(); $_sejour->loadRefCurrAffectation("{$date} " . CMbDT::time()); $_sejour->_ref_curr_affectation->loadRefLit(); $_sejour->_ref_curr_affectation->_ref_lit->loadCompleteView(); } $lits = CMbArray::pluck($listSejours, "_ref_curr_affectation", "_ref_lit"); $sorter_chambre = CMbArray::pluck($lits, "_ref_chambre", "_view"); $sorter_service = CMbArray::pluck($lits, "_ref_chambre", "_ref_service", "_view"); $sorter_lit = CMbArray::pluck($lits, "_view"); $sorter_sejour_sortie = CMbArray::pluck($listSejours, "sortie"); $sorter_sejour_entree = CMbArray::pluck($listSejours, "entree");
$ljoin = array(); $ljoin["id_sante400"] = "sejour.sejour_id = id_sante400.object_id AND id_sante400.object_class = 'CSejour'"; $where["id_sante400.id_sante400_id"] = "IS NULL"; // Comptage $count = $sejour->countList($where, null, $ljoin); $max = $sip_config["repair_segment"]; $max = min($max, $count); CAppUI::stepAjax("Export de {$max} sur {$count} objets de type 'CSejour' à 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); $errors = 0; // Export réel if (!$sip_config["verify_repair"]) { $sejours = $sejour->loadList($where, $sejour->_spec->key, "0, {$max}"); if (!CAppUI::conf("dPplanningOp CSejour tag_dossier") || !CAppUI::conf("dPpatients CPatient tag_ipp")) { CAppUI::stepAjax("Aucun tag (patient/séjour) de défini pour la synchronisation.", UI_MSG_ERROR); return; } $echange = 0; foreach ($sejours as $sejour) { $sejour->loadRefPraticien(); $sejour->loadRefPatient(); $sejour->_ref_patient->loadIPP(); if ($sejour->_ref_prescripteurs) { $sejour->loadRefsPrescripteurs(); } $sejour->loadRefAdresseParPraticien(); $sejour->_ref_patient->loadRefsFwd(); $sejour->loadRefsActes();
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $date = CValue::get("date", CMbDT::date()); $group = CGroups::loadCurrent(); $sejour = new CSejour(); $where = array(); $where["sejour.grossesse_id"] = "IS NOT NULL"; $where["sejour.entree"] = "<= '{$date} 23:59:59' "; $where["sejour.sortie"] = ">= '{$date} 00:00:00' "; $where["sejour.group_id"] = " = '{$group->_id}' "; $order = "sejour.entree DESC"; /** @var CSejour[] $listSejours */ $listSejours = $sejour->loadList($where, $order, null, null, null); $grossesses = CMbObject::massLoadFwdRef($listSejours, "grossesse_id"); CMbObject::massLoadFwdRef($grossesses, "parturiente_id"); $naissances = CMbObject::massLoadBackRefs($grossesses, "naissances"); $sejours_enfant = CMbObject::massLoadFwdRef($naissances, "sejour_enfant_id"); CMbObject::massLoadFwdRef($sejours_enfant, "patient_id"); foreach ($listSejours as $_sejour) { $grossesse = $_sejour->loadRefGrossesse(); $grossesse->loadRefParturiente(); $naissances = $grossesse->loadRefsNaissances(); $grossesse->_ref_sejour = $_sejour; $grossesse->loadRefLastOperation(); foreach ($naissances as $_naissance) { $_naissance->loadRefSejourEnfant()->loadRefPatient(); $_naissance->loadRefOperation(); }
* * @category Admissions * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $sejours_ids = CValue::get("sejours_ids"); // Chargement des séjours $sejour = new CSejour(); $where = array(); $where["sejour_id"] = "IN ({$sejours_ids})"; /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where); $result = ""; CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($sejours as $_sejour) { $_sejour->loadRefPatient(); } // Tri par nom de patient $sorter_nom = CMbArray::pluck($sejours, "_ref_patient", "nom"); $sorter_prenom = CMbArray::pluck($sejours, "_ref_patient", "prenom"); array_multisort($sorter_nom, SORT_ASC, $sorter_prenom, SORT_ASC, $sejours); $last_sejour = end($sejours); foreach ($sejours as $_sejour) { $_operation = $_sejour->loadRefLastOperation(); if (!$_operation->_id) { continue; }
$total_prat = array(); foreach ($listPrat as $key => $prat) { $totalPrat[$prat->_id]["prat"] = $prat; $totalPrat[$prat->_id]["hospi"] = 0; $totalPrat[$prat->_id]["ambu"] = 0; $totalPrat[$prat->_id]["total"] = 0; } $sejour = new CSejour(); $whereSejour = array(); $whereSejour["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $whereSejour["sejour.entree_reelle"] = "IS NOT NULL"; $whereSejour[] = "`sejour`.`entree_reelle` <= '{$dateEntree}'"; $whereSejour["sejour.sortie"] = ">= '{$dateSortie}'"; $whereSejour["sejour.annule"] = "= '0'"; /** @var CSejour[] $listSejours */ $listSejours = $sejour->loadList($whereSejour); // Stockage des informations liées au praticiens foreach ($listSejours as $_sejour) { $_sejour->loadRefPraticien(1); foreach ($listPrat as $key => $_prat) { // Cas d'un sejour de type Ambulatoire if ($_prat->_id == $_sejour->_ref_praticien->_id && $_sejour->type == "ambu") { $totalPrat[$_prat->_id]["ambu"]++; $totalAmbulatoire++; } // Autres cas if ($_prat->_id == $_sejour->_ref_praticien->_id && $_sejour->type == "comp") { $totalPrat[$_prat->_id]["hospi"]++; $totalHospi++; } // Total des hospitalisations (Ambu + autres)
/** * Charge les séjours sur le congés entre deux dates * * @param CPlageConge $plage Plage de congés concernée * @param string $date_min Date minimale * @param string $date_max Date maximale * * @return CSejour[] */ static function loadSejoursSurConges(CPlageConge $plage, $date_min, $date_max) { $group_id = CGroups::loadCurrent()->_id; $date_min = max($date_min, $plage->date_debut); $date_max = min($date_max, $plage->date_fin); $date_max = CMbDT::date("+1 DAY", $date_max); $sejour = new CSejour(); $ljoin["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id"; $ljoin["technicien"] = "bilan_ssr.technicien_id = technicien.technicien_id"; $where = array(); $where["type"] = "= 'ssr'"; $where["group_id"] = "= '{$group_id}'"; $where["sejour.annule"] = "!= '1'"; $where["sejour.entree"] = "<= '{$date_max}'"; $where["sejour.sortie"] = ">= '{$date_min}'"; $where["technicien.kine_id"] = " = '{$plage->user_id}'"; return $sejour->loadList($where, null, null, null, $ljoin); }