public function transmitEprescriptionAction()
 {
     $medicationId = (int) $this->_getParam('medicationId');
     $medication = new Medication();
     $medication->medicationId = $medicationId;
     $medication->populate();
     //echo $medication->toString();
     //echo $medicationId;
     $data = $medication->toArray();
     $practice = new Practice();
     $practice->practiceId = MainController::getActivePractice();
     $practice->populate();
     $data['practiceName'] = $practice->name;
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $medication->pharmacyId;
     $pharmacy->populate();
     $data['pharmacy'] = $pharmacy->toArray();
     $prescriber = new Provider();
     $prescriber->personId = $medication->prescriberPersonId;
     $prescriber->populate();
     $prescriber->person->populate();
     $data['prescriber'] = $prescriber->toArray();
     $data['prescriber']['agentFirstName'] = '';
     $data['prescriber']['agentLastName'] = '';
     $data['prescriber']['agentSuffix'] = '';
     $addressIterator = new AddressIterator();
     $addressIterator->setFilters(array('class' => 'person', 'personId' => $prescriber->personId));
     $data['prescriber']['address'] = $addressIterator->first()->toArray();
     $phoneIterator = new PhoneNumberIterator();
     $phoneIterator->setFilters(array('class' => 'person', 'personId' => $prescriber->personId));
     $data['prescriber']['phone'] = $phoneIterator->first()->toArray();
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $data['patient'] = $patient->toArray();
     $phoneIterator->setFilters(array('class' => 'person', 'personId' => $patient->personId));
     $data['patient']['phone'] = $phoneIterator->first()->toArray();
     //var_dump($data);exit;
     $data = $this->makePostArray($data);
     //var_dump($this->makePostArray($data));exit;
     //var_dump($data);exit;
     $transmitEPrescribeURL = Zend_Registry::get('config')->healthcloud->URL;
     $transmitEPrescribeURL .= "SSRX/NewRx?apiKey=" . Zend_Registry::get('config')->healthcloud->apiKey;
     $cookieFile = tempnam(sys_get_temp_dir(), "ssddcookies_");
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $transmitEPrescribeURL);
     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     $output = curl_exec($ch);
     echo $output;
     exit;
 }
 public function ajaxListAddressesAction()
 {
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('address')->where('person_id = ?', $patientId);
     $addressIterator = new AddressIterator();
     $addressIterator->setDbSelect($sqlSelect);
     foreach ($addressIterator as $addr) {
         $tmp = array();
         $tmp['id'] = $addr->address_id;
         $tmp['data'][] = $addr->name;
         $tmp['data'][] = $addr->type;
         $tmp['data'][] = $addr->line1;
         $tmp['data'][] = $addr->line2;
         $tmp['data'][] = $addr->city;
         //$tmp['data'][] = $addr->region;
         $tmp['data'][] = $addr->state;
         $tmp['data'][] = $addr->postal_code;
         $tmp['data'][] = $addr->notes;
         $tmp['data'][] = $addr->active;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
 public function ajaxListAddressesAction()
 {
     $personId = (int) $this->_getParam('personId');
     $rows = array();
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('address')->where('person_id = ?', $personId);
     $addressIterator = new AddressIterator();
     $addressIterator->setDbSelect($sqlSelect);
     foreach ($addressIterator as $addr) {
         $rows[] = $this->_toJSON($addr, 'addressId', array('name', 'type', 'line1', 'line2', 'city', 'state', 'postal_code', 'notes', 'active'));
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }