$end = CMbDT::date("next sunday", $start);
$muser = new CMediusers();
$musers = $muser->loadProfessionnelDeSanteByPref(PERM_READ, $function_id);
$function = new CFunctions();
$function->load($function_id);
echo "<h1>" . $function->_view . " (" . CMbDT::format($start, CAppUI::conf('longdate')) . " - " . CMbDT::format($end, CAppUI::conf('longdate')) . ")</h1>";
$pconsult = new CPlageconsult();
$ds = $pconsult->getDS();
$where = array();
$where[] = "chir_id " . $ds->prepareIn(array_keys($musers)) . " OR remplacant_id " . $ds->prepareIn(array_keys($musers));
$where["date"] = " BETWEEN '{$start}' AND '{$end}' ";
/** @var CPlageconsult[] $pconsults */
$pconsults = $pconsult->loadList($where, "date", null, "chir_id");
$pconsults_by_date_and_prat = array();
if (!count($pconsults)) {
    echo "<div class='small-info'>Les praticiens de ce cabinet n'ont pas de plages de consultations sur cette période</div>";
    CApp::rip();
}
foreach ($pconsults as $_pc) {
    $chir_id = CValue::get("chir_id", $_pc->chir_id);
    $_pc->loadRefChir();
    $_pc->loadRefRemplacant();
    echo "<h2>";
    echo $_pc->_ref_chir->_view;
    if ($_pc->remplacant_id) {
        echo "remplacé par : " . $_pc->_ref_remplacant->_view;
    }
    echo "</h2>";
    echo CApp::fetch("dPcabinet", "inc_plage_selector_weekly");
    echo "<hr class=\"pagebreak\">";
}
    if (count($cstes)) {
        CStoredObject::massLoadFwdRef($cstes, "user_id");
        foreach ($cstes as $_cste) {
            $_cste->loadRefUser();
        }
        $smarty_cstes->assign("constantes_medicales_grid", CConstantesMedicales::buildGrid($cstes, false));
        $smarty_cstes->assign("sejour", $_sejour);
        $patients_offline[$patient->_guid]["constantes"] = $smarty_cstes->fetch("print_constantes.tpl", '', '', 0);
    }
    // Plan de soins
    $page_break = 0;
    if (count($patients_offline[$patient->_guid]["transmissions"]) || count($patients_offline[$patient->_guid]["observations"]) || count($patients_offline[$patient->_guid]["consultations"]) || $patients_offline[$patient->_guid]["constantes"]) {
        $page_break = 1;
    }
    $params = array("sejours_ids" => $_sejour->_id, "date" => $date, "hours_before" => "2", "hours_after" => "2", "empty_lines" => "2", "dialog" => 1, "mode_lite" => 1, "page_break" => $page_break);
    $patients_offline[$patient->_guid]["plan_soins"] = CApp::fetch("soins", "offline_plan_soins", $params);
    // Pour IE9 qui a des soucis avec les espaces entre une fermeture et une ouverture de td
    $patients_offline[$patient->_guid]["plan_soins"] = preg_replace('/>\\s+<(t[dh])/mi', "><\\1", $patients_offline[$patient->_guid]["plan_soins"]);
}
if ($service_id != "urgence") {
    if ($service_id == "NP") {
        array_multisort(CMbArray::pluck($patients_offline, "sejour", "_ref_patient", "nom"), SORT_ASC, $patients_offline);
    } else {
        array_multisort(CMbArray::pluck($patients_offline, "sejour", "_ref_curr_affectation", "_ref_lit", "_view"), SORT_ASC, $patients_offline);
    }
}
$smarty = new CSmartyDP();
$smarty->assign("date", $date);
$smarty->assign("service", $service);
$smarty->assign("service_id", $service_id);
$smarty->assign("patients_offline", $patients_offline);
$ljoin = array();
$ljoin["evenement_ssr"] = "evenement_ssr.therapeute_id = users_mediboard.user_id";
$where["evenement_ssr.evenement_ssr_id"] = "IS NOT NULL";
$group = "users_mediboard.user_id";
$kines = $mediuser->loadList($where, null, null, $group, $ljoin);
CPrescriptionLine::$_load_for_delete = true;
// Parcours des kines et chargement du planning
foreach ($kines as $_kine) {
    $args_planning = array();
    $args_planning["kine_id"] = $_kine->_id;
    $args_planning["surveillance"] = 0;
    $args_planning["large"] = 1;
    $args_planning["print"] = 1;
    $args_planning["height"] = 600;
    $args_planning["date"] = $date;
    // Chargement du planning de technicien
    $plannings[$_kine->_id]["technicien"] = CApp::fetch("ssr", "ajax_planning_technicien", $args_planning);
    // Chargement du planning de surveillance
    $args_planning["surveillance"] = 1;
    $plannings[$_kine->_id]["surveillance"] = CApp::fetch("ssr", "ajax_planning_technicien", $args_planning);
}
$monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date));
$sunday = CMbDT::date("next sunday", CMbDT::date("-1 DAY", $date));
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("plannings", $plannings);
$smarty->assign("kines", $kines);
$smarty->assign("date", $date);
$smarty->assign("monday", $monday);
$smarty->assign("sunday", $sunday);
$smarty->display("offline_plannings_techniciens.tpl");
$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;
    }
    $consult_anesth = $_operation->loadRefsConsultAnesth();
    if ($consult_anesth->_id) {
        $result .= CApp::fetch("dPcabinet", "print_fiche", array("dossier_anesth_id" => $consult_anesth->_id, "offline" => 1, "multi" => 1));
        if ($_sejour->_id != $last_sejour->_id) {
            $result .= "<hr style=\"border: none; page-break-after: always;\" />";
        }
    }
}
echo $result != "" ? $result : "<h1>" . CAppUI::tr("CConsultAnesth.none") . "</h1>";
/**
 * Read FTP files
 *  
 * @category FTP
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @version  SVN: $Id:$ 
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
$sender_ftp_id = CValue::get("sender_ftp_id");
$sender_ftp = new CSenderFTP();
$senders_ftp = array();
if ($sender_ftp_id) {
    $sender_ftp->load($sender_ftp_id);
    $sender_ftp->loadRefsExchangesSources();
    $senders_ftp[] = $sender_ftp->actif ? $sender_ftp : array();
} else {
    // Chargement de la liste des expéditeurs d'intégration
    $where = array();
    $where["actif"] = " = '1'";
    $senders_ftp = $sender_ftp->loadList($where);
    foreach ($senders_ftp as $_sender_ftp) {
        $_sender_ftp->loadRefsExchangesSources();
    }
}
foreach ($senders_ftp as $_sender_ftp) {
    echo CApp::fetch("ftp", "ajax_dispatch_files", array("sender_ftp_guid" => $_sender_ftp->_guid));
}
$plannings = array();
$equipements = array();
$plateau = new CPlateauTechnique();
$plateau->group_id = CGroups::loadCurrent()->_id;
/** @var CPlateauTechnique[] $plateaux */
$plateaux = $plateau->loadMatchingList();
foreach ($plateaux as $_plateau) {
    $_plateau->loadRefsEquipements();
    foreach ($_plateau->_ref_equipements as $_equipement) {
        if (!$_equipement->visualisable) {
            unset($_plateau->_ref_equipements[$_equipement->_id]);
            continue;
        }
        $equipements[$_equipement->_id] = $_equipement;
        $args_planning = array();
        $args_planning["equipement_id"] = $_equipement->_id;
        $args_planning["date"] = $date;
        $plannings[$_equipement->_id] = CApp::fetch("ssr", "ajax_planning_equipement", $args_planning);
    }
}
$monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date));
$sunday = CMbDT::date("next sunday", CMbDT::date("-1 DAY", $date));
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("plannings", $plannings);
$smarty->assign("plateaux", $plateaux);
$smarty->assign("equipements", $equipements);
$smarty->assign("date", $date);
$smarty->assign("monday", $monday);
$smarty->assign("sunday", $sunday);
$smarty->display("offline_plannings_equipements.tpl");
 * @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();
$date = CView::request("date", "date default|" . CMbDT::date());
CView::checkin();
$date_max = CMbDT::date("+2 month", $date);
$group = CGroups::loadCurrent();
$grossesse = new CGrossesse();
$where = array();
$where["terme_prevu"] = "BETWEEN '{$date}' AND '{$date_max}'";
$where["group_id"] = "= '{$group->_id}'";
$grossesses = $grossesse->loadList($where);
$sejours = CStoredObject::massLoadBackRefs($grossesses, "sejours", "entree_prevue DESC");
CStoredObject::massLoadBackRefs($sejours, "operations", "date ASC");
$fiches_anesth = array();
$params = array("dossier_anesth_id" => "", "operation_id" => "", "offline" => 1, "print" => 1, "pdf" => 0);
/** @var CGrossesse $_grossesse */
foreach ($grossesses as $_grossesse) {
    foreach ($_grossesse->loadRefsConsultations() as $_consult) {
        foreach ($_consult->loadRefsDossiersAnesth() as $_dossier_anesth) {
            $params["dossier_anesth_id"] = $_dossier_anesth->_id;
            $fiches_anesth[$_dossier_anesth->_id] = CApp::fetch("dPcabinet", "print_fiche", $params);
        }
    }
}
$smarty = new CSmartyDP();
$smarty->assign("fiches_anesth", $fiches_anesth);
$smarty->display("offline_print_fiches.tpl");
    $_sejour->loadRefsConsultAnesth();
    $_sejour->_ref_consult_anesth->loadRefConsultation();
    if ($_sejour->_ref_consult_anesth->_id && !$_sejour->_ref_consult_anesth->operation_id) {
        $consult_id = $_sejour->_ref_consult_anesth->_id;
    } else {
        $_sejour->loadRefsOperations();
        foreach ($_sejour->_ref_operations as $_operation) {
            $_operation->loadRefsConsultAnesth();
            if ($_operation->_ref_consult_anesth->_id) {
                $_operation->_ref_consult_anesth->loadRefConsultation();
                $consult_id = $_operation->_ref_consult_anesth->_id;
            }
        }
    }
    if ($consult_id) {
        $args_dossier = array("dossier_anesth_id" => $consult_id, "offline" => 1, "pdf" => 0);
        $fiches_anesth[$_sejour->_id] = CApp::fetch("dPcabinet", "print_fiche", $args_dossier);
    }
    $args_fiche = array("sejour_id" => $_sejour->_id, "offline" => 1);
    $outputs[$_sejour->_id] = CApp::fetch("soins", "print_dossier_soins", $args_fiche);
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("_sejours", $_sejours);
$smarty->assign("service_id", $service_id);
$smarty->assign("service", $service);
$smarty->assign("date", $date);
$smarty->assign("dateTime", CMbDT::dateTime());
$smarty->assign("outputs", $outputs);
$smarty->assign("fiches_anesth", $fiches_anesth);
$smarty->display("print_dossiers_service.tpl");
                $stat_etablissement = array("ref" => $etablissement_tranfert, "count" => 0);
            }
            $stat_etablissement["count"]++;
        }
    }
    // Statistiques d'entrée
    if (CMbDT::date($_sejour->entree) == $date) {
        $stats["entree"]["total"]++;
        // Statistiques  d'âge de patient
        $patient =& $_sejour->_ref_patient;
        if ($patient->_annees < "1") {
            $stats["entree"]["less_than_1"]++;
        }
        if ($patient->_annees >= "75") {
            $stats["entree"]["more_than_75"]++;
        }
    }
    // Chargement nécessaire du mode offline
    if ($offline) {
        $params = array("rpu_id" => $_sejour->_ref_rpu->_id, "dialog" => 1, "offline" => 1);
        $offlines[$_sejour->_id] = CApp::fetch("dPurgences", "print_dossier", $params);
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("date", $date);
$smarty->assign("stats", $stats);
$smarty->assign("sejours", $sejours);
$smarty->assign("offline", $offline);
$smarty->assign("offlines", $offlines);
$smarty->display("print_main_courante.tpl");
CMbObject::massLoadRefsNotes($sejours);
CSejour::massLoadNDA($sejours);
/** @var CPatient[] $patients */
$patients = CStoredObject::massLoadFwdRef($sejours, "patient_id");
CPatient::massLoadIPP($patients);
foreach ($sejours as $sejour) {
    $patient = $sejour->loadRefPatient();
    $sejour->loadRefPraticien();
    $sejour->checkDaysRelative($date);
    $sejour->loadRefsNotes();
}
$sorter_patient = CMbArray::pluck($sejours, "_ref_patient", "nom");
if ($service_id == "NP") {
    array_multisort($sorter_patient, SORT_ASC, $sejours);
} else {
    $sorter_affectation = CMbArray::pluck($sejours, "_ref_curr_affectation", "_ref_lit", "_view");
    array_multisort($sorter_affectation, SORT_ASC, $sorter_patient, SORT_ASC, $sejours);
}
$period = CAppUI::conf("soins offline_sejour period", $group);
$dossiers_complets = array();
foreach ($sejours as $sejour) {
    $params = array("sejour_id" => $sejour->_id, "dialog" => 1, "offline" => 1, "in_modal" => 1, "embed" => $embed, "period" => $period);
    $dossiers_complets[$sejour->_id] = CApp::fetch("soins", "print_dossier_soins", $params);
}
$smarty = new CSmartyDP();
$smarty->assign("date", $date);
$smarty->assign("hour", CMbDT::time());
$smarty->assign("service", $service);
$smarty->assign("sejours", $sejours);
$smarty->assign("dossiers_complets", $dossiers_complets);
$smarty->display("offline_sejours.tpl");
$root = $doc->createElement("modeles");
$doc->appendChild($root);
$where = array("compte_rendu_id" => CSQLDataSource::prepareIn($modeles_ids));
// Récupération des header_id, footer_id, preface_id et ending_id
$ds = CSQLDataSource::get("std");
$request = new CRequest();
$request->addTable("compte_rendu");
$request->addWhere($where);
$components_ids = array();
foreach (array("header_id", "footer_id", "preface_id", "ending_id") as $_component) {
    $request->select = array();
    $request->addSelect($_component);
    $components_ids = array_merge($components_ids, $ds->loadColumn($request->makeSelect()));
}
$modeles_ids = array_unique(array_merge($components_ids, $modeles_ids));
CMbArray::removeValue("", $modeles_ids);
foreach ($modeles_ids as $_modele_id) {
    $modele = CApp::fetch("dPcompteRendu", "ajax_export_modele", array("modele_id" => $_modele_id));
    $doc_modele = new CMbXMLDocument(null);
    @$doc_modele->loadXML($modele);
    // Importation du noeud CPrescription
    $modele_importe = $doc->importNode($doc_modele->firstChild, true);
    // Ajout de ce noeud comme fils de protocoles
    $doc->documentElement->appendChild($modele_importe);
}
$filename = 'Modèles ' . ($owner ? " - {$owner}" : '') . ($object_class ? " - " . CAppUI::tr($object_class) : '') . '.xml';
$content = $doc->saveXML();
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . strlen($content) . ';');
echo $content;
 /**
  * Loads the related fields for indexing datum
  *
  * @return array
  */
 function getIndexableData()
 {
     $prat = $this->getIndexablePraticien();
     if (!$prat) {
         $prat = new CMediusers();
     }
     $array["id"] = $this->_id;
     $array["author_id"] = $this->getOwnerId();
     $array["prat_id"] = $prat->_id;
     $array["title"] = $this->loadRefExClass()->name;
     $content = CApp::fetch("forms", "view_ex_object", array("ex_class_id" => $this->_ex_class_id, "ex_object_id" => $this->_id));
     $array["body"] = $this->getIndexableBody($content);
     $date = $this->getCreateDate();
     if (!$date) {
         $date = CMbDT::dateTime();
     }
     $array["date"] = str_replace("-", "/", $date);
     $array["function_id"] = $prat->function_id;
     $array["group_id"] = $this->group_id;
     $array["patient_id"] = $this->getIndexablePatient()->_id;
     $ref_object = $this->getReferenceObject("CSejour");
     if ($ref_object) {
         $array["object_ref_id"] = $ref_object->_id;
         $array["object_ref_class"] = $ref_object->_class;
     } else {
         $ref_object = $this->getReferenceObject("CConsultation");
         $array["object_ref_id"] = $ref_object->_id;
         $array["object_ref_class"] = $ref_object->_class;
     }
     $array["ex_class_id"] = $this->_ex_class_id;
     return $array;
 }
Beispiel #13
0
            if ($_consultation->heure < $heure_min) {
                $heure_min = $_consultation->heure;
            }
            if ($_consultation->chrono < CConsultation::TERMINE) {
                $nb_a_venir++;
            }
            if ($_consultation->chrono == CConsultation::PATIENT_ARRIVE) {
                $nb_attente++;
            }
            $_consultation->loadRefSejour();
            $_consultation->loadRefPatient();
            $_consultation->loadRefCategorie();
            $_consultation->countDocItems();
            if ($offline && $_consultation->patient_id && !isset($patients_fetch[$_consultation->patient_id])) {
                $args = array("object_guid" => $_consultation->_ref_patient->_guid, "ajax" => 1);
                $patients_fetch[$_consultation->patient_id] = CApp::fetch("system", "httpreq_vw_complete_object", $args);
            }
        }
    }
    if (!count($listPlages[$key_prat]["plages"]) && !$empty) {
        unset($listPlages[$key_prat]);
        unset($praticiens[$key_prat]);
    }
}
$prat_available = $praticiens;
if (!$prats_selected) {
    $prats_selected = array_keys($praticiens);
} else {
    $prats_selected = explode("-", $prats_selected);
}
$diff = array_diff(array_keys($praticiens), $prats_selected);
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);
Beispiel #15
0
<?php

/* $Id: $ */
/**
 * @package Mediboard
 * @subpackage soins
 * @version $Revision: $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
$sejour_id = CValue::getOrSession("sejour_id");
if ($sejour_id) {
    echo CApp::fetch("soins", "ajax_vw_dossier_sejour", array("sejour_id" => $sejour_id, "popup" => 1));
}
            unset($check_lists[$_check_list_id]);
            continue;
        }
        $_check_list->loadItemTypes();
        $_check_list->loadBackRefs('items');
        /** @var $_item CDailyCheckItem */
        foreach ($_check_list->_back['items'] as $_item) {
            $_item->loadRefsFwd();
        }
    }
    $params = array("dossier_anesth_id" => $_interv->_ref_consult_anesth->_id, "operation_id" => $_interv->_id, "offline" => 1, "print" => 1, "pdf" => 0);
    $fiches_anesthesies[$_interv->_id] = CApp::fetch("dPcabinet", "print_fiche", $params);
}
if ($offline && CModule::getActive("forms")) {
    $params = array("detail" => 3, "reference_id" => $sejour->_id, "reference_class" => $sejour->_class, "target_element" => "ex-objects-{$sejour->_id}", "print" => 1, "limit" => $forms_limit);
    $formulaires = CApp::fetch("forms", "ajax_list_ex_object", $params);
}
// L'appel à print_fiche écrase les interventions du dossier d'anesthésie.
// Il faut charger le suivi médical à posteriori
$cibles = array();
$last_trans_cible = array();
$users = array();
$sejour->loadSuiviMedical($datetime_min, null, $cibles, $last_trans_cible, $user_id = null, $users, 1);
if ($embed) {
    // Fichiers et documents du sejour
    $sejour->loadRefsDocItems(false);
    // Fichiers et documents des interventions
    $interventions = $sejour->_ref_operations;
    foreach ($interventions as $_interv) {
        $_interv->loadRefPlageOp();
        $_interv->loadRefsDocItems(false);
$nbDoc = array();
foreach ($sejours as $_sejour) {
    $compte_rendu = new CCompteRendu();
    $compte_rendu->setObject($_sejour);
    $compte_rendu->nom = $modele->nom;
    $compte_rendu->modele_id = $modele->_id;
    $compte_rendu->margin_top = $modele->margin_top;
    $compte_rendu->margin_bottom = $modele->margin_bottom;
    $compte_rendu->margin_left = $modele->margin_left;
    $compte_rendu->margin_right = $modele->margin_right;
    $compte_rendu->page_height = $modele->page_height;
    $compte_rendu->page_width = $modele->page_width;
    $compte_rendu->fast_edit = $modele->fast_edit;
    $compte_rendu->fast_edit_pdf = $modele->fast_edit_pdf;
    $compte_rendu->private = $modele->private;
    $compte_rendu->_source = $source;
    $compte_rendu->factory = $modele->factory;
    $templateManager = new CTemplateManager();
    $templateManager->isModele = false;
    $templateManager->document = $source;
    $_sejour->fillTemplate($templateManager);
    $templateManager->applyTemplate($compte_rendu);
    $compte_rendu->_source = $templateManager->document;
    if ($msg = $compte_rendu->store()) {
        CAppUI::setMsg($msg, UI_MSG_ERROR);
        continue;
    }
    $nbDoc[$compte_rendu->_id] = 1;
}
echo CApp::fetch("dPcompteRendu", "print_docs", array("nbDoc" => $nbDoc));