OEModule\PASAPI\resources\Patient::mapPractice PHP Method

mapPractice() private method

Handle mapping of the resource PracticeCode to the Patient model.
private mapPractice ( Patient $patient )
$patient Patient
    private function mapPractice(\Patient $patient)
    {
        if (property_exists($this, 'PracticeCode')) {
            if ($code = $this->getAssignedProperty('PracticeCode')) {
                if ($practice = \Practice::model()->findByAttributes(array('code' => $code))) {
                    $patient->practice_id = $practice->id;
                } else {
                    $this->addWarning('Could not find Practice for code ' . $code);
                }
            } else {
                $patient->practice_id = null;
            }
        } else {
            if (!$this->partial_record) {
                $patient->practice_id = null;
            }
        }
    }