/** * {@inheritdoc} */ public function run(OptionsResolverInterface $resolver) { $records = array(); $localRecords = $this->localSource->execute(); $results = $this->cpdSource->execute(); $cachedMrns = array(); foreach ($results as $key => $result) { $result = array_change_key_case($result, CASE_LOWER); $mrn = $result['patient']; try { if (!isset($cachedMrns[$mrn])) { $result['previous_record'] = $this->provider->getPatientByMRN($mrn); $cachedMrns[$mrn] = $result['previous_record']; } else { $result['previous_record'] = $cachedMrns[$mrn]; } } catch (PatientNotFoundException $e) { unset($result, $results[$key]); continue; } $record['identifier'] = $result['pk_id']; $result['import_description'] = sprintf('%s genetic results on the %s.', $result['cpd_id'], $result['patient']); $record = $resolver->resolve($result); if ($record['patient'] && $record['genetic_test_version_id'] == '2' && !in_array($record['pk_id'], $localRecords)) { $records[] = $record; } unset($results[$key]); } unset($cachedMrns, $localRecords); return $records; }
/** * Merge a source * * @param SourceInterface $source */ public function mergeSource(SourceInterface $source) { if (array_key_exists($source->sourceId(), $this->sources)) { unset($this->sources[$source->sourceId()]); } else { $this->newSources[$source->sourceId()] = $source; } $this->sources[$source->sourceId()] = $source; }
/** * @param SourceInterface $source * @return bool */ public function equals(SourceInterface $source) { if (!$source instanceof FileSource) { return false; } if ($this->path !== $source->getPath()) { return false; } if ($this->line !== $source->getLine()) { return false; } if ($this->column !== $source->getColumn()) { return false; } return true; }
public function match(SourceInterface $source) { if (!$source instanceof CliSource) { return false; } if (count($this->specificationParts) == 0) { return array(); } $argvParts = $source->getArguments(); $curArgvPart = array_shift($argvParts); $parameters = array(); foreach ($this->specificationParts as $i => $specPart) { switch ($specPart[0]) { case self::PART_WORD: if ($specPart[1] != $curArgvPart) { return false; } else { $curArgvPart = array_shift($argvParts); continue; } break; case self::PART_PARAMETER: $parameterName = ltrim(rtrim($specPart[1], '?'), ':'); $parameters[$parameterName] = null; if ($curArgvPart == '' && substr($specPart[1], -1) != '?') { return false; } $parameters[$parameterName] = $curArgvPart; $curArgvPart = array_shift($argvParts); break; case self::PART_OPTION: $optionName = substr($specPart[1], 1); $parameters[$optionName] = array(); while ($curArgvPart[0] == '-') { $parameters[$optionName][] = $curArgvPart; $curArgvPart = array_shift($argvParts); } break; } } return $parameters; }
/** * {@inheritdoc} */ public function setSource(SourceInterface $source) { $this->setOption('source', $source->getMachineName()); return $this->addObject($source); }
/** * @param TokenInterface $token * @return UserInterface */ public function getUser(TokenInterface $token) { return $this->source->findByPK($token->userPK()); }
/** * Adds another source to the list of words. * * @param SourceInterface $source * @return self */ public function addSource(SourceInterface $source) { $this->words = array_merge($this->words, $source->getWords()); return $this; }
/** * Set the source of this layer. * * @param SourceInterface $source * The source object. */ public function setSource(SourceInterface $source) { /* @var Source $source */ $this->setOption('source', $source->getMachineName()); }