OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity::getBestReadingByMethods PHP Method

getBestReadingByMethods() public method

Get the best reading based on the type
public getBestReadingByMethods ( string $side, $methods )
$side string
    public function getBestReadingByMethods($side, $methods)
    {
        $best = null;
        foreach ($methods as $method) {
            foreach ($this->{$side . '_readings'} as $reading) {
                if ($reading->method->id == $method->id) {
                    if (!$best || $reading->value >= $best->value) {
                        $best = $reading;
                    }
                }
            }
        }
        if ($best) {
            return $best->convertTo($best->value);
        }
        return $best;
    }