Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 3
0
/**
 * 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();
}
 /**
  * @see parent::onBeforeMerge
  */
 function onBeforeMerge(CMbObject $mbObject)
 {
     if (!parent::onBeforeMerge($mbObject)) {
         return;
     }
     // Si pas en mode alternatif
     if (!CAppUI::conf("alternative_mode")) {
         throw new CMbException("no_alternative_mode");
     }
     $patient = $mbObject;
     $patient_elimine = new CPatient();
     $patient_elimine->load(reset($mbObject->_merging));
     // Si Client
     if (!CAppUI::conf('sip server')) {
         $mbObject->_fusion = array();
         foreach (CGroups::loadGroups() as $_group) {
             /** @var CInteropSender $sender */
             $sender = $mbObject->_eai_sender_guid ? CMbObject::loadFromGuid($mbObject->_eai_sender_guid) : null;
             if ($sender && $sender->group_id == $_group->_id) {
                 continue;
             }
             $patient->_IPP = null;
             $patient->loadIPP($_group->_id);
             $patient1_ipp = $patient->_IPP;
             $patient_elimine->_IPP = null;
             $patient_elimine->loadIPP($_group->_id);
             $patient2_ipp = $patient_elimine->_IPP;
             // Passage en trash des IPP des patients
             $tap_IPP = CPatient::getTagIPP($_group->_id);
             if (!$tap_IPP) {
                 continue;
             }
             $idexPatient = new CIdSante400();
             $idexPatient->tag = $tap_IPP;
             $idexPatient->object_class = "CPatient";
             $idexPatient->object_id = $patient->_id;
             $idexsPatient = $idexPatient->loadMatchingList();
             $idexPatientElimine = new CIdSante400();
             $idexPatientElimine->tag = $tap_IPP;
             $idexPatientElimine->object_class = "CPatient";
             $idexPatientElimine->object_id = $patient_elimine->_id;
             $idexsPatientElimine = $idexPatientElimine->loadMatchingList();
             $idexs = array_merge($idexsPatient, $idexsPatientElimine);
             $idexs_changed = array();
             if (count($idexs) > 1) {
                 foreach ($idexs as $_idex) {
                     // On continue pour ne pas mettre en trash l'IPP du patient que l'on garde
                     if ($_idex->id400 == $patient1_ipp) {
                         continue;
                     }
                     $old_tag = $_idex->tag;
                     $_idex->tag = CAppUI::conf('dPpatients CPatient tag_ipp_trash') . $tap_IPP;
                     $_idex->last_update = CMbDT::dateTime();
                     if (!($msg = $_idex->store())) {
                         if ($_idex->object_id == $patient_elimine->_id) {
                             $idexs_changed[$_idex->_id] = $old_tag;
                         }
                     }
                 }
             }
             if (!$patient1_ipp && !$patient2_ipp) {
                 continue;
             }
             $mbObject->_fusion[$_group->_id] = array("patientElimine" => $patient_elimine, "patient1_ipp" => $patient1_ipp, "patient2_ipp" => $patient2_ipp, "idexs_changed" => $idexs_changed);
         }
     }
     $this->sendFormatAction("onBeforeMerge", $mbObject);
 }
/**
 * 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();
Exemplo n.º 6
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);
 }
    if ($filter->_date_min) {
        $query .= $ds->prepare(" AND plageconsult.date >= ?", $filter->_date_min);
    }
    if ($filter->_date_max) {
        $query .= $ds->prepare(" AND plageconsult.date <= ?", $filter->_date_max);
    }
    if ($filter->_user_id) {
        $query .= $ds->prepare(" AND users_mediboard.user_id = ?", $filter->_user_id);
    }
    if ($filter->_function_id) {
        $query .= $ds->prepare(" AND functions_mediboard.function_id = ?", $filter->_function_id);
    }
    $query .= "\n            GROUP BY consultation.adresse_par_prat_id\n            ORDER BY total DESC\n            LIMIT {$page}, {$limit};";
    $list = $ds->loadHashList($query);
} elseif ($compute_mode == "correspondants") {
    $tag = CPatient::getTagIPP();
    if ($tag) {
        $query = "SELECT\n              medecin.medecin_id,\n              COUNT(DISTINCT(patients.patient_id)) AS total\n\n            FROM patients\n            LEFT JOIN id_sante400   ON id_sante400.object_id = patients.patient_id AND id_sante400.object_class = 'CPatient'\n            LEFT JOIN correspondant ON correspondant.patient_id = patients.patient_id\n            LEFT JOIN medecin       ON medecin.medecin_id = correspondant.medecin_id\n            WHERE\n              id_sante400.tag = ?1 AND\n              correspondant.medecin_id IS NOT NULL\n            GROUP BY correspondant.medecin_id\n            ORDER BY total DESC\n            LIMIT {$page}, {$limit};";
        $query_corresp = $ds->prepare($query, $tag);
        $query = "SELECT\n              patients.medecin_traitant,\n              COUNT(DISTINCT(patients.patient_id)) AS total\n\n            FROM patients\n            LEFT JOIN id_sante400 ON id_sante400.object_id = patients.patient_id AND id_sante400.object_class = 'CPatient'\n            WHERE\n              id_sante400.tag = ?1 AND\n              patients.medecin_traitant IS NOT NULL\n            GROUP BY patients.medecin_traitant\n            ORDER BY total DESC\n            LIMIT {$page}, {$limit};";
        $query_traitant = $ds->prepare($query, $tag);
    } else {
        $query_corresp = "SELECT\n              medecin.medecin_id,\n              COUNT(DISTINCT(patients.patient_id)) AS total\n\n            FROM patients\n            LEFT JOIN correspondant ON correspondant.patient_id = patients.patient_id\n            LEFT JOIN medecin       ON medecin.medecin_id = correspondant.medecin_id\n            WHERE\n              correspondant.medecin_id IS NOT NULL\n            GROUP BY correspondant.medecin_id\n            ORDER BY total DESC\n            LIMIT {$page}, {$limit};";
        $query = "SELECT\n              patients.medecin_traitant,\n              COUNT(DISTINCT(patients.patient_id)) AS total\n\n            FROM patients\n            WHERE\n              patients.medecin_traitant IS NOT NULL\n            GROUP BY patients.medecin_traitant\n            ORDER BY total DESC\n            LIMIT {$page}, {$limit};";
        $query_traitant = $ds->prepare($query, $tag);
    }
    $list_corresp = $ds->loadHashList($query_corresp);
    $list_traitant = $ds->loadHashList($query_traitant);
    foreach ($list_traitant as $_medecin_id => $_count) {
        if (array_key_exists($_medecin_id, $list_corresp)) {
            $list_corresp[$_medecin_id] += $_count;
Exemplo n.º 8
0
/**
 * 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');
    $patient = new CPatient();
    $patient_specs = CModelObjectFieldDescription::getSpecList($patient);
    CModelObjectFieldDescription::addBefore($patient->_specs["_IPP"], $patient_specs);
    /** @var CMbFieldSpec[] $_patient_specs */
    $_patient_specs = CModelObjectFieldDescription::getArray($patient_specs);
    echo count($_patient_specs) . " traits d'import";
    //0 = first line
    if ($start == 0) {
        $start++;
    }
    $line_nb = 0;
    while ($line = fgetcsv($fp, null, ";")) {
        $patient = new CPatient();
        if ($line_nb >= $start && $line_nb < $start + $count) {
            $line_rapport = "ligne {$line_nb} - ";
            //foreach SPECS, first load
            foreach ($_patient_specs as $key => $_specs) {
                $field = $_specs->fieldName;
                $data = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $line[$key]);
                //specific cleanups
                if ($_specs instanceof CPhoneSpec) {
                    $data = preg_replace('/\\D/', '', $data);
                }
                if ($field == "sexe") {
                    $data = strtolower($data);
                }
                if ($field == "deces" && $data == "0000-00-00") {
                    $data = null;
                }
                $patient->{$field} = $data;
            }
            $line_rapport .= "Patient {$patient->nom} {$patient->prenom} ({$patient->naissance})";
            //clone and IPP
            $IPP = $patient->_IPP;
            $patient->_generate_IPP = false;
            $patient_full = new CPatient();
            $patient_full->extendsWith($patient);
            // load by ipp if basic didn't find.
            if (!$patient->_id) {
                $patient->loadFromIPP();
                if ($patient->_id) {
                    $line_rapport .= " (trouvé par IPP)";
                }
            }
            //load patient with basics
            if (!$patient->_id) {
                $patient->_IPP = null;
                $patient->loadMatchingPatient();
                if ($patient->_id) {
                    $line_rapport .= " (trouvé par matching)";
                }
            }
            //update fields if import have more data
            foreach ($patient->getPlainFields() as $field => $value) {
                if (!$patient->{$field}) {
                    $patient->{$field} = $patient_full->{$field};
                }
            }
            // fields created by store, let the store do the job for these
            $patient->civilite = "guess";
            //found
            if ($patient->_id) {
                //check IPP
                $patient->loadIPP();
                //update
                $patient->store();
                if (!$patient->_IPP) {
                    $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                    $idex->last_update = CMbDT::dateTime();
                    $idex->store();
                    if ($idex->_id) {
                        $line_rapport .= ", IPP créé : {$IPP}";
                    }
                    echo "<tr style=\"color:#c98000\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] déjà existant (MAJ ipp : {$idex->id400})</td></tr>";
                } else {
                    $line_rapport .= " déjà existant";
                    if ($patient->_IPP != $IPP) {
                        mbLog($patient->_view . " [ipp: " . $patient->_IPP . " / ipp_import:" . $IPP);
                        $line_rapport .= " [IPP du fichier: {$IPP} / ipp en base: {$patient->_IPP} ]";
                    }
                    $line_rapport .= " [IPP en base et fichier identiques]";
                    echo "<tr style=\"color:#c98000\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] déjà existant (ipp : {$patient->_IPP})</td></tr>";
                }
            } else {
                $result = $patient->store();
                if (!$result) {
                    $line_rapport .= " créé avec succes";
                    //create IPP
                    $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                    if ($idex->_id) {
                        $line_rapport .= ", IPP précédente : {$idex->id400}";
                    }
                    $idex->last_update = CMbDT::dateTime();
                    $idex->store();
                    if ($idex->_id) {
                        $line_rapport .= ", IPP enregistrée : {$idex->id400}";
                    }
                    echo "<tr style=\"color:green\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] créé (ipp : {$idex->id400})</td></tr>";
                } else {
                    $patient->repair();
                    $result = $patient->store();
                    $line_rapport .= " réparé et créé";
                    if (!$result) {
                        //create IPP
                        $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                        if ($idex->_id) {
                            $line_rapport .= ", IPP précédente : {$idex->id400}";
                        }
                        $idex->last_update = CMbDT::dateTime();
                        $idex->store();
                        if ($idex->_id) {
                            $line_rapport .= ", IPP enregistrée : {$idex->id400}";
                        }
                        echo "<tr style=\"color:green\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] créé (ipp : {$idex->id400})</td></tr>";
                    } else {
                        $line_rapport .= " non créé : {$result}";
                        mbLog("LINE {$line_nb} : erreur: " . $result);
                        echo "<tr  style=\"color:red\"><td>{$line_nb}</td><td>\n              <div class=\"error\">le patient [{$patient->nom} {$patient->prenom}] n'a pas été créé<br/>\n            erreur: {$result}</div></td></tr>";
                    }
                }
            }
            $line_rapport .= "\n";
            fwrite($file_import, $line_rapport);
        }
        if ($line_nb > $start + $count) {
            break;
        }
        $line_nb++;
    }
}
 /**
  * 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);
     $code = null;
     // Création/MAJ d'un correspondant patient
     if ($mbObject instanceof CCorrespondantPatient) {
         if (!$mbObject->patient_id) {
             return;
         }
         $mbObject = $mbObject->loadRefPatient();
         $mbObject->_receiver = $receiver;
         $code = "A31";
     } elseif ($mbObject instanceof CIdSante400) {
         $idex = $mbObject;
         // Concerne pas les patients / Pas en mode modification
         if ($idex->object_class != "CPatient" || !$idex->_old->_id) {
             return;
         }
         // Pas un tag IPP
         if ($idex->tag != CPatient::getTagIPP()) {
             return;
         }
         // Vraiment une modif de l'idex ?
         if ($idex->id400 == $idex->_old->id400) {
             return;
         }
         $code = "A47";
         $patient = new CPatient();
         $patient->load($idex->object_id);
         $patient->_receiver = $receiver;
         $patient->_patient_elimine = clone $patient;
         // Affecte le nouvel IPP au patient
         $patient->_IPP = $idex->id400;
         // Affecte l'ancien IPP au "patient éliminé"
         $patient->_patient_elimine->_IPP = $idex->_old->id400;
         if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
             return;
         }
         $this->sendITI($this->profil, $this->transaction, $this->message, $code, $patient);
         return;
     } else {
         if ($mbObject->_naissance) {
             return;
         }
         switch ($mbObject->_ref_current_log->type) {
             case "create":
                 $code = "A28";
                 break;
             case "store":
                 // Patient lié
                 if ($mbObject->fieldModified("patient_link_id")) {
                     $code = "A24";
                     break;
                 }
                 // Annulation de la liaison avec le patient lié
                 if ($mbObject->_old->patient_link_id && !$mbObject->patient_link_id) {
                     $code = "A37";
                     break;
                 }
                 if ($receiver->_configs["send_patient_with_visit"]) {
                     /** @var CPatient $mbObject */
                     $sejour = $mbObject->loadRefsSejours(array("entree_reelle" => "IS NOT NULL"));
                     if (count($sejour) < 1) {
                         $code = null;
                         break;
                     }
                 }
                 if ($receiver->_configs["send_patient_with_current_admit"]) {
                     // On charge seulement le séjour courant pour le patient
                     $sejours = $mbObject->getCurrSejour(null, $receiver->group_id);
                     if (!$sejours) {
                         break;
                     }
                     $sejour = reset($sejours);
                     if (!$sejour->_id) {
                         break;
                     }
                     $mbObject->_ref_sejour = $sejour;
                 }
                 // Dans tous les autres cas il s'agit d'une modification
                 $code = $receiver->_configs["send_update_patient_information"] == "A08" ? "A08" : "A31";
                 break;
             default:
                 $code = null;
         }
     }
     if (!$code) {
         return;
     }
     $patient = $mbObject;
     if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) {
         return;
     }
     if (!$patient->_IPP) {
         // Génération de l'IPP dans le cas de la création, ce dernier n'était pas créé
         if ($msg = $patient->generateIPP()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
         }
         if (!$patient->_IPP) {
             $IPP = new CIdSante400();
             $IPP->loadLatestFor($patient, $receiver->_tag_patient);
             $patient->_IPP = $IPP->id400;
         }
     }
     // Envoi pas les patients qui n'ont pas d'IPP
     if (!$receiver->_configs["send_all_patients"] && !$patient->_IPP) {
         return;
     }
     $this->sendITI($this->profil, $this->transaction, $this->message, $code, $patient);
     $patient->_IPP = null;
 }
Exemplo n.º 10
0
$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";
    $ljoin["functions_mediboard"] = "users_mediboard.function_id = functions_mediboard.function_id";
    $where["functions_mediboard.group_id"] = " = '{$current_group}'";
    $res_current_etab["CConsultation"] = $consultation->countList($where, null, $ljoin);
    // - Lits
    $ljoin = array();
    $where = array();