示例#1
0
/**
 * Delete content and update exchange
 *
 * @param CContentTabular $content_tabular Content tabular
 * @param int             $type_content_id Content ID
 * @param date            $date_max        Date max
 * @param int             $max             Max exchange
 *
 * @return int
 */
function deleteContentAndUpdateExchange(CContentTabular $content_tabular, $type_content_id, $date_max, $max)
{
    $ds = $content_tabular->_spec->ds;
    // Récupère les content Tabulé
    $query = "SELECT cx.content_id\r\n            FROM content_tabular AS cx, exchange_hl7v2 AS ec\r\n            WHERE ec.`date_production` < '{$date_max}'\r\n            AND ec.{$type_content_id} = cx.content_id\r\n            LIMIT {$max};";
    $ids = CMbArray::pluck($ds->loadList($query), "content_id");
    // Suppression du contenu Tabulé
    $query = "DELETE FROM content_tabular\r\n            WHERE content_id " . CSQLDataSource::prepareIn($ids);
    $ds->exec($query);
    // Mise à jour des échanges
    $query = "UPDATE exchange_hl7v2\r\n              SET `{$type_content_id}` = NULL \r\n              WHERE `{$type_content_id}` " . CSQLDataSource::prepareIn($ids);
    $ds->exec($query);
    $count = $ds->affectedRows();
    return $count;
}
 /**
  * count list of Op not linked to a plage
  *
  * @param date      $start    date de début
  * @param date|null $end      date de fin
  * @param array     $chir_ids chir targeted
  *
  * @return int number of HP found
  */
 static function countForDates($start, $end = null, $chir_ids = array())
 {
     $d_start = $start;
     $d_end = $end ? $end : $start;
     $op = new COperation();
     $ljoin = array();
     $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id";
     $where = array();
     if (count($chir_ids)) {
         $where["chir_id"] = CSQLDataSource::prepareIn($chir_ids);
     }
     $where["operations.plageop_id"] = "IS NULL";
     $where["operations.date"] = "BETWEEN '{$d_start}' AND '{$d_end}'";
     $where["operations.annulee"] = "= '0'";
     $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
     /** @var COperation[] $listHorsPlage */
     return $op->countList($where, null, $ljoin);
 }
 static function loadAllFor($libelles)
 {
     $libelles = array_map("strtoupper", $libelles);
     // Initialisation du tableau
     $colors_by_libelle = array();
     foreach ($libelles as $_libelle) {
         $color = new self();
         $color->libelle = $_libelle;
         $colors_by_libelle[$_libelle] = $color;
     }
     $color = new self();
     $where = array();
     $libelles = array_map("addslashes", $libelles);
     $where["libelle"] = CSQLDataSource::prepareIn($libelles);
     foreach ($color->loadList($where) as $_color) {
         $colors_by_libelle[$_color->libelle] = $_color;
     }
     return $colors_by_libelle;
 }
 /**
  * count the number of alerts for this bloc
  *
  * @param array $key_ids list of salle keys
  *
  * @return int
  */
 static function countAlertesIntervsForSalles($key_ids)
 {
     if (!count($key_ids)) {
         return 0;
     }
     $inSalles = CSQLDataSource::prepareIn($key_ids);
     $alerte = new CAlert();
     $ljoin = array();
     $ljoin["operations"] = "operations.operation_id = alert.object_id";
     $ljoin["plagesop"] = "plagesop.plageop_id = operations.plageop_id";
     $where = array();
     $where["alert.object_class"] = "= 'COperation'";
     $where["alert.tag"] = "= 'mouvement_intervention'";
     $where["alert.handled"] = "= '0'";
     $where[] = "operations.salle_id " . $inSalles . " OR plagesop.salle_id " . $inSalles . " OR (plagesop.salle_id IS NULL AND operations.salle_id IS NULL)";
     return $alerte->countList($where, null, $ljoin);
 }
示例#5
0
    $ljoin["facture_relance"] = "facture_relance.object_id = facture_etablissement.facture_id";
    $where["facture_relance.object_class"] = " = 'CFactureEtablissement'";
}
$where["{$type_date_search}"] = "BETWEEN '{$date_min}' AND '{$date_max}'";
if (($etat_cloture == "1" || $search_easy == 3) && $type_date_search != "cloture") {
    $where["cloture"] = "IS NULL";
} elseif (($etat_cloture == "2" || $search_easy == 2) && $type_date_search != "cloture") {
    $where["cloture"] = "IS NOT NULL";
}
if ($no_finish_reglement || $search_easy == 6) {
    $where["patient_date_reglement"] = "IS NOT NULL";
}
if ($chirSel == -1) {
    $where["praticien_id"] = CSQLDataSource::prepareIn(array_keys($listChir));
} else {
    $where["praticien_id"] = $chirSel ? " = '{$chirSel}'" : CSQLDataSource::prepareIn(array_keys($listChir));
}
if ($patient_id) {
    $where["patient_id"] = " = '{$patient_id}' ";
}
if ($num_facture) {
    $where["facture_id"] = " = '{$num_facture}' ";
}
if ($numero && !CAppUI::conf("dPfacturation Other use_search_easy") && ($etat_relance || $search_easy == 7)) {
    $where["facture_relance.numero"] = " = '{$numero}'";
}
if ($search_easy == 5) {
    $where["annule"] = " = '1'";
}
if ($search_easy == 1) {
    $where["definitive"] = " = '1'";
$function_id = $user->function_id;
// Liste des fonctions disponibles
$functions = new CFunctions();
$order = "text";
$functions = $functions->loadListWithPerms(PERM_EDIT, null, $order);
// Chargement du catalogue demandé
$catalogue = new CCatalogueLabo();
$catalogue->load(CValue::getOrSession("catalogue_labo_id"));
if ($catalogue->_id && $catalogue->getPerm(PERM_EDIT)) {
    $catalogue->loadRefs();
    $function_id = $catalogue->function_id;
} else {
    $catalogue = new CCatalogueLabo();
}
// Chargement de tous les catalogues
$where = array();
$where["pere_id"] = "IS NULL";
$where[] = "function_id IS NULL OR function_id " . CSQLDataSource::prepareIn(array_keys($functions));
$order = "identifiant";
$listCatalogues = $catalogue->loadList($where, $order);
foreach ($listCatalogues as &$_catalogue) {
    $_catalogue->loadRefsDeep();
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("canSante400", CModule::getCanDo("dPsante400"));
$smarty->assign("listCatalogues", $listCatalogues);
$smarty->assign("catalogue", $catalogue);
$smarty->assign("function_id", $function_id);
$smarty->assign("functions", $functions);
$smarty->display("vw_edit_catalogues.tpl");
示例#7
0
// Consultations gratuites
if (!CValue::getOrSession("cs")) {
    $where[] = "du_patient + du_tiers > 0";
}
if ($date) {
    //CSQLDataSource::$trace = true;
    $ljoin["facture_liaison"] = "facture_liaison.facture_id = facture_etablissement.facture_id";
    $ljoin["sejour"] = "facture_liaison.object_id = sejour.sejour_id";
    $where["facture_liaison.facture_class"] = " = 'CFactureEtablissement'";
    $where["facture_liaison.object_class"] = " = 'CSejour'";
    $where["sejour.sortie"] = " LIKE '%{$date}%'";
}
// Filtre sur les praticiens
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
$where["facture_etablissement.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
// Initialisation du tableau de reglements
$reglement = new CReglement();
$recapReglement["total"] = array("nb_sejours" => "0", "reste_patient" => "0", "reste_tiers" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "nb_impayes_tiers" => "0", "nb_impayes_patient" => "0", "secteur1" => "0", "secteur2" => "0");
foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) {
    $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0");
}
// Reglements via les factures d'établissement
$where["cloture"] = "IS NOT NULL";
$where["facture_etablissement.patient_id"] = "IS NOT NULL";
$order = "ouverture, praticien_id";
//mbTrace(count($where));
$facture = new CFactureEtablissement();
$listFactures = $facture->loadGroupList($where, $order, null, "facture_id", $ljoin);
$listPlages = array();
foreach ($listFactures as $_facture) {
示例#8
0
$where["bloc_id"] = "= '{$bloc_id}'";
$salles = $salle->loadListWithPerms(PERM_READ, $where);
// Récupération des opérations
$ljoin = array();
$ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id";
$where = array();
$in_salles = CSQLDataSource::prepareIn(array_keys($salles));
$where[] = "plagesop.salle_id {$in_salles}  OR operations.salle_id {$in_salles}";
$where["materiel"] = "!= ''";
$where[] = " operations.date BETWEEN '{$date_min}' AND '{$date_max}'";
if ($praticien_id) {
    $where["operations.chir_id"] = " = '{$praticien_id}'";
} elseif ($function_id) {
    $mediuser = new CMediusers();
    $users = $mediuser->loadProfessionnelDeSante(PERM_READ, $function_id);
    $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($users));
}
$order = "operations.date, rank";
$operation = new COperation();
$ops = $operation->loadList($where, $order, null, "operation_id", $ljoin);
$operations = array();
$commande = new CCommandeMaterielOp();
foreach ($commande->_specs["etat"]->_list as $spec) {
    $operations[$spec] = array();
}
foreach ($ops as $_op) {
    /** @var COperation $_op */
    $_op->loadRefPatient();
    $_op->loadRefChir()->loadRefFunction();
    $_op->loadRefPlageOp();
    $_op->loadExtCodesCCAM();
示例#9
0
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19285 $
 */
CCanDo::checkRead();
$user = CMediusers::get();
// Chargement des fontions
$function = new CFunctions();
$listFunctions = $function->loadListWithPerms(PERM_EDIT);
// Chargement du pack demandé
$pack = new CPackExamensLabo();
$pack->load(CValue::getOrSession("pack_examens_labo_id"));
if ($pack->_id && $pack->getPerm(PERM_EDIT)) {
    $pack->loadRefs();
} else {
    $pack = new CPackExamensLabo();
}
//Chargement de tous les packs
$where = array("function_id IS NULL OR function_id " . CSQLDataSource::prepareIn(array_keys($listFunctions)));
$where["obsolete"] = " = '0'";
$order = "libelle";
$listPacks = $pack->loadList($where, $order);
foreach ($listPacks as $key => $curr_pack) {
    $listPacks[$key]->loadRefs();
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("listFunctions", $listFunctions);
$smarty->assign("listPacks", $listPacks);
$smarty->assign("pack", $pack);
$smarty->display("vw_edit_packs.tpl");
示例#10
0
}
$affectation = new CAffectation();
$affectations = $affectation->loadList($where, $order, null, null, $ljoin);
$_sejours = CStoredObject::massLoadFwdRef($affectations, "sejour_id");
$services = $services + CStoredObject::massLoadFwdRef($affectations, "service_id");
$patients = CStoredObject::massLoadFwdRef($_sejours, "patient_id");
CPatient::massCountPhotoIdentite($patients);
foreach ($affectations as $_affectation_imc) {
    /* @var CAffectation $_affectation_imc*/
    if (CAppUI::conf("dPhospi vue_temporelle show_imc_patient", "CService-" . $_affectation_imc->service_id)) {
        $_affectation_imc->loadRefSejour()->loadRefPatient()->loadRefLatestConstantes(null, array("poids", "taille"));
    }
}
// Préchargement des users
$user = new CUser();
$where = array("user_id" => CSQLDataSource::prepareIn(CMbArray::pluck($_sejours, "praticien_id")));
$users = $user->loadList($where);
$praticiens = CStoredObject::massLoadFwdRef($_sejours, "praticien_id");
CStoredObject::massLoadFwdRef($praticiens, "function_id");
CStoredObject::massCountBackRefs($affectations, "affectations_enfant");
$_operations = CStoredObject::massLoadBackRefs($sejours, "operations", "date ASC");
CStoredObject::massLoadFwdRef($_operations, "plageop_id");
loadVueTempo($sejours, $suivi_affectation, null, $operations, $date_min, $date_max, $period, $prestation_id, $functions_filter, $filter_function, $sejours_non_affectes);
if (CAppUI::conf("dPadmissions show_deficience")) {
    CStoredObject::massLoadBackRefs($patients, "dossier_medical");
    $dossiers = CMbArray::pluck($sejours, "_ref_patient", "_ref_dossier_medical");
    CDossierMedical::massCountAntecedentsByType($dossiers, "deficience");
}
loadVueTempo($affectations, $suivi_affectation, null, $operations, $date_min, $date_max, $period, $prestation_id, $functions_filter, $filter_function, $sejours_non_affectes);
if (count($affectations) && CAppUI::conf("dPadmissions show_deficience")) {
    $dossiers = CMbArray::pluck($affectations, "_ref_sejour", "_ref_patient", "_ref_dossier_medical");
示例#11
0
 /**
  * Charge la liste de plages et opérations pour un jour donné
  * Analogue à CMediusers::loadRefsForDay
  *
  * @param string $date Date to look for
  * @param bool   $second_chir Use chir_2, chir_3 and chir_4
  *
  * @return void
  */
 function loadRefsForDay($date, $second_chir = false)
 {
     // Liste des utilisateurs
     $user = new CMediusers();
     $listPrats = $user->loadPraticiens(PERM_READ);
     // Liste des fonctions
     $function = new CFunctions();
     $listFunctions = $function->loadListWithPerms(PERM_READ);
     // Plages d'opérations
     $plage = new CPlageOp();
     $conf_chambre_operation = $plage->conf("chambre_operation");
     $ljoin = array();
     $add_where = "";
     $add_or_where = "";
     if ($second_chir) {
         $ljoin["operations"] = "plagesop.plageop_id = operations.plageop_id";
         $prepare_prats = CSQLDataSource::prepareIn(array_keys($listPrats));
         $add_where = "operations.chir_id " . $prepare_prats . " OR operations.chir_2_id " . $prepare_prats . " OR operations.chir_3_id " . $prepare_prats . " OR operations.chir_4_id " . $prepare_prats;
         $add_or_where = " OR {$add_where}";
     }
     $where = array();
     $where["plagesop.date"] = "= '{$date}'";
     $where["plagesop.salle_id"] = "= '{$this->_id}'";
     $where[] = "`plagesop`.`chir_id` " . CSQLDataSource::prepareIn(array_keys($listPrats)) . " OR `plagesop`.`spec_id` " . CSQLDataSource::prepareIn(array_keys($listFunctions)) . $add_or_where;
     $order = "debut";
     $this->_ref_plages = $plage->loadList($where, $order, null, "plageop_id", $ljoin);
     // Chargement d'optimisation
     CMbObject::massLoadFwdRef($this->_ref_plages, "chir_id");
     CMbObject::massLoadFwdRef($this->_ref_plages, "anesth_id");
     CMbObject::massLoadFwdRef($this->_ref_plages, "spec_id");
     CMbObject::massLoadFwdRef($this->_ref_plages, "salle_id");
     CMbObject::massCountBackRefs($this->_ref_plages, "notes");
     CMbObject::massCountBackRefs($this->_ref_plages, "affectations_personnel");
     foreach ($this->_ref_plages as $_plage) {
         /** @var CPlageOp $_plage */
         $_plage->loadRefChir();
         $_plage->loadRefAnesth();
         $_plage->loadRefSpec();
         $_plage->loadRefSalle();
         $_plage->makeView();
         $_plage->loadRefsOperations();
         $_plage->loadRefsNotes();
         $_plage->loadAffectationsPersonnel();
         $_plage->_unordered_operations = array();
         // Chargement d'optimisation
         CMbObject::massLoadFwdRef($_plage->_ref_operations, "chir_id");
         $sejours = CMbObject::massLoadFwdRef($_plage->_ref_operations, "sejour_id");
         CMbObject::massLoadFwdRef($sejours, "patient_id");
         foreach ($_plage->_ref_operations as $operation) {
             $operation->loadRefAnesth();
             $operation->loadRefChirs();
             $operation->loadRefPatient();
             $operation->loadExtCodesCCAM();
             $operation->loadRefPlageOp();
             if ($conf_chambre_operation) {
                 $operation->loadRefAffectation();
             }
             // Extraire les interventions non placées
             if ($operation->rank == 0) {
                 $_plage->_unordered_operations[$operation->_id] = $operation;
                 unset($_plage->_ref_operations[$operation->_id]);
             }
         }
     }
     // Interventions déplacés
     $deplacee = new COperation();
     $ljoin = array();
     $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id";
     $where = array();
     $where["operations.plageop_id"] = "IS NOT NULL";
     $where["plagesop.salle_id"] = "!= operations.salle_id";
     $where["plagesop.date"] = "= '{$date}'";
     $where["operations.salle_id"] = "= '{$this->_id}'";
     $where[] = "`plagesop`.`chir_id` " . CSQLDataSource::prepareIn(array_keys($listPrats)) . " OR `plagesop`.`spec_id` " . CSQLDataSource::prepareIn(array_keys($listFunctions)) . $add_or_where;
     $order = "operations.time_operation";
     $this->_ref_deplacees = $deplacee->loadList($where, $order, null, "operation_id", $ljoin);
     // Chargement d'optimisation
     CMbObject::massLoadFwdRef($this->_ref_deplacees, "chir_id");
     $sejours_deplacees = CMbObject::massLoadFwdRef($this->_ref_deplacees, "sejour_id");
     CMbObject::massLoadFwdRef($sejours_deplacees, "patient_id");
     foreach ($this->_ref_deplacees as $_deplacee) {
         /** @var COperation $_deplacee */
         $_deplacee->loadRefChirs();
         $_deplacee->loadRefPatient();
         $_deplacee->loadExtCodesCCAM();
         $_deplacee->loadRefPlageOp();
     }
     // Hors plage
     $urgence = new COperation();
     $ljoin = array();
     $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id";
     $where = array();
     $where["operations.date"] = "= '{$date}'";
     $where["operations.plageop_id"] = "IS NULL";
     $where["operations.salle_id"] = "= '{$this->_id}'";
     if ($second_chir) {
         $where[] = $add_where;
     } else {
         $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($listPrats));
     }
     $order = "time_operation, chir_id";
     $this->_ref_urgences = $urgence->loadList($where, $order, null, "operation_id");
     // Chargement d'optimisation
     CMbObject::massLoadFwdRef($this->_ref_urgences, "chir_id");
     $sejours_urgences = CMbObject::massLoadFwdRef($this->_ref_urgences, "sejour_id");
     CMbObject::massLoadFwdRef($sejours_urgences, "patient_id");
     foreach ($this->_ref_urgences as $_urgence) {
         /** @var COperation $_urgence */
         $_urgence->loadRefChirs();
         $_urgence->loadRefPatient();
         $_urgence->loadExtCodesCCAM();
         $_urgence->loadRefPlageOp();
         if ($conf_chambre_operation) {
             $_urgence->loadRefAffectation();
         }
     }
 }
示例#12
0
}
// filtre sur les types de sortie
$filterType = "";
if ($type == "ambucomp") {
    $filterType = "AND (`sejour`.`type` = 'ambu' OR `sejour`.`type` = 'comp')";
} elseif ($type) {
    if ($type !== 'tous') {
        $filterType = "AND `sejour`.`type` = '{$type}'";
    }
} else {
    $filterType = "AND `sejour`.`type` != 'urg' AND `sejour`.`type` != 'seances'";
}
// filtre sur les services
if (count($services_ids) && $enabled_service) {
    $leftjoinService = "LEFT JOIN affectation\n                        ON affectation.sejour_id = sejour.sejour_id AND affectation.sortie = sejour.sortie";
    $filterService = "AND affectation.service_id " . CSQLDataSource::prepareIn($services_ids);
} else {
    $leftjoinService = $filterService = "";
}
// filtre sur le praticiens
if ($prat_id) {
    $filterPrat = "AND sejour.praticien_id = '{$prat_id}'";
} else {
    $filterPrat = "";
}
if ($only_confirmed) {
    $filterConfirmed = "AND sejour.confirme IS NOT NULL";
} else {
    $filterConfirmed = "";
}
$group = CGroups::loadCurrent();
示例#13
0
        $tab_start[$j] = date("t", mktime(0, 0, 0, $i, 1, $year));
        $j++;
    }
} else {
    list($a, $m, $j) = explode("-", $filter->date_debut);
    $debut_periode = "{$a}-{$m}-01";
    $fin_periode = CMbDT::transform('+1 month', $debut_periode, '%Y-%m-%d');
    $fin_periode = CMbDT::transform('-1 day', $fin_periode, '%Y-%m-%d');
}
$tableau_periode = array();
for ($i = 0; $i < CMbDT::daysRelative($debut_periode, $fin_periode) + 1; $i++) {
    $tableau_periode[$i] = CMbDT::transform('+' . $i . 'day', $debut_periode, '%Y-%m-%d');
}
$where = array();
$where[] = "((date_debut >= '{$debut_periode}' AND date_debut <= '{$fin_periode}'" . ")OR (date_fin >= '{$debut_periode}' AND date_fin <= '{$fin_periode}')" . "OR (date_debut <='{$debut_periode}' AND date_fin >= '{$fin_periode}'))";
$where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id);
$plageconge = new CPlageConge();
$plagesconge = array();
$orderby = "user_id";
/** @var CPlageConge[] $plagesconge */
$plagesconge = $plageconge->loadList($where, $orderby);
$tabUser_plage = array();
$tabUser_plage_indices = array();
foreach ($plagesconge as $_plage) {
    $_plage->loadRefUser();
    $_plage->_ref_user->loadRefFunction();
    $_plage->_deb = CMbDT::daysRelative($debut_periode, $_plage->date_debut);
    $_plage->_fin = CMbDT::daysRelative($_plage->date_debut, $_plage->date_fin) + 1;
    $_plage->_duree = CMbDT::daysRelative($_plage->date_debut, $_plage->date_fin) + 1;
}
$smarty = new CSmartyDP();
// Patients non placés
$sejour = new CSejour();
$ljoinNP = array();
$ljoinNP["affectation"] = "sejour.sejour_id    = affectation.sejour_id";
$ljoinNP["patients"] = "sejour.patient_id   = patients.patient_id";
$ljoinNP["users"] = "sejour.praticien_id = users.user_id";
$whereNP = array();
$whereNP["sejour.group_id"] = "= '{$group->_id}'";
$whereNP["sejour.type"] = CSQLDataSource::prepareIn($types_hospi, $type_hospi);
$whereNP["affectation.affectation_id"] = "IS NULL";
$whereNP["affectation.lit_id"] = "IS NULL";
$whereNP["sejour.annule"] = "= '0'";
if (count($services_ids)) {
    // Tenir compte des affectations sans lit_id (dans le couloir du service)
    unset($whereNP["affectation.affectation_id"]);
    $whereNP[] = "((sejour.service_id " . CSQLDataSource::prepareIn($services_ids) . " OR sejour.service_id IS NULL) AND affectation.affectation_id IS NULL) OR " . "(affectation.lit_id IS NULL AND affectation.service_id " . CSQLDataSource::prepareIn($services_ids) . ")";
}
if ($praticien->_id) {
    $whereNP["sejour.praticien_id"] = "= '{$praticien->_id}'";
}
$order = $orderNP = null;
if ($order_col == "_patient") {
    $order = $orderNP = "patients.nom {$order_way}, patients.prenom, sejour.entree";
}
if ($order_col == "_praticien") {
    $order = $orderNP = "users.user_last_name {$order_way}, users.user_first_name";
}
if ($order_col == "_chambre") {
    $ljoin["lit"] = "lit.lit_id = affectation.lit_id";
    $ljoin["chambre"] = "chambre.chambre_id = lit.chambre_id";
    $order = "chambre.nom {$order_way}, patients.nom, patients.prenom, sejour.entree";
示例#15
0
$sejourReq = new CRequest();
$sejourReq->addLJoinClause("patients", "patients.patient_id = sejour.patient_id");
$sejourReq->addLJoinClause("users", "users.user_id = sejour.praticien_id");
$sejourReq->addWhereClause("sejour.{$filter->_horodatage}", "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max}'");
$sejourReq->addWhereClause("sejour.group_id", "= '{$group->_id}'");
$sejourReq->addWhereClause("sejour.annule", "= '0'");
// On supprime les sejours d'urgence
$sejourReq->addWhereClause("sejour.type", "!= 'urg'");
// Clause de filtre par spécialité / chir
if ($filter->_specialite or $filter->praticien_id) {
    $speChirs = new CMediusers();
    $speChirs = $speChirs->loadList(array("function_id" => "= '{$filter->_specialite}'"));
    if (count($filter->praticien_id)) {
        $sejourReq->addWhereClause("sejour.praticien_id", CSQLDataSource::prepareIn($filter->praticien_id));
    } else {
        $sejourReq->addWhereClause("sejour.praticien_id", CSQLDataSource::prepareIn(array_keys($speChirs)));
    }
}
if ($filter->_filter_type) {
    $sejourReq->addWhereClause("sejour.type", "= '{$filter->_filter_type}'");
}
if ($filter->convalescence == "o") {
    $sejourReq->addWhereClause(null, "(sejour.convalescence IS NOT NULL AND sejour.convalescence != '')");
}
if ($filter->convalescence == "n") {
    $sejourReq->addWhereClause(null, "(sejour.convalescence IS NULL OR sejour.convalescence = '')");
}
if ($filter->consult_accomp) {
    $sejourReq->addWhereClause(null, "(sejour.consult_accomp = '" . $filter->consult_accomp . "')");
}
$sejourReq->addOrder("DATE(sejour.{$filter->_horodatage})");
 /**
  * Mass load mechanism for forward references of an object collection
  *
  * @param self[] $objects      Array of objects
  * @param string $field        Field to load
  * @param string $object_class Restrict to explicit object class in case of meta reference
  * @param bool   $keep_sorted  Keep the same order as the one in $objects
  *
  * @return self[] Loaded collection, null if unavailable, with ids as keys of guids for meta references
  */
 static function massLoadFwdRef($objects, $field, $object_class = null, $keep_sorted = false)
 {
     if (!count($objects)) {
         return array();
     }
     $object = reset($objects);
     $spec = $object->_specs[$field];
     if (!$spec instanceof CRefSpec) {
         trigger_error("Can't mass load not ref '{$field}' for class '{$object->_class}'", E_USER_WARNING);
         return null;
     }
     $meta = $spec->meta;
     if ($object_class && !$spec->meta) {
         trigger_error("Mass load with object class is unavailable for non meta ref '{$field}' in class '{$object->_class}'", E_USER_WARNING);
         return null;
     }
     // Delegated mass load forward references by meta class then append in global array with guid as keys
     if ($meta && !$object_class) {
         $object_classes = array();
         foreach ($objects as $_object) {
             $object_classes[$_object->{$meta}] = true;
         }
         $fwd_objects = array();
         foreach (array_keys($object_classes) as $_object_class) {
             // Merge array_values to get rid of non integer keys
             $fwd_objects = array_merge($fwd_objects, array_values(self::massLoadFwdRef($objects, $field, $_object_class)));
         }
         // Final array has guids for keys;
         return array_combine(CMbArray::pluck($fwd_objects, "_guid"), $fwd_objects);
     }
     // No existing class
     if (!self::classExists($spec->class)) {
         return null;
     }
     /** @var self $fwd */
     $class = CValue::first($object_class, $spec->class);
     $fwd = self::getInstance($class);
     // Inactive module
     if (!$fwd->_ref_module) {
         return null;
     }
     // Get the ids
     $fwd_ids = array();
     if ($object_class) {
         foreach ($objects as $_object) {
             if ($_object->{$meta} == $object_class) {
                 $fwd_ids[] = $_object->{$field};
             }
         }
     } else {
         $fwd_ids = CMbArray::pluck($objects, $field);
     }
     // Trim real ids
     $fwd_ids = array_unique($fwd_ids);
     CMbArray::removeValue("", $fwd_ids);
     // Only run when there's something to look for
     if (!count($fwd_ids)) {
         return array();
     }
     $where[$fwd->_spec->key] = CSQLDataSource::prepareIn($fwd_ids);
     $list = $fwd->loadList($where);
     if (!$keep_sorted) {
         return $list;
     }
     $list_sorted = array();
     foreach ($fwd_ids as $_fwd_id) {
         $list_sorted[$_fwd_id] = $list[$_fwd_id];
     }
     return $list_sorted;
 }
示例#17
0
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkEdit();
$do = CValue::get("do", "0");
// Auto send categories
$category = new CFilesCategory();
$category->send_auto = "1";
foreach ($categories = $category->loadMatchingList() as $_category) {
    $_category->countDocItems();
    $_category->countUnsentDocItems();
}
// Unsent docItems
$max_load = CAppUI::conf("dPfiles CDocumentSender auto_max_load");
$where["file_category_id"] = CSQLDataSource::prepareIn(array_keys($categories));
$where["etat_envoi"] = "!= 'oui'";
$where["object_id"] = "IS NOT NULL";
$file = new CFile();
$items["CFile"] = $file->loadList($where, "file_id DESC", $max_load);
$count["CFile"] = $file->countList($where);
$document = new CCompteRendu();
$items["CCompteRendu"] = $document->loadList($where, "compte_rendu_id DESC", $max_load);
$count["CCompteRendu"] = $document->countList($where);
// Sending
$max_send = CAppUI::conf("dPfiles CDocumentSender auto_max_send");
foreach ($items as $_items) {
    $sent = 0;
    /** @var CDocumentItem[] $_items */
    foreach ($_items as $_item) {
        $_item->loadTargetObject();
示例#18
0
} else {
    $query = $request->makeSelectCount($log);
    $counts["copy"] = $ds->loadResult($query);
}
//</editor-fold>
//<editor-fold desc=" ----- Insert ----- ">
$request = new CRequest();
$request->addWhereClause("user_log_id", "BETWEEN {$min} AND {$max}");
$request->addForceIndex("PRIMARY");
// Insert clauses
$triplets = array();
foreach ($inserts as $_insert) {
    list($object_class, $type, $fields) = $_insert;
    $triplets[] = "{$object_class}-{$type}-{$fields}";
}
$where = "CONCAT_WS('-', `object_class`, `type`, `fields`) " . CSQLDataSource::prepareIn($triplets);
$request->addWhere($where);
// Actual query
if ($execute) {
    $query = $request->makeSelect($log);
    $list = $ds->loadList($query);
    $class_to_table = array();
    foreach ($list as $_row) {
        $_object_class = $_row["object_class"];
        $_type = $_row["type"];
        $_fields = $_row["fields"];
        if (!isset($class_to_table[$_object_class])) {
            $_obj = CModelObject::getInstance($_object_class);
            $_spec = $_obj->_spec;
            $class_to_table[$_object_class] = array("table" => $_spec->table, "key" => $_spec->key);
        }
示例#19
0
 */
CCanDo::checkRead();
// Récupération des paramètres
$filter = new CPlageconsult();
$filter->_date_min = CValue::getOrSession("_date_min", CMbDT::date());
$filter->_date_max = CValue::getOrSession("_date_max", CMbDT::date());
$consult = new CConsultation();
$where = array();
$ljoin["plageconsult"] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
$where["consultation.du_tiers"] = "> 0";
$where["consultation.tiers_date_reglement"] = "IS NULL";
$where["plageconsult.date"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max}'";
// Filtre sur les praticiens
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
$where["plageconsult.chir_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
$order = "plageconsult.date";
/** @var CConsultation[] $listConsults */
$listConsults = $consult->loadList($where, $order, null, null, $ljoin);
$total = array("nb" => 0, "value" => 0);
foreach ($listConsults as $consult) {
    $consult->loadRefsFwd();
    $consult->loadRefsReglements();
    // Chargment de la FSE
    if (CModule::getActive("fse")) {
        if ($fse = CFseFactory::createFSE()) {
            $fse->loadIdsFSE($consult);
        }
    }
    // Retour Noemie déjà traité
    $hasNoemie = !$consult->_current_fse || $consult->_current_fse->hasNoemie();
if ($patients_count[$state] > 0) {
    /** @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;
示例#21
0
    $ljoin["consultation"] = "facture_liaison.object_id = consultation.consultation_id";
    $ljoin["plageconsult"] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
    $where["facture_liaison.facture_class"] = " = 'CFactureCabinet'";
    $where["facture_liaison.object_class"] = " = 'CConsultation'";
    $where["plageconsult.plageconsult_id"] = " = '{$plage_id}'";
} else {
    $where["ouverture"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max}'";
}
// Consultations gratuites
if (!CValue::getOrSession("cs")) {
    $where[] = "du_patient + du_tiers > 0";
}
// Filtre sur les praticiens
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
$where["praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
// Initialisation du tableau de reglements
$reglement = new CReglement();
$recapReglement["total"] = array("nb_consultations" => "0", "reste_patient" => "0", "reste_tiers" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "nb_impayes_tiers" => "0", "nb_impayes_patient" => "0", "secteur1" => "0", "secteur2" => "0", "secteur3" => "0", "du_tva" => "0");
foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) {
    $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0");
}
// Etat des règlements
if ($all_impayes) {
    $where[] = "(patient_date_reglement IS NULL AND du_patient > 0)\n    || (tiers_date_reglement IS NULL AND du_tiers > 0)";
} else {
    if ($filter->_etat_reglement_patient == "reglee") {
        $where["patient_date_reglement"] = "IS NOT NULL";
    }
    if ($filter->_etat_reglement_patient == "non_reglee") {
        $where["patient_date_reglement"] = "IS NULL";
示例#22
0
        $whereFavoris["function_id"] = " IS NULL";
        $whereFavoris["group_id"] = " IS NULL";
        $whereFavoris["user_id"] = "= '{$user->_id}'";
        $tab_favoris_user = $favoris->loadList($whereFavoris);
        unset($whereFavoris["user_id"]);
        $function_id = $user->loadRefFunction()->_id;
        $whereFavoris["function_id"] = " = '{$function_id}'";
        $tab_favoris_function = $favoris->loadList($whereFavoris);
        unset($whereFavoris["function_id"]);
        $group_id = $user->loadRefFunction()->group_id;
        $whereFavoris["group_id"] = " = '{$group_id}'";
        $tab_favoris_group = $favoris->loadList($whereFavoris);
        $tab_favoris = $tab_favoris_user + $tab_favoris_function + $tab_favoris_group;
    }
    // récupération des favoris sans cibles avec search_auto à "oui"
    $whereFavorisSansCibles["contextes"] = CSQLDataSource::prepareIn(array("generique", $contexte));
    $whereFavorisSansCibles["function_id"] = " IS NULL";
    $whereFavorisSansCibles["group_id"] = " IS NULL";
    $whereFavorisSansCibles["user_id"] = "= '{$user->_id}'";
    $whereFavorisSansCibles["search_auto"] = " LIKE '1'";
    $tab_favoris_user_sans_cibles = $favoris_sans_cibles->loadList($whereFavorisSansCibles);
    unset($whereFavorisSansCibles["user_id"]);
    $function_id = $user->loadRefFunction()->_id;
    $whereFavoris["function_id"] = " = '{$function_id}'";
    $tab_favoris_function_sans_cibles = $favoris_sans_cibles->loadList($whereFavorisSansCibles);
    unset($whereFavorisSansCibles["function_id"]);
    $group_id = $user->loadRefFunction()->group_id;
    $whereFavorisSansCibles["group_id"] = " = '{$group_id}'";
    $tab_favoris_group_sans_cibles = $favoris->loadList($whereFavorisSansCibles);
    $tab_favoris += $tab_favoris_user_sans_cibles + $tab_favoris_function_sans_cibles + $tab_favoris_group_sans_cibles;
}
示例#23
0
 /**
  * Chargement des affectations courantes et à venir du patient
  *
  * @param date $date Date de référence
  *
  * @return void
  */
 function loadRefsAffectations($date = null)
 {
     $affectation = new CAffectation();
     // Affectations inactives
     if (!$affectation->_ref_module) {
         $this->_ref_curr_affectation = null;
         $this->_ref_next_affectation = null;
     }
     if (!$date) {
         $date = CMbDT::dateTime();
     }
     $sejours = $this->loadRefsSejours();
     $group = CGroups::loadCurrent();
     // Affectation actuelle et prochaine affectation
     $where["affectation.sejour_id"] = CSQLDataSource::prepareIn(array_keys($sejours));
     $where["sejour.group_id"] = "= '{$group->_id}'";
     $order = "affectation.entree";
     // @FIXME A quoi sert cette jointure ?
     $ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
     // Affection courante
     $this->_ref_curr_affectation = new CAffectation();
     $where["affectation.entree"] = "<  '{$date}'";
     $where["affectation.sortie"] = ">= '{$date}'";
     $this->_ref_curr_affectation->loadObject($where, $order, null, $ljoin);
     // Prochaine affectations
     $this->_ref_next_affectation = new CAffectation();
     $where["affectation.entree"] = "> '{$date}'";
     $this->_ref_next_affectation->loadObject($where, $order, null, $ljoin);
 }
        $quotas = $function->quotas;
    }
    $listPrat = CConsultation::loadPraticiens(PERM_EDIT, $user->function_id, null, true);
    $listAllPrat = CConsultation::loadPraticiens(null, null, null, true);
    $where = array();
    $where["date"] = $ds->prepare("BETWEEN %1 AND %2", "{$plage->date}", "{$plage->date}");
    $where[] = "libelle != 'automatique' OR libelle IS NULL";
    $where["chir_id"] = " = '{$user->_id}'";
    if ($display_nb_consult == "cab" || $display_nb_consult == "etab") {
        $where["chir_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
        /** @var CPlageconsult[] $plages_func */
        $plages_func = $plage->loadList($where);
        $utilisation_func = utilisation_rdv($plages_func, $listPlace, $plage);
    }
    if ($display_nb_consult == "etab") {
        $where["chir_id"] = CSQLDataSource::prepareIn(array_keys($listAllPrat));
        /** @var CPlageconsult[] $plages_etab */
        $plages_etab = $plage->loadList($where);
        $utilisation_etab = utilisation_rdv($plages_etab, $listPlace, $plage);
    }
    // next consult
    $next_plage = $plage->getNextPlage();
    // previous consult
    $previous_plage = $plage->getPreviousPlage();
}
// user's function available
$mediuser = new CMediusers();
$mediusers = $mediuser->loadProfessionnelDeSanteByPref(PERM_READ, $function_id);
// Vérifier le droit d'écriture sur la plage sélectionnée
$plage->canDo();
// Création du template
示例#25
0
$where = array();
// Filtre sur les dates
$where["reglement.date"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max} 23:59:59'";
// Filtre sur les modes de paiement
if ($filter->_mode_reglement) {
    $where["reglement.mode"] = "= '{$filter->_mode_reglement}'";
}
// Filtre sur les praticiens
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
// Chargement des règlements via les factures
$ljoin["facture_cabinet"] = "reglement.object_id = facture_cabinet.facture_id";
if (!$all_group_compta) {
    $where["facture_cabinet.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
}
$where["facture_cabinet.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
$where["reglement.object_class"] = " = 'CFactureCabinet'";
$reglement = new CReglement();
/** @var CReglement[] $reglements */
$reglements = $reglement->loadList($where, " facture_cabinet.facture_id, reglement.date", null, null, $ljoin);
$reglement = new CReglement();
// Calcul du récapitulatif
// Initialisation du tableau de reglements
$recapReglement["total"] = array("nb_consultations" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "secteur1" => "0", "secteur2" => "0", "secteur3" => "0", "du_tva" => "0");
foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) {
    $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0");
}
$listReglements = array();
$listConsults = array();
$factures = CStoredObject::massLoadFwdRef($reglements, "object_id");
$patients = CStoredObject::massLoadFwdRef($factures, "patient_id");
示例#26
0
    $smarty->assign("sans_anesth", $sans_anesth);
    $smarty->assign("count_ops", $count_ops);
    $smarty->display("vw_idx_visite_anesth.tpl");
} else {
    // Selection des plages du praticien et de celles de sa spécialité
    $praticien_id = null;
    $function_ids = null;
    if ($selPraticien->isPraticien()) {
        $praticien_id = $selPraticien->user_id;
        $function_ids = CMbArray::pluck($selPraticien->loadBackRefs("secondary_functions"), "function_id");
        $function_ids[] = $selPraticien->function_id;
    }
    // Planning du mois
    $month_min = CMbDT::format($date, "%Y-%m-01");
    $month_max = CMbDT::format($date, "%Y-%m-31");
    $sql = "SELECT plagesop.*, plagesop.date AS opdate,\r\n        SEC_TO_TIME(SUM(TIME_TO_SEC(operations.temp_operation))) AS duree,\r\n        COUNT(operations.operation_id) AS total,\r\n        SUM(operations.rank_voulu > 0) AS planned_by_chir,\r\n        COUNT(IF(operations.rank > 0, NULLIF(operations.rank, operations.rank_voulu), NULL)) AS order_validated,\r\n        functions_mediboard.text AS nom_function, functions_mediboard.color as color_function\r\n      FROM plagesop\r\n      LEFT JOIN operations\r\n        ON plagesop.plageop_id = operations.plageop_id\r\n          AND operations.annulee = '0'\r\n          AND operations.chir_id = '{$praticien_id}'\r\n      LEFT JOIN functions_mediboard\r\n        ON functions_mediboard.function_id = plagesop.spec_id\r\n      WHERE (plagesop.chir_id = '{$praticien_id}' OR plagesop.spec_id " . CSQLDataSource::prepareIn($function_ids) . ")\r\n        AND plagesop.date BETWEEN '{$month_min}' AND '{$month_max}'\r\n      GROUP BY plagesop.plageop_id\r\n      ORDER BY plagesop.date, plagesop.debut, plagesop.plageop_id";
    $listPlages = array();
    if ($praticien_id) {
        $listPlages = $ds->loadList($sql);
    }
    // Urgences du mois
    $sql = "SELECT operations.*, operations.date AS opdate,\r\n        SEC_TO_TIME(SUM(TIME_TO_SEC(operations.temp_operation))) AS duree,\r\n        COUNT(operations.operation_id) AS total\r\n      FROM operations\r\n      WHERE operations.annulee = '0'\r\n        AND operations.chir_id = '{$praticien_id}'\r\n        AND operations.plageop_id IS NULL\r\n        AND operations.date BETWEEN '{$month_min}' AND '{$month_max}'\r\n      GROUP BY operations.date\r\n      ORDER BY operations.date";
    $listUrgences = array();
    if ($praticien_id) {
        $listUrgences = $ds->loadList($sql);
    }
    $listDays = array();
    foreach ($listPlages as $curr_ops) {
        $listDays[$curr_ops["opdate"]][$curr_ops["plageop_id"]] = $curr_ops;
    }
    foreach ($listUrgences as $curr_ops) {
示例#27
0
/**
 * dPbloc
 *
 * @category Bloc
 * @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();
$date = CValue::get("date");
$bloc_id = CValue::get("bloc_id");
$bloc = new CBlocOperatoire();
$bloc->load($bloc_id);
$in_salles = CSQLDataSource::prepareIn($bloc->loadBackIds("salles"));
$ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id";
$where[] = "operations.salle_id {$in_salles} OR plagesop.salle_id {$in_salles}";
$where[] = "operations.date = '{$date}'";
$where["labo"] = "= 1";
$order = "entree_salle, time_operation";
$operation = new COperation();
/** @var COperation[] $operations */
$operations = $operation->loadList($where, $order, null, null, $ljoin);
CMbObject::massLoadFwdRef($operations, "plageop_id");
$chirs = CMbObject::massLoadFwdRef($operations, "chir_id");
CMbObject::massLoadFwdRef($chirs, "function_id");
$sejours = CMbObject::massLoadFwdRef($operations, "sejour_id");
CMbObject::massLoadFwdRef($sejours, "patient_id");
foreach ($operations as $_operation) {
    $_operation->loadRefPatient();
if ($all_prats) {
    $prats = $user->loadPraticiens(PERM_READ);
    $where["plageconsult.chir_id"] = CSQLDataSource::prepareIn(array_keys($prats));
} else {
    $where["plageconsult.chir_id"] = "= '{$user->_id}'";
}
/* @var CConsultation[] $consultations*/
$consultation = new CConsultation();
$consultations = $consultation->loadList($where, null, null, null, $ljoin);
$totals["consultations"] = count($consultations);
/** @var CPlageConsult[] $plages */
$plages = CStoredObject::massLoadFwdRef($consultations, "plageconsult_id");
CStoredObject::massLoadFwdRef($consultations, "sejour_id");
CStoredObject::massLoadFwdRef($consultations, "patient_id");
// Pré-chargement des users
$where = array("user_id" => CSQLDataSource::prepareIn(CMbArray::pluck($plages, "chir_id")));
$user->loadList($where);
/** @var CMediusers[] $chirs */
$chirs = CStoredObject::massLoadFwdRef($plages, "chir_id");
CStoredObject::massLoadFwdRef($chirs, "function_id");
CStoredObject::massLoadBackRefs($consultations, "actes_ccam");
foreach ($consultations as $key => $_consult) {
    // Chargemement des codes CCAM
    $_consult->loadExtCodesCCAM();
    $codes_ccam = $_consult->_ext_codes_ccam;
    // Nombre d'acte cotés par le praticien et réinitialisation du count pour le cache
    $nb_actes_ccam = count($_consult->loadRefsActesCCAM());
    // Aucun acte prévu ou coté
    if (!count($codes_ccam) && !$_consult->_count_actes) {
        $_consult->loadRefSejour();
        $_consult->loadRefPraticien()->loadRefFunction();
 * $Id$
 *
 * @package    Mediboard
 * @subpackage dPfacturation
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$out = fopen('php://output', 'w');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="ExportCompta.xls"');
$facture_class = CValue::get("facture_class", 'CFactureEtablissement');
$factures_id = CValue::get("factures", array());
$factures_id = explode("|", $factures_id);
$where = array();
$where["facture_id"] = CSQLDataSource::prepareIn(array_values($factures_id));
$facture = new $facture_class();
$factures = $facture->loadList($where);
// Ligne d'entête
$fields = array();
$fields[] = "Date";
$fields[] = "Facture";
$fields[] = "Patient";
$fields[] = "Montant";
fputcsv($out, $fields, ';');
foreach ($factures as $_facture) {
    /* @var CFactureEtablissement $_facture*/
    $_facture->loadRefPatient();
    $_facture->loadRefsObjects();
    $_facture->loadRefsReglements();
    $fields = array();
示例#30
0
 /**
  * Count the exchanges for the all sejours
  *
  * @param CMbObject[] $objects CMbObject
  * @param String      $type    Type
  * @param String      $subtype Sous type
  *
  * @return void
  */
 static function massCountExchanges($objects, $type = null, $subtype = null)
 {
     if (!count($objects)) {
         return null;
     }
     $object = current($objects);
     $object_ids = CMbArray::pluck($objects, $object->_spec->key);
     $object_ids = array_unique($object_ids);
     CMbArray::removeValue("", $object_ids);
     if (!count($object_ids)) {
         return null;
     }
     $where = array("object_id" => CSQLDataSource::prepareIn($object_ids), "object_class" => "= '{$object->_class}'");
     if ($type) {
         $where["type"] = "= '{$type}'";
     }
     if ($subtype) {
         $where["sous_type"] = "= '{$subtype}'";
     }
     $count_exchanges = array();
     foreach (CExchangeDataFormat::getAll() as $_data_format) {
         /** @var CExchangeDataFormat $data_format */
         $data_format = new $_data_format();
         if (!$data_format->hasTable()) {
             continue;
         }
         $table_exchange = $data_format->_spec->table;
         $count_exchanges[$table_exchange] = $data_format->countMultipleList($where, null, "object_id", null, array("object_id"));
     }
     foreach ($count_exchanges as $_exchange => $_counts) {
         foreach ($_counts as $_value) {
             $total = $_value["total"];
             $object_id = $_value["object_id"];
             if (!isset($objects[$object_id]->_nb_exchanges_by_format[$_exchange])) {
                 $objects[$object_id]->_nb_exchanges_by_format[$_exchange] = 0;
             }
             $objects[$object_id]->_nb_exchanges_by_format[$_exchange] += $total;
             $objects[$object_id]->_nb_exchanges += $total;
         }
     }
 }