$sejour_ids = $sejour->loadIds($where); // Identifiants de catégorie de prescriptions disponibles $function = $mediuser->loadRefFunction(); $executants = $function->loadBackRefs("executants_prescription"); $category_ids = CMbArray::pluck($executants, "category_prescription_id"); // Recherche des lignes de prescriptions executables $line = new CPrescriptionLineElement(); $join = array(); $where = array(); $join["element_prescription"] = "element_prescription.element_prescription_id = prescription_line_element.element_prescription_id"; $where["element_prescription.category_prescription_id"] = $ds->prepareIn($category_ids); $join["prescription"] = "prescription.prescription_id = prescription_line_element.prescription_id"; $where["prescription.type"] = "= 'sejour'"; $where["prescription.object_class"] = "= 'CSejour'"; $where["prescription.object_id"] = $ds->prepareIn($sejour_ids); $line_ids = $line->loadIds($where, null, null, null, $join); // Prescriptions exécutables $query = new CRequest(); $query->addSelect("DISTINCT prescription_id"); $query->addTable("prescription_line_element"); $query->addWhereClause("prescription_line_element_id", $ds->prepareIn($line_ids)); $prescription_ids = $ds->loadColumn($query->makeSelect()); // Séjours planifiables $query = new CRequest(); $query->addSelect("DISTINCT object_id"); $query->addTable("prescription"); $query->addWhereClause("prescription_id", $ds->prepareIn($prescription_ids)); $sejour_ids = $ds->loadColumn($query->makeSelect()); $where = array(); $where["sejour_id"] = $ds->prepareIn($sejour_ids); $join = array();