public function actionAddPreviousOperation()
 {
     if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
         throw new Exception("Patient not found:" . @$_POST['patient_id']);
     }
     if (!isset($_POST['previous_operation'])) {
         throw new Exception("Missing previous operation text");
     }
     if (@$_POST['edit_operation_id']) {
         if (!($po = PreviousOperation::model()->findByPk(@$_POST['edit_operation_id']))) {
             $po = new PreviousOperation();
         }
     } else {
         $po = new PreviousOperation();
     }
     $po->patient_id = $patient->id;
     $po->side_id = @$_POST['previous_operation_side'] ? @$_POST['previous_operation_side'] : null;
     $po->operation = @$_POST['previous_operation'];
     $po->date = $this->processFuzzyDate();
     if ($po->date == '0000-00-00') {
         $po->date = null;
     }
     if (!$po->save()) {
         echo json_encode($po->getErrors());
         return;
     }
     echo json_encode(array());
 }
示例#2
0
 public function addPreviousOperation($operation, $side_id, $date)
 {
     if (!($pa = PreviousOperation::model()->find('patient_id=? and operation=? and date=?', array($this->id, $operation, $date)))) {
         $pa = new PreviousOperation();
         $pa->patient_id = $this->id;
         $pa->operation = $operation;
         $pa->date = $date;
     }
     $pa->side_id = $side_id ? $side_id : null;
     if (!$pa->save()) {
         throw new Exception("Unable to save previous operation: " . print_r($pa->getErrors(), true));
     }
 }