Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : Practice | ||
리턴 | Practice | the static model class |
private function mapPractice(\Patient $patient) { 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 { if (!$this->partial_record) { $patient->practice_id = null; } } }
/** * Imports the 'CcgAssignment' file. * * @param array $data * * @throws Exception If Failed to save commissioning body assignment */ private function importCcgAssignment(array $data) { $practice = Practice::model()->findByAttributes(array('code' => $data['practice_code'])); $ccg = CommissioningBody::model()->findByAttributes(array('code' => $data['ccg_code'], 'commissioning_body_type_id' => $this->cbtId)); if (!$practice || !$ccg) { return; } $found = false; foreach ($practice->commissioningbodyassigments as $assignment) { if ($assignment->commissioning_body_id == $ccg->id) { $found = true; } else { if ($assignment->commissioning_body->commissioning_body_type_id == $this->cbtId) { if ($assignment->delete() && $this->audit !== 'false') { Audit::add('ProcessHscicDataCommand', 'Assignment Deleted'); } } } } if (!$found) { $assignment = new CommissioningBodyPracticeAssignment(); $assignment->commissioning_body_id = $ccg->id; $assignment->practice_id = $practice->id; if (!$assignment->save()) { throw new Exception('Failed to save commissioning body assignment: ' . print_r($assignment->errors, true)); } if ($this->audit !== 'false') { Audit::add('ProcessHscicDataCommand', 'Assignment Saved'); } } }