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; }
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; }
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(); } } $do = new CDoObjectAddEdit("CPrescriptionLabo"); $do->doIt();
/** * 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; }
/** * Search and map a user inside the LDAP * * @param CUser $user * @param CSourceLDAP $source_ldap * @param resource $ldapconn * @param string $person [optional] * @param string $filter [optional] * @param boolean $force_create [optional] * * @return CUser */ static function searchAndMap(CUser $user, CSourceLDAP $source_ldap, $ldapconn, $person = null, $filter = null, $force_create = false) { if (!$person) { $person = $user->user_username; } $person = utf8_encode($person); if (!$filter) { $filter = "(samaccountname={$person})"; } $results = $source_ldap->ldap_search($ldapconn, $filter); if (!$results || $results["count"] == 0) { $user->_bound = false; $user->_count_ldap = 0; return $user; } if ($results["count"] > 1) { throw new CMbException("CSourceLDAP_too-many-results"); } $results = $results[0]; $idex = new CIdSante400(); $idex->tag = CAppUI::conf("admin LDAP ldap_tag"); $idex->object_class = "CUser"; $idex->id400 = self::getObjectGUID($results); $idex->loadMatchingObject(); // On sauvegarde le password renseigné $user_password = $user->user_password; $_user_password = $user->_user_password; // objectguid retrouvé on charge le user if ($idex->_id) { $user = new CUser(); $user->load($idex->object_id); } else { // objectguid non retrouvé on associe à l'user courant l'objectguid // Si on est pas en mode création on le recherche if (!$force_create) { // Suppression du password pour le loadMatchingObject $user->user_password = null; $user->_user_password = null; $user->loadMatchingObject(); if (!$user->_id) { throw new CMbException("Auth-failed-user-unknown"); } } } $user->_bound = true; $user = self::mapTo($user, $results); // Save Mediuser variables $actif = $user->_user_actif; $deb_activite = $user->_user_deb_activite; $fin_activite = $user->_user_fin_activite; // Restore User password variables $user->user_password = $user_password; $user->_user_password = $_user_password; if (!$user->user_type) { $user->user_type = 0; } // Pas de profil $user->template = 0; $user->user_login_errors = 0; $user->repair(); $msg = $user->store(); if ($msg) { throw new CMbException($msg); } if (!$force_create && !$user->_ref_mediuser->actif || $force_create && !$actif) { throw new CMbException("Auth-failed-user-deactivated"); } // Restore Mediuser variables $user->_user_actif = $actif; $user->_user_deb_activite = $deb_activite; $user->_user_fin_activite = $fin_activite; $user->_count_ldap = 1; if (!$idex->_id) { $idex->object_id = $user->_id; $idex->last_update = CMbDT::dateTime(); if ($msg = $idex->store()) { throw new CMbException($msg); } } return $user; }
<?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é");
$sejour->loadRefsAffectations(); $sejour->loadNDA(); $sejour->loadLogs(); $sejour->loadRefsConsultations(); $sejour->loadRefsConsultAnesth(); $sejour->_ref_last_log->type = "create"; $dest_hprim = new CDestinataireHprim(); $dest_hprim->message = "patients"; $dest_hprim->loadMatchingObject(); if (!$sejour->_NDA) { $nda = new CIdSante400(); //Paramétrage de l'id 400 $nda->object_class = "CSejour"; $nda->object_id = $nda->_id; $nda->tag = $dest_hprim->_tag_sejour; $nda->loadMatchingObject(); $sejour->_NDA = $nda->id400; } if (CAppUI::conf("sip send_sej_pa") && $sejour->_etat != "preadmission") { continue; } if (CAppUI::conf("sip sej_no_numdos") && $sejour->_NDA && $sejour->_NDA != "-") { continue; } $domEvenement = new CHPrimXMLVenuePatient(); $domEvenement->emetteur = CAppUI::conf('mb_id'); $domEvenement->destinataire = $dest_hprim->nom; $domEvenement->group_id = $dest_hprim->group_id; $messageEvtPatient = $domEvenement->generateTypeEvenement($sejour); $doc_valid = $domEvenement->schemaValidate(); if (!$doc_valid) {
* @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $idex = new CIdSante400(); $idex->object_class = "CPatient"; $idex->tag = CAppUI::conf("dPpatients CPatient tag_conflict_ipp") . CAppUI::conf("dPpatients CPatient tag_ipp"); /** @var CIdSante400[] $ipp_conflicts */ $ipp_conflicts = $idex->loadMatchingList(); $conflicts = array(); foreach ($ipp_conflicts as $_conflict) { $patient_conflict = new CPatient(); $patient_conflict->load($_conflict->object_id); $patient_conflict->loadIPP(); $IPP = new CIdSante400(); $IPP->object_class = "CPatient"; $IPP->tag = CAppUI::conf("dPpatients CPatient tag_ipp"); $IPP->id400 = $_conflict->id400; $IPP->loadMatchingObject(); $patient = new CPatient(); $patient->load($IPP->object_id); $patient->loadIPP(); $conflicts[] = array("patient" => $patient, "patient_conflict" => $patient_conflict); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("conflicts", $conflicts); $smarty->display("inc_ipp_conflicts.tpl");
/** * Handle event * * @param CHL7Acknowledgment $ack Acknowledgement * @param CPatient $patient Person * @param array $data Nodes data * * @return null|string */ function handle(CHL7Acknowledgment $ack, CPatient $patient, $data) { // Traitement du message des erreurs $comment = ""; $object = null; $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $exchange_hl7v2->_ref_sender->loadConfigValues(); $sender = $this->_ref_sender = $exchange_hl7v2->_ref_sender; // Patient $patientPI = CValue::read($data['personIdentifiers'], "PI"); if (!$patientPI) { return $exchange_hl7v2->setAckAR($ack, "E007", null, $patient); } $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI); // Patient non retrouvé par son IPP if (!$IPP->_id) { return $exchange_hl7v2->setAckAR($ack, "E105", null, $patient); } $patient->load($IPP->object_id); $sejour = null; // Sejour $venueAN = CValue::read($data["personIdentifiers"], "AN"); if (!$venueAN) { $venueAN = CValue::read($data["admitIdentifiers"], "AN"); } if ($venueAN) { $NDA = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $venueAN); // Séjour non retrouvé par son NDA if (!$NDA->_id) { return $exchange_hl7v2->setAckAR($ack, "E205", null, $patient); } /** @var CSejour $sejour */ $sejour = $NDA->loadTargetObject(); if (!$sejour->_id) { return $exchange_hl7v2->setAckAR($ack, "E220", null, $patient); } if ($sejour->patient_id !== $patient->_id) { return $exchange_hl7v2->setAckAR($ack, "E606", null, $patient); } } // Pas d'observations $first_result = reset($data["observations"]); if (!$first_result) { return $exchange_hl7v2->setAckAR($ack, "E225", null, $patient); } // Recherche par date $observation_dt = $this->getOBRObservationDateTime($first_result["OBR"]); if (!$sejour) { $sejours = $patient->getCurrSejour($observation_dt); //FIXME ignorer les annulés $sejour = reset($sejours); if (!$sejour || !$sejour->_id) { return $exchange_hl7v2->setAckAR($ack, "E220", null, $patient); } } // Récupération des observations foreach ($data["observations"] as $_observation) { // Récupération de la date du relevé $observation_dt = $this->getOBRObservationDateTime($_observation["OBR"]); $name = $this->getOBRServiceIdentifier($_observation["OBR"]); // OBR identity identifier $OBR_identity_identifier = null; $handle_OBR_identity_identifier = $sender->_configs["handle_OBR_identity_identifier"]; if ($handle_OBR_identity_identifier) { $OBR_identity_identifier = $this->queryTextNode($handle_OBR_identity_identifier, $_observation["OBR"]); } foreach ($_observation["OBX"] as $key => $_OBX) { $status = $this->getObservationResultStatus($_OBX); if ($status === "X") { continue; } // OBX.2 : Value type $value_type = $this->getOBXValueType($_OBX); $date = $observation_dt ? $observation_dt : $this->getOBXObservationDateTime($_OBX); $praticien_id = $this->getObservationAuthor($_OBX); // Recherche de l'objet avec la date correspondante fourni dans l'observation $object = $this->getObjectWithDate($date, $patient, $praticien_id, $sejour); if (!$object || !$object->_id) { return $exchange_hl7v2->setAckAR($ack, "E301", null, $patient); } $name = $name . $key; switch ($value_type) { // Reference Pointer to External Report case "RP": if (!$this->getReferencePointerToExternalReport($_OBX, $object, $name)) { return $exchange_hl7v2->setAckAR($ack, $this->codes, null, $object); } break; // Encapsulated Data // Encapsulated Data case "ED": if (!$this->getEncapsulatedData($_OBX, $object, $name)) { return $exchange_hl7v2->setAckAR($ack, $this->codes, null, $object); } break; // Pulse Generator and Lead Observation Results // Pulse Generator and Lead Observation Results case "ST": case "CWE": case "DTM": case "NM": case "SN": if (!$this->getPulseGeneratorAndLeadObservationResults($_OBX, $patient, $object, $observation_dt)) { return $exchange_hl7v2->setAckAR($ack, $this->codes, null, $object); } break; // Not supported // Not supported default: return $exchange_hl7v2->setAckAR($ack, "E302", null, $object); } // On store l'idex de l'identifiant du système tiers $idex = new CIdSante400(); $idex->object_class = $object->_class; $idex->object_id = $object->_id; $idex->tag = "OBR_{$sender->_tag_hl7}"; $idex->id400 = $OBR_identity_identifier; $idex->loadMatchingObject(); $idex->store(); } } return $exchange_hl7v2->setAckCA($ack, $this->codes, $comment, $object); }
/** * Store the external ID of the given object * * @param CMbObject $object The MB to store the external ID of * @param string $db_id The Import ID to store on the MB Object * * @return string The external ID store error message */ function storeIdExt(CMbObject $object, $db_id) { $id_ext = new CIdSante400(); $id_ext->setObject($object); $id_ext->tag = $this->getImportTag(); $id_ext->id400 = $db_id; $id_ext->escapeValues(); $id_ext->loadMatchingObject(); $id_ext->last_update = CMbDT::dateTime(); $id_ext->unescapeValues(); return $id_ext->store(); }
function getIdExterne() { $idExterne = new CIdSante400(); // Chargement de l'id externe de la prescription (tag: Imeds) $idExterne->loadLatestFor($this, "iMeds"); if (!$idExterne->_id) { // Afactoriser : assez complexe (concatenation du code 4 praticien et du code 4 prescription) $tagCatalogue = CAppUI::conf('dPlabo CCatalogueLabo remote_name'); $this->loadRefsFwd(); $prat =& $this->_ref_praticien; $tagCode4 = "labo code4"; $idSantePratCode4 = new CIdSante400(); $idSantePratCode4->loadLatestFor($prat, $tagCode4); $idPresc = new CIdSante400(); $idPresc->tag = "{$tagCatalogue} Prat:" . str_pad($idSantePratCode4->id400, 4, '0', STR_PAD_LEFT); // tag LABO Prat: 0017 $idPresc->object_class = "CPrescriptionLabo"; $idPresc->loadMatchingObject("id400 DESC"); $numprovisoire = str_pad($idSantePratCode4->id400, 4, '0', STR_PAD_LEFT) . str_pad($idPresc->id400, 4, '0', STR_PAD_LEFT); // Envoi à la source créée 'get_id_prescriptionlabo' (SOAP) $exchange_source = CExchangeSource::get("get_id_prescriptionlabo", "soap"); $exchange_source->setData(array("NumMedi" => $numprovisoire, "pwd" => $exchange_source->password)); $exchange_source->send("NDOSLAB"); $idExterne->tag = "iMeds"; $idExterne->object_class = "CPrescriptionLabo"; $idExterne->object_id = $this->_id; $idExterne->id400 = $exchange_source->getACQ()->NDOSLABResult; $idExterne->last_update = CMbDT::dateTime(); $idExterne->store(); } return $idExterne; }
/** * Packs import */ function importPacks($packs) { global $m, $remote_name; // Chargement des identifiants externes des packs $idPackExamen = new CIdSante400(); $idPackExamen->tag = $remote_name; $idPackExamen->object_class = "CPackExamensLabo"; $idPackExamens = $idPackExamen->loadMatchingList(); // Parcours des identifiants externes des Packs d'examens foreach ($idPackExamens as $_id_pack_examen) { $packExamen = new CPackExamensLabo(); $packExamen->load($_id_pack_examen->object_id); // Chargement des items de packs $packExamen->loadRefsItemExamenLabo(); // On vide chaque pack foreach ($packExamen->_ref_items_examen_labo as $_packItemExamen) { // Chargement de l'examen labo pour obtenir l'identifiant necessaire pour supprime l'id externe $_packItemExamen->loadRefExamen(); // Suppression de l'id400 du packItem $_id_pack_examen = new CIdSante400(); $_id_pack_examen->tag = $remote_name; $_id_pack_examen->object_class = $_packItemExamen->_class; $_id_pack_examen->object_id = $_packItemExamen->_id; $_id_pack_examen->loadMatchingObject(); if ($_id_pack_examen->_id) { $_id_pack_examen->delete(); } // Suppression du pack item $_packItemExamen->delete(); } if ($packExamen->_id) { $packExamen->obsolete = 1; $packExamen->store(); } } // Nombre de packs et d'analyses $nb["packs"] = 0; $nb["analysesOK"] = 0; $nb["analysesKO"] = 0; // Liste des analyses nono trouvees $erreurs = array(); // On crée chaque pack ainsi qu'un id400 associé foreach ($packs->bilan as $_pack) { $pack = new CPackExamensLabo(); $pack->function_id = ""; $pack->libelle = utf8_decode((string) $_pack->libelle); $pack->code = (int) $_pack->code; // Sauvegarde du pack $idPack = new CIdSante400(); // tag des id externe des packs => nom du laboatoire ==> LABO $idPack->tag = $remote_name; $idPack->id400 = (int) $_pack->code; $pack->obsolete = 0; $idPack->bindObject($pack); // On crée les analyses correspondantes foreach ($_pack->analyses->cana as $_analyse) { // Creation de l'analyse $analyse = new CPackItemExamenLabo(); // Chargement de l'analyse $examLabo = new CExamenLabo(); $whereExam = array(); $whereExam['identifiant'] = (string) " = '{$_analyse}'"; $examLabo->loadObject($whereExam); if ($examLabo->_id) { $analyse->pack_examens_labo_id = $pack->_id; $analyse->examen_labo_id = $examLabo->examen_labo_id; // Sauvegarde de l'analyse et de son id400 $idExamen = new CIdSante400(); $idExamen->tag = $remote_name; $idExamen->id400 = (string) $_analyse; $idExamen->bindObject($analyse); $nb["analysesOK"]++; } else { $erreurs[][(string) $_pack->libelle] = (string) $_analyse; $nb["analysesKO"]++; } } $nb["packs"]++; } // Recapitulatif des importations CAppUI::stepAjax("Packs Importés: " . $nb["packs"], UI_MSG_OK); CAppUI::stepAjax("Analyses Importées: " . $nb["analysesOK"], UI_MSG_OK); CAppUI::stepAjax("Analyses non importées: " . $nb["analysesKO"], UI_MSG_WARNING); foreach ($erreurs as $erreur) { foreach ($erreur as $_key => $_erreur) { CAppUI::stepAjax("Analyse non trouvée: " . $_erreur . " dans le pack " . utf8_decode($_key), UI_MSG_WARNING); } } }
if ($d1->_is_master_ipp || $d2->_is_master_ipp) { $and .= "AND id1.object_class = 'CPatient' \n AND id2.object_class = 'CPatient'"; } if ($d1->_is_master_nda || $d2->_is_master_nda) { $and .= "AND id1.object_class = 'CSejour' \n AND id2.object_class = 'CSejour'"; } $intersect_id400s = $ds->loadList("SELECT id1.id400\n FROM id_sante400 AS id1 \n LEFT JOIN id_sante400 AS id2 ON id2.id400 = id1.id400 \n AND id2.object_class = id1.object_class\n WHERE id1.tag = '{$d1->tag}'\n AND id2.tag = '{$d2->tag}'\n {$and}"); $intersect_id400s = CMbArray::pluck($intersect_id400s, "id400"); if (!$intersect_id400s) { $intersect_id400s = array(); } $intersect = array(); foreach ($intersect_id400s as $_id400) { $idex_d1 = new CIdSante400(); $idex_d1->tag = "{$d1->tag}"; $idex_d1->id400 = $_id400; $idex_d1->loadMatchingObject(); $idex_d1->loadTargetObject(); $idex_d2 = new CIdSante400(); $idex_d2->tag = "{$d2->tag}"; $idex_d2->id400 = $_id400; $idex_d2->loadMatchingObject(); $idex_d2->loadTargetObject(); $intersect[$_id400] = array($idex_d1, $idex_d2); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("d1_id", $d1_id); $smarty->assign("d2_id", $d2_id); $smarty->assign("intersect", $intersect); $smarty->display("inc_resolve_conflicts.tpl");
/** * store the idex * * @param CPatient|CSejour $object patient or sejour * @param String[] $identifier identifiers * @param String $tag tag * * @return null|String */ function storeIdex($object, $identifier, $tag) { $idex = new CIdSante400(); $idex->tag = "{$tag}"; $idex->id400 = "{$identifier}"; $idex->setObject($object); $idex->loadMatchingObject(); if ($msg = $idex->store()) { return $msg; } return null; }
/** * Charge le séjour depuis son NDA * * @param string $nda NDA du séjour * * @return void */ function loadFromNDA($nda) { // Aucune configuration de numéro de dossier if (null == ($tag_NDA = $this->getTagNDA())) { return; } $idDossier = new CIdSante400(); $idDossier->id400 = $nda; $idDossier->tag = $tag_NDA; $idDossier->object_class = $this->_class; $idDossier->loadMatchingObject(); if ($idDossier->_id) { $this->load($idDossier->object_id); $this->_NDA = $idDossier->id400; } }