public function processEditAction()
 {
     $params = $this->_getParam('pharmacy');
     if (isset($params['preferred'])) {
         $params['preferred'] = 1;
     }
     $pharmacy = new Pharmacy();
     $pharmacy->populateWithArray($params);
     //$pharmacy->pharmacyId = Pharmacy::generateGUID();
     $pharmacy->LastModifierDate = date('Y-m-d H:i:s');
     $pharmacy->persist();
     $data['pharmacyId'] = $pharmacy->pharmacyId;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function generateTestSsDemoDataAction()
 {
     $basePath = Zend_Registry::get('basePath');
     $xmlFile = $basePath . 'xml/ss-demo-data.xml';
     $xml = new SimpleXMLElement(file_get_contents($xmlFile));
     foreach ($xml as $key => $value) {
         switch ($key) {
             case 'prescriber':
                 $person = new Person();
                 $person->active = 1;
                 $person->lastName = (string) $value->PrescriberLastName;
                 $person->firstName = (string) $value->PrescriberFirstName;
                 $person->middleName = (string) $value->PrescriberMiddleName;
                 $person->suffix = (string) $value->PrescriberNameSuffix;
                 //$person->initials = (string)$value->PrescriberNamePrefix;
                 $provider = new Provider();
                 $provider->person = $person;
                 $provider->sureScriptsSPI = (string) $value->SPI;
                 $provider->deaNumber = (string) $value->DEANumber;
                 $provider->stateLicenseNumber = (string) $value->StateLicenseNumber;
                 $provider->persist();
                 //ProviderSpecialty, ClinicName
                 $phone = new PhoneNumber();
                 $phone->personId = $provider->personId;
                 $phone->name = 'Primary';
                 $phone->type = 4;
                 $phone->number = str_replace('-', '', (string) $value->PrescriberPhone);
                 $phone->persist();
                 $address = new Address();
                 $address->personId = $provider->personId;
                 $address->name = 'Main';
                 $address->type = 4;
                 $address->active = 1;
                 $address->line1 = (string) $value->ClinicAddressLine1;
                 $address->line2 = (string) $value->ClinicAddressLine2;
                 $address->city = (string) $value->ClinicCity;
                 $address->state = (string) $value->ClinicState;
                 $address->postalCode = (string) $value->ClinicZip;
                 $address->persist();
                 break;
             case 'pharmacy':
                 $pharmacy = new Pharmacy();
                 $pharmacy->NCPDPID = (string) $value->NCPDPID;
                 /*$pharmacy-> = (string)$value->ReferenceQualifier;
                 		$pharmacy-> = (string)$value->PharmacistLastName;
                 		$pharmacy-> = (string)$value->PharmacistFirstName;
                 		$pharmacy-> = (string)$value->PharmacistMiddleName;
                 		$pharmacy-> = (string)$value->PharmacistNamePrefix;
                 		$pharmacy-> = (string)$value->PharmacistNameSuffix;*/
                 $pharmacy->StoreName = (string) $value->PharmacyName;
                 $pharmacy->AddressLine1 = (string) $value->PharmacyAddressLine1;
                 $pharmacy->City = (string) $value->PharmacyCity;
                 $pharmacy->State = (string) $value->PharmacyState;
                 $pharmacy->Zip = (string) $value->PharmacyZip;
                 $pharmacy->PhonePrimary = (string) $value->PharmacyPhone;
                 $pharmacy->persist();
                 break;
             case 'patient':
                 $person = new Person();
                 $person->active = 1;
                 $person->lastName = (string) $value->PatientLastName;
                 $person->firstName = (string) $value->PatientFirstName;
                 $person->middleName = (string) $value->PatientMiddleName;
                 //$person->initials = (string)$value->PatientNamePrefix;
                 $person->identifier = (string) $value->PatientSS;
                 $address = new Address();
                 $address->name = 'Main';
                 $address->type = 4;
                 $address->active = 1;
                 $address->line1 = (string) $value->PatientAddressLine1;
                 $address->line2 = (string) $value->PatientAddressLine2;
                 $address->city = (string) $value->PatientCity;
                 $address->state = (string) $value->PatientState;
                 $address->postalCode = (string) $value->PatientZip;
                 $patient = new Patient();
                 $patient->person = $person;
                 $patient->homeAddress = $address;
                 $patient->persist();
                 $phone = new PhoneNumber();
                 $phone->personId = $patient->personId;
                 $phone->name = 'Primary';
                 $phone->type = 4;
                 $phone->number = str_replace('-', '', (string) $value->PatientPhone);
                 $phone->persist();
                 break;
             case 'medication':
                 break;
         }
     }
     echo 'Done';
     die;
 }
示例#3
0
 public static function loadPharmacy($filename)
 {
     trigger_error('before loading pharmacies: ' . calcTS(), E_USER_NOTICE);
     set_time_limit(300);
     // 5 minutes
     $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . preg_replace('/.*(\\/|\\ee)/', '', $filename);
     $pharmDataTmp = fopen($filename, 'r');
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('pharmacies', array('pharmacyId', 'NCPDPID', 'preferred'));
     $pharmacies = array();
     if ($rows = $db->fetchAll($sqlSelect)) {
         foreach ($rows as $row) {
             $pharmacies[$row['NCPDPID']] = array('pharmacyId' => $row['pharmacyId'], 'preferred' => $row['preferred']);
         }
     }
     fseek($pharmDataTmp, 0);
     $counter = 0;
     while ($line = fgets($pharmDataTmp)) {
         $pharmacy = array();
         $pharmacy['NCPDPID'] = substr($line, 0, 7);
         $pharmacy['StoreNumber'] = substr($line, 7, 35);
         $pharmacy['ReferenceNumberAlt1'] = substr($line, 42, 35);
         $pharmacy['ReferenceNumberAlt1Qualifier'] = substr($line, 77, 3);
         $pharmacy['StoreName'] = substr($line, 80, 35);
         $pharmacy['AddressLine1'] = substr($line, 115, 35);
         $pharmacy['AddressLine2'] = substr($line, 150, 35);
         $pharmacy['City'] = substr($line, 185, 35);
         $pharmacy['State'] = substr($line, 220, 2);
         $pharmacy['Zip'] = substr($line, 222, 11);
         $pharmacy['PhonePrimary'] = substr($line, 233, 25);
         $pharmacy['Fax'] = substr($line, 258, 25);
         $pharmacy['Email'] = substr($line, 283, 80);
         $pharmacy['PhoneAlt1'] = substr($line, 363, 25);
         $pharmacy['PhoneAlt1Qualifier'] = substr($line, 388, 3);
         $pharmacy['PhoneAlt2'] = substr($line, 391, 25);
         $pharmacy['PhoneAlt2Qualifier'] = substr($line, 416, 3);
         $pharmacy['PhoneAlt3'] = substr($line, 419, 25);
         $pharmacy['PhoneAlt3Qualifier'] = substr($line, 444, 3);
         $pharmacy['PhoneAlt4'] = substr($line, 447, 25);
         $pharmacy['PhoneAlt4Qualifier'] = substr($line, 472, 3);
         $pharmacy['PhoneAlt5'] = substr($line, 475, 25);
         $pharmacy['PhoneAlt5Qualifier'] = substr($line, 500, 3);
         $pharmacy['ActiveStartTime'] = substr($line, 503, 22);
         $pharmacy['ActiveEndTime'] = substr($line, 525, 22);
         $pharmacy['ServiceLevel'] = substr($line, 547, 5);
         $pharmacy['PartnerAccount'] = substr($line, 552, 35);
         $pharmacy['LastModifiedDate'] = substr($line, 587, 22);
         $pharmacy['TwentyFourHourFlag'] = substr($line, 609, 1);
         $pharmacy['Available CrossStreet'] = substr($line, 610, 35);
         $pharmacy['RecordChange'] = substr($line, 645, 1);
         $pharmacy['OldServiceLevel'] = substr($line, 646, 5);
         $pharmacy['TextServiceLevel'] = substr($line, 651, 100);
         $pharmacy['TextServiceLevelChange'] = substr($line, 751, 100);
         $pharmacy['Version'] = substr($line, 851, 5);
         $pharmacy['NPI'] = substr($line, 856, 10);
         $data = array();
         foreach ($pharmacy as $key => $value) {
             $data[$key] = trim($value);
         }
         $p = new Pharmacy();
         $p->_shouldAudit = false;
         $p->populateWithArray($data);
         if (isset($pharmacies[$p->NCPDPID])) {
             $p->pharmacyId = $pharmacies[$p->NCPDPID]['pharmacyId'];
             $p->preferred = $pharmacies[$p->NCPDPID]['preferred'];
         }
         //$p->populatePharmacyIdWithNCPDPID();
         $p->persist();
         $counter++;
     }
     fclose($pharmDataTmp);
     unlink($filename);
     trigger_error('Number of rows updated: ' . $counter, E_USER_NOTICE);
     trigger_error('after loading pharmacies: ' . calcTS(), E_USER_NOTICE);
     return $counter;
 }