Exemplo n.º 1
0
 /**
  * Update soundex data
  *
  * @return bool
  */
 protected function createSoundex()
 {
     $where = array("nom_soundex2" => "IS NULL", "nom" => "!= ''");
     $limit = "0,1000";
     $pat = new CPatient();
     $listPat = $pat->loadList($where, null, $limit);
     while (count($listPat)) {
         foreach ($listPat as &$pat) {
             if ($msg = $pat->store()) {
                 trigger_error("Erreur store [{$pat->_id}] : {$msg}");
                 return false;
             }
         }
         $listPat = $pat->loadList($where, null, $limit);
     }
     return true;
 }
Exemplo n.º 2
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();
}
Exemplo n.º 3
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$patient_id = CValue::post('patient_id');
$patient = new CPatient();
if (!$patient->load($patient_id)) {
    CAppUI::stepAjax("Chargement impossible du patient", UI_MSG_ERROR);
}
$patient->patient_link_id = "";
if ($msg = $patient->store()) {
    CAppUI::stepAjax("Association du patient impossible : {$msg}", UI_MSG_ERROR);
}
CAppUI::stepAjax("{$patient->_view} désassocié");
CApp::rip();
Exemplo n.º 4
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$callback = CValue::post("callback");
$group = CGroups::loadCurrent();
$patient = new CPatient();
$patient->nom = "anonyme";
$patient->prenom = "anonyme";
$patient->sexe = CAppUI::conf("dPpatients CPatient anonymous_sexe", $group);
$patient->naissance = CAppUI::conf("dPpatients CPatient anonymous_naissance", $group);
$msg = $patient->store();
if ($msg) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
} else {
    CAppUI::setMsg(CAppUI::tr("CPatient-msg-create"), UI_MSG_OK);
}
echo CAppUI::getMsg();
if ($callback) {
    CAppUI::callbackAjax($callback, $patient->_id, $patient->_view);
}
CApp::rip();
 /**
  * Handle event A37 - Unlink two previously linked patients
  *
  * @param CHL7Acknowledgment $ack       Acknowledgment
  * @param CPatient           $patient_1 Person
  * @param CPatient           $patient_2 Person
  * @param array              $data      Data
  *
  * @return string
  */
 function handleA37(CHL7Acknowledgment $ack, CPatient $patient_1, CPatient $patient_2, $data)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     // Association des deux patients
     $patient_1->patient_link_id = "";
     if ($msg = $patient_1->store()) {
         return $exchange_hl7v2->setAckAR($ack, "E503", $msg, $patient_1);
     }
     return $exchange_hl7v2->setAckAA($ack, "I502", null, $patient_1);
 }
Exemplo n.º 6
0
 /**
  * Load patient PES
  *
  * @param CCnStep $step        Step
  * @param int     $step_number Step number
  *
  * @throws CMbException
  *
  * @return CPatient $patient
  */
 static function loadPatientPES(CCnStep $step, $step_number)
 {
     // PES-PAM_Encounter_Management_Basic
     $test = $step->_ref_test;
     $partner = $test->_ref_partner;
     $name = null;
     switch ($step_number) {
         case 10:
             $name = "ONE";
             break;
         case 20:
             $name = "TWO";
             break;
         case 30:
             $name = "THREE";
             break;
         case 40:
             $name = "FOUR";
             break;
         case 50:
             if ($step->number == 80) {
                 $name = "UPDATE";
             } else {
                 $name = "FIVE";
             }
             break;
     }
     $name = "PAM{$name}";
     $patient = new CPatient();
     $where = array();
     $where["nom"] = " = '{$name}_{$partner->name}_{$test->_id}'";
     $patient->loadObject($where);
     if (!$patient->_id) {
         $patient->random();
         $patient->nom = "{$name}_{$partner->name}_{$test->_id}";
         if ($msg = $patient->store()) {
             throw new CMbException($msg);
         }
     }
     return $patient;
 }
Exemplo n.º 7
0
 /**
  * @see parent::store()
  */
 function store()
 {
     $this->completeField("entree_reelle", "entree", "patient_id", "type_pec", "grossesse_id", "mode_sortie");
     /** @var CSejour $old */
     $old = $this->loadOldObject();
     // Vérification de la validité des codes CIM
     if ($this->DP != null) {
         $dp = CCodeCIM10::get($this->DP);
         if (!$dp->exist) {
             CAppUI::setMsg("Le code CIM saisi n'est pas valide", UI_MSG_WARNING);
             $this->DP = "";
         }
     }
     if ($this->DR != null) {
         $dr = CCodeCIM10::get($this->DR);
         if (!$dr->exist) {
             CAppUI::setMsg("Le code CIM saisi n'est pas valide", UI_MSG_WARNING);
             $this->DR = "";
         }
     }
     // Mode de sortie normal par défaut si l'autorisation de sortie est réalisée
     if ($this->conf("specified_output_mode") && !$this->mode_sortie && $this->fieldModified("confirme")) {
         $this->mode_sortie = "normal";
     }
     // Annulation de l'établissement de transfert si le mode de sortie n'est pas transfert
     if (null !== $this->mode_sortie) {
         if ("transfert" != $this->mode_sortie) {
             $this->etablissement_sortie_id = "";
         }
         if ("mutation" != $this->mode_sortie) {
             $this->service_sortie_id = "";
         }
     }
     // Mise à jour du type PEC si vide
     if (!$this->_id && !$this->type_pec) {
         $this->type_pec = $this->grossesse_id ? "O" : "M";
     }
     // Annulation de la sortie réelle si on annule le mode de sortie
     if ($this->mode_sortie === "") {
         $this->sortie_reelle = "";
     }
     // Annulation de l'établissement de provenance si le mode d'entrée n'est pas transfert
     if ($this->fieldModified("mode_entree")) {
         if ("7" != $this->mode_entree) {
             $this->etablissement_entree_id = "";
         }
         if ("6" != $this->mode_entree) {
             $this->service_entree_id = "";
         }
     }
     // Passage au mode transfert si on value un établissement de provenance
     if ($this->fieldModified("etablissement_entree_id")) {
         if ($this->etablissement_entree_id != null) {
             $this->mode_entree = 7;
         }
     }
     // Passage au mode mutation si on value un service de provenance
     if ($this->fieldModified("service_entree_id")) {
         if ($this->service_entree_id != null) {
             $this->mode_entree = 6;
         }
     }
     $patient_modified = $this->fieldModified("patient_id");
     // Si le patient est modifié et qu'il y a des consultations, on cascade les consultations
     if (!$this->_forwardRefMerging && $this->sejour_id && $patient_modified) {
         /** @var CConsultation[] $consultations */
         $consultations = $this->loadBackRefs("consultations");
         foreach ($consultations as $_consult) {
             $_consult->_sync_consults_from_sejour = true;
             $_consult->patient_id = $this->patient_id;
             if ($msg = $_consult->store()) {
                 return $msg;
             }
         }
     }
     // Pour un séjour non annulé, mise à jour de la date de décès du patient
     // suivant le mode de sortie
     if (!$this->annule) {
         $patient = new CPatient();
         $patient->load($this->patient_id);
         if ($this->fieldModified("mode_sortie")) {
             if ("deces" == $this->mode_sortie) {
                 $patient->deces = $this->_date_deces;
             } else {
                 if ($this->_old->mode_sortie == "deces") {
                     $patient->deces = "";
                 }
             }
         }
         // On verifie que le champ a été modifié pour faire le store (sinon probleme lors de la fusion de patients)
         if ($patient->fieldModified("deces")) {
             // Ne pas faire de return $msg ici, car ce n'est pas "bloquant"
             $patient->store();
         }
     }
     // Si annulation possible que par le chef de bloc
     if (CAppUI::conf("dPplanningOp COperation cancel_only_for_resp_bloc") && $this->fieldModified("annule", 1) && $this->entree_reelle && !CModule::getCanDo("dPbloc")->edit) {
         foreach ($this->loadRefsOperations() as $_operation) {
             if ($_operation->rank) {
                 CAppUI::setMsg("Impossible de sauvegarder : une des interventions du séjour est validée.\nContactez le responsable de bloc", UI_MSG_ERROR);
                 return null;
             }
         }
     }
     // On fixe la récusation si pas définie pour un nouveau séjour
     if (!$this->_id && ($this->recuse === "" || $this->recuse === null)) {
         $this->recuse = CAppUI::conf("dPplanningOp CSejour use_recuse") ? -1 : 0;
     }
     // no matter of config, if sejour is "urgence" type: recusation 0
     if ($this->type == "urg") {
         $this->recuse = 0;
     }
     // Si gestion en mode expert de l'isolement
     if (CAppUI::conf("dPplanningOp CSejour systeme_isolement") == "expert") {
         $this->isolement_date = $this->_isolement_date !== $this->entree && $this->isolement ? $this->_isolement_date : "";
         if (!$this->isolement) {
             $this->isolement_fin = "";
         }
     }
     $facture = null;
     if (CModule::getActive("dPfacturation") && CAppUI::conf("dPplanningOp CFactureEtablissement use_facture_etab")) {
         // Création de la facture de sejour
         $this->loadRefsFactureEtablissement();
         $facture = $this->_ref_last_facture;
         if (!$facture->_id) {
             $facture->ouverture = CMbDT::date();
         }
         if (CAppUI::conf("dPfacturation CFactureEtablissement use_temporary_bill")) {
             $facture->temporaire = 1;
         }
         $facture->group_id = $this->group_id;
         $facture->patient_id = $this->patient_id;
         $facture->praticien_id = $this->praticien_id;
         $facture->type_facture = $this->_type_sejour;
         $facture->dialyse = $this->_dialyse;
         $facture->cession_creance = $this->_cession_creance;
         $facture->statut_pro = $this->_statut_pro;
         $facture->assurance_maladie = $this->_assurance_maladie;
         $facture->assurance_accident = $this->_assurance_accident;
         $facture->rques_assurance_accident = $this->_rques_assurance_accident;
         $facture->rques_assurance_maladie = $this->_rques_assurance_maladie;
         //Store de la facture
         if ($msg = $facture->store()) {
             return $msg;
         }
     }
     $this->completeField("mode_entree_id");
     if ($this->mode_entree_id) {
         /** @var CModeEntreeSejour $mode */
         $mode = $this->loadFwdRef("mode_entree_id");
         $this->mode_entree = $mode->mode;
     }
     $this->completeField("mode_sortie_id");
     if ($this->mode_sortie_id) {
         /** @var CModeSortieSejour $mode */
         $mode = $this->loadFwdRef("mode_sortie_id");
         $this->mode_sortie = $mode->mode;
     }
     // Gestion du tarif et precodage des actes
     if ($this->_bind_tarif && $this->_id) {
         $this->getActeExecution();
         if ($msg = $this->bindTarif()) {
             return $msg;
         }
     }
     // Si on change la grossesse d'un séjour, il faut remapper les naissances éventuelles
     $change_grossesse = $this->fieldModified("grossesse_id");
     /** @var CNaissance[] $naissances */
     $naissances = array();
     if ($change_grossesse) {
         $naissances = $old->loadRefGrossesse()->loadRefsNaissances();
     }
     // Sectorisation Rules
     $this->getServiceFromSectorisationRules();
     if ($this->fieldModified("completion_sortie") && $this->completion_sortie && !$this->reception_sortie) {
         $this->reception_sortie = $this->completion_sortie;
     }
     if ($this->fieldModified("reception_sortie", "") && !$this->completion_sortie) {
         $this->completion_sortie = "";
     }
     $this->getUFs();
     $eai_sender_guid = $this->_eai_sender_guid;
     // On fait le store du séjour
     if ($msg = parent::store()) {
         return $msg;
     }
     $this->_eai_sender_guid = $eai_sender_guid;
     if ($change_grossesse) {
         foreach ($naissances as $_naissance) {
             $_naissance->grossesse_id = $this->grossesse_id;
             if ($msg = $_naissance->store()) {
                 return $msg;
             }
         }
     }
     // Changement des liaisons de prestations si besoin
     // Seulement par rapport à l'entrée
     if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") {
         $decalage = CMbDT::daysRelative($old->entree, $this->entree);
         if ($decalage != 0) {
             $liaisons = $this->loadBackRefs("items_liaisons");
             foreach ($liaisons as $_liaison) {
                 $_liaison->date = CMbDT::date("{$decalage} days", $_liaison->date);
                 if ($msg = $_liaison->store()) {
                     return $msg;
                 }
             }
         }
     }
     if (CModule::getActive("dPfacturation") && CAppUI::conf("dPplanningOp CFactureEtablissement use_facture_etab")) {
         if (count($this->_ref_factures) == 0) {
             $liaison = new CFactureLiaison();
             $liaison->object_id = $this->_id;
             $liaison->object_class = $this->_class;
             $liaison->facture_id = $facture->_id;
             $liaison->facture_class = "CFactureEtablissement";
             //Store de la table de liaison entre facture et séjour
             if ($msg = $liaison->store()) {
                 return $msg;
             }
         }
     }
     if ($patient_modified) {
         $list_backrefs = array("contextes_constante", "deliveries", "consultations");
         foreach ($list_backrefs as $_backname) {
             /** @var CConstantesMedicales[]|CProductDelivery[]|CConsultation[] $backobjects */
             $backobjects = $this->loadBackRefs($_backname);
             if (!$backobjects) {
                 continue;
             }
             foreach ($backobjects as $_object) {
                 if ($_object->patient_id == $this->patient_id) {
                     continue;
                 }
                 $_object->patient_id = $this->patient_id;
                 if ($_object instanceof CConsultation) {
                     $_object->_skip_count = true;
                 }
                 if ($msg = $_object->store()) {
                     CAppUI::setMsg($msg, UI_MSG_WARNING);
                 }
             }
         }
     }
     // Cas d'une annulation de séjour
     if ($this->annule) {
         // Suppression des affectations
         if ($msg = $this->delAffectations()) {
             return $msg;
         }
         // Suppression des opérations
         if ($msg = $this->cancelOperations()) {
             return $msg;
         }
         // Annulation des mouvements
         if ($msg = $this->cancelMovements()) {
             return $msg;
         }
     }
     // Synchronisation des affectations
     if (!$this->_no_synchro && !($this->type == "seances")) {
         $this->loadRefsAffectations();
         $firstAff =& $this->_ref_first_affectation;
         $lastAff =& $this->_ref_last_affectation;
         // Cas où on a une premiere affectation différente de l'heure d'admission
         if ($firstAff->_id && $firstAff->entree != $this->_entree) {
             $firstAff->entree = $this->_entree;
             $firstAff->_no_synchro = 1;
             $firstAff->store();
         }
         // Cas où on a une dernière affectation différente de l'heure de sortie
         if ($lastAff->_id && $lastAff->sortie != $this->_sortie) {
             $lastAff->sortie = $this->_sortie;
             $lastAff->_no_synchro = 1;
             $lastAff->store();
         }
         //si le sejour a une sortie ==> compléter le champ effectue de la derniere affectation
         if ($lastAff->_id) {
             $this->_ref_last_affectation->effectue = $this->sortie_reelle ? 1 : 0;
             $this->_ref_last_affectation->store();
         }
     }
     // try to assign an affectation
     $this->createAffectationLitUnique();
     $this->createAffectationService();
     // Génération du NDA ?
     if ($this->_generate_NDA) {
         // On ne synchronise pas un séjour d'urgences qui est un reliquat
         $rpu = $this->loadRefRPU();
         if ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id) {
             return null;
         }
         if ($msg = $this->generateNDA()) {
             return $msg;
         }
     }
     return null;
 }
Exemplo n.º 8
0
 /**
  * Recording patient
  * 
  * @param CPatient    $newPatient Patient
  * @param CIdSante400 $IPP        Object id400
  * 
  * @return null|string null if successful otherwise returns and error message
  */
 static function storePatientSIP(CPatient $newPatient, $IPP)
 {
     $newPatient->_IPP = $IPP;
     return $newPatient->store();
 }
<?php

/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision:$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkAdmin();
$action = CValue::post("action", "modify");
$patient = new CPatient();
switch ($action) {
    case "modify":
        while (!$patient->load(rand(1, 5000))) {
        }
        // randomize name
        $nom = str_split($patient->nom);
        shuffle($nom);
        $patient->nom = implode("", $nom);
        break;
    case "create":
        $patient->sample();
        //$patient->updateFormFields();
        break;
}
CAppUI::displayMsg($patient->store(), "CPatient-msg-{$action}");
//mbTrace($patient);
echo CAppUI::getMsg();
CApp::rip();