/**
  * Build ZBE segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $receiver = $event->_receiver;
     $sejour = $this->sejour;
     $movement = $this->movement;
     $affectation = $this->curr_affectation;
     if ($this->other_affectation) {
         $affectation = $this->other_affectation;
     }
     $action_movement = null;
     if ($sejour->_cancel_hospitalization) {
         $action_movement = "CANCEL";
     } else {
         foreach (self::$actions as $action => $events) {
             if (in_array($event->code, $events)) {
                 $action_movement = $action;
             }
         }
     }
     // ZBE-1: Movement ID (EI) (optional)
     $identifiers[] = array($movement->_view, CAppUI::conf("hl7 assigning_authority_namespace_id"), CAppUI::conf("hl7 assigning_authority_universal_id"), CAppUI::conf("hl7 assigning_authority_universal_type_id"));
     $idexMovement = CIdSante400::getMatch("CMovement", $receiver->_tag_movement, null, $movement->_id);
     if ($idexMovement->_id) {
         $configs = $receiver->_configs;
         $identifiers[] = array($idexMovement->id400, $configs["assigning_authority_namespace_id"], $configs["assigning_authority_universal_id"], $configs["assigning_authority_universal_type_id"]);
     }
     $data[] = $identifiers;
     // ZBE-2: Start of Movement Date/Time (TS)
     $start_of_movement = $action_movement == "CANCEL" ? $movement->last_update : $movement->start_of_movement;
     $data[] = $start_of_movement > $sejour->sortie ? $sejour->sortie : $start_of_movement;
     // ZBE-3: End of Movement Date/Time (TS) (optional)
     // Forbidden (IHE France)
     $data[] = null;
     // ZBE-4: Action on the Movement (ID)
     $data[] = $action_movement;
     // ZBE-5: Indicator "Historical Movement" (ID)
     $data[] = $movement->_current ? "N" : "Y";
     // ZBE-6: Original trigger event code (ID) (optional)
     $data[] = $action_movement == "UPDATE" || $action_movement == "CANCEL" ? $movement->original_trigger_code : null;
     $ufs = $sejour->getUFs(null, $affectation->_id);
     // ZBE-7: Ward of medical responsibility in the period starting with this movement (XON) (optional)
     $uf_type = $receiver->_configs["build_ZBE_7"];
     $uf_medicale = isset($ufs[$uf_type]) ? $ufs[$uf_type] : null;
     if (isset($uf_medicale->_id)) {
         $data[] = array(array($uf_medicale->libelle, null, null, null, null, $this->getAssigningAuthority("mediboard"), "UF", null, null, $uf_medicale->code));
     } else {
         $data[] = null;
     }
     // Traitement des segments spécifiques extension PAM
     $this->fillOtherSegments($data, $ufs, $event);
     $this->fill($data);
 }
 function syncPatient($update = true)
 {
     $medecin_id = $this->consume("medecin_id");
     // Gestion des id400
     $tag = "medecin-patient";
     $idex = new CIdSante400();
     $idex->object_class = "CPatient";
     $idex->id400 = $medecin_id;
     $idex->tag = $tag;
     // Identité
     $patient = new CPatient();
     $patient->nom = $this->consume("nom");
     $patient->prenom = CValue::first($this->consume("prenom"), $patient->nom);
     // Simulation de l'âge
     $year = 1980 - strlen($patient->nom);
     $month = '01';
     $day = str_pad(strlen($patient->prenom) % 30, 2, '0', STR_PAD_LEFT);
     $patient->naissance = "{$year}-{$month}-{$day}";
     // Binding
     $this->trace($patient->getProperties(true), "Patient à enregistrer");
     $idex->bindObject($patient);
     $this->markStatus(self::STATUS_PATIENT);
 }
Esempio n. 3
0
 /**
  * @see parent::storeIdExt()
  */
 protected function storeIdExt(CMbObject $object, $map_to)
 {
     if ($object instanceof CIdSante400) {
         return;
     }
     // Rattachement d'un ID externe
     $idex = CIdSante400::getMatchFor($object, "migration");
     if (!$idex->_id) {
         $idex->id400 = $map_to;
         $idex->last_update = CMbDT::dateTime();
         $idex->store();
         CAppUI::stepAjax("Idex '%s' créé sur '%s'", UI_MSG_OK, $idex->id400, $object);
     }
 }
Esempio n. 4
0
 /**
  * Charge l'idex de l'établissement
  *
  * @return string|null
  */
 function loadIdex()
 {
     $tag_group = $this->getTagGroup();
     if (!$this->_id || !$tag_group) {
         return null;
     }
     // Récupération du premier idex créé
     $order = "id400 ASC";
     // Recuperation de la valeur de l'id400
     $idex = new CIdSante400();
     $idex->setObject($this);
     $idex->tag = $tag_group;
     $idex->loadMatchingObject($order);
     return $idex->id400;
 }
 /**
  * Merge an array of objects
  *
  * @param self[] $objects An array of CMbObject to merge
  * @param bool   $fast    Tell wether to use SQL (fast) or PHP (slow but checked and logged) algorithm
  *
  * @return string|null
  */
 function merge($objects, $fast = false)
 {
     $alternative_mode = $this->_id != null;
     // Modes and object count check
     if ($alternative_mode && count($objects) > 1) {
         return "mergeAlternativeTooManyObjects";
     }
     if (!$alternative_mode && count($objects) < 2) {
         return "mergeTooFewObjects";
     }
     // Trigger before event
     $this->notify("BeforeMerge");
     if (!$this->_id && ($msg = $this->store())) {
         $this->notify("MergeFailure");
         return $msg;
     }
     foreach ($objects as $object) {
         $this->_merging[$object->_id] = $object;
     }
     foreach ($objects as &$object) {
         $msg = $fast ? $this->fastTransferBackRefsFrom($object) : $this->transferBackRefsFrom($object);
         if ($msg) {
             $this->notify("MergeFailure");
             return $msg;
         }
         $object_id = $object->_id;
         $object->_mergeDeletion = true;
         if ($msg = $object->delete()) {
             return $msg;
         }
         // If external IDs are available, we save old objects' id as external IDs
         if (CModule::getInstalled("dPsante400")) {
             $idex = new CIdSante400();
             $idex->setObject($this);
             $idex->tag = "merged";
             $idex->id400 = $object_id;
             $idex->last_update = CMbDT::dateTime();
             $idex->store();
         }
     }
     // Trigger after event
     $this->notify("AfterMerge");
     return $this->store();
 }
}
$mov = new CMovement();
$query = $request->makeSelect();
$list = $mov->_spec->ds->loadList($query);
if (!$do_it) {
    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)) {
Esempio n. 7
0
            $results[$i]["error"] = $msg;
            $results[$i]["username"] = "";
            $results[$i]["password"] = "";
            continue;
        }
        CAppUI::setMsg("Utilisateur créé", UI_MSG_OK);
        $mediuser->insFunctionPermission();
        $mediuser->insGroupPermission();
        $results[$i]["result"] = 0;
        $results[$i]["username"] = $mediuser->_user_username;
        $results[$i]["password"] = $mediuser->_user_password;
        $number_idex = $results[$i]["idex"];
        if (!$number_idex) {
            continue;
        }
        $idex = new CIdSante400();
        $idex->tag = CMediusers::getTagMediusers($group_id);
        $idex->id400 = $number_idex;
        if ($idex->loadMatchingObject()) {
            $unfound["idex"][$number_idex] = true;
            CAppUI::setMsg("Identifiant déjà existant", UI_MSG_WARNING);
            continue;
        }
        $idex->setObject($mediuser);
        $msg = $idex->store();
        if ($msg) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
    }
    fclose($fp);
}
Esempio n. 8
0
// Récupération des spécialités CPAM
$spec_cpam = new CSpecCPAM();
$spec_cpam = $spec_cpam->loadList(null, 'spec_cpam_id ASC');
// Récupération des profils
$profile = new CUser();
$profile->template = 1;
/** @var CUser[] $profiles */
$profiles = $profile->loadMatchingList();
// Creation du tableau de profil en fonction du type
$tabProfil = array();
foreach ($profiles as $profil) {
    $tabProfil[$profil->user_type][] = $profil->_id;
}
$tag = false;
if ($object->_id) {
    $tag = CIdSante400::getMatch($object->_class, CMediusers::getTagSoftware(), null, $object->_id)->id400;
}
$password_info = CAppUI::$user->_specs['_user_password']->minLength > 4 ? "Le mot de passe doit être composé d'au moins 6 caractères, comprenant des lettres et au moins un chiffre." : "Le mot de passe doit être composé d'au moins 4 caractères.";
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("tabProfil", $tabProfil);
$smarty->assign("utypes", CUser::$types);
$smarty->assign("ps_types", CUser::$ps_types);
$smarty->assign("banques", $banques);
$smarty->assign("object", $object);
$smarty->assign("profiles", $profiles);
$smarty->assign("functions", $functions);
$smarty->assign("disciplines", $disciplines);
$smarty->assign("spec_cpam", $spec_cpam);
$smarty->assign("tag_mediuser", CMediusers::getTagMediusers($group->_id));
$smarty->assign("is_admin", CAppUI::$user->isAdmin());
 /**
  * Trigger when merge failed
  *
  * @param CMbObject $mbObject Object
  *
  * @return bool
  */
 function onMergeFailure(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return false;
     }
     // On va réatribuer les idexs en cas de problème dans la fusion
     foreach ($mbObject->_fusion as $group_id => $infos_fus) {
         if (!$infos_fus || !array_key_exists("idexs_changed", $infos_fus)) {
             return false;
         }
         foreach ($infos_fus["idexs_changed"] as $idex_id => $tag_name) {
             $idex = new CIdSante400();
             $idex->load($idex_id);
             if (!$idex->_id) {
                 continue;
             }
             // Réattribution sur l'objet non supprimé
             $sejour_elimine = $infos_fus["sejourElimine"];
             $idex->object_id = $sejour_elimine->_id;
             $idex->tag = $tag_name;
             $idex->last_update = CMbDT::dateTime();
             $idex->store();
         }
     }
 }
Esempio n. 10
0
$verouillee = CValue::post("verouillee");
// Si la prescription est verouillée, un id externe est créé pour identifier la prescription
if ($verouillee) {
    $tagCatalogue = CAppUI::conf('dPlabo CCatalogueLabo remote_name');
    $prescription_labo_id = CValue::post("prescription_labo_id");
    $prescription = new CPrescriptionLabo();
    $prescription->load($prescription_labo_id);
    if (!$prescription->verouillee) {
        $prescription->loadRefsFwd();
        // Chargement de l'id400 "labo code4" du praticien
        $prat =& $prescription->_ref_praticien;
        $tagCode4 = "labo code4";
        $idSantePratCode4 = new CIdSante400();
        $idSantePratCode4->loadLatestFor($prat, $tagCode4);
        // creation de l'id400 de la prescription
        $idPresc = new CIdSante400();
        //Paramétrage de l'id 400
        $idPresc->tag = "{$tagCatalogue} Prat:" . str_pad($idSantePratCode4->id400, 4, '0', STR_PAD_LEFT);
        // tag LABO Prat: 0017
        $idPresc->object_class = "CPrescriptionLabo";
        // Chargement du dernier id externe de prescription du praticien s'il existe
        $idPresc->loadMatchingObject("id400 DESC");
        // Incrementation de l'id400
        $idPresc->id400++;
        $idPresc->id400 = str_pad($idPresc->id400, 4, '0', STR_PAD_LEFT);
        $idPresc->_id = null;
        $idPresc->last_update = CMbDT::dateTime();
        $idPresc->object_id = $prescription->_id;
        $idPresc->store();
    }
}
Esempio n. 11
0
 /**
  * Static shortcut to to idex for a given object
  *
  * @param CMbObject $mbObject Object
  * @param string    $tag      Tag
  * 
  * @return CIdSante400 
  */
 static function getMatchFor(CMbObject $mbObject, $tag = null)
 {
     $idex = new CIdSante400();
     $idex->loadLatestFor($mbObject, $tag);
     return $idex;
 }
 /**
  * Record admit
  *
  * @param CHPrimXMLAcquittementsPatients $dom_acq    Acquittement
  * @param CPatient                       $newPatient Patient
  * @param array                          $data       Data
  * @param CSejour                        &$newVenue  Admit
  *
  * @return CHPrimXMLAcquittementsPatients $msgAcq 
  **/
 function venuePatient(CHPrimXMLAcquittementsPatients $dom_acq, CPatient $newPatient, $data, &$newVenue = null)
 {
     $echg_hprim = $this->_ref_echange_hprim;
     // Cas 1 : Traitement du patient
     $domEnregistrementPatient = new CHPrimXMLEnregistrementPatient();
     $domEnregistrementPatient->_ref_echange_hprim = $echg_hprim;
     $msgAcq = $domEnregistrementPatient->enregistrementPatient($dom_acq, $newPatient, $data);
     if ($echg_hprim->statut_acquittement != "OK") {
         return $msgAcq;
     }
     // Cas 2 : Traitement de la venue
     $dom_acq = new CHPrimXMLAcquittementsPatients();
     $dom_acq->_identifiant_acquitte = $data['identifiantMessage'];
     $dom_acq->_sous_type_evt = $this->sous_type;
     $dom_acq->_ref_echange_hprim = $echg_hprim;
     // Traitement du message des erreurs
     $avertissement = $msgID400 = $msgVenue = $msgNDA = "";
     $_code_Venue = $_code_NumDos = $_num_dos_create = $_modif_venue = false;
     $sender = $echg_hprim->_ref_sender;
     $sender->loadConfigValues();
     $this->_ref_sender = $sender;
     $idSourceVenue = $data['idSourceVenue'];
     $idCibleVenue = $data['idCibleVenue'];
     if (!$newVenue) {
         $newVenue = new CSejour();
     }
     // Cas d'une annulation
     $cancel = false;
     if ($data['action'] == "suppression") {
         $cancel = true;
     }
     // Affectation du patient
     $newVenue->patient_id = $newPatient->_id;
     // Affectation de l'établissement
     $newVenue->group_id = $sender->group_id;
     $commentaire = "";
     $codes = array();
     // Si CIP
     if (!CAppUI::conf('smp server')) {
         // Acquittement d'erreur : identifiants source et cible non fournis pour le patient / venue
         if (!$idSourceVenue && !$idCibleVenue) {
             return $echg_hprim->setAckError($dom_acq, "E100", $commentaire, $newVenue);
         }
         $nda = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $idSourceVenue);
         // idSource non connu
         if (!$nda->_id) {
             // idCible fourni
             if ($idCibleVenue) {
                 if ($newVenue->load($idCibleVenue)) {
                     // Dans le cas d'une annulation de la venue
                     if ($cancel) {
                         if ($msgAcq = $this->doNotCancelVenue($newVenue, $dom_acq, $echg_hprim)) {
                             return $msgAcq;
                         }
                     }
                     // Recherche d'un num dossier déjà existant pour cette venue
                     // Mise en trash du numéro de dossier reçu
                     $newVenue->loadNDA();
                     if ($this->trashNDA($newVenue, $sender)) {
                         $nda->_trash = true;
                     } else {
                         // Mapping du séjour si pas de numéro de dossier
                         $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
                         $msgVenue = CEAISejour::storeSejour($newVenue, $sender);
                         $commentaire = CEAISejour::getComment($newVenue);
                         $_code_NumDos = "I121";
                         $_code_Venue = true;
                     }
                 } else {
                     $_code_NumDos = "I120";
                 }
             } else {
                 $_code_NumDos = "I122";
             }
             if (!$newVenue->_id) {
                 // Mapping du séjour
                 $newVenue->_NDA = $nda->id400;
                 $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
                 // Séjour retrouvé
                 if (CAppUI::conf("hprimxml strictSejourMatch")) {
                     if ($newVenue->loadMatchingSejour(null, true, $sender->_configs["use_sortie_matching"])) {
                         // Dans le cas d'une annulation de la venue
                         if ($cancel) {
                             if ($msgAcq = $this->doNotCancelVenue($newVenue, $dom_acq, $echg_hprim)) {
                                 return $msgAcq;
                             }
                         }
                         // Recherche d'un num dossier déjà existant pour cette venue
                         // Mise en trash du numéro de dossier reçu
                         $newVenue->loadNDA();
                         if ($this->trashNDA($newVenue, $sender)) {
                             $nda->_trash = true;
                         } else {
                             // Mapping du séjour
                             $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
                             $msgVenue = CEAISejour::storeSejour($newVenue, $sender);
                             $commentaire = CEAISejour::getComment($newVenue);
                             $_code_NumDos = "A121";
                             $_code_Venue = true;
                         }
                     }
                 } else {
                     $collision = $newVenue->getCollisions();
                     if (count($collision) == 1) {
                         $newVenue = reset($collision);
                         // Dans le cas d'une annulation de la venue
                         if ($cancel) {
                             if ($msgAcq = $this->doNotCancelVenue($newVenue, $dom_acq, $echg_hprim)) {
                                 return $msgAcq;
                             }
                         }
                         // Recherche d'un num dossier déjà existant pour cette venue
                         // Mise en trash du numéro de dossier reçu
                         $newVenue->loadNDA();
                         if ($this->trashNDA($newVenue, $sender)) {
                             $nda->_trash = true;
                         } else {
                             // Mapping du séjour
                             $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
                             $msgVenue = CEAISejour::storeSejour($newVenue, $sender);
                             $commentaire = CEAISejour::getComment($newVenue);
                             $_code_NumDos = "A122";
                             $_code_Venue = true;
                         }
                     }
                 }
                 if (!$newVenue->_id && !isset($nda->_trash)) {
                     // Mapping du séjour
                     $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
                     $msgVenue = CEAISejour::storeSejour($newVenue, $sender);
                     $commentaire = CEAISejour::getComment($newVenue);
                 }
             }
             if (isset($nda->_trash)) {
                 $nda->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_trash') . $sender->_tag_sejour;
                 $nda->loadMatchingObject();
                 $codes = array("I125");
                 $commentaire = "Sejour non récupéré. Impossible d'associer le numéro de dossier.";
             }
             if ($cancel) {
                 $codes[] = "A130";
                 $nda->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_trash') . $sender->_tag_sejour;
             }
             $msgNDA = CEAISejour::storeNDA($nda, $newVenue, $sender);
             if (!isset($nda->_trash)) {
                 $codes = array($msgVenue ? $_code_Venue ? "A103" : "A102" : ($_code_Venue ? "I102" : "I101"), $msgNDA ? "A105" : $_code_NumDos);
             }
             if ($msgVenue || $msgNDA) {
                 $avertissement = $msgVenue . " " . $msgNDA;
             } else {
                 if (!isset($nda->_trash)) {
                     $commentaire .= "Numéro dossier créé : {$nda->id400}.";
                 }
             }
         } else {
             $newVenue->_NDA = $nda->id400;
             $newVenue->load($nda->object_id);
             // Dans le cas d'une annulation de la venue
             if ($cancel) {
                 if ($msgAcq = $this->doNotCancelVenue($newVenue, $dom_acq, $echg_hprim)) {
                     return $msgAcq;
                 }
             }
             // Mapping du séjour
             $newVenue = $this->mappingVenue($data['venue'], $newVenue, $cancel);
             // idCible non fourni
             if (!$idCibleVenue) {
                 $_code_NumDos = "I123";
             } else {
                 $tmpVenue = new CSejour();
                 // idCible connu
                 if ($tmpVenue->load($idCibleVenue)) {
                     if ($tmpVenue->_id != $nda->object_id) {
                         $commentaire = "L'identifiant source fait référence au séjour : {$nda->object_id}";
                         $commentaire .= "et l'identifiant cible au séjour : {$tmpVenue->_id}.";
                         return $dom_acq->generateAcquittementsError("E104", $commentaire, $newVenue);
                     }
                     $_code_NumDos = "I124";
                 } else {
                     $_code_NumDos = "A120";
                 }
             }
             $msgVenue = CEAISejour::storeSejour($newVenue, $sender);
             $codes = array($msgVenue ? "A103" : "I102", $_code_NumDos);
             if ($cancel) {
                 $codes[] = "A130";
                 $nda->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_trash') . $sender->_tag_sejour;
                 $nda->last_update = CMbDT::dateTime();
                 $msgNDA = $nda->store();
             }
             if ($msgVenue || $msgNDA) {
                 $avertissement = $msgVenue . " " . $msgNDA;
             }
             $commentaire = CEAISejour::getComment($newVenue);
         }
         return $echg_hprim->setAck($dom_acq, $codes, $avertissement, $commentaire, $newVenue);
     }
 }
/**
 * Catalogue import
 */
function importCatalogue($cat, $parent_id = null)
{
    global $remote_name;
    CApp::setTimeLimit(180);
    // On rend toutes les analyses du catalogue obsoletes
    $idAnalyse = new CIdSante400();
    $idAnalyse->tag = $remote_name;
    $idAnalyse->object_class = "CExamenLabo";
    $idAnalyses = $idAnalyse->loadMatchingList();
    foreach ($idAnalyses as $_id_analyse) {
        $examenLabo = new CExamenLabo();
        $examenLabo->identifiant = $_id_analyse->id400;
        $examenLabo->loadMatchingObject();
        if ($examenLabo->_id) {
            $examenLabo->obsolete = 1;
            $examenLabo->store();
        }
    }
    $idCatalogue = new CIdSante400();
    $idCatalogue->tag = $remote_name;
    $idCatalogue->object_class = "CCatalogueLabo";
    $idCatalogues = $idCatalogue->loadMatchingList();
    foreach ($idCatalogues as $_id_catalogue) {
        $catalogueLabo = new CCatalogueLabo();
        $catalogueLabo->identifiant = $_id_catalogue->id400;
        $catalogueLabo->loadMatchingObject();
        if ($catalogueLabo->_id) {
            $catalogueLabo->obsolete = 1;
            $catalogueLabo->store();
        }
    }
    $compteur["analyses"] = 0;
    $compteur["chapitres"] = 0;
    $compteur["sousChapitre"] = 0;
    $catalogues = array();
    // Creation du catalogue global LABO
    $catal = new CCatalogueLabo();
    $catalogue = new CCatalogueLabo();
    $catal->identifiant = substr(hash('md5', $remote_name), 0, 4);
    // libelle modifié par hash
    $catal->libelle = $remote_name;
    $catal->pere_id = $parent_id;
    // creation de son id400
    $idCat = new CIdSante400();
    $idCat->tag = $remote_name;
    $idCat->id400 = $remote_name;
    $catal->obsolete = 0;
    $idCat->bindObject($catal);
    //CAppUI::stepAjax("Catalogue '$catal->libelle' importé", UI_MSG_OK);
    $path = $remote_name;
    // on met a jour $catalogues
    $catalogues[$path] = $catal;
    //Parcours des analyses
    foreach ($cat->analyse as $_analyse) {
        $chapitre = (string) $_analyse->chapitre;
        $path = "{$remote_name}/{$chapitre}/";
        if (!$chapitre) {
            $path = $remote_name;
        }
        $catChapitre = new CCatalogueLabo();
        // si le catalogue n'existe pas deja
        if (!array_key_exists($path, $catalogues)) {
            // creation du catalogue
            $catChapitre->identifiant = substr(hash('md5', $chapitre), 0, 4);
            // libelle modifié par hash;
            $catChapitre->libelle = $chapitre;
            $catChapitre->pere_id = $catal->_id;
            $catChapitre->decodeUtfStrings();
            //creation de l'id400
            $idCatChapitre = new CIdSante400();
            $idCatChapitre->tag = $remote_name;
            $idCatChapitre->id400 = substr(hash('md5', $chapitre), 0, 4);
            $catChapitre->obsolete = 0;
            $idCatChapitre->bindObject($catChapitre);
            //CAppUI::stepAjax("Catalogue '$catChapitre->libelle' importé", UI_MSG_OK);
            $compteur["chapitres"]++;
            // on met a jour $catalogues
            $catalogues[$path] = $catChapitre;
        }
        $catChapitre = $catalogues[$path];
        $catalogue = $catChapitre;
        // si il y a un sous chapitre a creer==> le pere du sous chapitre est $catalogue->_id;
        $sschapitre = (string) $_analyse->sschapitre;
        if ($sschapitre) {
            // modification du path
            $path .= $sschapitre;
            $catssChapitre = new CCatalogueLabo();
            if (!array_key_exists($path, $catalogues)) {
                // creation du catalogue
                $catssChapitre->identifiant = substr(hash('md5', $sschapitre), 0, 4);
                // libelle modifié par hash;
                $catssChapitre->libelle = $sschapitre;
                $catssChapitre->pere_id = $catChapitre->_id;
                $catssChapitre->decodeUtfStrings();
                //creation de l'id400
                $idCatssChapitre = new CIdSante400();
                $idCatssChapitre->tag = $remote_name;
                $idCatssChapitre->id400 = substr(hash('md5', $sschapitre), 0, 4);
                $catssChapitre->obsolete = 0;
                $idCatssChapitre->bindObject($catssChapitre);
                //CAppUI::stepAjax("Sous Catalogue '$catssChapitre->libelle' importé", UI_MSG_OK);
                $compteur["sousChapitre"]++;
                //on met à jour les catalogues
                $catalogues[$path] = $catssChapitre;
            }
            $catssChapitre = $catalogues[$path];
            $catalogue = $catssChapitre;
        }
        // Code de l'analyse
        $catAtt = $_analyse->attributes();
        $code = $catAtt["code"];
        $idAnalyse = new CIdSante400();
        $idAnalyse->tag = $remote_name;
        $idAnalyse->id400 = (string) $code;
        $analyse = new CExamenLabo();
        $analyse->identifiant = (string) $code;
        $analyse->libelle = (string) $_analyse->libelle;
        $analyse->decodeUtfStrings();
        $analyse->technique = (string) $_analyse->technique;
        $analyse->duree_execution = (string) $_analyse->delaitechnique;
        $materiel = utf8_decode((string) $_analyse->materiel);
        $materiel = trim($materiel);
        switch ($materiel) {
            case "SANG VEINEUX":
                $analyse->type_prelevement = "sang";
                break;
            case "URINE":
                $analyse->type_prelevement = "urine";
                break;
            case "BIOPSIE":
                $analyse->type_prelevement = "biopsie";
                break;
        }
        //$analyse->applicabilite = (string) $_analyse->applicablesexe;
        $analyse->execution_lun = (string) $_analyse->joursrealisation->lundi;
        $analyse->execution_mar = (string) $_analyse->joursrealisation->mardi;
        $analyse->execution_mer = (string) $_analyse->joursrealisation->mercredi;
        $analyse->execution_jeu = (string) $_analyse->joursrealisation->jeudi;
        $analyse->execution_ven = (string) $_analyse->joursrealisation->vendredi;
        $analyse->execution_sam = (string) $_analyse->joursrealisation->samedi;
        $analyse->execution_dim = (string) $_analyse->joursrealisation->dimanche;
        $analyse->catalogue_labo_id = $catalogue->_id;
        $analyse->type = "num";
        $analyse->obsolete = 0;
        $idAnalyse->bindObject($analyse);
        //CAppUI::stepAjax("Analyse '$analyse->identifiant' importée", UI_MSG_OK);
        $compteur["analyses"]++;
    }
    // fin du foreach
    CAppUI::stepAjax("Analyses Importées: " . $compteur["analyses"] . ", Chapitres Importés: " . $compteur["chapitres"] . ", Sous chapitres Importés: " . $compteur["sousChapitre"], UI_MSG_OK);
}
 /**
  * Return the Object with the information of the medecin in the message
  *
  * @param DOMNode   $node   Node
  * @param CMbObject $object object
  *
  * @return int|null|string
  */
 function getDoctor(DOMNode $node, CMbObject $object)
 {
     $type_id = $this->queryTextNode("XCN.13", $node);
     $id = $this->queryTextNode("XCN.1", $node);
     $last_name = $this->queryTextNode("XCN.2/FN.1", $node);
     $first_name = $this->queryTextNode("XCN.3", $node);
     switch ($type_id) {
         case "RPPS":
             $object->rpps = $id;
             break;
         case "ADELI":
             $object->adeli = $id;
             break;
         case "RI":
             // Notre propre RI
             if ($this->queryTextNode("XCN.9/HD.2", $node) == CAppUI::conf("hl7 assigning_authority_universal_id")) {
                 return $id;
             }
         default:
             // Recherche du praticien par son idex
             $idex = CIdSante400::getMatch($object->_class, $this->_ref_sender->_tag_mediuser, $id);
             if ($idex->_id) {
                 return $idex->object_id;
             }
             if ($object instanceof CMediusers) {
                 $object->_user_first_name = $first_name;
                 $object->_user_last_name = $last_name;
             }
             if ($object instanceof CMedecin) {
                 $object->prenom = $first_name;
                 $object->nom = $last_name;
             }
             break;
     }
     // Cas où l'on a aucune information sur le médecin
     if (!$object->rpps && !$object->adeli && !$object->_id && ($object instanceof CMediusers && !$object->_user_last_name || $object instanceof CMedecin && !$object->nom)) {
         return null;
     }
     if ($object instanceof CMedecin && $object->loadMatchingObjectEsc()) {
         return $object->_id;
     }
     $sender = $this->_ref_sender;
     $ds = $object->getDS();
     if ($object instanceof CMediusers) {
         $ljoin = array();
         $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
         $where = array();
         $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
         if ($object->rpps || $object->adeli) {
             if ($object->rpps) {
                 $where[] = $ds->prepare("rpps = %", $object->rpps);
             }
             if ($object->adeli) {
                 $where[] = $ds->prepare("adeli = %", $object->adeli);
             }
             // Dans le cas où le praticien recherché par son ADELI ou RPPS est multiple
             if ($object->countList($where, null, $ljoin) > 1) {
                 $ljoin["users"] = "users_mediboard.user_id = users.user_id";
                 $where[] = $ds->prepare("users.user_last_name = %", $last_name);
             }
             $object->loadObject($where, null, null, $ljoin);
             if ($object->_id) {
                 return $object->_id;
             }
         }
         $user = new CUser();
         $ljoin = array();
         $ljoin["users_mediboard"] = "users.user_id = users_mediboard.user_id";
         $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
         $where = array();
         $where["functions_mediboard.group_id"] = " = '{$sender->group_id}'";
         $where[] = $ds->prepare("users.user_first_name = %", $first_name);
         $where[] = $ds->prepare("users.user_last_name = %", $last_name);
         $order = "users.user_id ASC";
         if ($user->loadObject($where, $order, null, $ljoin)) {
             return $user->_id;
         }
         $object->_user_first_name = $first_name;
         $object->_user_last_name = $last_name;
         return $this->createDoctor($object);
     }
 }
Esempio n. 15
0
<?php

/**
 * $Id$
 *  
 * @category CDA
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$group_type = CValue::post("group_type");
$group_id = CValue::post("group_id");
$group = new CGroups();
$group->load($group_id);
$idex = new CIdSante400();
$idex->tag = "cda_association_code";
$idex->setObject($group);
$idex->loadMatchingObject();
$idex->last_update = CMbDT::dateTime();
$idex->id400 = $group_type;
if ($group_type && ($msg = $idex->store())) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
}
CAppUI::setMsg("Configuration effectué");
Esempio n. 16
0
 /**
  * Build SCH segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $receiver = $event->_receiver;
     $appointment = $this->appointment;
     $data = array();
     // SCH-1: Placer Appointment ID (EI) (optional)
     $data[] = null;
     // SCH-2: Filler Appointment ID (EI) (optional)
     $identifiers[] = array($appointment->_id, CAppUI::conf("hl7 assigning_authority_namespace_id"), CAppUI::conf("hl7 assigning_authority_universal_id"), CAppUI::conf("hl7 assigning_authority_universal_type_id"));
     $idex = CIdSante400::getMatch("CConsultation", $receiver->_tag_consultation, null, $appointment->_id);
     if ($idex->_id) {
         $configs = $receiver->_configs;
         $identifiers[] = array($idex->id400, $configs["assigning_authority_namespace_id"], $configs["assigning_authority_universal_id"], $configs["assigning_authority_universal_type_id"]);
     }
     $data[] = $identifiers;
     // SCH-3: Occurrence Number (NM) (optional)
     $data[] = null;
     // SCH-4: Placer Group Number (EI) (optional)
     $data[] = null;
     // SCH-5: Schedule ID (CE) (optional)
     $data[] = null;
     // SCH-6: Event Reason (CE)
     /* @todo Voir comment améliorer */
     $data[] = array(array(1, "CConsultation"));
     // SCH-7: Appointment Reason (CE) (optional)
     $data[] = array(array($appointment->_id, $appointment->motif));
     // SCH-8: Appointment Type (CE) (optional)
     $data[] = null;
     // SCH-9: Appointment Duration (NM) (optional)
     $data[] = null;
     // SCH-10: Appointment Duration Units (CE) (optional)
     $data[] = null;
     // SCH-11: Appointment Timing Quantity (TQ) (optional repeating)
     $data[] = array(array(null, null, "M" . $appointment->_duree, $appointment->_datetime, $appointment->_date_fin));
     // SCH-12: Placer Contact Person (XCN) (optional repeating)
     $data[] = $this->getXCN($appointment->_ref_praticien, $receiver);
     // SCH-13: Placer Contact Phone Number (XTN) (optional)
     $data[] = null;
     // SCH-14: Placer Contact Address (XAD) (optional repeating)
     $data[] = null;
     // SCH-15: Placer Contact Location (PL) (optional)
     $data[] = null;
     // SCH-16: Filler Contact Person (XCN) ( repeating)
     $first_log = $appointment->loadFirstLog();
     $mediuser = $first_log->loadRefUser()->loadRefMediuser();
     $data[] = $this->getXCN($mediuser, $receiver);
     // SCH-17: Filler Contact Phone Number (XTN) (optional)
     $data[] = null;
     // SCH-18: Filler Contact Address (XAD) (optional repeating)
     $data[] = null;
     // SCH-19: Filler Contact Location (PL) (optional)
     $data[] = null;
     // SCH-20: Entered By Person (XCN) ( repeating)
     $data[] = $this->getXCN($mediuser, $receiver);
     // SCH-21: Entered By Phone Number (XTN) (optional repeating)
     $data[] = null;
     // SCH-22: Entered By Location (PL) (optional)
     $data[] = null;
     // SCH-23: Parent Placer Appointment ID (EI) (optional)
     $data[] = null;
     // SCH-24: Parent Filler Appointment ID (EI) (optional)
     $data[] = null;
     // SCH-25: Filler Status Code (CE) (optional)
     $data[] = $this->getFillerStatutsCode($appointment);
     // SCH-26: Placer Order Number (EI) (optional repeating)
     $data[] = null;
     // SCH-27: Filler Order Number (EI) (optional repeating)
     $data[] = null;
     $this->fill($data);
 }
 /**
  * Passage en trash du NDA
  *
  * @param CSejour        $venue  Venue
  * @param CInteropSender $sender Expéditeur
  *
  * @return bool
  */
 function trashNDA(CSejour $venue, CInteropSender $sender)
 {
     if (isset($sender->_configs["type_sej_pa"])) {
         if ($venue->_NDA && preg_match($sender->_configs["type_sej_pa"], $venue->_NDA)) {
             // Passage en pa_ de l'id externe
             $num_pa = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $venue->_NDA);
             if ($num_pa->_id) {
                 $num_pa->tag = CAppUI::conf('dPplanningOp CSejour tag_dossier_pa') . $sender->_tag_sejour;
                 $num_pa->last_update = CMbDT::dateTime();
                 $num_pa->store();
             }
             return false;
         }
     }
     if ($venue->_NDA) {
         return true;
     }
     return false;
 }
Esempio n. 18
0
<?php

/* $Id: view_identifiants.php 28748 2015-06-27 09:01:22Z lryo $ */
/**
 * @package Mediboard
 * @subpackage sante400
 * @version $Revision: 28748 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
CCanDo::checkRead();
$canSante400 = CModule::getCanDo("dPsante400");
$dialog = CValue::get("dialog");
$page = intval(CValue::get('page', 0));
// Chargement du filtre
$filter = new CIdSante400();
$filter->object_id = CValue::get("object_id");
$filter->object_class = CValue::get("object_class");
$filter->tag = CValue::get("tag");
$filter->id400 = CValue::get("id400");
$filter->nullifyEmptyFields();
// Récupération de la liste des classes disponibles
if ($filter->object_class && $filter->object_id) {
    $listClasses = array($filter->object_class);
} else {
    $listClasses = CApp::getInstalledClasses();
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("page", $page);
$smarty->assign("filter", $filter);
 function mapAndStorePayment(DOMNode $node, CFactureCabinet $facture, CIdSante400 $idex)
 {
     $reglement = new CReglement();
     $reglement->load($idex->object_id);
     // Recherche du règlement si pas retrouvé par son idex
     $reglement->setObject($facture);
     $reglement->date = $this->getDatePayment($node) . " 00:00:00";
     $amount_paid = $this->getAmountPaid($node);
     $reglement->montant = $amount_paid;
     $direction = $this->getDirection($node);
     if ($direction == "-") {
         $reglement->montant = $reglement->montant * -1;
     }
     $reglement->emetteur = "tiers";
     $reglement->mode = "autre";
     $reglement->loadOldObject();
     if ($reglement->_old && round($reglement->montant, 3) == round($reglement->_old->montant, 3)) {
         return $reglement;
     }
     // Mise à jour du montant (du_tiers) de la facture
     $value = $reglement->_old ? $reglement->montant - $reglement->_old->montant : $reglement->montant;
     // Acquittement de la facture associée ?
     if ($msg = $reglement->store()) {
         return $msg;
     }
     // Gestion de l'idex
     if (!$idex->object_id) {
         $idex->object_id = $reglement->_id;
     }
     $idex->last_update = CMbDT::dateTime();
     if ($msg = $idex->store()) {
         return $msg;
     }
     if ($direction != "+") {
         return $reglement;
     }
     return $reglement;
 }
 /**
  * Handle A29 event - Delete person information
  *
  * @param CHL7Acknowledgment $ack        Acknowledgement
  * @param CPatient           $newPatient Person
  * @param array              $data       Nodes data
  *
  * @return null|string
  */
 function handleA29(CHL7Acknowledgment $ack, CPatient $newPatient, $data)
 {
     // Traitement du message des erreurs
     $comment = $warning = "";
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $this->_ref_sender;
     $patientPI = CValue::read($data['personIdentifiers'], "PI");
     $IPP = new CIdSante400();
     if ($patientPI) {
         $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI);
     }
     if (!$patientPI || !$IPP->_id) {
         return $exchange_hl7v2->setAckAR($ack, "E150", null, $newPatient);
     }
     $newPatient->load($IPP->object_id);
     // Passage en trash de l'IPP du patient
     if ($msg = $newPatient->trashIPP($IPP)) {
         return $exchange_hl7v2->setAckAR($ack, "E151", $msg, $newPatient);
     }
     // Annulation de tous les séjours du patient qui n'ont pas d'entrée réelle
     $where = array();
     $where['entree_reelle'] = "IS NULL";
     $where['group_id'] = " = '{$sender->group_id}'";
     $sejours = $newPatient->loadRefsSejours($where);
     foreach ($sejours as $_sejour) {
         // Notifier les autres destinataires autre que le sender
         $_sejour->_eai_sender_guid = $sender->_guid;
         // Pas de génération de NDA
         $_sejour->_generate_NDA = false;
         // On ne check pas la cohérence des dates des consults/intervs
         $_sejour->_skip_date_consistencies = true;
         // On annule le séjour
         $_sejour->annule = 1;
         $_sejour->store();
     }
     $codes = array("I150");
     return $exchange_hl7v2->setAckAA($ack, $codes, $comment, $newPatient);
 }
 /**
  * Récupération du segment ZBE
  *
  * @param DOMNode   $node     Node
  * @param CSejour   $newVenue Admit
  * @param CMovement $movement Movement
  *
  * @return CMovement|string|null
  */
 function getZBE(DOMNode $node, CSejour $newVenue, CMovement $movement)
 {
     $sender = $this->_ref_sender;
     $idex_create = false;
     $event_code = $this->_ref_exchange_hl7v2->code;
     $own_movement = null;
     $sender_movement = null;
     foreach ($this->queryNodes("ZBE.1", $node) as $ZBE_1) {
         $EI_1 = $this->queryTextNode("EI.1", $ZBE_1);
         $EI_2 = $this->queryTextNode("EI.2", $ZBE_1);
         $EI_3 = $this->queryTextNode("EI.3", $ZBE_1);
         // Notre propre identifiant de mouvement
         if ($EI_2 == CAppUI::conf("hl7 assigning_authority_namespace_id") || $EI_3 == CAppUI::conf("hl7 assigning_authority_universal_id")) {
             $own_movement = $EI_1;
             break;
         }
         // L'identifiant de mouvement du sender
         if ($EI_3 == $sender->_configs["assigning_authority_universal_id"] || $EI_2 == $sender->_configs["assigning_authority_universal_id"]) {
             $sender_movement = $EI_1;
             continue;
         }
     }
     if (!$own_movement && !$sender_movement) {
         return "Impossible d'identifier le mouvement";
     }
     $movement_id = $own_movement ? $own_movement : $sender_movement;
     if (!$movement_id) {
         return null;
     }
     $start_movement_dt = $this->queryTextNode("ZBE.2/TS.1", $node);
     $action = $this->queryTextNode("ZBE.4", $node);
     $original_trigger = $this->queryTextNode("ZBE.6", $node);
     if (!$original_trigger) {
         $original_trigger = $event_code;
     }
     $movement->sejour_id = $newVenue->_id;
     $movement->original_trigger_code = $original_trigger;
     $movement->cancel = 0;
     $idexMovement = new CIdSante400();
     // Notre propre ID de mouvement
     if ($own_movement) {
         $movement_id_split = explode("-", $movement_id);
         $movement->movement_type = $movement_id_split[0];
         $movement->_id = $movement_id_split[1];
         $movement->loadMatchingObjectEsc();
         if (!$movement->_id) {
             return null;
         }
         if ($sender_movement) {
             $idexMovement = CIdSante400::getMatch("CMovement", $sender->_tag_movement, $sender_movement);
             if (!$idexMovement->_id) {
                 $idex_create = true;
             }
         }
     } else {
         $idexMovement = CIdSante400::getMatch("CMovement", $sender->_tag_movement, $movement_id);
         if ($idexMovement->_id) {
             $movement->load($idexMovement->object_id);
         } else {
             $idex_create = true;
             if ($event_code != "A02" && $event_code != "A21") {
                 $movement->cancel = 0;
                 $movement->loadMatchingObjectEsc();
             }
         }
         $movement->movement_type = $newVenue->getMovementType($original_trigger);
     }
     // Erreur dans le cas où le type du mouvement est UPDATE ou CANCEL et que l'on a pas retrouvé le mvt
     if (($action == "UPDATE" || $action == "CANCEL") && !$movement->_id) {
         return null;
     }
     if ($action == "CANCEL") {
         $movement->cancel = true;
     }
     $movement->start_of_movement = $start_movement_dt;
     $movement->last_update = CMbDT::dateTime();
     $movement->_eai_sender_guid = $sender->_guid;
     if ($msg = $movement->store()) {
         return $msg;
     }
     if ($idex_create) {
         $idexMovement->last_update = CMbDT::dateTime();
         $idexMovement->object_id = $movement->_id;
         $idexMovement->_eai_sender_guid = $sender->_guid;
         if ($msg = $idexMovement->store()) {
             return $msg;
         }
     }
     return $movement;
 }
 /**
  * Delete acte
  *
  * @param CActe       $acte   Acte
  * @param CMbObject   $object Object
  * @param CIdSante400 $idex   Idex
  *
  * @return String|null
  */
 function deleteActe($acte, $object, $idex)
 {
     if ($msg = $idex->delete()) {
         return $msg;
     }
     if ($msg = $acte->delete()) {
         return $msg;
     }
     if ($msg = $object->store()) {
         return $msg;
     }
     return null;
 }
Esempio n. 23
0
 /**
  * Chargement du dernier identifiant id400
  *
  * @param string $tag Tag à utiliser comme filtre
  *
  * @return CIdSante400
  */
 function loadLastId400($tag = null)
 {
     $idex = new CIdSante400();
     if ($idex->_ref_module) {
         $idex->loadLatestFor($this, $tag);
         $this->_ref_last_id400 = $idex;
     }
     return $idex;
 }
Esempio n. 24
0
 function isIPPConflict($ipp)
 {
     // Pas de tag IPP => pas d'affichage d'IPP
     if (null == ($tag_ipp = CAppUI::conf("dPpatients CPatient tag_ipp"))) {
         return null;
     }
     $idex = new CIdSante400();
     $idex->object_class = 'CPatient';
     $idex->tag = $tag_ipp;
     $idex->id400 = $ipp;
     $idex->loadMatchingObject();
     return $idex->_id;
 }
Esempio n. 25
0
 static function generateIdex(CMbObject $object, $tag, $group_id)
 {
     $group = CGroups::loadFromGuid("CGroups-{$group_id}");
     // On préfère générer un identifiant d'un établissement virtuel pour les séjours non-facturables
     $group_id_pour_sejour_facturable = CAppUI::conf('dPsante400 CDomain group_id_pour_sejour_facturable', $group);
     if ($object instanceof CSejour && !$object->facturable && $group_id_pour_sejour_facturable) {
         $group_id = $group_id_pour_sejour_facturable;
     }
     $group_domain = new CGroupDomain();
     $group_domain->object_class = $object->_class;
     $group_domain->group_id = $group_id;
     $group_domain->master = 1;
     $group_domain->loadMatchingObject();
     if (!$group_domain->_id) {
         return;
     }
     $domain = $group_domain->loadRefDomain();
     $conf = CAppUI::conf("dPsante400 CIncrementer");
     $cluster_count = abs(intval($conf["cluster_count"]));
     $cluster_position = abs(intval($conf["cluster_position"]));
     if ($cluster_count == 0) {
         $cluster_count = 1;
     }
     if ($cluster_count == 1) {
         $cluster_position = 0;
     }
     $mutex = new CMbSemaphore("incrementer-{$object->_class}");
     $mutex->acquire();
     $incrementer = $domain->loadRefIncrementer();
     // Chargement du dernier 'increment' s'il existe sinon on déclenche une erreur
     if (!$incrementer->_id) {
         $mutex->release();
         return;
     }
     // Incrementation de l'idex
     $value = $incrementer->value;
     // Valeur compatible avec la position dans le cluster
     do {
         $value++;
     } while ($value % $cluster_count != $cluster_position);
     do {
         // Idex vraiment disponible ?
         $idex = new CIdSante400();
         $idex->object_class = $object->_class;
         $idex->tag = $tag;
         $idex->id400 = self::formatValue($object, $incrementer->pattern, $value);
         $idex->loadMatchingObject();
     } while ($idex->_id && ($value += $cluster_count));
     $incrementer->value = $value;
     $incrementer->last_update = CMbDT::dateTime();
     $incrementer->store();
     // Création de l'identifiant externe
     $idex->object_id = $object->_id;
     $idex->last_update = CMbDT::dateTime();
     $idex->store();
     $mutex->release();
     return $idex;
 }
 /**
  * @see parent::extractData
  */
 function extractData()
 {
     /** @var CDocumentItem $docItem */
     $docItem = $this->mbObject;
     $this->realm_code = "FR";
     $this->langage = $docItem->language;
     //Récupération du dernier log qui correspond à la date de création de cette version
     $last_log = $docItem->loadLastLog();
     $this->date_creation = $last_log->date;
     $this->date_author = $last_log->date;
     $this->targetObject = $object = $docItem->loadTargetObject();
     if ($object instanceof CConsultAnesth) {
         $this->targetObject = $object = $object->loadRefConsultation();
     }
     $this->practicien = $object->loadRefPraticien();
     $this->patient = $object->loadRefPatient();
     $this->patient->loadLastINS();
     $this->patient->loadIPP();
     $this->mbObject = $docItem;
     $this->root = CMbOID::getOIDFromClass($docItem, $this->receiver);
     $this->practicien->loadRefFunction();
     $this->practicien->loadRefOtherSpec();
     $group = new CGroups();
     $group->load($this->practicien->_group_id);
     $this->healt_care = CCdaTools::loadEntryJV("CI-SIS_jdv_healthcareFacilityTypeCode.xml", CIdSante400::getValueFor($group, "cda_association_code"));
     if ($docItem instanceof CFile) {
         $this->version = "1";
         $this->nom = basename($docItem->file_name);
     } else {
         $this->version = $docItem->version;
         $this->nom = $docItem->nom;
     }
     $this->id_cda_lot = "{$this->root}.{$docItem->_id}";
     $this->id_cda = "{$this->id_cda_lot}.{$this->version}";
     $confidentialite = "N";
     if ($docItem->private) {
         $confidentialite = "R";
     }
     $this->confidentialite = CCdaTools::loadEntryJV("CI-SIS_jdv_confidentialityCode.xml", $confidentialite);
     if ($docItem->type_doc) {
         $type = explode("^", $docItem->type_doc);
         $this->code = CCdaTools::loadEntryJV("CI-SIS_jdv_typeCode.xml", $type[1]);
     }
     //conformité HL7
     $this->templateId[] = $this->createTemplateID("2.16.840.1.113883.2.8.2.1", "HL7 France");
     //Conformité CI-SIS
     $this->templateId[] = $this->createTemplateID("1.2.250.1.213.1.1.1.1", "CI-SIS");
     //Confirmité IHE XSD-SD => contenu non structuré
     $this->templateId[] = $this->createTemplateID("1.3.6.1.4.1.19376.1.2.20", "IHE XDS-SD");
     $this->industry_code = CCdaTools::loadEntryJV("CI-SIS_jdv_practiceSettingCode.xml", "ETABLISSEMENT");
     $mediaType = "application/pdf";
     //Génération du PDF
     if ($docItem instanceof CFile) {
         $path = $docItem->_file_path;
         switch ($docItem->file_type) {
             case "image/tiff":
                 $mediaType = "image/tiff";
                 break;
             case "application/pdf":
                 $mediaType = $docItem->file_type;
                 $path = CCdaTools::generatePDFA($docItem->_file_path);
                 break;
             case "image/jpeg":
             case "image/jpg":
                 $mediaType = "image/jpeg";
                 break;
             case "application/rtf":
                 $mediaType = "text/rtf";
                 break;
             default:
                 $docItem->convertToPDF();
                 $file = $docItem->loadPDFconverted();
                 $path = CCdaTools::generatePDFA($file->_file_path);
         }
     } else {
         if ($msg = $docItem->makePDFpreview(1, 0)) {
             throw new CMbException($msg);
         }
         $file = $docItem->_ref_file;
         $path = CCdaTools::generatePDFA($file->_file_path);
     }
     $this->file = $path;
     $this->mediaType = $mediaType;
     $service["nullflavor"] = null;
     switch (get_class($object)) {
         case "CSejour":
             /** @var CSejour $object CSejour */
             $dp = $object->DP;
             $service["time_start"] = $object->entree;
             $service["time_stop"] = $object->sortie;
             $service["executant"] = $object->loadRefPraticien();
             if ($dp) {
                 $service["oid"] = "2.16.840.1.113883.6.3";
                 $service["code"] = $dp;
                 $service["type_code"] = "cim10";
             } else {
                 $service["nullflavor"] = "UNK";
             }
             break;
         case "COperation":
             /** @var COperation $object COperation */
             $no_acte = 0;
             foreach ($object->loadRefsActesCCAM() as $_acte_ccam) {
                 if ($_acte_ccam->code_activite === "4" || !$_acte_ccam->_check_coded || $no_acte >= 1) {
                     continue;
                 }
                 $service["time_start"] = $_acte_ccam->execution;
                 $service["time_stop"] = "";
                 $service["code"] = $_acte_ccam->code_acte;
                 $service["oid"] = "1.2.250.1.213.2.5";
                 $_acte_ccam->loadRefExecutant();
                 $service["executant"] = $_acte_ccam->_ref_executant;
                 $service["type_code"] = "ccam";
                 $no_acte++;
             }
             if ($no_acte === 0) {
                 $service["time_start"] = $object->debut_op;
                 $service["time_stop"] = $object->fin_op;
                 $service["executant"] = $object->loadRefPraticien();
                 $service["nullflavor"] = "UNK";
             }
             break;
         case "CConsultation":
             /** @var CConsultation $object CConsultation */
             $object->loadRefPlageConsult();
             $no_acte = 0;
             foreach ($object->loadRefsActesCCAM() as $_acte_ccam) {
                 if (!$_acte_ccam->_check_coded || $_acte_ccam->code_activite === "4" || $no_acte >= 1) {
                     continue;
                 }
                 $service["time_start"] = $_acte_ccam->execution;
                 $service["time_stop"] = "";
                 $service["code"] = $_acte_ccam->code_acte;
                 $service["oid"] = "1.2.250.1.213.2.5";
                 $_acte_ccam->loadRefExecutant();
                 $service["executant"] = $_acte_ccam->_ref_executant;
                 $service["type_code"] = "ccam";
                 $no_acte++;
             }
             if ($no_acte === 0) {
                 $service["time_start"] = $object->_datetime;
                 $service["time_stop"] = $object->_date_fin;
                 $service["executant"] = $object->loadRefPraticien();
                 $service["nullflavor"] = "UNK";
             }
             break;
         default:
     }
     $this->service_event = $service;
     if ($this->old_version) {
         $oid = CMbOID::getOIDFromClass($docItem, $this->receiver);
         $this->old_version = "{$oid}.{$this->old_id}.{$this->old_version}";
     }
 }
Esempio n. 27
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();
}
Esempio n. 28
0
 /**
  * Recording NPA
  *
  * @param String         $NPA    NPA
  * @param CSejour        $sejour Sejour
  * @param CInteropSender $sender Sender
  *
  * @return null|string
  */
 static function storeNPA($NPA, CSejour $sejour, CInteropSender $sender)
 {
     if (!$NPA) {
         return null;
     }
     // L'expéditeur gère les NPA
     $manage_npa = CMbArray::get($sender->_configs, "manage_npa");
     if (!$manage_npa) {
         return null;
     }
     //Récupération du tag pour les NPA
     $tag = CSejour::getTagNPA($sender->group_id);
     if (!$tag) {
         return null;
     }
     $idex_NPA = CIdSante400::getMatch("CSejour", $tag, null, $sejour->_id);
     $idex_NPA->object_id = $sejour->_id;
     $idex_NPA->last_update = CMbDT::dateTime();
     $idex_NPA->_eai_sender_guid = $sender->_guid;
     $idex_NPA->id400 = $NPA;
     return $idex_NPA->store();
 }
 /**
  * Handle event
  *
  * @param CHL7Acknowledgment $ack        Acknowledgement
  * @param CPatient           $newPatient Person
  * @param array              $data       Nodes data
  *
  * @return null|string
  */
 function handle(CHL7Acknowledgment $ack, CPatient $newPatient, $data)
 {
     // Traitement du message des erreurs
     $comment = $warning = "";
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $exchange_hl7v2->_ref_sender->loadConfigValues();
     $sender = $exchange_hl7v2->_ref_sender;
     foreach ($data["merge"] as $_data_merge) {
         $data = $_data_merge;
         $mbPatient = new CPatient();
         $mbPatientElimine = new CPatient();
         $patientPI = CValue::read($data['personIdentifiers'], "PI");
         $patientRI = CValue::read($data['personIdentifiers'], "RI");
         $patientEliminePI = CValue::read($data['personElimineIdentifiers'], "PI");
         $patientElimineRI = CValue::read($data['personElimineIdentifiers'], "RI");
         // Acquittement d'erreur : identifiants RI et PI non fournis
         if (!$patientRI && !$patientPI || !$patientElimineRI && !$patientEliminePI) {
             return $exchange_hl7v2->setAckAR($ack, "E100", null, $newPatient);
         }
         $idexPatient = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI);
         if ($mbPatient->load($patientRI)) {
             if ($idexPatient->object_id && $mbPatient->_id != $idexPatient->object_id) {
                 $comment = "L'identifiant source fait référence au patient : {$idexPatient->object_id}";
                 $comment .= " et l'identifiant cible au patient : {$mbPatient->_id}.";
                 return $exchange_hl7v2->setAckAR($ack, "E130", $comment, $newPatient);
             }
         }
         if (!$mbPatient->_id) {
             $mbPatient->load($idexPatient->object_id);
         }
         $idexPatientElimine = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientEliminePI);
         if ($mbPatientElimine->load($patientElimineRI)) {
             if ($idexPatientElimine->object_id && $mbPatientElimine->_id != $idexPatientElimine->object_id) {
                 $comment = "L'identifiant source fait référence au patient : {$idexPatientElimine->object_id}";
                 $comment .= "et l'identifiant cible au patient : {$mbPatientElimine->_id}.";
                 return $exchange_hl7v2->setAckAR($ack, "E131", $comment, $newPatient);
             }
         }
         if (!$mbPatientElimine->_id) {
             $mbPatientElimine->load($idexPatientElimine->object_id);
         }
         if (!$mbPatient->_id || !$mbPatientElimine->_id) {
             $comment = !$mbPatient->_id ? "Le patient {$mbPatient->_id} est inconnu dans Mediboard." : "Le patient {$mbPatientElimine->_id} est inconnu dans Mediboard.";
             return $exchange_hl7v2->setAckAR($ack, "E120", $comment, $newPatient);
         }
         // Passage en trash de l'IPP du patient a éliminer
         $newPatient->trashIPP($idexPatientElimine);
         if ($mbPatient->_id == $mbPatientElimine->_id) {
             return $exchange_hl7v2->setAckAA($ack, "I104", null, $newPatient);
         }
         $patientsElimine_array = array($mbPatientElimine);
         $first_patient_id = $mbPatient->_id;
         $checkMerge = $mbPatient->checkMerge($patientsElimine_array);
         // Erreur sur le check du merge
         if ($checkMerge) {
             $comment = "La fusion de ces deux patients n'est pas possible à cause des problèmes suivants : {$checkMerge}";
             return $exchange_hl7v2->setAckAR($ack, "E121", $comment, $newPatient);
         }
         $mbPatientElimine_id = $mbPatientElimine->_id;
         /** @todo mergePlainFields resets the _id */
         $mbPatient->_id = $first_patient_id;
         // Notifier les autres destinataires
         $mbPatient->_eai_sender_guid = $sender->_guid;
         $mbPatient->_merging = CMbArray::pluck($patientsElimine_array, "_id");
         if ($msg = $mbPatient->merge($patientsElimine_array)) {
             return $exchange_hl7v2->setAckAR($ack, "E103", $msg, $mbPatient);
         }
         $mbPatient->_mbPatientElimine_id = $mbPatientElimine_id;
         $comment = CEAIPatient::getComment($mbPatient, $mbPatientElimine);
     }
     return $exchange_hl7v2->setAckAA($ack, "I103", $comment, $mbPatient);
 }
 /**
  * Lookup an object already imported
  *
  * @param string $guid Guid of the object to lookup
  * @param string $tag  Tag of it's Idex
  *
  * @return CIdSante400
  */
 function lookupObject($guid, $tag = "migration")
 {
     list($class, ) = explode("-", $guid);
     $idex = CIdSante400::getMatch($class, $tag, $guid);
     return $idex;
 }