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;
}
}
}