protected function getAllDisordersForSection(OphCoCvi_ClinicalInfo_Disorder_Section $section)
{
if (!$this->disorders_by_section) {
$this->disorders_by_section = array();
$seen = array();
// assume here that the assignment attributes have been set from the default controller.
if ($this->isModelDirty()) {
$cvi_disorders = $this->getAllDisordersFromAssignments();
} else {
$cvi_disorders = $this->cvi_disorders;
}
foreach ($cvi_disorders as $disorder) {
if (in_array($disorder->id, $seen)) {
continue;
}
if (!array_key_exists($disorder->section_id, $this->disorders_by_section)) {
$this->disorders_by_section[$disorder->section_id] = array($disorder);
} else {
$this->disorders_by_section[$disorder->section_id][] = $disorder;
}
$seen[] = $disorder->id;
}
}
if (!array_key_exists($section->id, $this->disorders_by_section)) {
return array();
}
return $this->disorders_by_section[$section->id];
}