/** * Called after the check that all required registry values * have been set correctly has run. * * @return void */ public function afterRegistry() { parent::afterRegistry(); $orgId = $this->respondent->getOrganizationId(); // These values are set for the generic table snippet and // should be reset for this snippet $this->browse = false; $this->extraFilter = array("gtr_organizations LIKE '%|{$orgId}|%'"); $this->menuEditActions = 'view'; $this->menuShowActions = 'create'; }
/** * Overrule to implement snippet specific filtering and sorting. * * @param \MUtil_Model_ModelAbstract $model */ protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model) { $filter['gto_id_respondent'] = $this->respondent->getId(); if (is_array($this->forOtherOrgs)) { $filter['gto_id_organization'] = $this->forOtherOrgs; } elseif (true !== $this->forOtherOrgs) { $filter['gto_id_organization'] = $this->respondent->getOrganizationId(); } // Filter for valid track reception codes $filter[] = 'gr2t_reception_code IN (SELECT grc_id_reception_code FROM gems__reception_codes WHERE grc_success = 1)'; $filter['grc_success'] = 1; // Active round // or // no round // or // token is success and completed $filter[] = 'gro_active = 1 OR gro_active IS NULL OR (grc_success=1 AND gto_completion_time IS NOT NULL)'; $filter['gsu_active'] = 1; // NOTE! $this->model does not need to be the token model, but $model is a token model $tabFilter = $this->model->getMeta('tab_filter'); if ($tabFilter) { $model->addFilter($tabFilter); } $model->addFilter($filter); // \MUtil_Echo::track($model->getFilter()); $this->processSortOnly($model); }
/** * Get the respondent linked to this token * * @return \Gems_Tracker_Respondent */ public function getRespondent() { $patientNumber = $this->getPatientNumber(); $organizationId = $this->getOrganizationId(); if (!$this->_respondentObject instanceof \Gems_Tracker_Respondent || $this->_respondentObject->getPatientNumber() !== $patientNumber || $this->_respondentObject->getOrganizationId() !== $organizationId) { $this->_respondentObject = $this->loader->getRespondent($patientNumber, $organizationId); } return $this->_respondentObject; }
/** * 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->respondent instanceof \Gems_Tracker_Respondent) { if (!$this->patientId) { $this->patientId = $this->respondent->getPatientNumber(); } if (!$this->organizationId) { $this->organizationId = $this->respondent->getOrganizationId(); } } // Try to get $this->respondentTrackId filled if (!$this->respondentTrackId) { if ($this->respondentTrack) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } else { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } } // Try to get $this->respondentTrack filled if ($this->respondentTrackId && !$this->respondentTrack) { $this->respondentTrack = $this->loader->getTracker()->getRespondentTrack($this->respondentTrackId); } // Set the user id if (!$this->userId) { $this->userId = $this->loader->getCurrentUser()->getUserId(); } if ($this->respondentTrack) { // We are updating $this->createData = false; // Try to get $this->trackEngine filled if (!$this->trackEngine) { // Set the engine used $this->trackEngine = $this->respondentTrack->getTrackEngine(); } } else { // We are inserting $this->createData = true; $this->saveLabel = $this->_($this->_('Add track')); // Try to get $this->trackId filled if (!$this->trackId) { if ($this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } else { $this->trackId = $this->request->getParam(\Gems_Model::TRACK_ID); } } // Try to get $this->trackEngine filled if ($this->trackId && !$this->trackEngine) { $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId); } if (!($this->trackEngine && $this->patientId && $this->organizationId && $this->userId)) { throw new \Gems_Exception_Coding('Missing parameter for ' . __CLASS__ . ': could not find data for editing a respondent track nor the track engine, patientId and organizationId needed for creating one.'); } } return parent::hasHtmlOutput(); }
/** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * * @return boolean False if required are missing. */ public function checkRegistryRequestsAnswers() { if (!$this->organizationId) { if ($this->respondent) { $this->organizationId = $this->respondent->getOrganizationId(); } if (!$this->organizationId) { $this->organizationId = $this->request->getParam(\MUtil_Model::REQUEST_ID2); } } if ($this->organizationId && !$this->respondentId) { if ($this->respondent) { $this->respondentId = $this->respondent->getId(); } if (!$this->respondentId) { $this->respondentId = $this->util->getDbLookup()->getRespondentId($this->request->getParam(\MUtil_Model::REQUEST_ID1), $this->organizationId); } } return $this->organizationId && $this->respondentId && $this->db && $this->model; }
protected function loadExport() { $this->export = $this->loader->getRespondentExport(); if ($this->token instanceof \Gems_Tracker_Token) { $this->addRespondent($this->token->getPatientNumber(), $this->token->getOrganizationId()); $this->export->addRespondentTrackFilter($this->token->getRespondentTrackId()); $this->export->addTokenFilter($this->token->getTokenId()); } elseif ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) { $this->addRespondent($this->respondentTrack->getPatientNumber(), $this->respondentTrack->getOrganizationId()); $this->export->addRespondentTrackFilter($this->respondentTrack->getRespondentTrackId()); } elseif ($this->respondent instanceof \Gems_Tracker_Respondent) { $this->addRespondent($this->respondent->getPatientNumber(), $this->respondent->getOrganizationId()); } }
/** * Process the respondent and return true when data has changed. * * The event has to handle the actual storage of the changes. * * @param \Gems_Tracker_Respondent $respondent * @param int $userId The current user * @return boolean True when something changed */ public function processChangedRespondent(\Gems_Tracker_Respondent $respondent) { $changes = 0; $tracker = $this->loader->getTracker(); $respTracks = $tracker->getRespondentTracks($respondent->getId(), $respondent->getOrganizationId()); $userId = $this->currentUser->getUserId(); foreach ($respTracks as $respondentTrack) { if ($respondentTrack instanceof \Gems_Tracker_RespondentTrack) { $changes += $respondentTrack->checkTrackTokens($userId); } } // \MUtil_Echo::track('Hi there! ' . $changes); return (bool) $changes; }
/** * 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(); }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if ($this->model instanceof \Gems_Model_AppointmentModel) { $model = $this->model; } else { $model = $this->loader->getModels()->createAppointmentModel(); $model->applyBrowseSettings(); } $model->addColumn(new \Zend_Db_Expr("CONVERT(gap_admission_time, DATE)"), 'date_only'); $model->set('date_only', 'formatFunction', array($this, 'formatDate')); // 'dateFormat', \Zend_Date::DAY_SHORT . ' ' . \Zend_Date::MONTH_NAME . ' ' . \Zend_Date::YEAR); $model->set('gap_admission_time', 'label', $this->_('Time'), 'formatFunction', array($this, 'formatTime')); // 'dateFormat', 'HH:mm ' . \Zend_Date::WEEKDAY); $this->_dateStorageFormat = $model->get('gap_admission_time', 'storageFormat'); // $this->_timeImg = \MUtil_Html::create('img', array('src' => 'stopwatch.png', 'alt' => '')); $model->set('gr2o_patient_nr', 'label', $this->_('Respondent nr')); if ($this->respondent instanceof \Gems_Tracker_Respondent) { $model->addFilter(array('gap_id_user' => $this->respondent->getId(), 'gap_id_organization' => $this->respondent->getOrganizationId())); } return $model; }