/** * Update the worklist display order for the current user based on the submitted ids. */ public function actionManualUpdateDisplayOrder() { $worklist_ids = @$_POST['item_ids'] ? explode(',', $_POST['item_ids']) : array(); if (!$this->manager->setWorklistDisplayOrderForUser(Yii::app()->user, $worklist_ids)) { OELog::log(print_r($this->manager->getErrors(), true)); throw new Exception('Unable to save new display order for worklists'); } $this->redirect('/worklist/manual'); }
/** * Update the Worklist Definition Mapping Attribute order. * * @param $id */ public function actionDefinitionMappingSort($id) { $definition = $this->getWorklistDefinition($id); $mapping_ids = @$_POST['item_ids'] ?: array(); if (count($mapping_ids)) { if (!$this->manager->setWorklistDefinitionMappingDisplayOrder($definition, $mapping_ids)) { OELog::log(print_r($this->manager->getErrors(), true)); $this->flashMessage('error', 'Could not reorder mappings'); } else { $this->flashMessage('success', 'Mappings re-ordered'); } } $this->redirect('/worklistAdmin/definitionMappings/' . $id); }
/** * @param null $verbosity * @param null $horizon */ public function actionGenerate($verbosity = null, $horizon = null) { $this->setLogLevel($verbosity); $date_limit = $this->getDateLimit($horizon); $this->info('Starting automatic worklist generation.'); $this->debug('Date limit is ' . $date_limit->format(Helper::NHS_DATE_FORMAT)); try { $result = $this->manager->generateAllAutomaticWorklists($date_limit); if ($result === false) { foreach ($this->manager->getErrors() as $err) { $this->error($err); } $this->finish(2); } else { $this->info('generation complete'); $this->debug("{$result} new worklists generated."); } } catch (Exception $e) { $this->fatal($e->getMessage()); } }
/** * @param \WorklistPatient $model * * @return bool|\WorklistPatient */ public function saveModel(\WorklistPatient $model) { // extract the values to be passed to the manager instance for mapping $patient = $this->mapPatient($model); $when = $this->mapWhen($model); $attributes = $this->mapAttributes($model); // allow the suppression of errors for appointments received prior to the ignore date if ($warning_limit = $this->worklist_manager->getWorklistIgnoreDate()) { if ($when < $warning_limit) { $this->warn_errors = true; } } if ($model->isNewRecord) { if (!($model = $this->worklist_manager->mapPatientToWorklistDefinition($patient, $when, $attributes))) { foreach ($this->worklist_manager->getErrors() as $err) { $this->addError($err); } if ($this->warn_errors) { return false; } throw new \Exception('Could not add patient to worklist'); } } else { $model->patient_id = $patient->id; if (!$this->worklist_manager->updateWorklistPatientFromMapping($model, $when, $attributes, !$this->partial_record)) { foreach ($this->worklist_manager->getErrors() as $err) { $this->addError($err); } if ($this->warn_errors) { return false; } throw new \Exception('Could not update patient worklist entry'); } } return $model; }
/** * @dataProvider shouldDisplayWorklistForContextProvider * * @param $context_list * @param $expected */ public function test_shouldDisplayWorklistForContext($context_list, $expected) { $manager = new WorklistManager(); $contexts = array(); $site = ComponentStubGenerator::generate('Site'); $firm = ComponentStubGenerator::generate('Firm'); foreach ($context_list as $ctx) { $c = $this->getMockBuilder('WorklistDefinitionDisplayContext')->disableOriginalConstructor()->setMethods(array('checkSite', 'checkFirm'))->getMock(); $c->expects($this->any())->method('checkSite')->with($site)->will($this->returnValue($ctx['checkSite'])); $c->expects($this->any())->method('checkFirm')->with($firm)->will($this->returnValue($ctx['checkFirm'])); $contexts[] = $c; } $definition = ComponentStubGenerator::generate('WorklistDefinition', array('display_contexts' => $contexts)); $worklist = ComponentStubGenerator::generate('Worklist', array('worklist_definition' => $definition)); $this->assertEquals($expected, $manager->shouldDisplayWorklistForContext($worklist, $site, $firm)); }