예제 #1
0
 public function addFamilyHistory($relative_id, $side_id, $condition_id, $comments)
 {
     if (!($fh = FamilyHistory::model()->find('patient_id=? and relative_id=? and side_id=? and condition_id=?', array($this->id, $relative_id, $side_id, $condition_id)))) {
         $fh = new FamilyHistory();
         $fh->patient_id = $this->id;
         $fh->relative_id = $relative_id;
         $fh->side_id = $side_id;
         $fh->condition_id = $condition_id;
     }
     $fh->comments = $comments;
     if (!$fh->save()) {
         throw new Exception("Unable to save family history: " . print_r($fh->getErrors(), true));
     }
 }
예제 #2
0
 /**
  * Adds FamilyHistory entry to the patient if it's not a duplicate
  *
  * @param $relative_id
  * @param $other_relative
  * @param $side_id
  * @param $condition_id
  * @param $other_condition
  * @param $comments
  * @throws Exception
  */
 public function addFamilyHistory($relative_id, $other_relative, $side_id, $condition_id, $other_condition, $comments)
 {
     $check_sql = 'patient_id=? and relative_id=? and side_id=? and condition_id=?';
     $params = array($this->id, $relative_id, $side_id, $condition_id);
     if ($other_relative) {
         $check_sql .= ' and other_relative=?';
         $params[] = $other_relative;
     } else {
         $check_sql .= ' and other_relative is null';
     }
     if ($other_condition) {
         $check_sql .= ' and other_condition=?';
         $params[] = $other_condition;
     } else {
         $check_sql .= ' and other_condition is null';
     }
     if (!($fh = FamilyHistory::model()->find($check_sql, $params))) {
         $fh = new FamilyHistory();
         $fh->patient_id = $this->id;
         $fh->relative_id = $relative_id;
         $fh->side_id = $side_id;
         $fh->condition_id = $condition_id;
     }
     $fh->comments = $comments;
     if (!$fh->save()) {
         throw new Exception("Unable to save family history: " . print_r($fh->getErrors(), true));
     }
     if ($this->no_family_history_date) {
         $this->no_family_history_date = null;
         if (!$this->save()) {
             throw new Exception('Could not remove no family history flag: ' . print_r($this->getErrors(), true));
         }
     }
 }