private function mapEthnicGroup(\Patient $patient)
{
if (property_exists($this, 'EthnicGroup')) {
$code = $this->getAssignedProperty('EthnicGroup');
if ($code) {
if ($eg = \EthnicGroup::model()->findByAttributes(array('code' => $code))) {
$patient->ethnic_group_id = $eg->id;
} else {
$this->addWarning('Unrecognised ethnic group code ' . $code);
}
} else {
$patient->ethnic_group_id = null;
}
} else {
if (!$this->partial_record) {
$patient->ethnic_group_id = null;
}
}
}