コード例 #1
0
ファイル: CSejour.class.php プロジェクト: fbone/mediboard4
 /**
  * check for a sectorisation rules to find a service_id
  * this feature will find the first sectorisation rule following his priority
  *
  * if 0 rules, no work
  * if 1 rule found, we redirect to the service_id
  *
  * @return bool it worked =)
  */
 function getServiceFromSectorisationRules()
 {
     if (!CAppUI::conf("dPplanningOp CRegleSectorisation use_sectorisation") || $this->service_id) {
         return false;
     }
     $this->completeField("type", "praticien_id", "entree", "sortie", "group_id", "type_pec", "handicap");
     // make sure entree & sortie well defined
     $this->updatePlainFields();
     $praticien = $this->loadRefPraticien();
     $patient = $this->loadRefPatient();
     $ds = CSQLDataSource::get('std');
     $where = array();
     $where["type_admission"] = $ds->prepare("= ? OR `type_admission` IS NULL", $this->type);
     $where["praticien_id"] = $ds->prepare("= ? OR `praticien_id` IS NULL", $this->praticien_id);
     $where["function_id"] = $ds->prepare("= ? OR `function_id` IS NULL", $praticien->function_id);
     $where["date_min"] = $ds->prepare("<= ? OR `date_min` IS NULL", $this->entree);
     $where["date_max"] = $ds->prepare(">= ? OR `date_max` IS NULL", $this->entree);
     $where["group_id"] = $ds->prepare("= ?", $this->group_id);
     if ($this->type_pec) {
         $where["type_pec"] = $ds->prepare("= ? OR `type_pec` IS NULL", $this->type_pec);
     }
     $duree = CMbDT::daysRelative($this->entree, $this->sortie);
     $where["duree_min"] = $ds->prepare("<= ? OR `duree_min` IS NULL", $duree);
     $where["duree_max"] = $ds->prepare(">= ? OR `duree_max` IS NULL", $duree);
     $where['age_min'] = $ds->prepare('<= ? OR `age_min` IS NULL', $patient->evalAge($this->entree));
     $where['age_max'] = $ds->prepare('>= ? OR `age_max` IS NULL', $patient->evalAge($this->entree));
     $where['handicap'] = $ds->prepare('= ? OR `handicap` IS NULL', $this->handicap);
     $regle = new CRegleSectorisation();
     /** @var CRegleSectorisation[] $regles */
     $regle->loadObject($where, "priority DESC");
     // one or more rules, lets do the work
     if ($regle->_id) {
         $regle->loadRefService();
         $this->service_id = $regle->service_id;
         CAppUI::setMsg("CRegleSectorisation-rule%d-rule%s", UI_MSG_OK, 1, $regle->_ref_service->nom);
         return true;
     }
     //no result, no work
     CAppUI::setMsg("CRegleSectorisation-no-rules-found", UI_MSG_WARNING);
     return false;
 }
コード例 #2
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage PlanningOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$rule_id = CValue::get("rule_id");
$clone = CValue::get("clone", 0);
$rule_sectorisation = new CRegleSectorisation();
$rule_sectorisation->load($rule_id);
if ($clone) {
    $rule_sectorisation->_id = null;
}
//mediusers
$user = CMediusers::get();
$users = $user->loadPraticiens(PERM_EDIT);
//functions
$function = new CFunctions();
$functions = $function->loadList(null, "text");
//services
$service = new CService();
$services = $service->loadGroupList();
//services
$group = new CGroups();
$groups = $group->loadList();
コード例 #3
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage PlanningOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$regleSector = new CRegleSectorisation();
$showinactive = CValue::getOrSession("inactive", 0);
$where = array();
$where["group_id"] = " ='" . CGroups::loadCurrent()->_id . "'";
if (!$showinactive) {
    $where["date_max"] = " > '" . CMbDT::dateTime() . "' OR date_max IS NULL";
    $where["date_min"] = " < '" . CMbDT::dateTime() . "' OR date_min IS NULL";
}
$order = "priority DESC, praticien_id, function_id";
$regles = $regleSector->loadList($where, $order);
//mass load
CStoredObject::massLoadFwdRef($regles, "praticien_id");
CStoredObject::massLoadFwdRef($regles, "service_id");
CStoredObject::massLoadFwdRef($regles, "function_id");
$max_prio = 0;
/**
 * @var CRegleSectorisation $_regle
 */
foreach ($regles as $_regle) {