/**
  * Check anti-CSRF protection
  */
 static function checkProtection()
 {
     if (!CAppUI::conf("csrf_protection") || strtoupper($_SERVER['REQUEST_METHOD']) != 'POST') {
         return;
     }
     if (!isset($_POST["csrf"])) {
         CAppUI::setMsg("CCSRF-no_token", UI_MSG_ERROR);
         return;
     }
     if (array_key_exists($_POST['csrf'], $_SESSION["tokens"])) {
         $token = $_SESSION['tokens'][$_POST['csrf']];
         if ($token["lifetime"] >= time()) {
             foreach ($token["fields"] as $_field => $_value) {
                 if (CValue::read($_POST, $_field) != $_value) {
                     CAppUI::setMsg("CCSRF-form_corrupted", UI_MSG_ERROR);
                     unset($_SESSION['tokens'][$_POST['csrf']]);
                     return;
                 }
             }
             //mbTrace("Le jeton est accepté !");
             unset($_SESSION['tokens'][$_POST['csrf']]);
         } else {
             CAppUI::setMsg("CCSRF-token_outdated", UI_MSG_ERROR);
             unset($_SESSION['tokens'][$_POST['csrf']]);
         }
         return;
     }
     CAppUI::setMsg("CCSRF-token_does_not_exist", UI_MSG_ERROR);
     return;
 }
Beispiel #2
0
 public function process(CAppUI $AppUI, array $myArray)
 {
     if (!$this->object->bind($myArray)) {
         $AppUI->setMsg($this->object->getError(), UI_MSG_ERROR);
         $this->resultPath = $this->errorPath;
         return $AppUI;
     }
     $action = $this->delete ? 'deleted' : 'stored';
     $this->success = $this->delete ? $this->object->delete($AppUI) : $this->object->store($AppUI);
     if (is_array($this->success) || !$this->success) {
         $AppUI->holdObject($this->object);
         /*
          * TODO: This nasty structure was introduced in v3.0 and is only
          *   transitional while the individual modules are updated to
          *   stop using $this->success as both a boolean and the error array.
          *   -- This was due to a bad design decision on my part. -caseydk
          */
         if (is_array($this->object->getError())) {
             $AppUI->setMsg($this->object->getError(), UI_MSG_ERROR);
         } else {
             $AppUI->setMsg($this->success, UI_MSG_ERROR);
         }
         $this->resultPath = $this->errorPath;
         return $AppUI;
     }
     if ($this->success) {
         $AppUI->setMsg($this->prefix . ' ' . $action, UI_MSG_OK, true);
         $this->resultPath = $this->successPath;
     } else {
         $this->resultPath = $this->accessDeniedPath;
     }
     return $AppUI;
 }
Beispiel #3
0
 /**
  * Store
  *
  * @return void
  */
 function doStore()
 {
     // keep track of former values for fieldModified below
     $obj = $this->_obj;
     $old = $obj->loadOldObject();
     if ($msg = $obj->store()) {
         CAppUI::setMsg($msg, UI_MSG_ERROR);
         if ($this->redirectError) {
             CAppUI::redirect($this->redirectError);
         }
     } else {
         // Keep trace for redirections
         CValue::setSession($this->objectKey, $obj->_id);
         // Insert new group and function permission
         if ($obj->fieldModified("function_id") || !$old->_id) {
             $obj->insFunctionPermission();
             $obj->insGroupPermission();
         }
         // Message
         CAppUI::setMsg($old->_id ? $this->modifyMsg : $this->createMsg, UI_MSG_OK);
         // Redirection
         if ($this->redirectStore) {
             CAppUI::redirect($this->redirectStore);
         }
     }
 }
Beispiel #4
0
 /**
  * Check HL7v2 tables presence
  *
  * @return bool
  */
 protected function checkHL7v2Tables()
 {
     $dshl7 = CSQLDataSource::get("hl7v2", true);
     if (!$dshl7 || !$dshl7->loadTable("table_entry")) {
         CAppUI::setMsg("CHL7v2Tables-missing", UI_MSG_ERROR);
         return false;
     }
     return true;
 }
 /**
  * @see parent::doStore()
  */
 function doStore()
 {
     if (isset($_FILES['attachment'])) {
         $mail_id = CValue::post('mail_id');
         $mail = new CUserMail();
         $mail->load($mail_id);
         $files = array();
         foreach ($_FILES['attachment']['error'] as $key => $file_error) {
             if (isset($_FILES['attachment']['name'][$key])) {
                 $files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]);
             }
         }
         foreach ($files as $_key => $_file) {
             if ($_file['error'] == UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             if ($_file['error'] != 0) {
                 CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR);
                 continue;
             }
             $attachment = new CMailAttachments();
             $attachment->name = $_file['name'];
             $content_type = mime_content_type($_file['tmp_name']);
             $attachment->type = $attachment->getTypeInt($content_type);
             $attachment->bytes = $_file['size'];
             $attachment->mail_id = $mail_id;
             $content_type = explode('/', $content_type);
             $attachment->subtype = strtoupper($content_type[1]);
             $attachment->disposition = 'ATTACHMENT';
             $attachment->extension = substr(strrchr($attachment->name, '.'), 1);
             $attachment->part = $mail->countBackRefs('mail_attachments') + 1;
             $attachment->store();
             $file = new CFile();
             $file->setObject($attachment);
             $file->author_id = CAppUI::$user->_id;
             $file->file_name = $attachment->name;
             $file->file_date = CMbDT::dateTime();
             $file->fillFields();
             $file->updateFormFields();
             $file->doc_size = $attachment->bytes;
             $file->file_type = mime_content_type($_file['tmp_name']);
             $file->moveFile($_file, true);
             if ($msg = $file->store()) {
                 CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR);
                 CApp::rip();
             }
             $attachment->file_id = $file->_id;
             if ($msg = $attachment->store()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
                 CApp::rip();
             }
         }
         CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK);
     } else {
         parent::doStore();
     }
 }
/**
 * Fonction utilitaire pour la sauvegarde rapide d'un object avec génération du message
 *
 * @param CMbObject $object Objet à enregister
 *
 * @return void
 */
function storeObject($object)
{
    $title = $object->_id ? "-msg-modify" : "-msg-create";
    if ($msg = $object->store()) {
        CAppUI::setMsg($msg, UI_MSG_ERROR);
        echo CAppUI::getMsg();
        CApp::rip();
    }
    CAppUI::setMsg(CAppUI::tr(get_class($object) . $title), UI_MSG_OK);
}
/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Urgences
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
function viewMsg($msg, $action, $txt = "")
{
    global $m, $tab;
    $action = CAppUI::tr($action);
    if ($msg) {
        CAppUI::setMsg("{$action}: {$msg}", UI_MSG_ERROR);
        CAppUI::redirect("m={$m}&tab={$tab}");
        return;
    }
    CAppUI::setMsg("{$action} {$txt}", UI_MSG_OK);
}
/**
 * Fonction utilitaire pour la sauvegarde rapide d'un object avec génération du message
 *
 * @param CMbObject $object Objet à enregister
 *
 * @return void
 */
function storeObject($object)
{
    $title = $object->_id ? "-msg-modify" : "-msg-create";
    if ($msg = $object->store()) {
        CAppUI::setMsg($msg, UI_MSG_ERROR);
        echo CAppUI::getMsg();
        // Il peut y avoir un msg de retour postérieur à la création de l'objet
        // On continue donc le processus de création de la naissance
        //CApp::rip();
    }
    CAppUI::setMsg(CAppUI::tr(get_class($object) . $title), UI_MSG_OK);
}
 /**
  * @see parent::onAfterStore()
  */
 function onAfterStore(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return;
     }
     /** @var $mbObject CAffectation */
     /** @var $_affectation CAffectation */
     foreach ($mbObject->loadRefsAffectationsEnfant() as $_affectation) {
         $_affectation->lit_id = $mbObject->lit_id;
         if ($msg = $_affectation->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
         }
     }
 }
Beispiel #10
0
 /**
  * Subject notification mechanism
  *
  * @param string $message on[Before|After][Build]
  *
  * @return void
  */
 static function notify($message)
 {
     $args = func_get_args();
     array_shift($args);
     // $message
     // Event Handlers
     self::makeHandlers();
     foreach (self::$handlers as $_handler) {
         try {
             call_user_func_array(array($_handler, "on{$message}"), $args);
         } catch (Exception $e) {
             CAppUI::setMsg($e, UI_MSG_ERROR);
         }
     }
 }
Beispiel #11
0
 /**
  * @throws CMbException
  * @return CSourceLDAP
  */
 static function connect()
 {
     $source_ldap = new CSourceLDAP();
     /** @var CSourceLDAP[] $sources_ldap */
     $sources_ldap = $source_ldap->loadList(null, "priority DESC");
     if (empty($sources_ldap)) {
         throw new CMbException("CSourceLDAP_undefined");
     }
     foreach ($sources_ldap as $_source) {
         try {
             $ldapconn = $_source->ldap_connect();
             $_source->_ldapconn = $ldapconn;
             return $_source;
         } catch (CMbException $e) {
             CAppUI::setMsg($e->getMessage(), UI_MSG_WARNING);
         }
     }
     return false;
 }
Beispiel #12
0
 function doStore()
 {
     parent::doStore();
     if (CModule::getActive("dPprescription") && !$this->_old->_id) {
         $p_to_c = new CPrescriptionProtocoleToConcept();
         $count_p_to_c = $p_to_c->countList();
         if ($count_p_to_c > 0) {
             /** @var CExObject $ex_object */
             $ex_object = $this->_obj;
             $all_fields = $ex_object->loadRefExClass()->loadRefsAllFields();
             $bool_concept_ids = array();
             foreach ($all_fields as $_field) {
                 if (strpos($_field->prop, "bool") === 0 && $_field->concept_id && $ex_object->{$_field->name} == "1") {
                     $bool_concept_ids[] = $_field->concept_id;
                 }
             }
             $bool_concept_ids = array_unique($bool_concept_ids);
             $where = array("concept_id" => $p_to_c->getDS()->prepareIn($bool_concept_ids));
             $protocole_ids = array_values(CMbArray::pluck($p_to_c->loadList($where), "protocole_id"));
             if (count($protocole_ids)) {
                 /** @var CSejour $sejour */
                 $sejour = $ex_object->getReferenceObject("CSejour");
                 if ($sejour && $sejour->_id) {
                     $prescription = $sejour->loadRefPrescriptionSejour();
                     if (!$prescription->_id) {
                         $prescription = new CPrescription();
                         $prescription->object_id = $sejour->_id;
                         $prescription->object_class = $sejour->_class;
                         $prescription->type = "sejour";
                         if ($msg = $prescription->store()) {
                             CAppUI::setMsg($msg, UI_MSG_WARNING);
                         }
                     }
                     $ops_ids = implode("-", CMbArray::pluck($sejour->loadRefsOperations(array("annulee" => "= '0'")), "operation_id"));
                     CAppUI::callbackAjax("window.opener.ExObject.checkOpsBeforeProtocole", $protocole_ids, $prescription->_id, $sejour->_id, $ops_ids);
                 }
             }
         }
     }
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage GestionCab
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$fiche_paie_id = CValue::getOrSession("fiche_paie_id", null);
$fichePaie = new CFichePaie();
$fichePaie->load($fiche_paie_id);
if (!$fichePaie->fiche_paie_id) {
    CAppUI::setMsg("Vous n'avez pas choisi de fiche de paie", UI_MSG_ERROR);
    CAppUI::redirect("m=dPgestionCab&tab=edit_paie");
}
if ($fichePaie->final_file) {
    echo $fichePaie->final_file;
} else {
    $fichePaie->loadRefsFwd();
    $fichePaie->_ref_params_paie->loadRefsFwd();
    // Création du template
    $smarty = new CSmartyDP();
    $smarty->assign("fichePaie", $fichePaie);
    $smarty->display("print_fiche.tpl");
}
<?php

/**
 * $Id$
 * 
 * @package    Mediboard
 * @subpackage dPcabinet
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$consultation_id = CValue::post("consultation_id");
$plageconsult_id = CValue::post("plageconsult_id");
$heure = CValue::post("heure");
$consult = new CConsultation();
$consult->load($consultation_id);
$new_consult = new CConsultation();
$new_consult->plageconsult_id = $plageconsult_id;
$new_consult->heure = $heure;
$new_consult->chrono = CConsultation::PLANIFIE;
$new_consult->patient_id = $consult->patient_id;
$new_consult->categorie_id = $consult->categorie_id;
$msg = $new_consult->store();
if ($msg) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
} else {
    CAppUI::setMsg(CAppUI::tr("CConsultation-msg-create"), UI_MSG_OK);
}
echo CAppUI::getMsg();
CApp::rip();
/**
 * import the patient file
 *
 * @param string   $file        path to the file
 * @param int      $start       start int
 * @param int      $count       number of iterations
 * @param resource $file_import file for report
 *
 * @return null
 */
function importFile($file, $start, $count, $file_import)
{
    $fp = fopen($file, 'r');
    $csv_file = new CCSVFile($fp);
    $csv_file->column_names = $csv_file->readLine();
    if ($start == 0) {
        $start++;
    } elseif ($start > 1) {
        $csv_file->jumpLine($start);
    }
    $group_id = CGroups::loadCurrent()->_id;
    $treated_line = 0;
    while ($treated_line < $count) {
        $treated_line++;
        $patient = new CPatient();
        $_patient = $csv_file->readLine(true);
        if (!$_patient) {
            CAppUI::stepAjax('Importation terminée', UI_MSG_OK);
            CApp::rip();
        }
        $patient->bind($_patient);
        $patient->loadFromIPP($group_id);
        if ($patient->_id) {
            $start++;
            continue;
        }
        $nom = $_patient['nom'] ? $_patient['nom'] : $_patient['nom_jeune_fille'];
        if (!$patient->nom) {
            if ($patient->nom_jeune_fille) {
                $patient->nom = $patient->nom_jeune_fille;
            } else {
                CMbDebug::log("Ligne #{$start} : Pas de nom");
                $start++;
                continue;
            }
        }
        $naissance = null;
        if ($patient->naissance) {
            $naissance = preg_replace('/(\\d{2})\\/(\\d{2})\\/(\\d{4})/', '\\3-\\2-\\1', $patient->naissance);
            $patient->naissance = $naissance;
        }
        $patient->repair();
        if (!$patient->naissance) {
            CMbDebug::log($_patient);
            CMbDebug::log("Ligne #{$start} : Date de naissance invalide ({$_patient['naissance']})");
            $start++;
            continue;
        }
        $patient->loadMatchingPatient();
        if (!$patient->_id) {
            $patient->bind($_patient);
            $patient->nom = $nom;
            $patient->naissance = $naissance;
            $patient->tel = preg_replace("/[^0-9]/", "", $patient->tel);
            $patient->tel_autre = preg_replace("/[^0-9]/", "", $patient->tel_autre);
            $patient->sexe = strtolower($patient->sexe);
            $patient->repair();
            if ($msg = $patient->store()) {
                CMbDebug::log($patient, null, true);
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        $ipp = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP($group_id), $patient->_IPP, $patient->_id);
        if ($ipp->_id && $ipp->id400 != $patient->_IPP) {
            CMbDebug::log("Ligne #{$start} : Ce patient possède déjà un IPP ({$ipp->id400})");
            $start++;
            continue;
        }
        if (!$ipp->_id) {
            if ($msg = $ipp->store()) {
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        CAppUI::setMsg('CPatient-msg-create', UI_MSG_OK);
    }
    echo CAppUI::getMsg();
}
Beispiel #16
0
 /**
  * @see parent::store()
  */
 function store()
 {
     if ($this instanceof CSejour || $this instanceof COperation) {
         global $can;
         $this->loadOldObject();
         $this->completeField("cloture_activite_1", "cloture_activite_4", 'codes_ccam');
         if (!$can->admin && CAppUI::conf("dPsalleOp CActeCCAM signature") && ($this->cloture_activite_1 || $this->cloture_activite_4) && $this->fieldModified("codes_ccam") && strcmp($this->codes_ccam, $this->_old->codes_ccam)) {
             $new_code = substr($this->codes_ccam, strlen($this->_old->codes_ccam) + 1);
             $code_ccam = new CDatedCodeCCAM($new_code);
             $code_ccam->getRemarques();
             $activites = $code_ccam->getActivites();
             if (isset($activites[1]) && $this->cloture_activite_1) {
                 CAppUI::setMsg("Impossible de rajouter un code : l'activité 1 est clôturée", UI_MSG_ERROR);
                 echo CAppUI::getMsg();
                 CApp::rip();
             }
             if (isset($activites[4]) && $this->cloture_activite_4) {
                 CAppUI::setMsg("Impossible de rajouter un code : l'activité 4 est clôturée", UI_MSG_ERROR);
                 echo CAppUI::getMsg();
                 CApp::rip();
             }
         }
     }
     // Standard store
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($this->_delete_actes && $this->_id) {
         if ($msg = $this->deleteActes()) {
             return $msg;
         }
     }
     return null;
 }
 * @package    Mediboard
 * @subpackage Cabinet
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 24175 $
 */
CCanDo::checkRead();
// Utilisateur sélectionné ou utilisateur courant
$prat_id = CValue::getOrSession("chirSel", 0);
$userSel = CMediusers::get($prat_id);
$userSel->loadRefs();
$canUserSel = $userSel->canDo();
// Vérification des droits sur les praticiens
$listChir = CConsultation::loadPraticiens(PERM_EDIT);
if (!$userSel->isMedical()) {
    CAppUI::setMsg("Vous devez selectionner un professionnel de santé", UI_MSG_ALERT);
    CAppUI::redirect("m=dPcabinet&tab=0");
}
$canUserSel->needsEdit();
$selConsult = CValue::getOrSession("selConsult", 0);
$dossier_anesth_id = CValue::getOrSession("dossier_anesth_id", 0);
if (isset($_GET["date"])) {
    $selConsult = null;
    CValue::setSession("selConsult", 0);
}
$anesth = new CTypeAnesth();
$anesth = $anesth->loadGroupList();
// Consultation courante
$consult = new CConsultation();
$consult->_ref_chir = $userSel;
if ($selConsult) {
/**
 * $Id: ajax_form_complement.php 28128 2015-04-29 13:16:11Z aurelie17 $
 *
 * @package    Mediboard
 * @subpackage Urgences
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 28128 $
 */
CCanDo::checkRead();
$rpu_id = CValue::getOrSession("rpu_id");
$sejour_id = CValue::get("sejour_id");
$rpu = new CRPU();
if ($rpu_id && !$rpu->load($rpu_id)) {
    global $m, $tab;
    CAppUI::setMsg("Ce RPU n'est pas ou plus disponible", UI_MSG_WARNING);
    CAppUI::redirect("m={$m}&tab={$tab}&rpu_id=0");
}
// Création d'un RPU pour un séjour existant
if ($sejour_id) {
    $rpu = new CRPU();
    $rpu->sejour_id = $sejour_id;
    $rpu->loadMatchingObject();
    $rpu->updateFormFields();
}
if ($rpu->_id || $rpu->sejour_id) {
    // Mise en session de l'id de la consultation, si elle existe.
    $rpu->loadRefConsult();
    if ($rpu->_ref_consult->_id) {
        CValue::setSession("selConsult", $rpu->_ref_consult->_id);
    }
Beispiel #19
0
$objects = array();
$result = null;
$checkMerge = null;
$statuses = array();
$merge_type = null;
if (class_exists($objects_class) && count($objects_id)) {
    foreach ($objects_id as $object_id) {
        /** @var CMbObject $object */
        $object = new $objects_class();
        $merge_type = $object->_spec->merge_type;
        if ($merge_type == 'none') {
            CAppUI::stepAjax("Merging_%sclass_is_forbidden_by_spec", UI_MSG_ERROR, CAppUI::tr($object->_class));
        }
        // the CMbObject is loaded
        if (!$object->load($object_id)) {
            CAppUI::setMsg("Chargement impossible de l'objet [{$object_id}]", UI_MSG_ERROR);
            continue;
        }
        $object->loadView();
        $object->loadAllFwdRefs(true);
        $object->_selected = false;
        $object->_disabled = false;
        $objects[] = $object;
    }
    // Default préselection of first object
    $_selected = reset($objects);
    // selection of the first CSejour or CPatient with an ext ID
    if ($objects_class == "CSejour" || $objects_class == "CPatient") {
        $no_extid = array();
        $extid = array();
        foreach ($objects as $_object) {
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19840 $
 */
CCanDo::checkRead();
$sejour_id = CValue::get("sejour_id");
$patient_id = CValue::get("patient_id");
// Chargement du patient
$patient = new CPatient();
$patient->load($patient_id);
$patient->loadRefsCorrespondantsPatient();
// On récupére le séjour
$sejour = new CSejour();
if ($sejour_id) {
    $sejour->load($sejour_id);
    // On vérifie que l'utilisateur a les droits sur le sejour
    if (!$sejour->_canRead) {
        global $m, $tab;
        CAppUI::setMsg("Vous n'avez pas accés à ce séjour", UI_MSG_WARNING);
        CAppUI::redirect("m={$m}&tab={$tab}&sejour_id=0");
    }
    $patient = $sejour->_ref_patient;
} else {
    $sejour->patient_id = $patient->_id;
    $sejour->_ref_patient = $patient;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("sejour", $sejour);
$smarty->assign("patient", $patient);
$smarty->assign("form", "editSejour");
$smarty->display("inc_vw_assurances.tpl");
 * @package    Mediboard
 * @subpackage Stock
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
// If it is a return to the group stock
if (isset($_POST['_return']) && isset($_POST['_code'])) {
    $stock_service = CProductStockService::getFromCode($_POST['_code']);
    $stock_group = CProductStockGroup::getFromCode($_POST['_code']);
    $_POST['quantity'] = -abs($_POST['quantity']);
    $_POST['_code'] = null;
    $_POST['_return'] = null;
    if ($stock_service && $stock_group) {
        $delivery = new CProductDelivery();
        $where = array('stock_id' => "= '{$stock_group->_id}'", 'stock_class' => "= 'CProductStockGroup'", 'service_id' => "= '{$stock_service->service_id}'", 'quantity' => "< 0");
        if (!$delivery->loadObject($where)) {
            $delivery->stock_id = $stock_group->_id;
            $delivery->stock_class = $stock_group->_class;
            $delivery->service_id = $stock_service->service_id;
        }
        $delivery->quantity += $_POST['quantity'];
        $delivery->date_dispensation = CMbDT::dateTime();
        if ($msg = $delivery->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
        $_POST['delivery_id'] = $delivery->_id;
    }
}
$do = new CDoObjectAddEdit('CProductDeliveryTrace');
$do->doIt();
Beispiel #22
0
 /**
  * Apply the rule to all actes
  *
  * @return void
  */
 function applyRuleToActes()
 {
     if (!$this->_apply_rules) {
         return;
     }
     $this->completeField("association_rule");
     $this->getActsByTarif();
     foreach ($this->_ref_actes_ccam as $_act) {
         $_act->_calcul_montant_base = 1;
         $_act->_position = array_search($_act->_id, array_keys($this->_ordered_acts));
         $this->applyRule($this->association_rule, $_act);
         if ($msg = $_act->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
             if (!in_array($_act->code_acte, $this->_check_failed_acts)) {
                 $this->_check_failed_acts[] = $_act->code_acte;
                 $this->updateRule();
                 break;
             }
         }
     }
     $this->_apply_rules = false;
 }
 if (CAppUI::conf("dPplanningOp COperation use_session_praticien")) {
     CValue::setSession("chir_id", $op->chir_id);
 }
 if (CBrisDeGlace::isBrisDeGlaceRequired()) {
     $canAccess = CAccessMedicalData::checkForSejour($op->_ref_sejour);
     if (!$canAccess) {
         if (!$op->canDo()->read) {
             global $m, $tab;
             CAppUI::setMsg("Vous n'avez pas accés à cette intervention hors plage", UI_MSG_WARNING);
             CAppUI::redirect("m={$m}&tab={$tab}&operation_id=0");
         }
     }
 } else {
     if (!$op->canDo()->read) {
         global $m, $tab;
         CAppUI::setMsg("Vous n'avez pas accés à cette intervention hors plage", UI_MSG_WARNING);
         CAppUI::redirect("m={$m}&tab={$tab}&operation_id=0");
     }
 }
 // Chargement des régérences
 $op->loadRefs();
 $op->loadRefsNotes();
 $op->_ref_chir->loadRefFunction();
 $op->loadRefs();
 foreach ($op->_ref_actes_ccam as $acte) {
     $acte->loadRefExecutant();
 }
 $sejour = $op->_ref_sejour;
 $sejour->loadRefsFwd();
 $sejour->loadRefCurrAffectation()->loadRefService();
 $sejour->_ref_praticien->canDo();
Beispiel #24
0
            }
        } else {
            try {
                $exchange_source->connect();
                CAppUI::setMsg("common-msg-Successful connection", UI_MSG_OK);
            } catch (CMbException $e) {
                $e->stepAjax(UI_MSG_ERROR);
            }
        }
        break;
    case 'send':
        if ($exchange_source->protocol == 'UDP') {
            try {
                $exchange_source->testUDPConnection();
                CAppUI::setMsg("common-msg-Successful connection", UI_MSG_OK);
            } catch (CMbException $e) {
                $e->stepAjax(UI_MSG_ERROR);
            }
        } else {
            try {
                $exchange_source->sendTestMessage();
                CAppUI::setMsg("common-msg-Message sent", UI_MSG_OK);
            } catch (CMbException $e) {
                $e->stepAjax(UI_MSG_ERROR);
            }
        }
        break;
    default:
        CAppUI::setMsg("CExchange-unknown-test", UI_MSG_ERROR, $type_action);
}
echo CAppUI::getMsg();
Beispiel #25
0
$destination_guid = CValue::get("destination_guid");
$name = CValue::get("file_name");
$category_id = CValue::get("category_id");
$allowed = array("CFile", "CCompteRendu");
if (!in_array($file_class, $allowed)) {
    CAppUI::stepAjax("CFile-msg-not_allowed_object_to_move", UI_MSG_ERROR);
}
/** @var CFile|CCompteRendu $file */
$file = new $file_class();
$file->load($file_id);
$file->file_category_id = $category_id && $category_id != $file->file_category_id ? $category_id : $file->file_category_id;
if ($file instanceof CFile) {
    $file->file_name = $name ? $name : $file->file_name;
}
$destination = CStoredObject::loadFromGuid($destination_guid);
if ($file->object_id == $destination->_id && $file->object_class == $destination->_class) {
    CAppUI::stepAjax("CFile-msg-from_equal_to", UI_MSG_ERROR);
}
$file->setObject($destination);
// check category
$cat = new CFilesCategory();
$cat->load($file->file_category_id);
if ($cat->class && $cat->class != $destination->_class) {
    $file->file_category_id = "";
}
if ($msg = $file->store()) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
} else {
    CAppUI::setMsg("CFile-msg-moved");
}
echo CAppUI::getMsg();
 /**
  * Trigger after event store
  *
  * @param CMbObject $mbObject Object
  *
  * @return void
  */
 function onAfterStore(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return false;
     }
     /** @var CInteropReceiver $receiver */
     $receiver = $mbObject->_receiver;
     $receiver->getInternationalizationCode($this->transaction);
     // Traitement Sejour
     if ($mbObject instanceof CSejour) {
         $sejour = $mbObject;
         $sejour->loadRefPatient();
         // Si on ne souhaite explicitement pas de synchro
         if ($sejour->_no_synchro) {
             return;
         }
         // Si on est en train de créer un séjour et qu'il s'agit d'une naissance
         $current_log = $sejour->loadLastLog();
         if ($current_log->type == "create" && $sejour->_naissance) {
             return;
         }
         // Si Serveur
         if (CAppUI::conf('smp server')) {
             return;
         }
         // Si le group_id du séjour est différent de celui du destinataire
         if ($sejour->group_id != $receiver->group_id) {
             return;
         }
         // Destinataire gère seulement les non facturables
         if ($receiver->_configs["send_no_facturable"] == "0" && $sejour->facturable) {
             return;
         }
         // Destinataire gère seulement les facturables
         if ($receiver->_configs["send_no_facturable"] == "2" && !$sejour->facturable) {
             return;
         }
         // Passage du séjour d'urgence en hospit, pas de génération de A06
         if ($sejour->_en_mutation) {
             return;
         }
         // Si on ne gère les séjours du bébé on ne transmet pas séjour si c'est un séjour enfant
         if (!$receiver->_configs["send_child_admit"]) {
             $naissance = new CNaissance();
             $naissance->sejour_enfant_id = $sejour->_id;
             $naissance->loadMatchingObject();
             if ($naissance->_id) {
                 return;
             }
         }
         // Recherche si on est sur un séjour de mutation
         $rpu = new CRPU();
         $rpu->mutation_sejour_id = $sejour->_id;
         $rpu->loadMatchingObject();
         if ($rpu->_id) {
             $sejour_rpu = $rpu->loadRefSejour();
             if (!$sejour->_cancel_hospitalization && $sejour_rpu->mode_sortie != "mutation") {
                 return;
             }
         }
         $current_affectation = null;
         $code = null;
         // Cas où :
         // * on est sur un séjour d'urgences qui n'est pas le relicat
         // * on est en train de réaliser la mutation
         /** @var CRPU $rpu */
         $rpu = $sejour->loadRefRPU();
         if ($rpu && $rpu->_id && $rpu->sejour_id != $rpu->mutation_sejour_id && $sejour->fieldModified("mode_sortie", "mutation") && !$sejour->UHCD) {
             $sejour = $rpu->loadRefSejourMutation();
             $sejour->loadRefPatient();
             $sejour->loadLastLog();
             $sejour->_receiver = $receiver;
             $code = "A06";
             // On récupère l'affectation courante qui n'a pas été transmise (affectation suite à la mutation)
             $current_affectation = $sejour->getCurrAffectation();
             $sejour->_ref_hl7_affectation = $current_affectation;
         } elseif ($sejour->fieldModified("type", "urg") && $sejour->_cancel_hospitalization) {
             $sejour->loadRefPatient();
             $sejour->loadLastLog();
             $sejour->_receiver = $receiver;
             $code = "A07";
             // On récupère l'affectation courante qui n'a pas été transmise (affectation suite à la mutation)
             $current_affectation = $sejour->getCurrAffectation();
             $sejour->_ref_hl7_affectation = $current_affectation;
         } elseif ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id) {
             return;
         }
         $code = $code ? $code : $this->getCodeSejour($sejour);
         // Dans le cas d'une création et que l'on renseigne entrée réelle et sortie réelle,
         // il est nécessaire de créer deux flux (A01 et A03)
         if ($sejour->_ref_last_log->type == "create" && $sejour->entree_reelle && $sejour->sortie_reelle) {
             $code = "A01";
             // Cas où :très souvent
             // * on est l'initiateur du message
             // * le destinataire ne supporte pas le message
             if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
                 return;
             }
             if (!$sejour->_NDA) {
                 // Génération du NDA dans le cas de la création, ce dernier n'était pas créé
                 if ($msg = $sejour->generateNDA()) {
                     CAppUI::setMsg($msg, UI_MSG_ERROR);
                 }
                 $NDA = new CIdSante400();
                 $NDA->loadLatestFor($sejour, $receiver->_tag_sejour);
                 $sejour->_NDA = $NDA->id400;
             }
             $patient = $sejour->_ref_patient;
             $patient->loadIPP($receiver->group_id);
             if (!$patient->_IPP) {
                 if ($msg = $patient->generateIPP()) {
                     CAppUI::setMsg($msg, UI_MSG_ERROR);
                 }
             }
             // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée
             if ($sejour->fieldModified("entree_reelle") && !$sejour->_old->entree_reelle) {
                 $current_affectation = $sejour->getCurrAffectation();
             }
             $this->createMovement($code, $sejour, $current_affectation);
             // Envoi de l'événement
             $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour);
             $code = "A03";
         }
         if (!$code) {
             return;
         }
         // Cas où :
         // * on est l'initiateur du message
         // * le destinataire ne supporte pas le message
         if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
             return;
         }
         if (!$sejour->_NDA) {
             // Génération du NDA dans le cas de la création, ce dernier n'était pas créé
             if ($msg = $sejour->generateNDA()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
             }
             $NDA = new CIdSante400();
             $NDA->loadLatestFor($sejour, $receiver->_tag_sejour);
             $sejour->_NDA = $NDA->id400;
         }
         $patient = $sejour->_ref_patient;
         $patient->loadIPP($receiver->group_id);
         if (!$patient->_IPP) {
             if ($msg = $patient->generateIPP()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
             }
         }
         // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée
         if ($sejour->fieldModified("entree_reelle") && !$sejour->_old->entree_reelle) {
             $current_affectation = $sejour->getCurrAffectation();
         }
         $this->createMovement($code, $sejour, $current_affectation);
         // Envoi de l'événement
         $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour);
     }
     // Traitement Affectation
     if ($mbObject instanceof CAffectation) {
         $affectation = $mbObject;
         $current_log = $affectation->_ref_current_log;
         if (!$current_log || $affectation->_no_synchro || !in_array($current_log->type, array("create", "store"))) {
             return;
         }
         // Affectation non liée à un séjour
         $sejour = $affectation->loadRefSejour();
         if (!$sejour->_id) {
             return;
         }
         // Destinataire gère seulement les non facturables
         if ($receiver->_configs["send_no_facturable"] == "0" && $sejour->facturable) {
             return;
         }
         // Destinataire gère seulement les facturables
         if ($receiver->_configs["send_no_facturable"] == "2" && !$sejour->facturable) {
             return;
         }
         // Première affectation des urgences on ne la transmet pas, seulement pour l'évènement de bascule
         // Sauf si nous sommes dans un séjour d'UHCD
         if ($affectation->_mutation_urg && !$sejour->UHCD) {
             return;
         }
         // Si on ne gère les séjours du bébé on ne transmet pas l'affectation si c'est un séjour enfant
         if (!$receiver->_configs["send_child_admit"]) {
             $naissance = new CNaissance();
             $naissance->sejour_enfant_id = $sejour->_id;
             $naissance->loadMatchingObject();
             if ($naissance->_id) {
                 return;
             }
         }
         // Pas d'envoie d'affectation si la patient n'est pas sortie des urgences
         $rpu = new CRPU();
         $rpu->mutation_sejour_id = $sejour->_id;
         $rpu->loadMatchingObject();
         if ($rpu->_id) {
             $sejour_rpu = $rpu->loadRefSejour();
             if (!$affectation->_mutation_urg && $sejour_rpu->mode_sortie != "mutation") {
                 return;
             }
         }
         // Pas d'envoie d'affectation pour les séjours reliquats
         // Sauf si le séjour est en UHCD
         $rpu = $sejour->loadRefRPU();
         if ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id && !$sejour->UHCD) {
             return;
         }
         // Si le group_id du séjour est différent de celui du destinataire
         if ($sejour->group_id != $receiver->group_id) {
             return;
         }
         // On envoie pas les affectations prévisionnelles
         if (!$receiver->_configs["send_provisional_affectation"] && $sejour->_etat == "preadmission") {
             return;
         }
         $first_affectation = $sejour->loadRefFirstAffectation();
         $code = $this->getCodeAffectation($affectation, $first_affectation);
         // Cas où :
         // * on est l'initiateur du message
         // * le destinataire ne supporte pas le message
         if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
             return;
         }
         $sejour->loadRefPatient();
         $sejour->_receiver = $receiver;
         $patient = $sejour->_ref_patient;
         $patient->loadIPP($receiver->group_id);
         if (!$patient->_IPP) {
             if ($msg = $patient->generateIPP()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
             }
         }
         $this->createMovement($code, $sejour, $affectation);
         $service = $affectation->loadRefService();
         $curr_affectation = $sejour->loadRefCurrAffectation();
         // On envoie pas de mouvement antérieur à la dernière affectation
         if (($service->uhcd || $service->radiologie || $service->urgence) && $affectation->sortie < $curr_affectation->sortie) {
             return;
         }
         // Ne pas envoyer la sortie si le séjour a une entrée réelle et si on modifie ou créé un affectation
         if (!$receiver->_configs["send_expected_discharge_with_affectation"] && $sejour->entree_reelle) {
             $sejour->sortie_prevue = null;
         }
         // Envoi de l'événement
         $this->sendITI($this->profil, $this->transaction, $this->message, $code, $mbObject);
     }
     // Traitement Naissance
     if ($mbObject instanceof CNaissance) {
         $current_log = $mbObject->loadLastLog();
         if ($current_log->type != "create") {
             return;
         }
         $naissance = $mbObject;
         if (!$this->isMessageSupported($this->transaction, $this->message, "A28", $receiver)) {
             return;
         }
         $sejour_enfant = $naissance->loadRefSejourEnfant();
         // Création du bébé
         $enfant = $sejour_enfant->_ref_patient;
         $enfant->loadIPP($receiver->group_id);
         $enfant->_receiver = $receiver;
         $enfant->_naissance_id = $naissance->_id;
         if (!$enfant->_IPP) {
             if ($msg = $enfant->generateIPP()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
             }
         }
         // Envoi pas les patients qui n'ont pas d'IPP
         if (!$receiver->_configs["send_all_patients"] && !$enfant->_IPP) {
             return;
         }
         // Envoi du A28 pour la création du bébé
         $this->sendITI($this->profil, $this->transaction, $this->message, "A28", $enfant);
         $enfant->_IPP = null;
         // Si on gère les séjours du bébé on transmet le séjour !
         if ($receiver->_configs["send_child_admit"]) {
             $sejour_enfant->_receiver = $receiver;
             // Si le group_id du séjour est différent de celui du destinataire
             if ($sejour_enfant->group_id != $receiver->group_id) {
                 return;
             }
             $code = $this->getCodeBirth($sejour_enfant);
             // Cas où :
             // * on est l'initiateur du message
             // * le destinataire ne supporte pas le message
             if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
                 return;
             }
             if (!$sejour_enfant->_NDA) {
                 // Génération du NDA dans le cas de la création, ce dernier n'était pas créé
                 if ($msg = $sejour_enfant->generateNDA()) {
                     CAppUI::setMsg($msg, UI_MSG_ERROR);
                 }
                 $NDA = new CIdSante400();
                 $NDA->loadLatestFor($sejour_enfant, $receiver->_tag_sejour);
                 $sejour_enfant->_NDA = $NDA->id400;
             }
             $current_affectation = null;
             // Cas où lors de l'entrée réelle j'ai une affectation qui n'a pas été envoyée
             if ($sejour_enfant->fieldModified("entree_reelle") && !$sejour_enfant->_old->entree_reelle) {
                 $current_affectation = $sejour_enfant->getCurrAffectation();
             }
             $this->createMovement($code, $sejour_enfant, $current_affectation);
             // Envoi de l'événement
             $this->sendITI($this->profil, $this->transaction, $this->message, $code, $sejour_enfant);
         }
     }
 }
 /**
  * Removes a module
  * Warning, it actually breaks module dependency
  *
  * @return boolean Job done
  */
 function remove()
 {
     if ($this->mod_type == "core") {
         CAppUI::setMsg("Impossible de supprimer le module '%s'", UI_MSG_ERROR, $this->mod_name);
         return false;
     }
     $success = true;
     foreach ($this->tables as $table) {
         $query = "DROP TABLE `{$table}`";
         if (!$this->ds->exec($query)) {
             $success = false;
             CAppUI::setMsg("Failed to remove table '%s'", UI_MSG_ERROR, $table);
         }
     }
     return $success;
 }
    CAppUI::setMsg(count($list) . " doublons à traiter");
} else {
    foreach ($list as $_mvt) {
        $ids = explode(",", $_mvt["ids"]);
        sort($ids);
        // IMPORTANT, must use the first movement created as a reference
        $first = new CMovement();
        $first->load($ids[0]);
        $second = new CMovement();
        $second->load($ids[1]);
        $tag = CIdSante400::getMatch($second->_class, $second->getTagMovement(), null, $second->_id);
        if ($tag->_id) {
            $tag->tag = "trash_{$tag->tag}";
            $tag->last_update = CMbDT::dateTime();
            $tag->store();
        } else {
            CAppUI::setMsg("Aucun tag sur mouvement #{$second->_id}");
        }
        $msg = $first->merge(array($second->_id => $second));
        if ($msg) {
            CAppUI::setMsg($msg, UI_MSG_WARNING);
        } else {
            CAppUI::setMsg("Mouvements fusionnés");
        }
    }
    if ($auto && count($list)) {
        CAppUI::js("removeMovementDuplicates()");
    }
}
echo CAppUI::getMsg();
CApp::rip();
Beispiel #29
0
if (!$username) {
    CAppUI::setMsg("Auth-failed-nousername", UI_MSG_ERROR);
} else {
    if ($user->user_type == 1 && (!$ldap_connection || $allow_login_as_ldap)) {
        // If admin: no need to give a password
        $_REQUEST['loginas'] = $username;
        CAppUI::login();
    } else {
        if (!$password) {
            CAppUI::setMsg("Auth-failed-nopassword", UI_MSG_ERROR);
        } else {
            $_REQUEST['loginas'] = $username;
            if (CAppUI::conf("admin LDAP ldap_connection")) {
                $_REQUEST['passwordas'] = $password;
                CAppUI::login(true);
            } else {
                if (!CUser::checkPassword($username, $password)) {
                    CAppUI::setMsg("Auth-failed-combination", UI_MSG_ERROR);
                } else {
                    CAppUI::login(true);
                }
            }
        }
    }
}
if ($msg = CAppUI::getMsg()) {
    echo $msg;
    return;
} else {
    CAppUI::callbackAjax('UserSwitch.reload');
}
function managePersonnel($obj)
{
    global $_iade_id, $_aideop_id, $_op_panseuse_id, $_sagefemme_id, $_manipulateur_id, $del_personnel;
    if ($_iade_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_iade_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("IADE ajoutée", UI_MSG_OK);
        }
    }
    if ($_aideop_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_aideop_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Aide opératoire ajoutée", UI_MSG_OK);
        }
    }
    if ($_op_panseuse_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_op_panseuse_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Panseuse ajoutée", UI_MSG_OK);
        }
    }
    if ($_sagefemme_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_sagefemme_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Sage femme ajoutée", UI_MSG_OK);
        }
    }
    if ($_manipulateur_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_manipulateur_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Manipulateur ajouté", UI_MSG_OK);
        }
    }
    foreach ($del_personnel as $_personnel_id) {
        if ($_personnel_id) {
            $affectation_personnel = new CAffectationPersonnel();
            $affectation_personnel->object_class = $obj->_class;
            $affectation_personnel->object_id = $obj->_id;
            $affectation_personnel->personnel_id = $_personnel_id;
            $affectation_personnel->loadMatchingObject();
            if ($affectation_personnel->_id) {
                if ($msg = $affectation_personnel->delete()) {
                    CAppui::setMsg($msg, UI_MSG_ERROR);
                } else {
                    CAppUI::setMsg("Personnel supprimé");
                }
            }
        }
    }
}