/**
 * 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);
}
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Labo
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$examen = new CExamenLabo();
$examen->load(CValue::get("examen_id"));
$patient = new CPatient();
$patient->load(CValue::get("patient_id"));
$item = new CPrescriptionLaboExamen();
$resultats = $item->loadResults($patient->_id, $examen->_id, 20);
// Création du graph
$graph = new CResultatsLaboGraph($patient, $examen, $resultats);
$graph->Stroke();
 function loadExamensWithoutObsolete()
 {
     $examenLabo = new CExamenLabo();
     $examenLabo->catalogue_labo_id = $this->_id;
     $examenLabo->obsolete = 0;
     $this->_ref_examens_labo = $examenLabo->loadMatchingList();
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Labo
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$listExams = array();
// Récuperation du mot recherché
$recherche = CValue::get("recherche");
// Chargements des analyses correspondantes
$exam = new CExamenLabo();
$limit = "30";
$where["libelle"] = "LIKE '%{$recherche}%' ";
$where["obsolete"] = " = '0'";
$listExams = $exam->loadList($where, null, $limit);
$countExams = $exam->countList($where);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("search", 1);
$smarty->assign("recherche", $recherche);
$smarty->assign("listExams", $listExams);
$smarty->assign("countExams", $countExams);
$smarty->assign("catalogue", new CCatalogueLabo());
$smarty->display("inc_vw_examens_catalogues.tpl");
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Labo
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$examen_labo_id = CValue::getOrSession("examen_labo_id");
// Chargement de l'examen demandé
$examen = new CExamenLabo();
// Chargement du catalogue demandé
if (CValue::get("catalogue_labo_id")) {
    $examen_labo_id = null;
    CValue::setSession("examen_labo_id");
}
if ($examen_labo_id) {
    $examen->load($examen_labo_id);
    $examen->loadRefs();
    $examen->getSiblings();
    $examen->getRootCatalogue();
    foreach ($examen->_ref_siblings as &$_sibling) {
        $_sibling->loadClassification();
    }
    $examen->loadClassification();
    $catalogue =& $examen->_ref_catalogue_labo;
} else {
示例#6
0
/**
 * 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);
        }
    }
}
 /**
  * load results items with given patient and exam
  */
 function loadResults($patient_id, $examen_labo_id, $limit = 10)
 {
     $examen = new CExamenLabo();
     $examen->load($examen_labo_id);
     $order = "date DESC";
     $prescription = new CPrescriptionLabo();
     $prescription->patient_id = $patient_id;
     $prescriptions = $prescription->loadMatchingList($order);
     // Load items for each prescription to preserve prescription date ordering
     $items = array();
     $item = new CPrescriptionLaboExamen();
     foreach ($prescriptions as $_prescription) {
         $item->prescription_labo_id = $_prescription->_id;
         $item->examen_labo_id = $examen_labo_id;
         foreach ($item->loadMatchingList($order) as $_item) {
             $items[$_item->_id] = $_item;
         }
     }
     foreach ($items as &$item) {
         $item->_ref_prescription_labo =& $prescriptions[$item->prescription_labo_id];
         $item->_ref_examen_labo =& $examen;
     }
     return $items;
 }