OEModule\OphCiExamination\components\OphCiExamination_API::getMostRecentVAForPatient PHP Method

getMostRecentVAForPatient() public method

To get the visual acuity from the element based on the all episodes for the patient
public getMostRecentVAForPatient ( Patient $patient, $side, $type, $element ) : null
$patient Patient
$side
$type
$element
return null
    public function getMostRecentVAForPatient(\Patient $patient, $side, $type, $element)
    {
        if (!in_array($type, array(static::$AIDED_VA_TYPE, static::$UNAIDED_VA_TYPE))) {
            throw new \Exception("Invalid type for VA {$type}");
        }
        $checkFunc = 'has' . ucfirst($side);
        if (!$element->{$checkFunc}()) {
            return null;
        }
        $method_type = $type == static::$AIDED_VA_TYPE ? models\OphCiExamination_VisualAcuity_Method::$AIDED_FLAG_TYPE : models\OphCiExamination_VisualAcuity_Method::$UNAIDED_FLAG_TYPE;
        $methods = models\OphCiExamination_VisualAcuity_Method::model()->findAll('type=?', array($method_type));
        $best_reading = $element->getBestReadingByMethods($side, $methods);
        return $best_reading;
    }
OphCiExamination_API