示例#1
0
 public function testProblemList()
 {
     $date = date('Y-m-d H:i:s');
     $comments = array();
     $comments[] = 'first comment';
     $comments[] = 'yet another comment';
     $problemInput = 'DMII KETOACD UNCONTROLD  (250.12)';
     $problemList = array();
     $problemList['code'] = '250.12';
     $problemList['dateOfOnset'] = $date;
     $problemList['immediacy'] = 'Chronic';
     $problemList['personId'] = '65650';
     $problemList['providerId'] = '1000172';
     $problemList['status'] = 'Active';
     $problemList['lastUpdated'] = $date;
     $problem = new ProblemList();
     $problemListComments = array();
     $tmpComment = array();
     $tmpComment['authorId'] = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $tmpComment['date'] = $date;
     foreach ($comments as $comment) {
         $tmpComment['comment'] = $comment;
         $problemListComments[] = $tmpComment;
     }
     $problem->setProblemListComments($problemListComments);
     $problem->populateWithArray($problemList);
     $problem->persist();
     // retrieve problem list id
     $problemListId = $problem->problemListId;
     // check if problem list successfully saved
     $problem = new ProblemList();
     $problem->problemListId = $problemListId;
     $problem->populate();
     // assert individual data
     foreach ($problemList as $fieldName => $value) {
         $this->assertEquals($problem->{$fieldName}, $value, "{$fieldName} not equal.");
     }
     // assert if comments contains the same number of comments
     $this->assertEquals(count($problem->problemListComments), count($comments), "Problem List Comments does not match.");
     // remove problem list by changing the status to Removed
     $status = 'Removed';
     $problem->status = $status;
     $problem->persist();
     $problem = new ProblemList();
     $problem->problemListId = $problemListId;
     $problem->populate();
     $this->assertEquals($problem->status, $status, "Status not equal.");
 }
 public function processSetFlagsAction()
 {
     $problemListId = (int) $this->_getParam('problemListId');
     $flags = $this->_getParam('flags');
     $data = false;
     if ($problemListId > 0 && strlen($flags) > 0) {
         $problemList = new ProblemList();
         $problemList->problemListId = $problemListId;
         if ($problemList->populate()) {
             $problemList->flags = $flags;
             $problemList->persist();
             $data = true;
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function viewProblemAction()
 {
     $problemListId = (int) $this->_getParam('problemListId');
     if (strlen($problemListId) <= 0) {
         throw new Exception(__('Empty Problem List ID'));
     }
     $problemList = new ProblemList();
     $problemList->problemListId = (int) $problemListId;
     $problemList->populate();
     $this->view->problemList = $problemList;
     $this->render('view-problem');
 }