Ejemplo n.º 1
0
 public static function inquire($visitId)
 {
     $claimIds = ClaimLine::listAllMostRecentClaimIds(array($visitId));
     $claimId = isset($claimIds[0]) ? $claimIds[0] : 0;
     $claimFile = self::getClaimFile($claimId);
     $query = array();
     $query['apiKey'] = Zend_Registry::get('config')->healthcloud->apiKey;
     $query['uid'] = $claimFile->claimFileId;
     $ch = curl_init();
     $url = Zend_Registry::get('config')->healthcloud->claimsServerUrl . '/check-status';
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($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);
     if (!curl_errno($ch)) {
         $data = json_decode($output, true);
         if ($data === null) {
             $response = 'Invalid HC response';
         } else {
             if (array_key_exists('response', $data)) {
                 $response = $data['response'];
             } else {
                 if (array_key_exists('error', $data)) {
                     $response = $data['error'];
                 } else {
                     $response = 'Unknown HC response: ' . print_r($data, true);
                 }
             }
         }
     } else {
         $response = __('There was an error connecting to HealthCloud to check claim status. Please try again or contact the system administrator.');
     }
     curl_close($ch);
     trigger_error($response);
     return $response . '';
 }
Ejemplo n.º 2
0
 public function processClaimsAction()
 {
     $type = $this->_getParam('type');
     $data = '';
     $claimList = isset($this->_session->claimList) ? $this->_session->claimList : array();
     $visitIds = isset($this->_session->visitIds) ? $this->_session->visitIds : array();
     $claimIds = ClaimLine::listAllMostRecentClaimIds($visitIds);
     $destinations = Claim::listOptions();
     $claimFile = new ClaimFile();
     $claimFile->destination = $type;
     $claimFile->claimIds = implode(',', $claimIds);
     $claimFile->status = 'transmitted';
     $claimFile->dateTime = date('Y-m-d H:i:s');
     $claimFile->userId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $claimFile->persist();
     if (isset($claimIds[0])) {
         switch ($type) {
             case 'healthcloud':
                 // takes 4010A files and send to healthcloud
                 $this->getResponse()->setHeader('Content-Type', 'text/plain');
                 $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="4010A1.txt"');
                 $data = Claim::render4010A1($claimFile, $claimIds);
                 $claimFile->persistData($data);
                 $claimFile->transmit($data);
                 break;
             case 'download4010A1':
                 $this->getResponse()->setHeader('Content-Type', 'text/plain');
                 $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="4010A1.txt"');
                 $data = Claim::render4010A1($claimFile, $claimIds);
                 break;
             case 'download5010':
                 break;
             case 'CMS1500PDF':
                 $data = $this->_downloadCMSPDF($claimIds, 1500);
                 break;
             case 'CMS1450PDF':
                 $data = $this->_downloadCMSPDF($claimIds, 1450);
                 break;
             case 'previewStatements':
                 $data = $this->_previewStatements($claimIds);
                 break;
             case 'publishStatements':
                 $data = $this->_download4010A1($claimFile, $claimIds);
                 $xml = new SimpleXMLElement('<data/>');
                 $result = $this->_previewStatements($claimIds, $xml);
                 $statementData = $xml->asXML();
                 $claimFile->persistData($data, $statementData);
                 $claimFile->transmit($data, $statementData);
                 $data = $result;
                 break;
             default:
                 break;
         }
     }
     $this->_session->visitIds = array();
     $this->view->content = $data;
     $this->render('download');
 }