Each node is a question for a given assessment flow. If it's parent is null, it is the root node for the related flow. There should only be one with a null parent for each flow.
Inheritance: extends BaseActiveRecordVersioned
 public function getRootNode()
 {
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('decisiontree_id' => $this->id, 'parent_id' => null));
     $node = OphCoTherapyapplication_DecisionTreeNode::model()->find($criteria);
     return $node;
 }
Example #2
0
 public function actionCreateDecisionTreeNodeRule($id)
 {
     $node = OphCoTherapyapplication_DecisionTreeNode::model()->findByPk((int) $id);
     $model = new OphCoTherapyapplication_DecisionTreeNodeRule();
     $model->node = $node;
     if (isset($_POST['OphCoTherapyapplication_DecisionTreeNodeRule'])) {
         $model->attributes = $_POST['OphCoTherapyapplication_DecisionTreeNodeRule'];
         $model->node_id = $node->id;
         if ($model->save()) {
             Audit::add('admin', 'create', $model->id, null, array('module' => 'OphCoTherapyapplication', 'model' => 'OphCoTherapyapplication_DecisionTreeNodeRule'));
             Yii::app()->user->setFlash('success', 'Decision Tree Node rule created');
             $this->redirect(array('viewdecisiontree', 'id' => $node->decisiontree_id, 'node_id' => $node->id));
         }
     }
     $this->renderPartial('create', array('model' => $model, 'node' => $node, 'title' => 'Rule for ' . ($node->outcome ? $node->outcome->name . ' Outcome' : $node->question)));
 }
Example #3
0
 /**
  * works out the node response value for the given node id on the element. Basically allows us to check for
  * submitted values, values stored against the element from being saved, or working out a default value if applicable.
  *
  * @param Element_OphCoTherapyapplication_PatientSuitability $element
  * @param string                                             $side
  * @param int                                                $node_id
  */
 public function getNodeResponseValue($element, $side, $node_id)
 {
     if (isset($_POST['Element_OphCoTherapyapplication_PatientSuitability'][$side . '_DecisionTreeResponse'])) {
         // responses have been posted, so should operate off the value for this node.
         return @$_POST['Element_OphCoTherapyapplication_PatientSuitability'][$side . '_DecisionTreeResponse'][$node_id];
     }
     foreach ($element->{$side . '_responses'} as $response) {
         if ($response->node_id == $node_id) {
             return $response->value;
         }
     }
     $node = OphCoTherapyapplication_DecisionTreeNode::model()->findByPk($node_id);
     return $node->getDefaultValue($side, $this->patient, $this->episode);
 }