/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if (!$this->multiTracks) { return false; } $this->tracker = $this->loader->getTracker(); if (!$this->respondentTrackId) { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } if ($this->respondentTrackId) { if (!$this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) { $this->respondentTrack = $this->tracker->getRespondentTrack($this->respondentTrackId); } } if ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) { if (!$this->respondentTrackId) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } $this->trackId = $this->respondentTrack->getTrackId(); if (!$this->respondentId) { $this->respondentId = $this->respondentTrack->getRespondentId(); } if (!$this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } $this->caption = $this->_('Other assignments of this track to this respondent.'); $this->onEmpty = $this->_('This track is assigned only once to this respondent.'); } else { if ($this->respondent instanceof \Gems_Tracker_Respondent) { if (!$this->respondentId) { $this->respondentId = $this->respondent->getId(); } if (!$this->organizationId) { $this->organizationId = $this->respondent->getOrganizationId(); } } $this->caption = $this->_('Existing assignments of this track to this respondent.'); $this->onEmpty = $this->_('This track is not assigned to this respondent.'); } if (!$this->trackId) { $this->trackId = $this->request->getParam(\Gems_Model::TRACK_ID); } if (!$this->trackId && $this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackId = $this->trackEngine->getTrackId(); } return $this->trackId && $this->respondentId && $this->organizationId && parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { // Try to set $this->respondentTrackId, it can be ok when not set if (!$this->respondentTrackId) { if ($this->respondentTrack) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } else { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } } // First attempt at trackId if (!$this->trackId && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } // Check if a sufficient set of data is there if (!($this->trackId || $this->patientId || $this->organizationId)) { // Now we really need $this->respondentTrack if (!$this->respondentTrack) { if ($this->respondentTrackId) { $this->respondentTrack = $this->loader->getTracker()->getRespondentTrack($this->respondentTrackId); } else { // Parameters not valid return false; } } } if (!$this->trackId) { $this->trackId = $this->respondentTrack->getTrackId(); } if (!$this->patientId) { $this->patientId = $this->respondentTrack->getPatientNumber(); } if (!$this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } // \MUtil_Echo::track($this->trackId, $this->patientId, $this->organizationId, $this->respondentTrackId); return $this->getModel()->loadFirst() && parent::hasHtmlOutput(); }
/** * Determines if this particular track should be included * in the report * * @param \Gems_Tracker_RespondentTrack $track * @return boolean This dummy implementation always returns true */ protected function _isTrackInFilter(\Gems_Tracker_RespondentTrack $track) { $result = false; $trackInfo = array('code' => $track->getCode(), 'trackid' => $track->getTrackId(), 'resptrackid' => $track->getRespondentTrackId(), 'respid' => $track->getRespondentId()); if (empty($this->trackFilter)) { $result = true; } else { // Now read the filter and split by track code or track id foreach ($this->trackFilter as $filter) { $remaining = array_diff_assoc($filter, $trackInfo); if (empty($remaining)) { $result = true; break; } } } // Only if track has a success code if ($result && $track->getReceptionCode()->isSuccess()) { return true; } return false; }