예제 #1
0
$crequest->addWhereClause("sejour.entree", "> '{$date}'");
$crequest->addGroup(array("`sejour_id`"));
$crequest->addHaving(array("COUNT(`sejour`.`sejour_id`)>1"));
$sejour = new CSejour();
$ds = $sejour->getDS();
$list_id_sejour = $ds->loadList($crequest->makeSelect());
usort($list_id_sejour, function ($a, $b) {
    return -strnatcmp($a["sortie"], $b["sortie"]);
});
$list_sejour = array();
$patients = array();
$guesses = array();
foreach ($list_id_sejour as $_id_sejour) {
    $sejour = new CSejour();
    $sejour->load($_id_sejour["sejour_id"]);
    $sejour->loadBackRefs("rpu");
    $sejour->loadRefPatient();
    $sejour->loadNDA();
    if (!isset($patients[$sejour->patient_id])) {
        $patients["{$sejour->patient_id}"] = $sejour->_ref_patient;
    }
    $patients["{$sejour->patient_id}"]->_ref_sejours[$sejour->_id] = $sejour;
}
$mergeables_count = 0;
foreach ($patients as $patient_id => $patient) {
    $patient->loadIPP();
    $guess = array();
    $nicer = array();
    $guess["mergeable"] = isset($guesses[$patient_id]) ? true : false;
    // Sibling patients
    $siblings = $patient->getSiblings();
예제 #2
0
    $lits = CMbObject::massLoadFwdRef($affectations, "lit_id");
    CMbObject::massLoadFwdRef($lits, "chambre_id");
    foreach ($affectations as $_affectation) {
        $_affectation->loadRefLit()->loadCompleteView();
        $_affectation->_rowspan = CMbDT::daysRelative($_affectation->entree, $_affectation->sortie) + 1;
        $date_temp = CMbDT::date($_affectation->entree);
        while ($date_temp <= CMbDT::date($_affectation->sortie)) {
            $dates[$date_temp] = $_affectation->_id;
            $date_temp = CMbDT::date("+1 day", $date_temp);
        }
    }
}
// Gestion des liaisons hors séjour
$dates_after = array();
/** @var CItemLiaison[] $items_liaisons */
$items_liaisons = $sejour->loadBackRefs("items_liaisons");
CMbObject::massLoadFwdRef($items_liaisons, "item_souhait_id");
CMbObject::massLoadFwdRef($items_liaisons, "item_realise_id");
CMbObject::massLoadFwdRef($items_liaisons, "sous_item_id");
foreach ($items_liaisons as $_item_liaison) {
    if ($_item_liaison->date > CMbDT::date($sejour->sortie)) {
        $dates_after[] = CMbDT::date($_item_liaison->date);
    }
    $_item = $_item_liaison->loadRefItem();
    $_item_liaison->loadRefItemRealise();
    if (!$_item->_id) {
        $_item = $_item_liaison->_ref_item_realise;
    }
    $_item_liaison->loadRefSousItem();
    switch ($_item->object_class) {
        case "CPrestationJournaliere":
예제 #3
0
 /**
  * Get all possible and existing RHS for given sejour, by date as keys
  *
  * @param CSejour $sejour Sejour
  *
  * @return CRHS[],null Null if not applyable
  */
 static function getAllRHSsFor(CSejour $sejour)
 {
     if (!$sejour->_id || $sejour->type != "ssr") {
         return null;
     }
     $rhss = array();
     /** @var CRHS $_rhs */
     foreach ($sejour->loadBackRefs("rhss") as $_rhs) {
         $rhss[$_rhs->date_monday] = $_rhs;
     }
     for ($date_monday = CMbDT::date("last sunday + 1 day", $sejour->_entree); $date_monday <= $sejour->_sortie; $date_monday = CMbDT::date("+1 week", $date_monday)) {
         if (!isset($rhss[$date_monday])) {
             $rhs = new CRHS();
             $rhs->sejour_id = $sejour->_id;
             $rhs->date_monday = $date_monday;
             $rhs->updateFormFields();
             $rhss[$date_monday] = $rhs;
         }
     }
     ksort($rhss);
     return $rhss;
 }