* @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$context_class = CValue::post("context_class");
$context_id = CValue::post("context_id");
$patient_id = CValue::post("patient_id");
$datetime_start = CValue::post("datetime_start");
$datetime_end = CValue::post("datetime_end");
$period = CValue::post("period", 120);
// in seconds
$graph = new CSupervisionGraph();
/** @var CSupervisionGraph[] $graphs */
$graphs = $graph->loadList(array("disabled" => "= '0'"));
$n = 500;
$datetime = $datetime_start;
$times = array();
while (--$n > 0 && $datetime < $datetime_end) {
    $observation_result_set = new CObservationResultSet();
    $observation_result_set->context_class = $context_class;
    $observation_result_set->context_id = $context_id;
    $observation_result_set->patient_id = $patient_id;
    $observation_result_set->datetime = $datetime;
    $observation_result_set->loadMatchingObject();
    $observation_result_set->store();
    $times[$datetime] = $observation_result_set;
    $datetime = CMbDT::dateTime("+{$period} SECONDS", $datetime);
}
foreach ($graphs as $_graph) {