Esempio n. 1
0
 public static function handlerSSSourceData(Audit $audit)
 {
     $data = array();
     if ($audit->objectClass != 'ESignature') {
         return $data;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication' || !strlen($eSignature->signature) > 0) {
         WebVista::log('esignature is not signed or medication');
         return $data;
     }
     // MEDICATION DATA
     $medication = new Medication();
     $medication->medicationId = (int) $eSignature->objectId;
     $medication->populate();
     if ($medication->transmit != 'ePrescribe' || $medication->isScheduled()) {
         WebVista::log('medication is either scheduled or not an eprescribe');
         return $data;
     }
     WebVista::log('generating source data');
     $data['_audit'] = $audit;
     $uuid = NSDR::create_guid();
     $data['messageId'] = str_replace('-', '', $uuid);
     $data['prescriberOrderNumber'] = $medication->medicationId . '_' . $audit->auditId;
     $data['rxReferenceNumber'] = $medication->rxReferenceNumber;
     WebVista::log('messageId:[' . $data['messageId'] . '] prescriberOrderNumber:[' . $data['prescriberOrderNumber'] . '], rxReferenceNumber:[' . $data['rxReferenceNumber'] . ']');
     $medData = array();
     $medData['description'] = $medication->description;
     $medData['strength'] = $medication->dose;
     $qualifiers = Medication::listQuantityQualifiersMapping();
     $medData['strengthUnits'] = $qualifiers[$medication->quantityQualifier];
     // temporarily set to the same with quantity
     $medData['quantity'] = $medication->quantity;
     $medData['quantityUnits'] = $qualifiers[$medication->quantityQualifier];
     $medData['daysSupply'] = $medication->daysSupply;
     $medData['directions'] = $medication->directions;
     $qualifier = 'R';
     if ($medication->prn) {
         $qualifier = 'PRN';
     }
     $medData['refills'] = $medication->refills;
     $medData['refillsUnits'] = $qualifier;
     $medData['substitutions'] = $medication->substitution ? '0' : '1';
     $writtenDate = date('Ymd', strtotime($medication->datePrescribed));
     if ($medication->datePrescribed == '0000-00-00 00:00:00') {
         $writtenDate = '';
     }
     $medData['writtenDate'] = $writtenDate;
     $medData['productCode'] = $medication->hipaaNDC;
     $medData['productQualifier'] = 'ND';
     $medData['dosageForm'] = DataTables::getDosageForm($medication->chmedDose);
     $medData['drugDBCode'] = $medication->pkey;
     $medData['drugDBQualifier'] = '';
     //'pkey'; valid options: "E|G|FG|FS|MC|MD|MG|MM"
     $medData['note'] = $medication->comment;
     $data['Medication'] = $medData;
     WebVista::log('medication data: ' . print_r($medData, true));
     // PHARMACY DATA
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $medication->pharmacyId;
     $pharmacy->populate();
     $pharmacyData = array();
     $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID;
     $pharmacyData['fileId'] = $pharmacy->pharmacyId;
     $pharmacyData['NPI'] = $pharmacy->NPI;
     $pharmacyData['storeName'] = $pharmacy->StoreName;
     $pharmacyData['storeNumber'] = $pharmacy->StoreNumber;
     $pharmacyData['email'] = $pharmacy->Email;
     $pharmacyData['twentyFourHourFlag'] = $pharmacy->TwentyFourHourFlag;
     $pharmacyData['crossStreet'] = $pharmacy->CrossStreet;
     $pharmacyData['addressLine1'] = $pharmacy->AddressLine1;
     $pharmacyData['addressLine2'] = $pharmacy->AddressLine2;
     $pharmacyData['city'] = $pharmacy->City;
     $pharmacyData['state'] = $pharmacy->State;
     $pharmacyData['zip'] = $pharmacy->Zip;
     $phones = array();
     $phones[] = array('number' => $pharmacy->PhonePrimary, 'type' => 'TE');
     $phones[] = array('number' => $pharmacy->Fax, 'type' => 'FX');
     $phones[] = array('number' => $pharmacy->PhoneAlt1, 'type' => $pharmacy->PhoneAlt1Qualifier);
     $phones[] = array('number' => $pharmacy->PhoneAlt2, 'type' => $pharmacy->PhoneAlt2Qualifier);
     $phones[] = array('number' => $pharmacy->PhoneAlt3, 'type' => $pharmacy->PhoneAlt3Qualifier);
     $phones[] = array('number' => $pharmacy->PhoneAlt4, 'type' => $pharmacy->PhoneAlt4Qualifier);
     $phones[] = array('number' => $pharmacy->PhoneAlt5, 'type' => $pharmacy->PhoneAlt5Qualifier);
     $pharmacyData['phones'] = $phones;
     $data['Pharmacy'] = $pharmacyData;
     WebVista::log('pharmacy data: ' . print_r($pharmacyData, true));
     // PRESCRIBER DATA
     $provider = new Provider();
     $provider->personId = $medication->prescriberPersonId;
     $provider->populate();
     $prescriberData = array();
     $prescriberData['DEANumber'] = $provider->deaNumber;
     // it has conflicts with DEANumber
     //$prescriberData['stateLicenseNumber'] = $provider->stateLicenseNumber;
     $prescriberData['fileId'] = $provider->personId;
     $prescriberData['clinicName'] = '';
     $identifierType = $provider->identifierType;
     if (strlen($identifierType) > 0) {
         //	$prescriberData[$identifierType] = $provider->identifier;
     }
     $prescriberData['lastName'] = $provider->person->lastName;
     $prescriberData['firstName'] = $provider->person->firstName;
     $prescriberData['middleName'] = $provider->person->middleName;
     $prescriberData['suffix'] = $provider->person->suffix;
     $prescriberData['prefix'] = '';
     $prescriberData['email'] = $provider->person->email;
     $prescriberData['specialtyCode'] = $provider->specialty;
     $specialtyQualifier = '';
     if (strlen($provider->specialty) > 0) {
         $specialtyQualifier = 'AM';
     }
     $prescriberData['specialtyQualifier'] = $specialtyQualifier;
     $building = Building::getBuildingDefaultLocation((int) $provider->personId);
     $ePrescriber = new EPrescriber();
     $ePrescriber->providerId = (int) $provider->personId;
     $ePrescriber->buildingId = (int) $building->buildingId;
     $ePrescriber->populateWithBuildingProvider();
     $prescriberData['SPI'] = $ePrescriber->SSID;
     $prescriberData['addressLine1'] = $building->line1;
     $prescriberData['addressLine2'] = $building->line2;
     $prescriberData['city'] = $building->city;
     $prescriberData['state'] = $building->state;
     $prescriberData['zip'] = $building->zipCode;
     $prescriberData['phones'] = $building->phoneNumbers;
     $data['Prescriber'] = $prescriberData;
     WebVista::log('prescriber data: ' . print_r($prescriberData, true));
     // PATIENT DATA
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $patientData = array();
     $patientData['lastName'] = $patient->person->lastName;
     $patientData['firstName'] = $patient->person->firstName;
     $patientData['middleName'] = $patient->person->middleName;
     $patientData['suffix'] = $patient->person->suffix;
     $patientData['prefix'] = '';
     $patientData['email'] = $patient->person->email;
     $patientData['fileId'] = $patient->recordNumber;
     $patientData['medicareNumber'] = '';
     // TODO: to be implemented
     $identifierType = $patient->identifierType;
     if (strlen($identifierType) > 0) {
         $patientData[$identifierType] = $patient->identifier;
     }
     $patientData['gender'] = $patient->person->getDisplayGender();
     $dateOfBirth = date('Ymd', strtotime($patient->person->dateOfBirth));
     if ($patient->person->dateOfBirth == '0000-00-00') {
         $dateOfBirth = '';
     }
     $patientData['dateOfBirth'] = $dateOfBirth;
     $address = new Address();
     $address->personId = $patient->personId;
     $addressIterator = $address->getIteratorByPersonId();
     foreach ($addressIterator as $address) {
         break;
         // retrieves the top address
     }
     $patientData['addressLine1'] = $address->line1;
     $patientData['addressLine2'] = $address->line2;
     $patientData['city'] = $address->city;
     $patientData['state'] = $address->state;
     $patientData['zip'] = $address->zipCode;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $patient->personId;
     $patientData['phones'] = $phoneNumber->phoneNumbers;
     $data['Patient'] = $patientData;
     WebVista::log('patient data: ' . print_r($patientData, true));
     // CHECK for attending/supervisor
     $attendingId = (int) TeamMember::getAttending($patient->teamId);
     $building = Building::getBuildingDefaultLocation($attendingId);
     $ePrescriber = new EPrescriber();
     $ePrescriber->providerId = $attendingId;
     $ePrescriber->buildingId = (int) $building->buildingId;
     $ePrescriber->populateWithBuildingProvider();
     if ($attendingId > 0 && strlen($ePrescriber->SSID) > 0) {
         // SUPERVISOR
         $provider = new Provider();
         $provider->personId = $attendingId;
         $provider->populate();
         $supervisorData = array();
         $supervisorData['DEANumber'] = $provider->deaNumber;
         $supervisorData['SPI'] = $ePrescriber->SSID;
         // it has conflicts with DEANumber
         //$supervisorData['stateLicenseNumber'] = $provider->stateLicenseNumber;
         $supervisorData['fileId'] = $provider->personId;
         $supervisorData['clinicName'] = '';
         $identifierType = $provider->identifierType;
         if (strlen($identifierType) > 0) {
             //	$prescriberData[$identifierType] = $provider->identifier;
         }
         $phoneNumber = new PhoneNumber();
         $phoneNumber->personId = $provider->personId;
         $supervisorData['phones'] = $phoneNumber->phoneNumbers;
         $supervisorData['lastName'] = $provider->person->lastName;
         $supervisorData['firstName'] = $provider->person->firstName;
         $supervisorData['middleName'] = $provider->person->middleName;
         $supervisorData['suffix'] = $provider->person->suffix;
         $supervisorData['prefix'] = '';
         $supervisorData['email'] = $provider->person->email;
         $supervisorData['specialtyCode'] = $provider->specialty;
         $specialtyQualifier = '';
         if (strlen($provider->specialty) > 0) {
             $specialtyQualifier = 'AM';
         }
         $supervisorData['specialtyQualifier'] = $specialtyQualifier;
         $supervisorData['addressLine1'] = $building->line1;
         $supervisorData['addressLine2'] = $building->line2;
         $supervisorData['city'] = $building->city;
         $supervisorData['state'] = $building->state;
         $supervisorData['zip'] = $building->zipCode;
         $supervisorData['phones'] = $building->phoneNumbers;
         $data['Supervisor'] = $supervisorData;
         WebVista::log('supervisor data: ' . print_r($supervisorData, true));
     }
     return $data;
 }
Esempio n. 2
0
 public static function pull()
 {
     $ch = curl_init();
     $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL;
     $ePrescribeURL .= 'ss-manager.raw/pull-inbounds?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey;
     curl_setopt($ch, CURLOPT_URL, $ePrescribeURL);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $output = curl_exec($ch);
     $error = '';
     $ret = 0;
     if (!curl_errno($ch)) {
         try {
             $xml = new SimpleXMLElement($output);
             foreach ($xml->data as $messages) {
                 foreach ($messages as $key => $message) {
                     $rawMessage = base64_decode((string) $message->rawMessage);
                     if ($key == 'refillRequest') {
                         $messageId = (string) $message->messageId;
                         $rxReferenceNumber = (string) $message->rxReferenceNumber;
                         $prescriberOrderNumber = (string) $message->prescriberOrderNumber;
                         $auditId = 0;
                         $medicationId = 0;
                         $xmlMessage = new SimpleXMLElement($rawMessage);
                         $lastName = (string) $xmlMessage->Body->RefillRequest->Patient->Name->LastName;
                         $firstName = (string) $xmlMessage->Body->RefillRequest->Patient->Name->FirstName;
                         $messageInfo = ' for ' . $lastName . ', ' . $firstName;
                         $description = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->DrugDescription;
                         $datePrescribed = date('m/d/Y', strtotime((string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->WrittenDate));
                         $messageInfo .= ' - ' . $description . ' #' . $datePrescribed;
                         if (strlen($prescriberOrderNumber) > 0) {
                             // currently check for medicationId using the prescriberOrderNumber medication_audit
                             $medAudit = explode('_', $prescriberOrderNumber);
                             $medicationId = (int) $medAudit[0];
                             $auditId = isset($medAudit[1]) ? (int) $medAudit[1] : 0;
                         }
                         $medication = new Medication();
                         $medication->medicationId = $medicationId;
                         $medication->populate();
                         $patientId = (int) $medication->personId;
                         $unresolved = 0;
                         // retrieve providerId using SPI
                         $SPI = (string) $xmlMessage->Body->RefillRequest->Prescriber->Identification->SPI;
                         $eprescriber = new EPrescriber();
                         $eprescriber->populateBySPI($SPI);
                         $providerId = (int) $eprescriber->providerId;
                         if (!$patientId > 0) {
                             // PON not set or invalid PON, try to automatch based on name, dob, medication and dates in the refreq, if only one match automatically link with correct PON
                             // retrieve pharmacyId using NCPDPID
                             $NCPDPID = (string) $xmlMessage->Body->RefillRequest->Pharmacy->Identification->NCPDPID;
                             $pharmacy = new Pharmacy();
                             $pharmacy->NCPDPID = $NCPDPID;
                             $pharmacy->populatePharmacyIdWithNCPDPID();
                             $pharmacyId = (string) $pharmacy->pharmacyId;
                             $gender = (string) $xmlMessage->Body->RefillRequest->Patient->Gender;
                             $dob = (string) $xmlMessage->Body->RefillRequest->Patient->DateOfBirth;
                             // retrieve patientId using LastName, FirstName, Gender and DOB
                             $db = Zend_Registry::get('dbAdapter');
                             $sqlSelect = $db->select()->from('person', 'person_id')->where('last_name = ?', $lastName)->where('first_name = ?', $firstName)->where('date_of_birth = ?', date('Y-m-d', strtotime($dob)))->limit(1);
                             if ($row = $db->fetchRow($sqlSelect)) {
                                 $patientId = $row['person_id'];
                             }
                             //trigger_error($sqlSelect->__toString());
                             // $qualifiers = Medication::listQuantityQualifiersMapping(); TODO: since qualifier are ambiguous, temporarily not to use this qualifier
                             $quantity = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->Quantity->Value;
                             $sqlSelect = $db->select()->from('medications')->where('description = ?', $description)->where('quantity = ?', $quantity)->where('personId = ?', (int) $patientId)->where('prescriberPersonId = ?', (int) $providerId)->where('pharmacyId = ?', (int) $pharmacyId);
                             $writtenDate = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->WrittenDate;
                             if (strlen($writtenDate) > 0) {
                                 $sqlSelect->where('datePrescribed LIKE ?', date('Y-m-d', strtotime($writtenDate)) . '%');
                             }
                             $medicationMatched = false;
                             //trigger_error($sqlSelect->__toString());
                             $rows = $db->fetchAll($sqlSelect);
                             if (count($rows) == 1) {
                                 $medication = new Medication();
                                 $medication->populateWithArray($rows[0]);
                                 $medicationId = $medication->medicationId;
                                 $auditId = Medication::getAuditId($medicationId);
                                 if ($auditId > 0) {
                                     $xmlMessage->Body->RefillRequest->PrescriberOrderNumber = $medicationId . '_' . $auditId;
                                     $rawMessage = $xmlMessage->asXML();
                                 }
                                 //trigger_error($sqlSelect->__toString());
                                 $medicationMatched = true;
                             }
                             $messageInfo = ' (Invalid/Missing PON';
                             if ($patientId > 0 && $medicationMatched) {
                                 $patient = new Patient();
                                 $patient->personId = $patientId;
                                 $patient->populate();
                                 $messageInfo .= ' - automatched to \'' . $patient->displayName . '\' MRN#' . $patient->recordNumber;
                             } else {
                                 $unresolved = 1;
                             }
                             $messageInfo .= ')';
                         }
                         $refillRequest = new MedicationRefillRequest();
                         $refillRequest->messageId = $messageId;
                         $refillRequest->medicationId = $medicationId;
                         $refillRequest->action = '';
                         $refillRequest->status = '';
                         $refillRequest->dateStart = '';
                         $refillRequest->details = 'Re: ' . $rxReferenceNumber;
                         $refillRequest->dateTime = date('Y-m-d H:i:s');
                         // disable audits autoprocess, this was set at CHProcessingDaemon
                         $processedAudits = Audit::$_processedAudits;
                         Audit::$_processedAudits = false;
                         $refillRequest->persist();
                         Audit::$_processedAudits = $processedAudits;
                         $messaging = new Messaging();
                         $messaging->messagingId = $messageId;
                         $messaging->populate();
                         $messaging->messageType = 'RefillRequest';
                         $messaging->objectId = $refillRequest->messageId;
                         $messaging->objectClass = 'MedicationRefillRequest';
                         $messaging->note = 'Refill request received - Re:' . $rxReferenceNumber . $messageInfo;
                         $messaging->auditId = $auditId;
                         $messaging->refills = (string) $message->refills;
                         $messaging->personId = $patientId;
                         $messaging->providerId = $providerId;
                         $messaging->unresolved = $unresolved;
                     } else {
                         if ($key == 'status') {
                             $relatesToMessageId = (string) $message->relatesToMessageId;
                             $messageId = (string) $message->messageId;
                             $code = (string) $message->code;
                             $description = (string) $message->description;
                             $messaging = new Messaging();
                             $messaging->messageType = 'Status';
                             $messaging->note = 'Status received for unknown messageId: ' . $relatesToMessageId;
                             $tmpMsg = new Messaging();
                             $tmpMsg->messagingId = $relatesToMessageId;
                             if ($tmpMsg->populate()) {
                                 // populate for newRx details
                                 $tmpMsg->status = 'Sent and Verified';
                                 $x = explode('(', $tmpMsg->note);
                                 $tmpMsg->note = 'newRx';
                                 if ($tmpMsg->objectClass == 'MedicationRefillResponse') {
                                     $tmpMsg->note = 'Refill response';
                                 }
                                 $tmpMsg->note .= ' sent and verified';
                                 if (isset($x[1])) {
                                     unset($x[0]);
                                     $tmpMsg->note .= ' (' . implode('(', $x);
                                 }
                                 $tmpMsg->unresolved = 0;
                                 $tmpMsg->persist();
                                 $messaging->auditId = $tmpMsg->auditId;
                                 $messaging->objectId = $tmpMsg->objectId;
                                 $messaging->objectClass = $tmpMsg->objectClass;
                                 $messaging->personId = $tmpMsg->personId;
                                 $messaging->providerId = $tmpMsg->providerId;
                                 $xmlTmpMessage = new SimpleXMLElement($tmpMsg->rawMessage);
                                 $lastName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->LastName;
                                 $firstName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->FirstName;
                                 $messageInfo = $lastName . ', ' . $firstName;
                                 $drugDescription = (string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->DrugDescription;
                                 $datePrescribed = date('m/d/Y', strtotime((string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->WrittenDate));
                                 $messageInfo .= ' - ' . $drugDescription . ' #' . $datePrescribed;
                                 $messaging->note = 'Status received for ' . $messageInfo;
                             }
                             $messaging->note .= "\n" . $code . ':' . $description;
                         } else {
                             if ($key == 'error') {
                                 $relatesToMessageId = (string) $message->relatesToMessageId;
                                 $messageId = (string) $message->messageId;
                                 $code = (string) $message->code;
                                 $description = (string) $message->description;
                                 $messaging = new Messaging();
                                 $messaging->messageType = 'Error';
                                 $messaging->note = 'Error received for unknown messageId: ' . $relatesToMessageId;
                                 $tmpMsg = new Messaging();
                                 $tmpMsg->messagingId = $relatesToMessageId;
                                 if ($tmpMsg->populate()) {
                                     // populate for newRx details
                                     $tmpMsg->status = 'Sent and Verified';
                                     $x = explode('(', $tmpMsg->note);
                                     $tmpMsg->note = 'newRx';
                                     if ($tmpMsg->objectClass == 'MedicationRefillResponse') {
                                         $tmpMsg->note = 'Refill response';
                                     }
                                     $tmpMsg->note .= ' sent and verified';
                                     if (isset($x[1])) {
                                         unset($x[0]);
                                         $tmpMsg->note .= ' (' . implode('(', $x);
                                     }
                                     $tmpMsg->unresolved = 0;
                                     $tmpMsg->persist();
                                     $messaging->auditId = $tmpMsg->auditId;
                                     $messaging->objectId = $tmpMsg->objectId;
                                     $messaging->objectClass = $tmpMsg->objectClass;
                                     $messaging->personId = $tmpMsg->personId;
                                     $messaging->providerId = $tmpMsg->providerId;
                                     $xmlTmpMessage = new SimpleXMLElement($tmpMsg->rawMessage);
                                     $lastName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->LastName;
                                     $firstName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->FirstName;
                                     $messageInfo = $lastName . ', ' . $firstName;
                                     $drugDescription = (string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->DrugDescription;
                                     $datePrescribed = date('m/d/Y', strtotime((string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->WrittenDate));
                                     $messageInfo .= ' - ' . $drugDescription . ' #' . $datePrescribed;
                                     $messaging->note = 'Error received for ' . $messageInfo;
                                 }
                                 $messaging->note .= "\n" . $code . ':' . $description;
                             } else {
                                 continue;
                             }
                         }
                     }
                     $messaging->rawMessage = $rawMessage;
                     $messaging->rawMessageResponse = base64_decode((string) $message->rawMessageResponse);
                     $messaging->status = 'Received';
                     $messaging->dateStatus = date('Y-m-d H:i:s');
                     $messaging->persist();
                     $ret++;
                 }
             }
             if ($ret > 0) {
                 self::sendPullResponse();
             }
         } catch (Exception $e) {
             $error = __('There was an error, the response couldn\'t be parsed as XML: ' . $output);
             trigger_error($error, E_USER_NOTICE);
         }
     } else {
         $error = __('There was an error connecting to HealthCloud. Please try again or contact the system administrator.');
         trigger_error('Curl error connecting to healthcare: ' . curl_error($ch), E_USER_NOTICE);
     }
     curl_close($ch);
     return $ret;
 }
Esempio n. 3
0
 protected function _checkCurrentLocation(Medication $medication)
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $personId = (int) $identity->personId;
     $building = Building::getBuildingDefaultLocation($personId);
     $ret = false;
     if ($building->buildingId > 0) {
         $eprescriber = new EPrescriber();
         $eprescriber->populateWithBuildingProvider((int) $building->buildingId, $personId);
         $location = 'for location: ' . $building->practice->name . '->' . $building->name;
         $err = $medication->summary . ' could not be signed because: ';
         if (!strlen($eprescriber->SSID) > 0) {
             $ret = $err . 'Medication will be ePrescribed and you do not have an SPI ' . $location;
         } else {
             $tmp = array();
             $line1Len = strlen($building->line1);
             if (!$line1Len > 0 || $line1Len > 35) {
                 $tmp[] = 'Address line1 field must be supplied and not more than 35 characters';
             }
             $line2Len = strlen($building->line2);
             if ($line2Len > 0 && $line2Len > 35) {
                 $tmp[] = 'Address line2 must not be more than 35 characters';
             }
             $cityLen = strlen($building->city);
             if (!$cityLen > 0 || $cityLen > 35) {
                 $tmp[] = 'Address city field must be supplied and not more than 35 characters';
             }
             if (strlen($building->state) != 2) {
                 $tmp[] = 'Address state field must be supplied and not more than 2 characters';
             }
             $zipCodeLen = strlen($building->zipCode);
             if ($zipCodeLen != 5 && $zipCodeLen != 9) {
                 $tmp[] = 'Address zipcode must be supplied and must be 5 or 9 digit long';
             }
             $phoneNumber = PhoneNumber::autoFixNumber($building->phoneNumber);
             $fax = PhoneNumber::autoFixNumber($building->fax);
             if (strlen($phoneNumber) < 11) {
                 $tmp[] = 'Phone number \'' . $phoneNumber . '\' is invalid';
             }
             $faxLen = strlen($fax);
             if ($faxLen > 0 && $faxLen < 11) {
                 $tmp[] = 'Fax number \'' . $fax . '\' is invalid';
             }
             if (count($tmp) > 0) {
                 $ret = $err . "\n" . implode("\n", $tmp) . ' ' . $location;
             }
         }
     } else {
         $ret = $medication->summary . ' could not be signed because: Medication will be ePrescribed and you do not have a default location.';
     }
     return $ret;
 }
 public function processSyncAllLocationAction()
 {
     $providerId = (int) $this->_getParam('providerId');
     $prescriber = new EPrescriber();
     $prescriberIterator = $prescriber->getIteratorByProviderId($providerId);
     $data = array();
     $data['error'] = array();
     $data['SSID'] = array();
     $prescribers = array();
     foreach ($prescriberIterator as $p) {
         $prescribers[] = $p;
         $result = $p->ssCheck();
         if ($result !== true) {
             $data['error'][] = '*)' . $p->building->name . ': ' . $result;
         }
     }
     if (!isset($data['error'][0])) {
         foreach ($prescribers as $p) {
             $result = $this->_syncLocation($p);
             if ($result !== true) {
                 $data['error'][] = '*)' . $p->building->name . ': ' . $result;
             } else {
                 $data['SSID'][$p->ePrescriberId] = $p->SSID;
             }
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }