/**
  * Seed the specialties table.
  *
  * @return void
  * @author PJ
  */
 private function seedTable($data)
 {
     foreach ($data as $lineIndex => $row) {
         $aliases = AggregateReporter::getAliases($row[17]);
         DB::table('physicians')->insert(['aoa_mem_id' => $row[0], 'full_name' => $row[1], 'prefix' => $row[2], 'first_name' => $row[3], 'middle_name' => $row[4], 'last_name' => $row[5], 'suffix' => $row[6], 'designation' => $row[7], 'SortColumn' => $row[8], 'MemberStatus' => $row[9], 'City' => $row[10], 'State_Province' => $row[11], 'Zip' => $row[12], 'Country' => $row[13], 'COLLEGE_CODE' => $row[14], 'YearOfGraduation' => $row[15], 'fellows' => $row[16], 'PrimaryPracticeFocusCode' => $row[17], 'PrimaryPracticeFocusArea' => $row[18], 'SecondaryPracticeFocusCode' => $row[19], 'SecondaryPracticeFocusArea' => $row[20], 'website' => $row[21], 'AOABoardCertified' => $row[22] == 'YES' ? 1 : 0, 'address_1' => $row[23], 'address_2' => $row[24], 'Phone' => $row[25], 'Email' => $row[26], 'ABMS' => $row[27] == 'YES' ? 1 : 0, 'Gender' => $row[28], 'CERT1' => $row[29], 'CERT2' => $row[30], 'CERT3' => $row[31], 'CERT4' => $row[32], 'CERT5' => $row[33], 'lat' => $row[34], 'lon' => $row[35], 'geo_confidence' => $row[36], 'geo_city' => $row[37], 'geo_state' => $row[38], 'geo_matches' => $row[39] == 'True' ? 1 : 0, 'alias_1' => empty($aliases[0]) ? null : $aliases[0]->id, 'alias_2' => empty($aliases[1]) ? null : $aliases[1]->id, 'alias_3' => empty($aliases[2]) ? null : $aliases[2]->id]);
     }
 }
Example #2
0
 /**
  * Search for physicians.
  *
  * @return JSON
  */
 public function search(Request $request)
 {
     $physicians = null;
     $searchDistance = $request->distance ? $request->distance : 0;
     $coords = $this->getCoordinates($request);
     $orderBy = $request->has('order_by') ? $request->order_by : 'distance';
     $sort = $request->has('sort') ? $request->sort : 'asc';
     $limit = $request->has('per_page') ? $request->per_page : '25';
     // if we don't have a requested distance, we'll cycle through
     // our fallback distances until we get at least 1 result;
     // if we don't have anything by our max distance, we'll return 0.
     if (!$request->has('distance')) {
         while (!$physicians || $physicians->count() == 0) {
             $searchDistance = $this->getNextDistance($searchDistance);
             $physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender);
             if ($searchDistance == $this->maxDistance) {
                 break;
             }
         }
     } else {
         $physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender);
     }
     $alias = Alias::find($request->alias_id);
     $queryMeta = ['city' => Str::title(urldecode($request->city)), 'state' => mb_strtoupper($request->state), 'zip' => $request->zip ? $request->zip : $this->getZip($request->city, $request->state), 'alias' => $alias ? $alias->alias : null, 'alias_id' => $alias ? $alias->id : null, 'aggregate' => AggregateReporter::report($physicians, $request->alias_id), 'q' => $request->q, 'gender' => $request->gender, 'count' => $physicians ? $physicians->count() : 0, 'radius' => $searchDistance, 'order_by' => $request->order_by, 'sort' => $request->sort, 'center' => ['lat' => $coords['lat'], 'lon' => $coords['lon']]];
     $physicians = $physicians->orderBy($orderBy, $sort)->paginate($limit)->appends($request->query());
     return $this->response->withPaginator($physicians, new PhysicianTransformer(), null, $queryMeta);
 }
Example #3
0
 public static function createPhysicianModel($row, Logger $log)
 {
     $locationData = self::getPhysicianLocationData($row, $log);
     if (!$locationData) {
         Log::error('Could not geolocate ' . $row->full_name);
         return;
     }
     $aliases = AggregateReporter::getAliases($row->PrimaryPracticeFocusCode);
     $physician = \App\Physician::create(['aoa_mem_id' => trim($row->id), 'full_name' => trim($row->full_name), 'prefix' => trim($row->prefix), 'first_name' => trim($row->first_name), 'middle_name' => trim($row->middle_name), 'last_name' => trim($row->last_name), 'suffix' => trim($row->suffix), 'designation' => trim($row->designation), 'SortColumn' => trim($row->SortColumn), 'MemberStatus' => trim($row->MemberStatus), 'City' => trim($row->City), 'State_Province' => trim($row->State_Province), 'Zip' => trim($row->Zip), 'Country' => trim($row->Country), 'COLLEGE_CODE' => trim($row->COLLEGE_CODE), 'YearOfGraduation' => trim($row->YearOfGraduation), 'fellows' => trim($row->fellows), 'PrimaryPracticeFocusCode' => trim($row->PrimaryPracticeFocusCode), 'PrimaryPracticeFocusArea' => trim($row->PrimaryPracticeFocusArea), 'SecondaryPracticeFocusCode' => trim($row->SecondaryPracticeFocusCode), 'SecondaryPracticeFocusArea' => trim($row->SecondaryPracticeFocusArea), 'website' => trim($row->website), 'AOABoardCertified' => $row->AOABoardCertified == 'YES' ? 1 : 0, 'address_1' => trim($row->address_1), 'address_2' => trim($row->address_2), 'Phone' => trim($row->Phone), 'Email' => trim($row->Email), 'ABMS' => $row->ABMS == 'YES' ? 1 : 0, 'Gender' => trim($row->Gender), 'CERT1' => trim($row->CERT1), 'CERT2' => trim($row->CERT2), 'CERT3' => trim($row->CERT3), 'CERT4' => trim($row->CERT4), 'CERT5' => trim($row->CERT5), 'lat' => trim($locationData->lat), 'lon' => trim($locationData->lon), 'geo_confidence' => trim($locationData->geo_confidence), 'geo_city' => trim($locationData->geo_city), 'geo_state' => trim($locationData->geo_state), 'geo_matches' => trim($locationData->geo_matches), 'alias_1' => empty($aliases[0]) ? null : $aliases[0]->id, 'alias_2' => empty($aliases[1]) ? null : $aliases[1]->id, 'alias_3' => empty($aliases[2]) ? null : $aliases[2]->id]);
     return !empty($physician) ? true : false;
 }