/**
  * Imports the 'Gp' CSV file.
  * 
  * @param array $data
  */
 private function importGp(array $data)
 {
     if (!($gp = Gp::model()->findbyAttributes(array('nat_id' => $data['code'])))) {
         $gp = new Gp();
         $gp->nat_id = $data['code'];
         $gp->obj_prof = $data['code'];
     }
     $isNewRecord = $gp->isNewRecord;
     $gp->is_active = $data['status'] == 'A' || $data['status'] == 'P' ? '1' : '0';
     if ($gp->saveOnlyIfDirty()->save()) {
         if ($this->audit !== 'false') {
             Audit::add('ProcessHscicDataCommand', ($isNewRecord ? 'Insert' : 'Update') . ' GP');
         }
     } else {
         // save has not been carried out, either mode was not dirty or save() failed
     }
     $contact = $gp->contact;
     $contact->primary_phone = $data['phone'];
     /*
      * Regexp
      * the first part match a word (any number of char, no whithespace)
      * than (after the first word) can follow any number of whitepace 
      * and for the last part the string must end 1 to 4 characters[A-Z]
      *
      * The goal is to extract the name initials from the field and use as a first name with the doctor title.
      *
      * Examples (egpam.zip): WELLINGS D, DONOGHUE CA, COLLOMBON MPM
      */
     if (preg_match("/^([\\S]+)\\s+([A-Z]{1,4})\$/i", trim($data['name']), $m)) {
         $contact->title = 'Dr';
         $contact->first_name = $m[2];
         $contact->last_name = $this->tidy($m[1]);
     } else {
         $contact->last_name = $data['name'];
     }
     $isNewRecord = $contact->isNewRecord;
     if ($contact->saveOnlyIfDirty()->save()) {
         if ($this->audit !== 'false') {
             Audit::add('ProcessHscicDataCommand', ($isNewRecord ? 'Insert' : 'Update') . ' GP-Contact');
         }
     } else {
         // save has not been carried out, either mode was not dirty or save() failed
     }
     if (!($address = $contact->address)) {
         $address = new Address();
         $address->contact_id = $contact->id;
     }
     $this->importAddress($address, array($data['addr1'], $data['addr2'], $data['addr3'], $data['addr4'], $data['addr5']));
     $address->postcode = $data['postcode'];
     $address->country_id = $this->countryId;
     $isNewRecord = $address->isNewRecord;
     if ($address->saveOnlyIfDirty()->save()) {
         if ($this->audit !== 'false') {
             Audit::add('ProcessHscicDataCommand', ($isNewRecord ? 'Insert' : 'Update') . ' GP-Address');
         }
     } else {
         // save has not been carried out, either mode was not dirty or save() failed
     }
     $gp = null;
 }