// Input //////////////////
 $where = array("product.product_id" => "= '{$product->_id}'", "product_order_item_reception.date" => "BETWEEN '{$date}' AND '{$to}'");
 $ljoin = array("product_order_item" => "product_order_item.order_item_id = product_order_item_reception.order_item_id", "product_reference" => "product_reference.reference_id = product_order_item.reference_id", "product" => "product.product_id = product_reference.product_id");
 $lot = new CProductOrderItemReception();
 /** @var CProductOrderItemReception[] $lots */
 $lots = $lot->loadList($where, null, null, null, $ljoin);
 $total = 0;
 foreach ($lots as $_lot) {
     $total += $_lot->quantity;
 }
 $max = max($max, $total);
 $series[0]["data"][] = array(count($series[0]["data"]) * 2 - 0.6, $total);
 // Hack pour les etablissements qui ont un service "Périmés"
 $where_services = array("nom" => "= 'Périmés'");
 $services_expired = new CService();
 $services_expired_ids = $services_expired->loadIds($where_services);
 // Output //////////////////
 $where = array("product_delivery.stock_class" => "= 'CProductStockGroup'", "product_delivery.stock_id" => "= '{$product->_ref_stock_group->_id}'", "product_delivery_trace.date_delivery" => "BETWEEN '{$date}' AND '{$to}'");
 if (count($services_expired_ids)) {
     $where[100] = "(product_delivery.type != 'expired' OR product_delivery.type IS NULL)\r\n                   AND product_delivery.service_id NOT IN (" . implode(',', $services_expired_ids) . ")";
 } else {
     $where[100] = "product_delivery.type != 'expired' OR product_delivery.type IS NULL";
 }
 $ljoin = array("product_delivery" => "product_delivery.delivery_id = product_delivery_trace.delivery_id");
 $trace = new CProductDeliveryTrace();
 /** @var CProductDeliveryTrace $traces */
 $traces = $trace->loadList($where, null, null, null, $ljoin);
 $total = 0;
 foreach ($traces as $_trace) {
     $total += $_trace->quantity;
 }
 /**
  * Get others PV1 QPD element
  *
  * @param DOMNode $node QPD element
  *
  * @return array
  */
 function getOtherRequestSejour(DOMNode $node)
 {
     // Recherche du service
     $service = new CService();
     $ds = $service->getDS();
     $where_returns = array();
     if ($service_name = $this->getDemographicsFields($node, "CSejour", "3.1")) {
         $service_name = preg_replace("/\\*+/", "%", $service_name);
         $where["code"] = $ds->prepare("LIKE %", $service_name);
         $ids = array_unique($service->loadIds($where, null, 100));
         // FIXME prendre les affectations en compte
         $where_returns["sejour.service_id"] = $ds->prepareIn($ids);
     }
     // Praticien
     if (($attending_doctor_name = $this->getDemographicsFields($node, "CSejour", "7.2.1")) || ($attending_doctor_name = $this->getDemographicsFields($node, "CSejour", "17.2.1"))) {
         $user = new CUser();
         $attending_doctor_name = preg_replace("/\\*+/", "%", $attending_doctor_name);
         $where["user_last_name"] = $ds->prepare("LIKE %", $attending_doctor_name);
         $ids = array_unique($user->loadIds($where, null, 100));
         $where_returns["sejour.praticien_id"] = $ds->prepareIn($ids);
     }
     // Médecin adressant
     if ($referring_doctor_name = $this->getDemographicsFields($node, "CSejour", "8.2.1")) {
         $medecin = new CMedecin();
         $referring_doctor_name = preg_replace("/\\*+/", "%", $referring_doctor_name);
         $where["nom"] = $ds->prepare("LIKE %", $referring_doctor_name);
         $ids = array_unique($medecin->loadIds($where, null, 100));
         $where_returns["sejour.adresse_par_prat_id"] = $ds->prepareIn($ids);
     }
     return $where_returns;
 }