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

mapGp() private method

Handle mapping of the Gp resource code to the patient model.
private mapGp ( Patient $patient )
$patient Patient
    private function mapGp(\Patient $patient)
    {
        if (property_exists($this, 'GpCode')) {
            $code = $this->getAssignedProperty('GpCode');
            if ($code) {
                if ($gp = \Gp::model()->findByAttributes(array('nat_id' => $code))) {
                    $patient->gp_id = $gp->id;
                } else {
                    $this->addWarning('Could not find GP for code ' . $code);
                }
            } else {
                $patient->gp_id = null;
            }
        } else {
            if (!$this->partial_record) {
                $patient->gp_id = null;
            }
        }
    }