Ejemplo n.º 1
0
 protected function _setupEnvironment()
 {
     parent::_setupEnvironment();
     // disable strict reporting
     error_reporting(E_ALL);
     return $this;
 }
Ejemplo n.º 2
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 3
0
 public static function generateVitalSignsTemplateKeyValue($vitalSignTemplateId = 1)
 {
     $vitalSignTemplate = new self();
     $vitalSignTemplate->vitalSignTemplateId = $vitalSignTemplateId;
     $vitalSignTemplate->populate();
     $vitals = array();
     try {
         $template = new SimpleXMLElement($vitalSignTemplate->template);
         foreach ($template as $vital) {
             $title = (string) $vital->attributes()->title;
             $vitals[$title] = (string) $vital->attributes()->label;
         }
     } catch (Exception $e) {
         WebVista::debug($e->getMessage());
     }
     return $vitals;
 }
Ejemplo n.º 4
0
 public function ormFields()
 {
     $fields = WebVista::getORMFields(get_class($this));
     return $fields;
 }
Ejemplo n.º 5
0
 public static function handlerSSAct(Audit $audit, array $sourceData)
 {
     if (!isset($sourceData['_audit']) || $audit->objectClass != 'ESignature') {
         WebVista::log('unable to send: _audit index does not exists or audit objectClass not ESignature ');
         return false;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication' || !strlen($eSignature->signature) > 0) {
         WebVista::log('unable to send: signature is not signed or objectClass not Medication');
         return false;
     }
     $medication = new Medication();
     $medication->medicationId = (int) $eSignature->objectId;
     $medication->populate();
     $medication->dateTransmitted = date('Y-m-d H:i:s');
     $medication->persist();
     $patientInfo = $sourceData['Patient']['lastName'] . ', ' . $sourceData['Patient']['firstName'] . ' ' . $sourceData['Patient']['middleName'] . ' MRN#' . $sourceData['Patient']['fileId'];
     $patientInfo .= ' - ' . $sourceData['Medication']['description'] . ' #' . date('m/d/Y', strtotime($sourceData['Medication']['writtenDate']));
     WebVista::log('patient info: ' . $patientInfo);
     $audit = $sourceData['_audit'];
     unset($sourceData['_audit']);
     $messaging = new Messaging();
     $messaging->messagingId = $sourceData['messageId'];
     $messaging->messageType = 'NewRx';
     $messaging->populate();
     $messaging->objectId = (int) $eSignature->objectId;
     $messaging->objectClass = $audit->objectClass;
     $messaging->status = 'Sending';
     $messaging->note = 'Sending newRx (' . $patientInfo . ')';
     $messaging->dateStatus = date('Y-m-d H:i:s');
     $messaging->auditId = $audit->auditId;
     // this must be required for retransmission in case of error
     $messaging->persist();
     if ($messaging->resend && $messaging->pharmacyId > 0) {
         // supersedes pharmacy from messaging
         $pharmacy = new Pharmacy();
         $pharmacy->pharmacyId = $messaging->pharmacyId;
         $pharmacy->populate();
         $pharmacyData = array();
         $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID;
         $pharmacyData['StoreName'] = $pharmacy->StoreName;
         $pharmacyData['addressLine1'] = $pharmacy->AddressLine1;
         $pharmacyData['addressLine2'] = $pharmacy->AddressLine2;
         $pharmacyData['city'] = $pharmacy->City;
         $pharmacyData['state'] = $pharmacy->State;
         $pharmacyData['zip'] = $pharmacy->Zip;
         $pharmacyData['phone'] = $pharmacy->PhonePrimary;
         $pharmacyData['fax'] = '';
         $sourceData['Pharmacy'] = $pharmacyData;
     }
     $query = http_build_query(array('data' => $sourceData));
     $ch = curl_init();
     $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL;
     $ePrescribeURL .= 'ss-manager.raw/new-rx?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey;
     WebVista::log('SS URL: ' . $ePrescribeURL);
     WebVista::log('URL Query: ' . $query);
     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);
     curl_setopt($ch, CURLOPT_USERPWD, 'admin:ch3!');
     $output = curl_exec($ch);
     $error = '';
     $messaging->status = 'Sent';
     $messaging->note = 'newRx pending';
     $messaging->unresolved = 1;
     WebVista::log('RESPONSE: ' . $output);
     if (!curl_errno($ch)) {
         try {
             $responseXml = new SimpleXMLElement($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);
             } else {
                 if (isset($responseXml->status)) {
                     $messaging->note = 'newRx awaiting confirmation';
                     if ((string) $responseXml->status->code == '010') {
                         // value 000 is for free standing error?
                         $messaging->status .= ' and Verified';
                         $messaging->note = 'newRx sent and verified';
                         $messaging->unresolved = 0;
                     }
                 } else {
                     $error = 'Unrecognized HealthCloud response: ' . $output;
                 }
             }
             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 prescribe new medication. Please try again or contact the system administrator.");
             trigger_error("There was an error prescribing 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);
     }
     $messaging->note .= ' (' . $patientInfo . ')';
     curl_close($ch);
     $ret = true;
     if (strlen($error) > 0) {
         $messaging->status = 'Error';
         $patientInfo = $sourceData['Patient']['lastName'] . ', ' . $sourceData['Patient']['firstName'] . ' ' . $sourceData['Patient']['middleName'] . ' MRN#' . $sourceData['Patient']['fileId'];
         $providerInfo = $sourceData['Prescriber']['lastName'] . ', ' . $sourceData['Prescriber']['firstName'] . ' ' . $sourceData['Prescriber']['middleName'];
         $medicationInfo = $sourceData['Medication']['description'] . ' #' . date('m/d/Y', strtotime($sourceData['Medication']['writtenDate']));
         $messaging->note = $error . ' Patient: ' . $patientInfo . ' Provider: ' . $providerInfo . ' Medication: ' . $medicationInfo;
         $ret = false;
     }
     if ($messaging->resend) {
         $messaging->resend = 0;
     }
     $messaging->retries++;
     $messaging->dateStatus = date('Y-m-d H:i:s');
     $messaging->persist();
     return $ret;
 }
 public static function refillRequestActionHandler(Audit $auditOrm, array $dataSourceData)
 {
     if (!count($dataSourceData) > 0) {
         WebVista::debug('Received an empty datasource');
         return false;
     }
     $orm = new GeneralAlert();
     $orm->populateWithArray($dataSourceData);
     $orm->persist();
     return true;
 }
Ejemplo n.º 7
0
 function editSignItemsAction()
 {
     $eSigIds = Zend_Json::decode($this->_getParam('electronicSignatureIds'));
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     if (strlen($eSigIds) <= 0) {
         $msg = __('No selected items to sign.');
         WebVista::log($msg);
         $this->getResponse()->setHttpResponseCode(500);
         $json->direct(array('error' => $msg));
         return;
     }
     $eSigIds = explode(',', $eSigIds);
     $signature = $this->_getParam('signature');
     foreach ($eSigIds as $eSigId) {
         if (strlen($eSigId) <= 0) {
             continue;
         }
         $esig = new ESignature();
         $esig->eSignatureId = (int) $eSigId;
         $esig->populate();
         $objectClass = $esig->objectClass;
         if ($objectClass == 'Medication') {
             // check for possible eprescribed
             $medication = new Medication();
             $medication->medicationId = (int) $esig->objectId;
             $medication->populate();
             if ($medication->transmit == 'ePrescribe') {
                 $result = $this->_checkCurrentLocation($medication);
                 if ($result !== false) {
                     $this->getResponse()->setHttpResponseCode(500);
                     $json->direct(array('error' => $result));
                     return;
                 }
             }
         }
         $signedDate = date('Y-m-d H:i:s');
         $esig->signedDateTime = $signedDate;
         $obj = new $esig->objectClass();
         $obj->documentId = $esig->objectId;
         $obj->eSignatureId = $esig->eSignatureId;
         try {
             $esig->sign($obj, $signature);
         } catch (Exception $e) {
             $this->getResponse()->setHttpResponseCode(500);
             $json->direct(array('error' => $e->getMessage()));
             return;
         }
         $esig->persist();
         $obj->populate();
         $obj->eSignatureId = $esig->eSignatureId;
         $obj->persist();
     }
 }
Ejemplo n.º 8
0
 public function startProcessing($infinite = true)
 {
     $infinite = (bool) $infinite;
     do {
         $ctr = ePrescribe::pull();
         WebVista::log('ePrescribe messages received: ' . $ctr);
         $this->_populateAudits();
         foreach ($this->_audits as $audit) {
             WebVista::log('start processing auditId:[' . $audit->auditId . '], objectClass:[' . $audit->objectClass . '], objectId:[' . $audit->objectId . ']');
             $audit->_persistMode = WebVista_Model_ORM::REPLACE;
             $audit->_ormPersist = true;
             if ($audit->startProcessing == '0000-00-00 00:00:00') {
                 $audit->startProcessing = date('Y-m-d H:i:s');
                 $audit->persist();
             }
             $processResult = true;
             foreach ($this->_processes as $process) {
                 $process->preProcess($audit);
                 $result = $process->process($audit);
                 $process->postProcess($audit);
                 $processResult &= $result;
                 if ($result) {
                     continue;
                 }
             }
             if ($processResult) {
                 $audit->endProcessing = date('Y-m-d H:i:s');
                 $audit->persist();
             }
         }
         // invoke extra process that are not dependent on Audits
         foreach ($this->_processes as $process) {
             $process->extraProcess();
         }
         sleep($this->_sleepInterval);
     } while ($infinite);
 }
Ejemplo n.º 9
0
    list($usec, $sec) = explode(" ", microtime());
    $ts = (double) $usec + (double) $sec;
    if (!isset($GLOBALS['gts'])) {
        $GLOBALS['gts'] = $ts;
    }
    return $ts - $GLOBALS['gts'];
}
if (!function_exists('lcfirst')) {
    function lcfirst($str)
    {
        $str[0] = strtolower($str[0]);
        return (string) $str;
    }
}
function __($key)
{
    //$translate = Zend_Registry::get('translate');
    //$rtext = $translate->_($key);
    //if ($key == $rtext) {
    //	trigger_error("untranslated: '$key' => '',", E_USER_NOTICE);
    //}
    //if (strlen($rtext) == 0) {
    return $key;
    //}
    //return $rtext;
}
calcTS();
define('APPLICATION_ENVIRONMENT', 'production');
require_once './application/library/WebVista/App.php';
WebVista::getInstance()->run();
Ejemplo n.º 10
0
    public function persist($single = true)
    {
        if ($single) {
            return parent::persist();
        }
        $db = Zend_Registry::get('dbAdapter');
        if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
            $sql = 'DELETE FROM `' . $this->_table . '` WHERE (`guid` = ' . $db->quote($this->guid) . ')';
            $db->query($sql);
            return $this;
        }
        if (!strlen($this->guid) > 0) {
            $this->guid = str_replace('-', '', NSDR::create_guid());
        }
        // Multiple fee schedule cannot be set for the same insurance programs for the same dates of service
        if ($this->hasConflicts()) {
            $error = __('Please choose different insurance programs or date of service.');
            throw new Exception($error);
        }
        if (!$this->dateObsolete || $this->dateObsolete == '0000-00-00') {
            $this->dateObsolete = $this->dateOfServiceEnd;
        }
        $updates = array();
        $fields = array();
        $values = array();
        $columns = array('name', 'guid', 'insuranceProgramIds', 'dateOfServiceStart', 'dateOfServiceEnd', 'procedureCode', 'fee', 'dateObsolete');
        foreach ($columns as $col) {
            $fields[$col] = '`' . $col . '`';
            $values[$col] = $db->quote($this->{$col});
            $updates[$col] = $fields[$col] . ' = ' . $values[$col];
        }
        $values['procedureCode'] = '`code`';
        unset($updates['guid']);
        unset($updates['procedureCode']);
        unset($updates['fee']);
        unset($updates['dateObsolete']);
        // name, guid, insuranceProgramIds, dateOfServiceStart, dateOfServiceEnd
        $sql = 'INSERT INTO `feeSchedules` (' . implode(', ', $fields) . ')
				SELECT ' . implode(', ', $values) . ' FROM procedureCodesCPT
			ON DUPLICATE KEY UPDATE ' . implode(', ', $updates);
        WebVista::debug($sql);
        $db->query($sql);
        return $this;
    }
Ejemplo n.º 11
0
 public function persist()
 {
     if ($this->number_id > 0 && $this->_isv2x()) {
         // check if 2.x
         WebVista::debug('Unable to alter because 2.x phone number detected');
         return false;
     }
     if ($this->_persistMode != WebVista_Model_ORM::DELETE && (int) $this->displayOrder <= 0) {
         $this->displayOrder = self::nextDisplayOrder($this->personId);
     }
     return parent::persist();
 }
Ejemplo n.º 12
0
 public function hasConflicts()
 {
     $db = Zend_Registry::get('dbAdapter');
     $ret = false;
     $dateStart = $db->quote($this->dateStart);
     $dateEnd = $db->quote($this->dateEnd);
     $sqlSelect = $db->select()->from($this->_table)->where('guid != ' . $db->quote($this->guid))->where('(' . $dateStart . ' >= dateStart AND ' . $dateStart . ' <= dateEnd) OR (' . $dateEnd . ' >= dateStart AND ' . $dateEnd . ' <= dateEnd)');
     $orWhere = array();
     foreach (explode(',', $this->insuranceProgramIds) as $ip) {
         $ip = (int) $ip;
         if (!$ip > 0) {
             continue;
         }
         $orWhere[] = "`insuranceProgramIds` LIKE '%{$ip}%'";
     }
     if (isset($orWhere[0])) {
         $sqlSelect->where(implode(' OR ', $orWhere));
     }
     $sqlSelect->limit(1);
     WebVista::debug($sqlSelect->__toString());
     if ($row = $db->fetchRow($sqlSelect)) {
         $ret = true;
     }
     return $ret;
 }