public function importUsersAction() { exit; $f = fopen('/tmp/newusers.csv', 'r'); $counter = 0; while (($data = fgetcsv($f)) !== FALSE) { if ($counter == 0) { $counter++; continue; } echo $data[4] . "<br />"; $user = new User(); $user->username = $data[0]; $user->password = $data[1]; //$user->passphrase = $data[2]; $user->person->firstName = $data[3]; $user->person->lastName = $data[4]; $user->person->middleName = $data[5]; $user->person->defaultIdentifier = $data[6]; $user->person->defaultIdentifierType = $data[7]; $user->persist(); //$user->person->persist(); if ($data[8] == "PROVIDER") { $provider = new Provider(); $provider->personId = $user->person->personId; $provider->type = "MD"; $provider->providerIdentifier = $data[6]; $provider->providerIdentifierType = $data[7]; $provider->persist(); } elseif ($data[8] == "STAFF") { // } elseif ($data[8] == "ADMIN") { // } //echo $user->toString(); echo $data[11] . "\n"; $counter++; } fclose($f); exit; }
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; }
public function addProcessAction() { $dateActiveStart = strtotime($this->_getParam('dateActiveStart')); $dateActiveEnd = strtotime($this->_getParam('dateActiveEnd')); $serviceLevel = (int) $this->_getParam('serviceLevel'); $personId = (int) $this->_getParam('personId'); $provider = new Provider(); $provider->person_id = $personId; $provider->populate(); $provider->serviceLevel = $serviceLevel; if ($dateActiveStart > 0 && $dateActiveEnd > 0) { $provider->dateActiveStart = date('Y-m-d H:i:s', $dateActiveStart); $provider->dateActiveEnd = date('Y-m-d H:i:s', $dateActiveEnd); } $person = new Person(); $person->person_id = $personId; $person->populate(); $address = new Address(); $address->person_id = $personId; $address->populateWithPersonId($personId); $phoneNumber = new PhoneNumber(); $phoneNumber->person_id = $personId; $phoneNumber->populateWithType(4); $practice = new Practice(); $practice->practiceId = $person->primaryPracticeId; $practice->populate(); $data = array(); $data['deaNumber'] = $provider->deaNumber; $data['stateLicenseNumber'] = $provider->stateLicenseNumber; //$data['portalId'] = Zend_Registry::get('config')->sureScripts->portalId; //$data['accountId'] = Zend_Registry::get('config')->sureScripts->accountId; $data['clinicName'] = '' . $practice->name; $data['lastName'] = $person->last_name; $data['firstName'] = $person->first_name; $address = new Address(); $address->personId = $provider->personId; $address->populateWithType(4); $data['addressLine1'] = $address->line1; $data['addressLine2'] = $address->line2; $data['addressCity'] = $address->city; $data['addressState'] = $address->state; $data['addressZipCode'] = $address->zipCode; $data['email'] = $person->email; $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $provider->personId; /* $phoneNumberIterator = $phoneNumber->getIteratorByPatientId(); $phones = array(); foreach ($phoneNumberIterator as $number) { if (!strlen($number->number) > 0) continue; // SS Type options: BN - Beeper, CP - Cellular, FX - Fax, HP - Home, NP - Night, TE – Telephone*, WP – Work $type = ''; switch ($number->type) { case PhoneNumber::TYPE_HOME: $type = 'HP'; case PhoneNumber::TYPE_WORK: $type = 'WP'; break; case PhoneNumber::TYPE_MOBILE: $type = 'CP'; break; case PhoneNumber::TYPE_FAX: $type = 'FX'; break; case PhoneNumber::TYPE_EMERGENCY: case PhoneNumber::TYPE_EMPLOYER: case PhoneNumber::TYPE_BILLING: $type = 'TE'; break; default: continue; } $phones[$type] = array('number'=>$number->number,'type'=>$type); } $te = null; if (isset($phones['TE'])) { $te = $phones['TE']; unset($phones['TE']); } $fx = null; if (isset($phones['FX'])) { $fx = $phones['FX']; unset($phones['FX']); } if ($te === null) { if (count($phones) > 0) { $te = array_unshift($phones); } else if ($fx !== null) { $te = $fx; } } if ($fx === null) { if (count($phones) > 0) { $fx = array_unshift($phones); } else if ($te !== null) { $fx = $te; } } $data['phones'] = array(); if ($te !== null) { $data['phones'][] = $te; } if ($fx !== null) { $data['phones'][] = $fx; } foreach ($phones as $p) { $data['phones'][] = $p; } */ $data['phones'] = $phoneNumber->phoneNumbers; /*$phoneNumbers = $phoneNumber->phoneNumbers; $fax = ''; if (isset($phoneNumbers['FAX'])) { $fax = $phoneNumbers['FAX']; unset($phoneNumbers['FAX']); } $phone = $fax; if (count($phoneNumbers) > 0) { $phone = array_pop($phoneNumbers); } $data['phoneNumber'] = $phone; $data['faxNumber'] = $fax;*/ $data['specialtyCode'] = $provider->specialty; $specialtyQualifier = ''; if (strlen($provider->specialty) > 0) { $specialtyQualifier = 'AM'; } $data['specialtyQualifier'] = $specialtyQualifier; $data['serviceLevel'] = $provider->serviceLevel; $now = strtotime('now'); $days30 = strtotime('+30 days', $now); $activeStartTime = gmdate("Y-m-d\\TH:i:s.0", $now) . 'Z'; $activeEndTime = gmdate("Y-m-d\\TH:i:s.0", $days30) . 'Z'; $data['activeStartTime'] = $provider->dateActiveStartZ; $data['activeEndTime'] = $provider->dateActiveEndZ; $dateActiveEnd = strtotime(date('Y-m-d', strtotime($provider->dateActiveEndZ))); if ($dateActiveEnd <= strtotime(date('Y-m-d'))) { // to disable a prescriber ActiveEndTime must be set to current date and ServiceLevel must be set to zero. $data['activeEndTime'] = date('Y-m-d'); $data['serviceLevel'] = 0; $provider->serviceLevel = 0; } $provider->persist(); $identifierType = $provider->identifierType; if (strlen($identifierType) > 0) { $data[$identifierType] = $provider->identifier; } /* foreach ($data as $k=>$v) { if (!strlen(trim($v)) > 0) { $tmp = ' '; if ($k == 'addressState') { $tmp = 'AZ'; } if ($k == 'addressZipCode') { $tmp = '12345'; } $data[$k] = $tmp; } }*/ $messaging = new Messaging(); //$messaging->messagingId = ''; $type = 'add'; $messaging->messageType = 'AddPrescriber'; if (strlen($provider->sureScriptsSPI) > 0) { $messaging->messageType = 'UpdatePrescriber'; $data['SPI'] = $provider->sureScriptsSPI; $type = 'update'; } $messaging->populate(); //$messaging->objectId = ''; //$messaging->objectClass = ''; $messaging->status = 'Sending'; $messaging->note = 'Sending prescriber data'; $messaging->dateStatus = date('Y-m-d H:i:s'); //$messaging->auditId = ''; $messaging->persist(); $query = http_build_query(array('type' => $type, 'data' => $data)); $ch = curl_init(); $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL; $ePrescribeURL .= 'ss-manager.raw/edit-prescriber?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey; curl_setopt($ch, CURLOPT_URL, $ePrescribeURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); 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); trigger_error('OUTPUT: ' . $output, E_USER_NOTICE); $error = ""; $prescriberSPI = ''; $messaging->status = 'Sent'; $messaging->note = 'Prescriber data sent'; if (!curl_errno($ch)) { try { $responseXml = simplexml_load_string($output); if (isset($responseXml->error)) { $errorCode = (string) $responseXml->error->code; $errorMsg = (string) $responseXml->error->message; if (isset($responseXml->error->errorCode)) { $errorCode = (string) $responseXml->error->errorCode; } if (isset($responseXml->error->errorMsg)) { $errorMsg = (string) $responseXml->error->errorMsg; } $error = $errorMsg; trigger_error('There was an error enabling an ePresciber, Error code: ' . $errorCode . ' Error Message: ' . $errorMsg, E_USER_NOTICE); } elseif (isset($responseXml->data)) { $xml = new SimpleXMLElement($responseXml->data); $prescriber = $xml->AddPrescriberResponse->Prescriber; if (isset($xml->AddPrescriberLocationResponse)) { $prescriber = $xml->AddPrescriberLocationResponse->Prescriber; } $prescriberSPI = (string) $prescriber->Identification->SPI; } if (isset($responseXml->rawMessage)) { $messaging->rawMessage = base64_decode((string) $responseXml->rawMessage); $messaging->rawMessageResponse = base64_decode((string) $responseXml->rawMessageResponse); } } catch (Exception $e) { $error = __("There was an error connecting to HealthCloud to enable ePrescribing for this provider. Please try again or contact the system administrator."); trigger_error("There was an error enabling an ePresciber, the response couldn't be parsed as XML: " . $output, E_USER_NOTICE); } } else { $error = __("There was an error connecting to HealthCloud to enable ePrescribing for this provider. Please try again or contact the system administrator."); trigger_error("Curl error connecting to healthcare enabled an ePrescribe record: " . curl_error($ch), E_USER_NOTICE); } curl_close($ch); if (strlen($error) > 0) { $messaging->status = 'Error'; $messaging->note = $error; $ret = false; } if ($messaging->resend) { $messaging->resend = 0; } $messaging->retries++; $messaging->dateStatus = date('Y-m-d H:i:s'); $messaging->persist(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $this->view->error = $error; if (strlen($error) > 0) { //$this->getResponse()->setHttpResponseCode(500); $json->direct(array('error' => $error)); return; } if ($type == 'add') { $provider->sureScriptsSPI = trim($prescriberSPI); $provider->persist(); } else { $prescriberSPI = $provider->sureScriptsSPI; } $this->view->message = "ePrescribing Information Saved for Provider, assigned SPI Number: " . $prescriberSPI; $this->view->prescriberSPI = $prescriberSPI; $json->direct(array('message' => $this->view->message, 'prescriberSPI' => $prescriberSPI, 'error' => $error)); }
protected function _syncLocation(EPrescriber $ePrescriber) { $ret = true; $dateActiveStart = strtotime($ePrescriber->dateActiveStart); $dateActiveEnd = strtotime($ePrescriber->dateActiveEnd); $serviceLevel = (int) $ePrescriber->serviceLevel; $personId = (int) $ePrescriber->providerId; $provider = new Provider(); $provider->personId = $personId; $provider->populate(); $provider->serviceLevel = $serviceLevel; if ($dateActiveStart > 0 && $dateActiveEnd > 0) { $provider->dateActiveStart = date('Y-m-d H:i:s', $dateActiveStart); $provider->dateActiveEnd = date('Y-m-d H:i:s', $dateActiveEnd); } $person = new Person(); $person->personId = $personId; $person->populate(); $practice = new Practice(); $practice->practiceId = $person->primaryPracticeId; $practice->populate(); $data = array(); $data['deaNumber'] = $provider->deaNumber; $data['stateLicenseNumber'] = $provider->stateLicenseNumber; //$data['portalId'] = Zend_Registry::get('config')->sureScripts->portalId; //$data['accountId'] = Zend_Registry::get('config')->sureScripts->accountId; $data['clinicName'] = '' . $practice->name; $data['lastName'] = $person->lastName; $data['firstName'] = $person->firstName; $address = $ePrescriber->building; $data['addressLine1'] = $address->line1; $data['addressLine2'] = $address->line2; $data['addressCity'] = $address->city; $data['addressState'] = $address->state; $data['addressZipCode'] = $address->zipCode; $data['email'] = $person->email; $data['phones'] = array(array('number' => PhoneNumber::autoFixNumber($address->phoneNumber), 'type' => 'TE'), array('number' => PhoneNumber::autoFixNumber($address->fax), 'type' => 'FX')); $data['specialtyCode'] = $provider->specialty; $specialtyQualifier = ''; if (strlen($provider->specialty) > 0) { $specialtyQualifier = 'AM'; } $data['specialtyQualifier'] = $specialtyQualifier; $data['serviceLevel'] = $provider->serviceLevel; $now = strtotime('now'); $days30 = strtotime('+30 days', $now); $activeStartTime = gmdate("Y-m-d\\TH:i:s.0", $now) . 'Z'; $activeEndTime = gmdate("Y-m-d\\TH:i:s.0", $days30) . 'Z'; $data['activeStartTime'] = $provider->dateActiveStartZ; $data['activeEndTime'] = $provider->dateActiveEndZ; $dateActiveEnd = strtotime(date('Y-m-d', strtotime($provider->dateActiveEndZ))); if ($dateActiveEnd <= strtotime(date('Y-m-d'))) { // to disable a prescriber ActiveEndTime must be set to current date and ServiceLevel must be set to zero. $data['activeEndTime'] = date('Y-m-d'); $data['serviceLevel'] = 0; $provider->serviceLevel = 0; } $provider->persist(); $identifierType = $provider->identifierType; if (strlen($identifierType) > 0) { $data[$identifierType] = $provider->identifier; } $messaging = new Messaging(); //$messaging->messagingId = ''; $type = 'add'; $messaging->messageType = 'AddPrescriber'; if (strlen($ePrescriber->SSID) > 0) { $messaging->messageType = 'UpdatePrescriber'; $data['SPI'] = $ePrescriber->SSID; $type = 'update'; } else { if (strlen($provider->sureScriptsSPI) > 0) { $messaging->messageType = 'AddPrescriberLocation'; $data['SPI'] = substr($provider->sureScriptsSPI, 0, -3); $type = 'addLocation'; } } // backupPortalId must be supplied if type is updateLocation $messaging->populate(); //$messaging->objectId = ''; //$messaging->objectClass = ''; $messaging->status = 'Sending'; $messaging->note = 'Sending prescriber data'; $messaging->dateStatus = date('Y-m-d H:i:s'); //$messaging->auditId = ''; $messaging->persist(); $query = http_build_query(array('type' => $type, 'data' => $data)); $ch = curl_init(); $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL; $ePrescribeURL .= 'ss-manager.raw/edit-prescriber?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey; curl_setopt($ch, CURLOPT_URL, $ePrescribeURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); 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); trigger_error('OUTPUT: ' . $output, E_USER_NOTICE); $error = ""; $prescriberSPI = ''; $messaging->status = 'Sent'; $messaging->note = 'Prescriber data sent'; if (!curl_errno($ch)) { try { $responseXml = simplexml_load_string($output); if (isset($responseXml->error)) { $errorCode = (string) $responseXml->error->code; $errorMsg = (string) $responseXml->error->message; if (isset($responseXml->error->errorCode)) { $errorCode = (string) $responseXml->error->errorCode; } if (isset($responseXml->error->errorMsg)) { $errorMsg = (string) $responseXml->error->errorMsg; } $error = $errorMsg; trigger_error('There was an error enabling an ePresciber, Error code: ' . $errorCode . ' Error Message: ' . $errorMsg, E_USER_NOTICE); } elseif (isset($responseXml->data)) { $xml = new SimpleXMLElement($responseXml->data); $prescriber = $xml->AddPrescriberResponse->Prescriber; //if ($type == 'addLocation') { if (isset($xml->AddPrescriberLocationResponse)) { $prescriber = $xml->AddPrescriberLocationResponse->Prescriber; } $prescriberSPI = (string) $prescriber->Identification->SPI; if (!strlen($prescriberSPI) > 0) { $error = 'Registration failed for location ' . $ePrescriber->building->name; } } if (isset($responseXml->rawMessage)) { $messaging->rawMessage = base64_decode((string) $responseXml->rawMessage); $messaging->rawMessageResponse = base64_decode((string) $responseXml->rawMessageResponse); } } catch (Exception $e) { $error = __("There was an error connecting to HealthCloud to enable ePrescribing for this provider. Please try again or contact the system administrator."); trigger_error("There was an error enabling an ePresciber, the response couldn't be parsed as XML: " . $output, E_USER_NOTICE); } } else { $error = __("There was an error connecting to HealthCloud to enable ePrescribing for this provider. Please try again or contact the system administrator."); trigger_error("Curl error connecting to healthcare enabled an ePrescribe record: " . curl_error($ch), E_USER_NOTICE); } curl_close($ch); if (strlen($error) > 0) { $messaging->status = 'Error'; $messaging->note = $error; $ret = false; } if ($messaging->resend) { $messaging->resend = 0; } $messaging->retries++; $messaging->dateStatus = date('Y-m-d H:i:s'); $messaging->persist(); if (strlen($error) > 0) { return $error; } if (!strlen($provider->sureScriptsSPI) > 0) { // handler of the first SPI $provider->sureScriptsSPI = $prescriberSPI; $provider->persist(); } if ($type == 'add' || $type == 'addLocation') { $ePrescriber->SSID = $prescriberSPI; $ePrescriber->persist(); } return $ret; }
public function generateTestDataAction() { // Patient Test Data $person = new Person(); $person->lastName = 'Test'; $person->firstName = 'One'; $person->persist(); $patient = new Patient(); $patient->personId = $person->personId; $patient->person = $person; $patient->persist(); // Provider Test Data $person = new Person(); $person->lastName = 'Provider'; $person->firstName = 'ClearHealth'; $person->persist(); $provider = new Provider(); $provider->personId = $person->personId; $provider->person = $person; $provider->persist(); // set provider as user $user = new User(); $user->username = '******'; $user->password = '******'; $user->person = $person; $user->persist(); echo 'Done.'; die; }