/**
  * Get import function
  *
  * @return CFunctions
  */
 function getImportFunction()
 {
     static $function;
     if ($function) {
         return $function;
     }
     $function_name = CAppUI::conf($this->_import_function_name_conf);
     $function = new CFunctions();
     $function->text = $function_name;
     $function->loadMatchingObjectEsc();
     if (!$function->_id) {
         $function->group_id = CGroups::loadCurrent()->_id;
         $function->type = "cabinet";
         $function->compta_partagee = 0;
         $function->color = "#CCCCCC";
         if ($msg = $function->store()) {
             CAppUI::setMsg($msg, UI_MSG_WARNING);
         }
     }
     return $function;
 }
 /**
  * Create the mediuser
  *
  * @param CMediusers $mediuser mediuser
  *
  * @return int
  */
 function createDoctor(CMediusers $mediuser)
 {
     $sender = $this->_ref_sender;
     $function = new CFunctions();
     $function->text = CAppUI::conf("hl7 importFunctionName");
     $function->group_id = $sender->group_id;
     $function->loadMatchingObjectEsc();
     if (!$function->_id) {
         $function->type = "cabinet";
         $function->compta_partagee = 0;
         $function->color = "ffffff";
         $function->store();
     }
     $mediuser->function_id = $function->_id;
     $mediuser->makeUsernamePassword($mediuser->_user_first_name, $mediuser->_user_last_name, null, true);
     $mediuser->_user_type = 13;
     // Medecin
     $mediuser->actif = CAppUI::conf("hl7 doctorActif") ? 1 : 0;
     $user = new CUser();
     $user->user_last_name = $mediuser->_user_last_name;
     $user->user_first_name = $mediuser->_user_first_name;
     // On recherche par le seek
     $users = $user->seek("{$user->user_last_name} {$user->user_first_name}");
     if (count($users) == 1) {
         $user = reset($users);
         $user->loadRefMediuser();
         $mediuser = $user->_ref_mediuser;
     } else {
         // Dernière recherche si le login est déjà existant
         $user = new CUser();
         $user->user_username = $mediuser->_user_username;
         if ($user->loadMatchingObject()) {
             // On affecte un username aléatoire
             $mediuser->_user_username .= rand(1, 10);
         }
         $mediuser->store();
     }
     return $mediuser->_id;
 }
Example #3
0
 // Fonction
 $function = new CFunctions();
 $function->group_id = $group_id;
 $function->text = $results[$i]["function_name"];
 $function->loadMatchingObject();
 if (!$function->_id) {
     if (in_array($results[$i]["type"], array("3", "4", "13"))) {
         $function->type = "cabinet";
     } else {
         $function->type = "administratif";
     }
     $function->color = "ffffff";
     $function->compta_partagee = 0;
     $function->consults_partagees = 1;
     $function->unescapeValues();
     $msg = $function->store();
     if ($msg) {
         CAppUI::setMsg($msg, UI_MSG_ERROR);
         $results[$i]["error"] = $msg;
         $results[$i]["username"] = "";
         $results[$i]["password"] = "";
         $i++;
         continue;
     }
 }
 $mediuser->function_id = $function->_id;
 // Spécialité CCAM
 if ($spec_cpam_code = $results[$i]["spec_cpam_code"]) {
     $spec_cpam = new CSpecCPAM();
     $spec_cpam->load(intval($spec_cpam_code));
     if ($spec_cpam->_id) {
$cabinet->text = $cabinet_text;
$cabinet->loadMatchingObject();
//exist ? problem !
if ($cabinet->_id) {
    CAppUI::stepAjax("Cabinet-already_exist_name%s", UI_MSG_ERROR, $cabinet_text);
} else {
    $cabinet->actif = 1;
    $cabinet->facturable = 1;
    $cabinet->cp = $cabinet_cp;
    $cabinet->ville = $cabinet_ville;
    $cabinet->adresse = $cabinet_adresse;
    $cabinet->compta_partagee = $compta_partagee;
    $cabinet->consults_partagees = $consult_partagee;
    $cabinet->tel = $cabinet_tel;
    $cabinet->fax = $cabinet_fax;
    if ($msg = $cabinet->store()) {
        CAppUI::stepAjax($msg, UI_MSG_ERROR);
    }
}
CAppUI::stepAjax("Cabinet_msg_cabinet%s_created_num%d", UI_MSG_OK, $cabinet->text, $cabinet->_id);
// --------------------------------
// praticien(s) && secretaires
$profile_prat = CValue::post("profile_prat");
$profile_sec = CValue::post("profile_sec");
foreach ($_POST["user"] as $type => $_user_list) {
    foreach ($_user_list as $_user) {
        if (!$_user['lastname'] || !$_user['firstname']) {
            continue;
        }
        $mediuser = new CMediusers();
        $mediuser->_user_last_name = trim($_user['lastname']);
 /**
  * Création du praticien
  *
  * @param CMediusers $mediuser Mediuser
  *
  * @return int
  */
 function createPraticien(CMediusers $mediuser)
 {
     $sender = $this->_ref_echange_hprim->_ref_sender;
     $functions = new CFunctions();
     $functions->text = CAppUI::conf("hprimxml functionPratImport");
     $functions->group_id = $sender->group_id;
     $functions->loadMatchingObject();
     if (!$functions->loadMatchingObject()) {
         $functions->type = "cabinet";
         $functions->compta_partagee = 0;
         $functions->store();
     }
     $mediuser->function_id = $functions->_id;
     $mediuser->makeUsernamePassword($mediuser->_user_first_name, $mediuser->_user_last_name, null, true);
     $user_type = CAppUI::conf("hprimxml user_type");
     $mediuser->_user_type = $user_type ? $user_type : 13;
     // Medecin
     $mediuser->actif = CAppUI::conf("hprimxml medecinActif") ? 1 : 0;
     $user = new CUser();
     $user->user_last_name = $mediuser->_user_last_name;
     $user->user_first_name = $mediuser->_user_first_name;
     $listPrat = $user->seek("{$user->user_last_name} {$user->user_first_name}");
     if (count($listPrat) == 1) {
         $user = reset($listPrat);
         $user->loadRefMediuser();
         $mediuser = $user->_ref_mediuser;
     } else {
         $mediuser->store();
     }
     return $mediuser->_id;
 }