Пример #1
0
 public function testImportEventIsSettableUponCreation()
 {
     $import = Mockery::mock('DAG\\Component\\Resource\\Model\\Import');
     $subject = Mockery::mock('DAG\\Bundle\\ResourceBundle\\Import\\ResourceInterface')->shouldReceive('isSubject')->zeroOrMoreTimes()->andReturn(true)->getMock();
     $target = Mockery::mock('DAG\\Bundle\\ResourceBundle\\Import\\ResourceInterface')->shouldReceive('isTarget')->zeroOrMoreTimes()->andReturn(true)->getMock();
     $event = new ImportEvent($subject, $target, $import);
     $this->assertSame($import, $event->getImport());
 }
Пример #2
0
 /**
  * Converts record array into actual target entity.
  *
  * @param ImportEvent $event
  */
 public function convert(ImportEvent $event)
 {
     $importer = $event->getImporter();
     if (!('sample' == $importer->getSubject() && 'cpd_genetic_results' == $importer->getName())) {
         return;
     }
     $records = $event->getRecords();
     $repo = $event->getTarget()->getRepository();
     $prototype = $this->prototypeProvider->getPrototypeByName('genetic-results');
     $fields['cpd-id'] = $prototype->getFieldByName('genetic-results-cpd-id');
     $fields['gene-id'] = $prototype->getFieldByName('genetic-results-gene-id');
     $fields['gene'] = $prototype->getFieldByName('genetic-results-gene');
     $fields['variant-detected'] = $prototype->getFieldByName('genetic-results-variant-detected');
     $fields['variant-categorization'] = $prototype->getFieldByName('genetic-results-variant-categorization');
     $fields['cdna-change'] = $prototype->getFieldByName('genetic-results-cdna-change');
     $fields['mutation-type-cdna'] = $prototype->getFieldByName('genetic-results-mutation-type-cdna');
     $fields['mutation-type-protein'] = $prototype->getFieldByName('genetic-results-mutation-type-protein');
     $fields['variant-alias'] = $prototype->getFieldByName('genetic-results-variant-alias');
     $fields['genetic-test-version-id'] = $prototype->getFieldByName('genetic-results-genetic-test-version-id');
     $fields['transcript-id'] = $prototype->getFieldByName('genetic-results-transcript-id');
     $fields['position'] = $prototype->getFieldByName('genetic-results-position');
     $fields['genotype'] = $prototype->getFieldByName('genetic-results-genotype');
     $fields['fdp'] = $prototype->getFieldByName('genetic-results-fdp');
     $fields['frd'] = $prototype->getFieldByName('genetic-results-frd');
     $fields['fad'] = $prototype->getFieldByName('genetic-results-fad');
     $fields['faf'] = $prototype->getFieldByName('genetic-results-faf');
     $fields['exon-id'] = $prototype->getFieldByName('genetic-results-exon-id');
     $fields['exon'] = $prototype->getFieldByName('genetic-results-exon');
     $sources = array();
     foreach ($records as $key => $record) {
         $source = new Source();
         $source->setPatient($record['patient']);
         $source->setSourceDate($record['activity_date']);
         $source->setAmount(1);
         $sample = new Sample();
         $sample->setPrototype($prototype);
         $sample->setPatient($record['patient']);
         $source->addSample($sample);
         if (array_key_exists('diagnosis', $record)) {
             $sample->setDiagnosis($record['diagnosis']);
         }
         foreach ($fields as $key => $field) {
             $fieldValue = new FieldValue();
             $fieldValue->setField($field);
             $fieldValue->setValue($record[str_replace('genetic_results_', '', str_replace('-', '_', $field->getName()))]);
             $sample->addField($fieldValue);
         }
         $sources[$record['pk_id']] = $source;
         unset($records[$key]);
     }
     $event->setRecords($sources);
 }
Пример #3
0
 /**
  * Convert.
  *
  * @param array $records
  * @return void
  */
 public function convert(ImportEvent $event)
 {
     $records = $event->getRecords();
     $flattened = array();
     foreach ($records as $key => $value) {
         foreach ($value as $possibleObject) {
             if (is_object($possibleObject) && !$possibleObject instanceof Resource && !$possibleObject instanceof DateTime) {
                 $flattened[] = $possibleObject;
             }
         }
         unset($records[$key]);
     }
     $event->setRecords($flattened);
 }
Пример #4
0
 /**
  * Initialize the import object.
  *
  * Figure out criteria to use...
  *
  * @param ImportEvent $event
  */
 public function initialize(ImportEvent $event)
 {
     $import = $event->getImport();
     $history = $event->getHistory();
     $importer = $event->getImporter();
     $criteria = array();
     if (empty($history)) {
         $criteria = $this->criteria->setParams($this->criteria->retrieveDefault());
     }
     if (empty($criteria)) {
         $criteria = $this->criteria->setParams($this->criteria->calculate($history));
     }
     $import->setImporter($importer->getName());
     $import->setCriteria($criteria->retrieve());
 }
Пример #5
0
 /**
  * Converts record array into actual target entity.
  *
  * @param ImportEvent $event
  */
 public function convert(ImportEvent $event)
 {
     $importer = $event->getImporter();
     if (!('sample' === $importer->getSubject() && 'hmtb_specimens_collection' === $importer->getName())) {
         return;
     }
     $records = $event->getRecords();
     $repo = $event->getTarget()->getRepository();
     $prototype = $this->prototypeProvider->getPrototypeByName('specimen-collection');
     $fields['sample-type'] = $prototype->getFieldByName('hmtb-sample-type');
     $fields['restricted'] = $prototype->getFieldByName('hmtb-restricted');
     $fields['subtype'] = $prototype->getFieldByName('hmtb-subtype');
     $fields['total-sum-vials-remaining'] = $prototype->getFieldByName('hmtb-total-sum-vials-remaining');
     $fields['blasts'] = $prototype->getFieldByName('hmtb-blasts');
     $fields['ct-cyle'] = $prototype->getFieldByName('hmtb-ct-cycle');
     $fields['ct-study-day'] = $prototype->getFieldByName('hmtb-ct-study-day');
     $fields['ct-peak-through'] = $prototype->getFieldByName('hmtb-ct-peak-through');
     $fields['ct-time-post-drug'] = $prototype->getFieldByName('hmtb-ct-time-post-drug');
     $fields['ct-time-post-drug-unit'] = $prototype->getFieldByName('hmtb-ct-time-post-drug-unit');
     $fields['ct-treatment-relation-time'] = $prototype->getFieldByName('hmtb-ct-treatment-relation-time');
     $fields['when-modified'] = $prototype->getFieldByName('hmtb-when-modified');
     $sources = array();
     foreach ($records as $key => $record) {
         $source = new Source();
         $source->setPatient($record['patient']);
         $source->setSourceDate($record['activity_date']);
         $source->setAmount(1);
         $sample = new Sample();
         $sample->setPrototype($prototype);
         $sample->setAmount(1);
         $sample->setPatient($record['patient']);
         $source->addSample($sample);
         foreach ($fields as $key => $field) {
             if (method_exists($field, 'getName')) {
                 $fieldValue = new FieldValue();
                 $fieldValue->setField($field);
                 $fieldValue->setSample($sample);
                 $fieldValue->setValue($record[str_replace('hmtb_', '', str_replace('-', '_', $field->getName()))]);
                 $sources[$record['identifier'] . $field->getName()] = $fieldValue;
             }
         }
         $sources[$record['identifier']] = $source;
         unset($records[$key]);
     }
     $event->setRecords($sources);
 }
Пример #6
0
 /**
  * Converts record array into actual target entity.
  *
  * @param ImportEvent $event
  */
 public function convert(ImportEvent $event)
 {
     $records = $event->getRecords();
     $prototype = $this->prototypeProvider->getPrototypeByName('ridic-dose');
     $fields = array();
     $fields['0'] = $prototype->getFieldByName('0');
     $fields['first-treatment'] = $prototype->getFieldByName('first-treatment');
     $fields['last-treatment'] = $prototype->getFieldByName('last-treatment');
     $fields['course-ser'] = $prototype->getFieldByName('course-ser');
     $fields['course-serv'] = $prototype->getFieldByName('course-serv');
     $fields['course-id'] = $prototype->getFieldByName('course-id');
     $fields['hup-mrn'] = $prototype->getFieldByName('hup-mrn');
     $fields['attending-npi'] = $prototype->getFieldByName('attending-npi');
     $fields['treatment-intent'] = $prototype->getFieldByName('treatment-intent');
     $fields['department-ser'] = $prototype->getFieldByName('department-ser');
     $fields['pcam-yn'] = $prototype->getFieldByName('pcam-yn');
     $fields['pah-yn'] = $prototype->getFieldByName('pah-yn');
     $fields['chh-yn'] = $prototype->getFieldByName('chh-yn');
     $fields['dh-yn'] = $prototype->getFieldByName('dh-yn');
     $fields['vf-yn'] = $prototype->getFieldByName('vf-yn');
     $fields['first-treatment-dt'] = $prototype->getFieldByName('first-treatment-dt');
     $fields['last-treatment-dt'] = $prototype->getFieldByName('last-treatment-dt');
     $fields['days-elapsed'] = $prototype->getFieldByName('days-elapsed');
     $fields['days-treated'] = $prototype->getFieldByName('days-treated');
     $fields['first-treatment-modality'] = $prototype->getFieldByName('first-treatment-modality');
     $fields['linac-yn'] = $prototype->getFieldByName('linac-yn');
     $fields['proton-yn'] = $prototype->getFieldByName('proton-yn');
     $fields['conformal-yn'] = $prototype->getFieldByName('conformal-yn');
     $fields['imrt-yn'] = $prototype->getFieldByName('imrt-yn');
     $fields['arc-yn'] = $prototype->getFieldByName('arc-yn');
     $fields['rapid-arc-yn'] = $prototype->getFieldByName('rapid-arc-yn');
     $fields['stereotactic-yn'] = $prototype->getFieldByName('stereotactic-yn');
     $fields['tbi-yn'] = $prototype->getFieldByName('tbi-yn');
     $fields['single-scattering-yn'] = $prototype->getFieldByName('single-scattering-yn');
     $fields['double-scattering-yn'] = $prototype->getFieldByName('double-scattering-yn');
     $fields['uniform-scanning-yn'] = $prototype->getFieldByName('uniform-scanning-yn');
     $fields['pbs-yn'] = $prototype->getFieldByName('pbs-yn');
     $fields['electron-static-yn'] = $prototype->getFieldByName('electron-static-yn');
     $fields['hdtse-yn'] = $prototype->getFieldByName('hdtse-yn');
     $fields['cyberknife-yn'] = $prototype->getFieldByName('cyberknife-yn');
     $fields['ref-point-serv'] = $prototype->getFieldByName('ref-point-serv');
     $fields['ref-point-id'] = $prototype->getFieldByName('ref-point-id');
     $fields['rx-total-dose'] = $prototype->getFieldByName('rx-total-dose');
     $fields['rx-daily-dose'] = $prototype->getFieldByName('rx-daily-dose');
     $fields['rx-session-dose'] = $prototype->getFieldByName('rx-session-dose');
     $fields['rx-fraction'] = $prototype->getFieldByName('rx-fraction');
     $fields['treated-total-dose'] = $prototype->getFieldByName('treated-total-dose');
     $fields['treated-fractions'] = $prototype->getFieldByName('treated-fractions');
     $fields['icd9-code'] = $prototype->getFieldByName('icd9-code');
     $fields['dx-desc'] = $prototype->getFieldByName('dx-desc');
     $fields['ref-point-ser'] = $prototype->getFieldByName('ref-point-ser');
     $fields['rx-fractions'] = $prototype->getFieldByName('rx-fractions');
     $fields['patient-ser'] = $prototype->getFieldByName('patient-ser');
     $activities = array();
     foreach ($records as $key => $record) {
         $activity = new Activity();
         $activity->setPatient($record['patient']);
         $activity->setActivityDate($record['activity_date']);
         $activity->setPrototype($prototype);
         foreach ($fields as $key => $field) {
             if (method_exists($field, 'getName')) {
                 $fieldValue = new FieldValue();
                 $fieldValue->setField($field);
                 $fieldValue->setActivity($activity);
                 $fieldValue->setValue($record[str_replace('-', '_', $field->getName())]);
                 $activities[$record['identifier'] . $field->getName()] = $fieldValue;
             }
         }
         $activities[$record['identifier']] = $activity;
         unset($records[$key]);
     }
     $event->setRecords($activities);
 }
 /**
  * Disable SQL logger.
  *
  * @param ImportEvent $event
  */
 public function disableSQLLog(ImportEvent $event)
 {
     $event->getTarget()->getManager()->getConnection()->getConfiguration()->setSQLLogger(null);
 }