/** * Retrieves underwriting answers for the policy number passed in. * * This method retrieves all underwriting answers associated with the quote or * policynumber passed in. The answers will each be encapsulated in an * Model_Insurance_Answer object, and returned in an array. * * @param string $policyNumber * The full quote or policy number identifying the answers in the data storage. * * @return array * An array of Model_Insurance_Answer objects, or null if no * answers are found. */ public function getUnderwritingAnswers($policyNumber) { $select = $this->select(); $select->where('policyNumber = ?', $policyNumber); $answersArray = $this->fetchAll($select); $returnArray = array(); foreach ($answersArray as $currentRow) { $underwritingAnswer = new Model_Insurance_Answer(); $underwritingAnswer->setPolicyNumber($currentRow['policyNumber']); $underwritingAnswer->setQuestionNumber($currentRow['questionID']); $underwritingAnswer->setAnswer($currentRow['answerGiven']); $dateAnswered = new Zend_Date($currentRow['dateAnswered'], Zend_Date::ISO_8601); $underwritingAnswer->setDateAnswered($dateAnswered); //Now set the expected answer. if (empty($this->_questionsModel)) { $this->_questionsModel = new Datasource_Insurance_Questions(); } $expectedAnswer = $this->_questionsModel->getExpectedAnswer($currentRow['questionID']); $underwritingAnswer->setExpectedAnswer($expectedAnswer); $returnArray[] = $underwritingAnswer; } //Finalise the return value consistent with this functions contract. if (empty($returnArray)) { // No warning given as this is a common/normal scenario $returnVal = null; } else { $returnVal = $returnArray; } return $returnVal; }