CCanDo::checkRead();
$operation_id = CValue::get("operation_id");
$interv = new COperation();
$interv->load($operation_id);
$interv->loadRefSejour()->loadRefPatient()->loadRefLatestConstantes();
$interv->loadRefPlageOp();
$interv->_ref_sejour->_ref_patient->loadRefDossierMedical();
$consult_anesth = $interv->loadRefsConsultAnesth();
$group = CGroups::loadCurrent();
$pack = $interv->loadRefGraphPack();
list($graphs, $yaxes_count, $time_min, $time_max, $time_debut_op_iso, $time_fin_op_iso) = CObservationResultSet::buildGraphs($interv, $pack->_id);
$time_debut_op = CMbDate::toUTCTimestamp($time_debut_op_iso);
$time_fin_op = CMbDate::toUTCTimestamp($time_fin_op_iso);
$evenements = CObservationResultSet::buildEventsGrid($interv, $time_debut_op_iso, $time_fin_op_iso, $time_min, $time_max);
$now = 100 * (CMbDate::toUTCTimestamp(CMbDT::dateTime()) - $time_min) / ($time_max - $time_min);
$graph_packs = CSupervisionGraphPack::getAllFor($group);
$concentrators = null;
if (CModule::getActive("patientMonitoring")) {
    $concentrator = new CMonitoringConcentrator();
    $concentrators = $concentrator->loadList();
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("pack", $pack);
$smarty->assign("interv", $interv);
$smarty->assign("graphs", $graphs);
$smarty->assign("evenements", $evenements);
$smarty->assign("time_debut_op", $time_debut_op);
$smarty->assign("time_fin_op", $time_fin_op);
$smarty->assign("yaxes_count", $yaxes_count);
$smarty->assign("consult_anesth", $consult_anesth);
$result_set_id = CValue::get("result_set_id");
$result_id = CValue::get("result_id");
$result_set = new CObservationResultSet();
if ($result_set_id) {
    $result_set->load($result_set_id);
    $object = $result_set->loadRefContext();
} else {
    /** @var COperation|CSejour $object */
    $object = CStoredObject::loadFromGuid($object_guid);
    $result_set->context_class = $object->_class;
    $result_set->context_id = $object->_id;
    $result_set->datetime = CMbDT::dateTime();
    $result_set->patient_id = $object->loadRelPatient()->_id;
}
list($results) = CObservationResultSet::getResultsFor($object);
$pack = new CSupervisionGraphPack();
$pack->load($pack_id);
$links = $pack->loadRefsGraphLinks();
foreach ($links as $_link) {
    $_graph = $_link->loadRefGraph();
    if ($_graph instanceof CSupervisionGraph) {
        $axes = $_graph->loadRefsAxes();
        foreach ($axes as $_axis) {
            $series = $_axis->loadRefsSeries();
            $_axis->loadRefsLabels();
            foreach ($series as $_serie) {
                $_result = new CObservationResult();
                $_result->value_type_id = $_serie->value_type_id;
                $_result->unit_id = $_serie->value_unit_id ? $_serie->value_unit_id : null;
                if ($result_set->_id) {
                    $_result->observation_result_set_id = $result_set->_id;
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$supervision_graph_pack_id = CValue::get("supervision_graph_pack_id");
$pack = new CSupervisionGraphPack();
$pack->load($supervision_graph_pack_id);
$pack->loadRefsNotes();
$smarty = new CSmartyDP();
$smarty->assign("pack", $pack);
$smarty->display("inc_edit_supervision_graph_pack.tpl");
 /**
  * Get chronological list
  *
  * @param COperation $interv  Intervention
  * @param int        $pack_id Pack ID
  *
  * @return CObservationResultSet[]
  */
 static function getChronological(COperation $interv, $pack_id)
 {
     $result_set = new self();
     $where = array("observation_result_set.context_class" => "= '{$interv->_class}'", "observation_result_set.context_id" => "= '{$interv->_id}'");
     $order = array("observation_result_set.datetime", "observation_result_set.observation_result_set_id");
     $pack = new CSupervisionGraphPack();
     $pack->load($pack_id);
     $graph_links = $pack->loadRefsGraphLinks();
     $list_by_datetime = array();
     $graphs = self::massLoadFwdRef($graph_links, "graph_id");
     /** @var self[] $list */
     $list = $result_set->loadList($where, $order);
     $grid = array();
     // Build the data structure
     $count = 0;
     $labels = array();
     foreach ($graphs as $_graph) {
         if ($_graph instanceof CSupervisionGraph) {
             $_axes = $_graph->loadRefsAxes();
             self::massCountBackRefs($_axes, "series");
             foreach ($_axes as $_axis) {
                 $_series = $_axis->loadRefsSeries();
                 $count += count($_series);
                 foreach ($_series as $_serie) {
                     $labels[] = $_serie;
                 }
             }
         } elseif ($_graph instanceof CSupervisionTimedData || $_graph instanceof CSupervisionTimedPicture) {
             $count++;
             $labels[] = $_graph;
         }
     }
     self::massCountBackRefs($list, "observation_results");
     // Fill the data structure
     foreach ($list as $_set) {
         $results = $_set->loadRefsResults();
         self::massLoadFwdRef($results, "file_id");
         foreach ($results as $_result) {
             $_result->loadRefFile();
             $_result->loadRefValueUnit();
         }
         $p = 0;
         $_row = array_fill(0, $count, null);
         foreach ($graphs as $_graph) {
             if ($_graph instanceof CSupervisionGraph) {
                 $_axes = $_graph->_ref_axes;
                 foreach ($_axes as $_axis) {
                     $_series = $_axis->_ref_series;
                     foreach ($_series as $_serie) {
                         foreach ($results as $_result) {
                             if ($_result->value_type_id == $_serie->value_type_id && $_result->unit_id == $_serie->value_unit_id) {
                                 $_row[$p] = $_result;
                             }
                         }
                         $p++;
                     }
                 }
             } elseif ($_graph instanceof CSupervisionTimedData || $_graph instanceof CSupervisionTimedPicture) {
                 foreach ($results as $_result) {
                     if ($_result->value_type_id == $_graph->value_type_id && $_result->unit_id == null) {
                         $_row[$p] = $_result;
                     }
                 }
                 $p++;
             }
         }
         $grid[$_set->datetime] = $_row;
         $list_by_datetime[$_set->datetime] = $_set;
     }
     return array($list, $grid, $graphs, $labels, $list_by_datetime);
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$group = CGroups::loadCurrent();
$graphs = CSupervisionGraph::getAllFor($group);
$timed_data = CSupervisionTimedData::getAllFor($group);
$timed_pictures = CSupervisionTimedPicture::getAllFor($group);
$instant_data = CSupervisionInstantData::getAllFor($group);
$packs = CSupervisionGraphPack::getAllFor($group, true);
foreach ($graphs as $_graph) {
    $_axes = $_graph->loadRefsAxes();
    foreach ($_axes as $_axis) {
        $_axis->loadBackRefs("series");
    }
}
$smarty = new CSmartyDP();
$smarty->assign("graphs", $graphs);
$smarty->assign("packs", $packs);
$smarty->assign("timed_data", $timed_data);
$smarty->assign("timed_pictures", $timed_pictures);
$smarty->assign("instant_data", $instant_data);
$smarty->display("inc_list_supervision_graph.tpl");
<?php

/**
 * $Id: ajax_list_supervision_graph_to_pack.php 19219 2013-05-21 12:26:07Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19219 $
 */
$supervision_graph_pack_id = CValue::get("supervision_graph_pack_id");
$pack = new CSupervisionGraphPack();
$pack->load($supervision_graph_pack_id);
$links = $pack->loadRefsGraphLinks();
foreach ($links as $_link) {
    $_link->loadRefGraph();
}
$smarty = new CSmartyDP();
$smarty->assign("pack", $pack);
$smarty->display("inc_list_supervision_graph_to_pack.tpl");