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 ajaxListPhonesAction()
 {
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $tmp = array();
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('number')->where('person_id = ?', $patientId);
     $phoneNumberIterator = new PhoneNumberIterator();
     $phoneNumberIterator->setDbSelect($sqlSelect);
     foreach ($phoneNumberIterator as $phone) {
         $tmp = array();
         $tmp['id'] = $phone->number_id;
         $tmp['data'][] = $phone->name;
         $tmp['data'][] = $phone->type;
         $tmp['data'][] = $phone->number;
         $tmp['data'][] = $phone->notes;
         $tmp['data'][] = $phone->active;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
 public function ajaxListPhonesAction()
 {
     $personId = (int) $this->_getParam('personId');
     $rows = array();
     $tmp = array();
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('number')->where('person_id = ?', $personId);
     $phoneNumberIterator = new PhoneNumberIterator();
     $phoneNumberIterator->setDbSelect($sqlSelect);
     foreach ($phoneNumberIterator as $phone) {
         $rows[] = $this->_toJSON($phone, 'phoneNumberId', array('name', 'type', 'number', 'notes', 'active'));
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }