Ejemplo n.º 1
0
 /**
  * Create domains
  *
  * @return bool
  */
 protected function createDomain()
 {
     $ds = $this->ds;
     $groups = $ds->loadList("SELECT * FROM groups_mediboard");
     $tab = array("CPatient", "CSejour");
     foreach ($groups as $_group) {
         $group_id = $_group["group_id"];
         $group_configs = $ds->loadHash("SELECT * FROM groups_config WHERE object_id = '{$group_id}'");
         foreach ($tab as $object_class) {
             if ($object_class == "CPatient") {
                 $tag_group = CPatient::getTagIPP($group_id);
                 if (!$group_configs || !array_key_exists("ipp_range_min", $group_configs)) {
                     continue;
                 }
                 $range_min = $group_configs["ipp_range_min"];
                 $range_max = $group_configs["ipp_range_max"];
             } else {
                 $tag_group = CSejour::getTagNDA($group_id);
                 if (!$group_configs || !array_key_exists("nda_range_min", $group_configs)) {
                     continue;
                 }
                 $range_min = $group_configs["nda_range_min"];
                 $range_max = $group_configs["nda_range_max"];
             }
             if (!$tag_group) {
                 continue;
             }
             // Insert domain
             $query = "INSERT INTO `domain` (`domain_id`, `incrementer_id`, `actor_id`, `actor_class`, `tag`)\n                      VALUES (NULL, NULL, NULL, NULL, '{$tag_group}');";
             $ds->query($query);
             $domain_id = $ds->insertId();
             // Insert group domain
             $query = "INSERT INTO `group_domain` (`group_domain_id`, `group_id`, `domain_id`, `object_class`, `master`)\n                      VALUES (NULL, '{$group_id}', '{$domain_id}', '{$object_class}', '1');";
             $ds->query($query);
             // Select incrementer for this group
             $select = "SELECT *\n                     FROM `incrementer`\n                     LEFT JOIN `domain` ON `incrementer`.`incrementer_id` = `domain`.`incrementer_id`\n                     LEFT JOIN `group_domain` ON `domain`.`domain_id` = `group_domain`.`domain_id`\n                     WHERE `incrementer`.`object_class` = '{$object_class}'\n                     AND `group_domain`.`group_id` = '{$group_id}';";
             $incrementer = $ds->loadHash($select);
             $incrementer_id = $incrementer["incrementer_id"];
             if ($incrementer_id) {
                 // Update domain with incrementer_id
                 $query = "UPDATE `domain`\n                      SET `incrementer_id` = '{$incrementer_id}'\n                      WHERE `domain_id` = '{$domain_id}';";
                 $ds->query($query);
                 // Update incrementer
                 if (!array_key_exists("nda_range_min", $group_configs) || !$range_max || $range_min === null) {
                     continue;
                 }
                 $query = "UPDATE `incrementer`\n                      SET `range_min` = '{$range_min}', `range_max` = '{$range_max}'\n                      WHERE `incrementer_id` = '{$incrementer_id}';";
                 $ds->query($query);
             }
         }
     }
     // Update constraints to stick to the event
     return true;
 }
Ejemplo n.º 2
0
 /**
  * @see parent::onAfterStore()
  */
 function onAfterStore(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return false;
     }
     if (!$mbObject->_id || !$this->create) {
         return false;
     }
     $group_id = $mbObject->_id;
     $object_class = array("CSejour", "CPatient");
     global $dPconfig;
     $original_value = $dPconfig["eai"]["use_domain"];
     $dPconfig["eai"]["use_domain"] = "0";
     foreach ($object_class as $_class) {
         switch ($_class) {
             case "CSejour":
                 $tag_group = CSejour::getTagNDA($group_id);
                 break;
             case "CPatient":
                 $tag_group = CPatient::getTagIPP($group_id);
                 break;
             default:
                 $tag_group = null;
         }
         if (!$tag_group) {
             continue;
         }
         $domain = new CDomain();
         $domain->tag = $tag_group;
         if ($domain->store()) {
             continue;
         }
         $group_domain = new CGroupDomain();
         $group_domain->group_id = $group_id;
         $group_domain->domain_id = $domain->_id;
         $group_domain->object_class = $_class;
         $group_domain->master = "1";
         $group_domain->store();
     }
     $dPconfig["eai"]["use_domain"] = "{$original_value}";
     return true;
 }
Ejemplo n.º 3
0
$idex->object_id = $object_id;
$idex->loadMatchingObject();
$group_id = CGroups::loadCurrent()->_id;
$idexs = array();
$idex_id = null;
if ($idex->_id) {
    $filter = new CIdSante400();
    $filter->object_class = $idex->object_class;
    $filter->object_id = $idex->object_id;
    $filter->tag = CSejour::getTagNDA($group_id);
    $idexs = $filter->loadMatchingList();
    $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_trash");
    $idexs += $filter->loadMatchingList();
    $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_cancel");
    $idexs += $filter->loadMatchingList();
    $filter->tag = CSejour::getTagNDA($group_id, "tag_dossier_pa");
    $idexs += $filter->loadMatchingList();
    // Chargement de l'objet afin de récupérer l'id400 associé (le latest)
    $object = new $filter->object_class();
    $object->load($filter->object_id);
    $object->loadNDA($group_id);
    foreach ($idexs as $key => $_idex) {
        $_idex->loadRefs();
        $_idex->getSpecialType();
        if (!$idex_id && $_idex->id400 == $object->_NDA) {
            $idex_id = $_idex->_id;
        }
    }
    ksort($idexs);
}
$smarty = new CSmartyDP();
/**
 * Liaison des object Hprim21 aux objets métiers
 *
 * @category Hprim21
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License; see http://www.gnu.org/licenses/gpl.html
 * @version  SVN: $Id: httpreq_link_hprim_objects.php 21867 2014-02-03 08:18:27Z nicolasld $
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
CApp::setTimeLimit(240);
$date_limite = CMbDT::date("- 1 month");
$qte_limite = 1000;
$tag_ipp = CPatient::getTagIPP();
$tag_sejour = CSejour::getTagNDA();
// Gestion des médecins
$hprimMedecin = new CHprim21Medecin();
$where = array();
$where["user_id"] = "IS NULL";
/** @var CHprim21Medecin[] $listHprimMedecins */
$listHprimMedecins = $hprimMedecin->loadList($where);
$total = count($listHprimMedecins);
// Liaison à un médecin existant
$nouv = 0;
foreach ($listHprimMedecins as $_medecin) {
    $_medecin->loadRefExchange();
    $echg_hprim = $_medecin->_ref_echange_hprim21;
    $medecin = new CMediusers();
    $ljoin = array();
    $ljoin["users"] = "users.user_id = users_mediboard.user_id";
Ejemplo n.º 5
0
 /**
  * Update the form (derived) fields plain fields
  *
  * @return void
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = $this->libelle ? $this->libelle : $this->nom;
     $this->_type_echange = $this->_class;
     $this->_self_tag = $this->getTag($this->group_id);
     $this->_tag_patient = CPatient::getTagIPP($this->group_id);
     $this->_tag_sejour = CSejour::getTagNDA($this->group_id);
     $this->_tag_consultation = CConsultation::getObjectTag($this->group_id);
     $this->_tag_mediuser = CMediusers::getObjectTag($this->group_id);
     $this->_tag_service = CService::getObjectTag($this->group_id);
     $this->_tag_chambre = CChambre::getObjectTag($this->group_id);
     $this->_tag_lit = C**t::getObjectTag($this->group_id);
     $this->_tag_movement = CMovement::getObjectTag($this->group_id);
     $this->_tag_visit_number = CSmp::getObjectTag($this->group_id);
 }
Ejemplo n.º 6
0
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 27868 $
 */
CCanDo::checkRead();
$view_current = CValue::get("view_current", 0);
CView::enforceSlave();
$smarty = new CSmartyDP();
// Pour l'établissement courant
if ($view_current) {
    $etab = CGroups::loadCurrent();
    $current_group = $etab->_id;
    $res_current_etab = array();
    $where = array();
    $ljoin = array();
    // - Nombre de séjours
    $tag_NDA = CSejour::getTagNDA($current_group);
    $where["tag"] = " = '{$tag_NDA}'";
    $where["object_class"] = " = 'CSejour'";
    $idex = new CIdSante400();
    $res_current_etab["CSejour-_NDA"] = $idex->countList($where);
    // - Patients IPP
    $tag_ipp = CPatient::getTagIPP($current_group);
    $where["tag"] = " = '{$tag_ipp}'";
    $where["object_class"] = " = 'CPatient'";
    $idex = new CIdSante400();
    $res_current_etab["CPatient-_IPP"] = $idex->countList($where);
    // - Nombre de consultations
    $where = array();
    $consultation = new CConsultation();
    $ljoin["plageconsult"] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
    $ljoin["users_mediboard"] = "plageconsult.chir_id = users_mediboard.user_id";
Ejemplo n.º 7
0
$filter->object_id = $idex->object_id;
$filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id);
$idexs = $filter->loadMatchingList(CGroups::loadCurrent()->_id);
$filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_cancel");
$idexs = array_merge($idexs, $filter->loadMatchingList());
$filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_trash");
$idexs = array_merge($idexs, $filter->loadMatchingList());
$filter->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id, "tag_dossier_pa");
$idexs = array_merge($idexs, $filter->loadMatchingList());
$tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id);
// Chargement de l'objet afin de récupérer l'id400 associé
$object = new $filter->object_class();
$object->load($filter->object_id);
$object->loadNDA(CGroups::loadCurrent()->_id);
foreach ($idexs as $_idex) {
    // L'identifiant 400 coché
    if ($_idex->_id == $idex_id) {
        $_idex->tag = CSejour::getTagNDA(CGroups::loadCurrent()->_id);
        if ($msg = $_idex->store()) {
            CAppUI::stepAjax($msg, UI_MSG_ERROR);
        }
        continue;
    }
    // L'ancien est à mettre en trash
    if ($_idex->id400 == $object->_NDA) {
        $_idex->tag = CAppUI::conf("dPplanningOp CSejour tag_dossier_trash") . $tag;
        if ($msg = $_idex->store()) {
            CAppUI::stepAjax($msg, UI_MSG_ERROR);
        }
    }
}
Ejemplo n.º 8
0
     $where["cp"] = $whereSoundex["cp"] = $whereLimited["cp"] = "LIKE '{$patient_cp}%'";
 }
 if ($prat_id) {
     $ljoin["consultation"] = "`consultation`.`patient_id` = `patients`.`patient_id`";
     $ljoin["plageconsult"] = "`plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`";
     $ljoin["sejour"] = "`sejour`.`patient_id` = `patients`.`patient_id`";
     $where[] = $whereLimited[] = "plageconsult.chir_id = '{$prat_id}' OR sejour.praticien_id = '{$prat_id}'";
     $whereSoundex[] = "plageconsult.chir_id = '{$prat_id}' OR sejour.praticien_id = '{$prat_id}'";
     $group_by = "patient_id";
 }
 if ($patient_nda) {
     $ljoin["sejour"] = "`sejour`.`patient_id` = `patients`.`patient_id`";
     $ljoin["id_sante400"] = "`id_sante400`.`object_id` = `sejour`.`sejour_id`";
     $where[] = $whereLimited[] = "`id_sante400`.`object_class` = 'CSejour'";
     $where["id_sante400.id400"] = " = '{$patient_nda}'";
     $where["id_sante400.tag"] = " = '" . CSejour::getTagNDA() . "'";
 }
 /** @var CPatient[] $patients */
 $patients = array();
 /** @var CPatient[] $patientsSoundex */
 $patientsSoundex = array();
 /** @var CPatient[] $patientsLimited */
 $patientsLimited = array();
 $order = "nom, prenom, naissance";
 $pat = new CPatient();
 // Chargement des patients
 if ($where) {
     // Séparation des patients par fonction
     if (CAppUI::conf('dPpatients CPatient function_distinct') && !CMediusers::get()->isAdmin()) {
         $function_id = CMediusers::get()->function_id;
         $where["function_id"] = $whereLimited["function_id"] = $whereSoundex["function_id"] = "= '{$function_id}'";
Ejemplo n.º 9
0
 /**
  * Trigger before event merge
  *
  * @param CMbObject $mbObject Object
  *
  * @throws CMbException
  *
  * @return bool
  */
 function onBeforeMerge(CMbObject $mbObject)
 {
     if (!parent::onBeforeMerge($mbObject)) {
         return false;
     }
     // Si pas en mode alternatif
     if (!CAppUI::conf("alternative_mode")) {
         throw new CMbException("no_alternative_mode");
     }
     $sejour = $mbObject;
     $sejour_elimine = new CSejour();
     $sejour_elimine->load(reset($mbObject->_merging));
     // Si Client
     if (!CAppUI::conf('smp server')) {
         $mbObject->_fusion = array();
         foreach (CGroups::loadGroups() as $_group) {
             $sender = CMbObject::loadFromGuid($mbObject->_eai_sender_guid);
             if ($sender && $sender->group_id == $_group->_id) {
                 continue;
             }
             $sejour->_NDA = null;
             $sejour->loadNDA($_group->_id);
             $sejour1_nda = $sejour->_NDA;
             $sejour_elimine->_NDA = null;
             $sejour_elimine->loadNDA($_group->_id);
             $sejour2_nda = $sejour_elimine->_NDA;
             // Passage en trash des NDA des séjours
             $tag_NDA = CSejour::getTagNDA($_group->_id);
             if (!$tag_NDA) {
                 continue;
             }
             $idexSejour = new CIdSante400();
             $idexSejour->tag = $tag_NDA;
             $idexSejour->object_class = "CSejour";
             $idexSejour->object_id = $sejour->_id;
             $idexsSejour = $idexSejour->loadMatchingList();
             $idexSejourElimine = new CIdSante400();
             $idexSejourElimine->tag = $tag_NDA;
             $idexSejourElimine->object_class = "CSejour";
             $idexSejourElimine->object_id = $sejour_elimine->_id;
             $idexsSejourElimine = $idexSejourElimine->loadMatchingList();
             /** @var CIdSante400[] $idexs */
             $idexs = array_merge($idexsSejour, $idexsSejourElimine);
             $idexs_changed = array();
             if (count($idexs) > 1) {
                 foreach ($idexs as $_idex) {
                     // On continue pour ne pas mettre en trash le NDA du séjour que l'on garde
                     if ($_idex->id400 == $sejour1_nda) {
                         continue;
                     }
                     $old_tag = $_idex->tag;
                     $_idex->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_trash') . $tag_NDA;
                     $_idex->last_update = CMbDT::dateTime();
                     if (!($msg = $_idex->store())) {
                         if ($_idex->object_id == $sejour_elimine->_id) {
                             $idexs_changed[$_idex->_id] = $old_tag;
                         }
                     }
                 }
             }
             if (!$sejour1_nda && !$sejour2_nda) {
                 continue;
             }
             $mbObject->_fusion[$_group->_id] = array("sejourElimine" => $sejour_elimine, "sejour1_nda" => $sejour1_nda, "sejour2_nda" => $sejour2_nda, "idexs_changed" => $idexs_changed);
         }
     }
     $this->sendFormatAction("onBeforeMerge", $mbObject);
     return true;
 }
Ejemplo n.º 10
0
$request = new CRequest();
$request->addSelect("sejour.sejour_id");
$request->addTable("sejour");
$request->addLJoinClause("rpu", "rpu.sejour_id = sejour.sejour_id");
$request->addWhereClause("annule", "!='1'");
$request->addWhereClause("facture", "!='1'");
$request->addWhereClause("sortie_reelle", "BETWEEN '" . CMbDT::dateTime("-{$day}DAY") . "' AND '" . CMbDT::dateTime() . "'");
$request->addWhereClause("rpu.sejour_id", "IS NOT NULL");
$request->addGroup("sejour.sejour_id");
$request->addHaving("count(*) = 1");
$request->setLimit($limit);
$list_sejour = $ds->loadList($request->makeSelect());
foreach ($list_sejour as $_sejour_id) {
    $sejour = new CSejour();
    $sejour->load($_sejour_id["sejour_id"]);
    if (!($nda = $sejour->getTagNDA())) {
        continue;
    }
    $rpu = $sejour->loadRefRPU();
    if ($rpu->mutation_sejour_id) {
        $sejour_reliquat = $rpu->loadRefSejourMutation();
        if (!($nda = $sejour_reliquat->getTagNDA())) {
            continue;
        }
        $consultations = $sejour_reliquat->loadRefsConsultations();
        foreach ($consultations as $_consultation) {
            $_consultation->facture = "1";
            $_consultation->store();
        }
    }
    $sejour->facture = "1";