/**
  * Create State instance from array $data
  *
  * @param array $data
  * @return \HealthCareAbroad\HelperBundle\Entity\State
  */
 public function createStateFromArray(array $data)
 {
     $requiredFields = array('id', 'name', 'country');
     if (isset($data['geoCountry']) && isset($data['geoCountry']['id'])) {
         $data['country'] = $this->getCountryById($data['geoCountry']['id']);
     }
     foreach ($requiredFields as $key) {
         if (!isset($data[$key])) {
             throw LocationServiceException::missingRequiredStateDataKey($key);
         }
     }
     $state = new State();
     $state->setId($data['id']);
     $state->setName($data['name']);
     $state->setCountry($data['country']);
     $state->setInstitutionId(isset($data['institutionId']) ? $data['institutionId'] : 0);
     $state->setAdministrativeCode(isset($data['administrativeCode']) ? $data['administrativeCode'] : null);
     $state->setStatus(isset($data['status']) ? $data['status'] : State::STATUS_ACTIVE);
     return $state;
 }
 /**
  * 
  * @param array $globaStateData
  * @return State
  */
 private function getHcaState($globalStateData, Country $country)
 {
     $hcaState = $this->locationService->getStateById($globalStateData['id']);
     if (!$hcaState) {
         // create new hca state
         $hcaState = new State();
         $hcaState->setId($globalStateData['id']);
         $hcaState->setName($globalStateData['name']);
         $hcaState->setCountry($country);
     }
     return $hcaState;
 }