/**
* marks the patient as having no allergies as of now
*
* @throws Exception
*/
public function setNoAllergies()
{
$transaction = Yii::app()->db->beginTransaction();
try {
foreach (PatientAllergyAssignment::model()->findAll('patient_id = ?', array($this->id)) as $paa) {
if (!$paa->delete()) {
throw new Exception('Unable to delete patient allergy assignment: ' . print_r($paa->getErrors(), true));
}
$this->audit('patient', 'remove-allergy');
}
$this->no_allergies_date = date('Y-m-d H:i:s');
if (!$this->save()) {
throw new Exception('Unable to set no allergy date:' . print_r($this->getErrors(), true));
}
$this->audit('patient', 'set-noallergydate');
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
throw $e;
}
}