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') { return $data; } $data['_audit'] = $audit; $medication = new Medication(); $medication->medicationId = (int) $eSignature->objectId; $medication->populate(); $data['PrescriberOrderNumber'] = $medication->medicationId; $medData = array(); $medData['DrugDescription'] = $medication->description; $medData['Strength'] = $medication->strength; $medData['StrengthUnits'] = $medication->unit; $medData['Quantity'] = $medication->quantity; $medData['Directions'] = $medication->directions; $medData['Refills'] = $medication->refills; $medData['Substitutions'] = $medication->substitution; $medData['WrittenDate'] = date('Ymd', strtotime($medication->datePrescribed)); $data['medication'] = $medData; $pharmacy = new Pharmacy(); $pharmacy->pharmacyId = $medication->pharmacyId; $pharmacy->populate(); $pharmacyData = array(); $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID; $pharmacyData['StoreName'] = $pharmacy->StoreName; $pharmacyData['AddressLine1'] = $pharmacy->AddressLine1 . ' ' . $pharmacy->AddressLine2; $pharmacyData['City'] = $pharmacy->City; $pharmacyData['State'] = $pharmacy->State; $pharmacyData['ZipCode'] = $pharmacy->Zip; $pharmacyData['PhoneNumber'] = $pharmacy->PhonePrimary; $data['pharmacy'] = $pharmacyData; $provider = new Provider(); $provider->personId = $medication->prescriberPersonId; $provider->populate(); $prescriberData = array(); $prescriberData['DEANumber'] = $provider->deaNumber; $prescriberData['SPI'] = $provider->sureScriptsSPI; $prescriberData['ClinicName'] = ''; $prescriberData['LastName'] = $provider->person->lastName; $prescriberData['FirstName'] = $provider->person->firstName; $prescriberData['Suffix'] = ''; $address = new Address(); $address->personId = $provider->personId; $address->populateWithPersonId(); $prescriberData['AddressLine1'] = $address->line1 . ' ' . $address->line2; $prescriberData['City'] = $address->city; $prescriberData['State'] = 'AZ'; //$address->state; $prescriberData['ZipCode'] = $address->postalCode; $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $provider->personId; $phoneNumber->populateWithPersonId(); $prescriberData['PhoneNumber'] = $phoneNumber->number; $data['prescriber'] = $prescriberData; $patient = new Patient(); $patient->personId = $medication->personId; $patient->populate(); $patientData = array(); $patientData['LastName'] = $patient->person->lastName; $patientData['FirstName'] = $patient->person->firstName; $enumeration = new Enumeration(); $enumeration->enumerationId = $patient->person->gender; $enumeration->populate(); $gender = $enumeration->key; $patientData['Gender'] = $gender; $patientData['DateOfBirth'] = date('Ymd', strtotime($patient->person->dateOfBirth)); $address = new Address(); $address->personId = $patient->personId; $address->populateWithPersonId(); $patientData['AddressLine1'] = $address->line1 . ' ' . $address->line2; $patientData['City'] = $address->city; $patientData['State'] = 'AZ'; //$address->state; $patientData['ZipCode'] = $address->postalCode; $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $patient->personId; $phoneNumber->populateWithPersonId(); $patientData['PhoneNumber'] = $phoneNumber->number; $data['patient'] = $patientData; return $data; $ret = array(); foreach ($data as $type => $row) { if (is_array($row)) { foreach ($row as $field => $value) { $key = $type . '[' . $field . ']'; $ret[$key] = $value; } } else { $ret[$type] = $row; } } return $ret; }
public function getPhoneNumber($autoFix = true) { if ($this->person_id > 0) { foreach ($this->getPhoneNumbers($autoFix) as $phoneNumber) { break; } } if (!isset($phoneNumber)) { $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $this->person_id; $phoneNumber->populateWithPersonId(); } return $phoneNumber; }
public function newRxAction() { $medicationId = 1077476; $data = array(); $medication = new Medication(); $medication->medicationId = $medicationId; $medication->populate(); $data['PrescriberOrderNumber'] = $medication->medicationId; $medData = array(); $medData['DrugDescription'] = $medication->description; $medData['Strength'] = $medication->strength; $medData['StrengthUnits'] = $medication->unit; $medData['Quantity'] = $medication->quantity; $medData['Directions'] = $medication->directions; $medData['Refills'] = $medication->refills; $medData['Substitutions'] = $medication->substitution; $medData['WrittenDate'] = date('Ymd', strtotime($medication->datePrescribed)); $data['medication'] = $medData; $pharmacy = new Pharmacy(); $pharmacy->pharmacyId = $medication->pharmacyId; $pharmacy->populate(); $pharmacyData = array(); $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID; $pharmacyData['StoreName'] = $pharmacy->StoreName; $pharmacyData['AddressLine1'] = $pharmacy->AddressLine1 . ' ' . $pharmacy->AddressLine2; $pharmacyData['City'] = $pharmacy->City; $pharmacyData['State'] = $pharmacy->State; $pharmacyData['ZipCode'] = $pharmacy->Zip; $pharmacyData['PhoneNumber'] = $pharmacy->PhonePrimary; $data['pharmacy'] = $pharmacyData; $provider = new Provider(); $provider->personId = $medication->prescriberPersonId; $provider->populate(); $prescriberData = array(); $prescriberData['DEANumber'] = $provider->deaNumber; $prescriberData['SPI'] = $provider->sureScriptsSPI; $prescriberData['ClinicName'] = ''; $prescriberData['LastName'] = $provider->person->lastName; $prescriberData['FirstName'] = $provider->person->firstName; $prescriberData['Suffix'] = ''; $address = new Address(); $address->personId = $provider->personId; $address->populateWithPersonId(); $prescriberData['AddressLine1'] = $address->line1 . ' ' . $address->line2; $prescriberData['City'] = $address->city; $prescriberData['State'] = 'AZ'; //$address->state; $prescriberData['ZipCode'] = $address->zipCode; $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $provider->personId; $phoneNumber->populateWithPersonId(); $prescriberData['PhoneNumber'] = $phoneNumber->number; $data['prescriber'] = $prescriberData; $patient = new Patient(); $patient->personId = $medication->personId; $patient->populate(); $patientData = array(); $patientData['LastName'] = $patient->person->lastName; $patientData['FirstName'] = $patient->person->firstName; $patientData['Gender'] = $patient->person->gender; $patientData['DateOfBirth'] = date('Ymd', strtotime($patient->person->dateOfBirth)); $address = new Address(); $address->personId = $patient->personId; $address->populateWithPersonId(); $patientData['AddressLine1'] = $address->line1 . ' ' . $address->line2; $patientData['City'] = $address->city; $patientData['State'] = 'AZ'; //$address->state; $patientData['ZipCode'] = $address->zipCode; $phoneNumber = new PhoneNumber(); $phoneNumber->personId = $patient->personId; $phoneNumber->populateWithPersonId(); $patientData['PhoneNumber'] = $phoneNumber->number; $data['patient'] = $patientData; $postFields = array(); foreach ($data as $type => $row) { if (is_array($row)) { foreach ($row as $field => $value) { $key = $type . '[' . $field . ']'; $postFields[$key] = $value; } } else { $postFields[$type] = $row; } } $ch = curl_init(); $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL; $ePrescribeURL .= 'ss-manager.raw/new-rx?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey; curl_setopt($ch, CURLOPT_URL, $ePrescribeURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); 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); curl_setopt($ch, CURLOPT_USERPWD, 'admin:ch3!'); $output = curl_exec($ch); trigger_error('OUTPUT: ' . $output, E_USER_NOTICE); $error = ""; 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 prescribing new medication, Error code: ' . $errorCode . ' Error Message: ' . $errorMsg, E_USER_NOTICE); } } catch (Exception $e) { $error = __("There was an error connecting to HealthCloud to prescribe new medication. Please try again or contact the system administrator."); trigger_error("There was an error prescribeing new medication, the response couldn't be parsed as XML: " . $output, E_USER_NOTICE); } } else { $error = __("There was an error connecting to HealthCloud to prescribe new medication. Please try again or contact the system administrator."); trigger_error("Curl error connecting to healthcare prescribed new medication: " . curl_error($ch), E_USER_NOTICE); } curl_close($ch); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; if (strlen($error) > 0) { $this->getResponse()->setHttpResponseCode(500); $json->direct(array('error' => $error)); return; } $json->direct(true); }