コード例 #1
0
ファイル: Pharmacy.php プロジェクト: huynt57/meboo_nhaplieu
 public function addPharmacy($attr)
 {
     $model = new Pharmacy();
     $model->setAttributes($attr);
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
コード例 #2
0
 public function actionAddPharmacy()
 {
     $attr = StringHelper::filterArrayString($_POST);
     $model = new Pharmacy();
     $model->setAttributes($attr);
     // $model->created_at = time();
     //$model->updated_at = time();
     if ($model->save(FALSE)) {
         ResponseHelper::JsonReturnSuccess("", "Success");
     } else {
         ResponseHelper::JsonReturnError("", "Server Error");
     }
 }
コード例 #3
0
ファイル: PharmacyController.php プロジェクト: huynt57/soyba
 public function actionDelete()
 {
     $request = Yii::app()->request;
     $id = $request->getQuery("id");
     $delete = Pharmacy::model()->findByAttributes(array('id' => $id));
     $delete->delete();
 }
コード例 #4
0
ファイル: CrawlerController.php プロジェクト: huynt57/soyba
 public function actionIndex()
 {
     $i = 1;
     for ($i = 1; $i < 2; $i++) {
         $simpleHTML = new SimpleHTMLDOM();
         $html = $simpleHTML->file_get_html("http://www.healthfamily.co/danh-sach-nha-thuoc-hieu-thuoc?p={$i}&r=100#.VavHvXj0HuU");
         foreach ($html->find('div.h125') as $element) {
             $name = $element->find('h3 a')->innertext;
             //  $address = $element->find('p.date-time', 0)->innertext;
             $pharmacy = new Pharmacy();
             $pharmacy->name = $name;
             $pharmacy->address = "";
             $pharmacy->save(FALSE);
         }
     }
     $this->render('index');
 }
コード例 #5
0
 function list_action($sort = "")
 {
     if (!empty($sort)) {
         $this->assign("pharmacies", Pharmacy::pharmacies_factory("", $sort));
     } else {
         $this->assign("pharmacies", Pharmacy::pharmacies_factory());
     }
     //print_r(Prescription::prescriptions_factory($id));
     return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
 }
 public function invoke()
 {
     if (isset($_POST['CheckCustomer'])) {
         $user = new User();
         $pharmacyID = $user->getID();
         $customer = new Customer();
         $customerID = $customer->getIDByNationalNb();
         $customerName = $customer->getNameByNationalNb();
         $pharmacy = new Pharmacy();
         $myResult = $pharmacy->getOldServicesByCustomerNationalNb();
         $myResult1 = $pharmacy->getOldServicesByCustomerNationalNb();
         $medView = new MedicationView();
         if ($row = mysql_fetch_assoc($myResult)) {
             $medView->showServices($myResult1, $pharmacyID, $customerID, $customerName);
         } else {
             $myResult = $customer->getInfoByNationalNb();
             if ($row = mysql_fetch_assoc($myResult)) {
                 $medView->showCustomerInfo($row, $pharmacyID, $customerID, $customerName);
             } else {
                 $medView->showUnavailable();
             }
         }
     }
 }
コード例 #7
0
</head>
<body class="body_title">

<?php 
$result = getPatientData($pid, "fname,lname,pid,pubpid,phone_home,pharmacy_id,DOB,DATE_FORMAT(DOB,'%Y%m%d') as DOB_YMD");
$provider_results = sqlQuery("select * from users where username='******'");
$age = getPatientAge($result["DOB_YMD"]);
$info = 'ID: ' . $result['pubpid'];
if ($result['DOB']) {
    $info .= ', ' . xl('DOB') . ': ' . $result['DOB'] . ', ' . xl('Age') . ': ' . $age;
}
if ($result['phone_home']) {
    $info .= ', ' . xl('Home') . ': ' . $result['phone_home'];
}
if ($result['pharmacy_id']) {
    $pharmacy = new Pharmacy($result['pharmacy_id']);
    if ($pharmacy->get_phone()) {
        $info .= ', Pharm: ' . $pharmacy->get_phone();
    }
}
?>

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
 <tr>
  <td style="width:45%; vertical-align:middle; white-space: nowrap">
   <span class="title_bar_top"><?php 
echo $result["fname"] . " " . $result["lname"];
?>
</span>
   <span style="font-size:0.7em;">(<?php 
echo $info;
コード例 #8
0
 public function pharmacyDownload($args)
 {
     $daily = 0;
     // default to full sync
     if (isset($args[0])) {
         $daily = (int) $args[0];
     }
     $ret = Pharmacy::activateDownload($daily);
     if (strlen($ret['error']) > 0) {
         // error
         echo $ret['error'];
         return false;
     }
     $filename = Pharmacy::downloadPharmacy($ret['downloadUrl'], $ret['cookieFile']);
     $counter = Pharmacy::loadPharmacy($filename);
     return true;
 }
コード例 #9
0
 public static function handlereFaxSourceData(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 = $eSignature->objectId;
     $medication->populate();
     $data['transmissionId'] = (int) $medication->medicationId;
     $data['recipients'] = array();
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $pharmacyId = $patient->defaultPharmacyId;
     $provider = new Provider();
     $provider->personId = $medication->prescriberPersonId;
     $provider->populate();
     // recipients MUST be a pharmacy?
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $pharmacyId;
     $pharmacy->populate();
     //$data['recipients'][] = array('fax'=>$pharmacy->Fax,'name'=>$pharmacy->StoreName,'company'=>$pharmacy->StoreName);
     // temporarily comment out the above recipient and use the hardcoded recipient
     $data['recipients'][] = array('fax' => '6022976632', 'name' => 'Jay Walker', 'company' => 'ClearHealth Inc.');
     $prescription = new Prescription();
     $prescription->prescriberName = $provider->firstName . ' ' . $provider->lastName . ' ' . $provider->title;
     $prescription->prescriberStateLicenseNumber = $provider->stateLicenseNumber;
     $prescription->prescriberDeaNumber = $provider->deaNumber;
     // Practice Info
     $primaryPracticeId = $provider->primaryPracticeId;
     $practice = new Practice();
     $practice->id = $primaryPracticeId;
     $practice->populate();
     $address = $practice->primaryAddress;
     $prescription->practiceName = $practice->name;
     $prescription->practiceAddress = $address->line1 . ' ' . $address->line2;
     $prescription->practiceCity = $address->city;
     $prescription->practiceState = $address->state;
     $prescription->practicePostalCode = $address->postalCode;
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $provider->personId;
     $attachment->populateWithAttachmentReferenceId();
     if ($attachment->attachmentId > 0) {
         $db = Zend_Registry::get('dbAdapter');
         $sqlSelect = $db->select()->from('attachmentBlobs')->where('attachmentId = ?', (int) $attachment->attachmentId);
         if ($row = $db->fetchRow($sqlSelect)) {
             $tmpFile = tempnam('/tmp', 'ch30_sig_');
             file_put_contents($tmpFile, $row['data']);
             $signatureFile = $tmpFile;
             $prescription->prescriberSignature = $signatureFile;
         }
     }
     $prescription->patientName = $patient->lastName . ', ' . $patient->firstName;
     $address = $patient->homeAddress;
     $prescription->patientAddress = $address->line1 . ' ' . $address->line2;
     $prescription->patientCity = $address->city;
     $prescription->patientState = $address->state;
     $prescription->patientPostalCode = $address->postalCode;
     $prescription->patientDateOfBirth = date('m/d/Y', strtotime($patient->dateOfBirth));
     $prescription->medicationDatePrescribed = date('m/d/Y', strtotime($medication->datePrescribed));
     $prescription->medicationDescription = $medication->description;
     $prescription->medicationComment = $medication->comment;
     $prescription->medicationQuantity = $medication->quantity;
     $prescription->medicationRefills = $medication->refills;
     $prescription->medicationDirections = $medication->directions;
     $prescription->medicationSubstitution = $medication->substitution;
     $prescription->create();
     $filename = $prescription->imageFile;
     $fileType = pathinfo($filename, PATHINFO_EXTENSION);
     $data['files'] = array();
     $contents = file_get_contents($filename);
     unlink($filename);
     $data['files'][] = array('contents' => base64_encode($contents), 'type' => $fileType);
     return $data;
 }
コード例 #10
0
ファイル: Pharmacy.php プロジェクト: huynt57/soyba
 public function getNearPharmacy($lat, $lng, $limit, $offset)
 {
     $retVal = array();
     $criteria = new CDbCriteria();
     if (!empty($lat) && !empty($lng)) {
         $criteria->select = "t.*, (2 * (3959 * ATAN2(\n          SQRT(\n            POWER(SIN((RADIANS(" . $lat . " - `t`.`laititude` ) ) / 2 ), 2 ) +\n            COS(RADIANS(`t`.`laititude`)) *\n            COS(RADIANS(" . $lat . ")) *\n            POWER(SIN((RADIANS(" . $lng . " - `t`.`longitude` ) ) / 2 ), 2 )\n          ),\n          SQRT(1-(\n            POWER(SIN((RADIANS(" . $lat . " - `t`.`laititude` ) ) / 2 ), 2 ) +\n            COS(RADIANS(`t`.`laititude`)) *\n            COS(RADIANS(" . $lat . ")) *\n            POWER(SIN((RADIANS(" . $lng . " - `t`.`longitude` ) ) / 2 ), 2 )\n          ))\n        )\n      )) as\n            distance";
         $criteria->having = 'distance < 3';
         $criteria->group = 't.id';
     }
     $criteria->order = 'distance ASC';
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $data = Pharmacy::model()->findAll($criteria);
     $attrs = $this->attributeLabels();
     foreach ($data as $item) {
         $itemArr = array();
         foreach ($attrs as $key => $value) {
             $itemArr[$key] = $item->{$key};
         }
         $itemArr['stars'] = Review::model()->sumRating($item->id, 2);
         $itemArr['reviews'] = Review::model()->countReview($item->id, 2);
         $retVal[] = $itemArr;
     }
     return $retVal;
 }
                            </td>
                            
                    <td style="width:50%;">
                            	<table>
                                    
                                    <tr>
                                    	<td>
                                        	إضافة صيدلية جديدة
                                        </td>

                                  </tr>
                                  
                                  <tr>
                                    	<td>
                                        	<?php 
$newpharmacy = new Pharmacy();
echo '<form method="post" action="' . $newpharmacy->addPharmacy() . '">';
?>
											
                                            <table>
                                                <tr>
                                                	<td>
                                                    	  اسم المستخدم
                                                    </td>
                                                	<td>
                                                    	<input name="UserName" type="text" />*
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                	<td>
コード例 #12
0
 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;
 }
コード例 #13
0
 public function ajaxLoadPharmaciesDataAction()
 {
     $counter = Pharmacy::loadPharmacy(urldecode($this->_getParam('filename')));
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($counter);
 }
コード例 #14
0
 function send_action_process($id)
 {
     $dummy = "";
     // Added by Rod to avoid run-time warnings
     if ($_POST['process'] != "true") {
         return;
     }
     if (empty($id)) {
         $this->function_argument_error();
     }
     $p = new Prescription($id);
     switch ($_POST['submit']) {
         case xl("Print") . " (" . xl("PDF") . ")":
             // The following statement added by Rod.
             // Looking at Controller.class.php, it appears that _state is set to false
             // to indicate that no further HTML is to be generated.
             $this->_state = false;
             // Added by Rod - see Controller.class.php
             return $this->_print_prescription($p, $dummy);
             break;
         case xl("Print") . " (" . xl("HTML") . ")":
             $this->_state = false;
             return $this->_print_prescription_css($p, $dummy);
             break;
         case xl("Print To Fax"):
             $this->_state = false;
             $this->is_print_to_fax = true;
             return $this->_print_prescription($p, $dummy);
             break;
         case xl("Email"):
             return $this->_email_prescription($p, $_POST['email_to']);
             break;
         case xl("Fax"):
             //this is intended to be the hook for the hylafax code we already have that hasn't worked its way into the tree yet.
             //$this->assign("process_result","No fax server is currently setup.");
             return $this->_fax_prescription($p, $_POST['fax_to']);
             break;
         case xl("Auto Send"):
             $pharmacy_id = $_POST['pharmacy_id'];
             //echo "auto sending to : " . $_POST['pharmacy_id'];
             $phar = new Pharmacy($_POST['pharmacy_id']);
             //print_r($phar);
             if ($phar->get_transmit_method() == TRANSMIT_PRINT) {
                 return $this->_print_prescription($p, $dummy);
             } elseif ($phar->get_transmit_method() == TRANSMIT_EMAIL) {
                 $email = $phar->get_email();
                 if (!empty($email)) {
                     return $this->_email_prescription($p, $phar->get_email());
                 }
                 //else print it
             } elseif ($phar->get_transmit_method() == TRANSMIT_FAX) {
                 $faxNum = $phar->get_fax();
                 if (!empty($faxNum)) {
                     return $this->_fax_prescription($p, $faxNum);
                 }
                 // return $this->assign("process_result","No fax server is currently setup.");
                 // else default is printing,
             } else {
                 //the pharmacy has no default or default is print
                 return $this->_print_prescription($p, $dummy);
             }
             break;
     }
     return;
 }
コード例 #15
0
 public function generateTestSsDemoDataAction()
 {
     $basePath = Zend_Registry::get('basePath');
     $xmlFile = $basePath . 'xml/ss-demo-data.xml';
     $xml = new SimpleXMLElement(file_get_contents($xmlFile));
     foreach ($xml as $key => $value) {
         switch ($key) {
             case 'prescriber':
                 $person = new Person();
                 $person->active = 1;
                 $person->lastName = (string) $value->PrescriberLastName;
                 $person->firstName = (string) $value->PrescriberFirstName;
                 $person->middleName = (string) $value->PrescriberMiddleName;
                 $person->suffix = (string) $value->PrescriberNameSuffix;
                 //$person->initials = (string)$value->PrescriberNamePrefix;
                 $provider = new Provider();
                 $provider->person = $person;
                 $provider->sureScriptsSPI = (string) $value->SPI;
                 $provider->deaNumber = (string) $value->DEANumber;
                 $provider->stateLicenseNumber = (string) $value->StateLicenseNumber;
                 $provider->persist();
                 //ProviderSpecialty, ClinicName
                 $phone = new PhoneNumber();
                 $phone->personId = $provider->personId;
                 $phone->name = 'Primary';
                 $phone->type = 4;
                 $phone->number = str_replace('-', '', (string) $value->PrescriberPhone);
                 $phone->persist();
                 $address = new Address();
                 $address->personId = $provider->personId;
                 $address->name = 'Main';
                 $address->type = 4;
                 $address->active = 1;
                 $address->line1 = (string) $value->ClinicAddressLine1;
                 $address->line2 = (string) $value->ClinicAddressLine2;
                 $address->city = (string) $value->ClinicCity;
                 $address->state = (string) $value->ClinicState;
                 $address->postalCode = (string) $value->ClinicZip;
                 $address->persist();
                 break;
             case 'pharmacy':
                 $pharmacy = new Pharmacy();
                 $pharmacy->NCPDPID = (string) $value->NCPDPID;
                 /*$pharmacy-> = (string)$value->ReferenceQualifier;
                 		$pharmacy-> = (string)$value->PharmacistLastName;
                 		$pharmacy-> = (string)$value->PharmacistFirstName;
                 		$pharmacy-> = (string)$value->PharmacistMiddleName;
                 		$pharmacy-> = (string)$value->PharmacistNamePrefix;
                 		$pharmacy-> = (string)$value->PharmacistNameSuffix;*/
                 $pharmacy->StoreName = (string) $value->PharmacyName;
                 $pharmacy->AddressLine1 = (string) $value->PharmacyAddressLine1;
                 $pharmacy->City = (string) $value->PharmacyCity;
                 $pharmacy->State = (string) $value->PharmacyState;
                 $pharmacy->Zip = (string) $value->PharmacyZip;
                 $pharmacy->PhonePrimary = (string) $value->PharmacyPhone;
                 $pharmacy->persist();
                 break;
             case 'patient':
                 $person = new Person();
                 $person->active = 1;
                 $person->lastName = (string) $value->PatientLastName;
                 $person->firstName = (string) $value->PatientFirstName;
                 $person->middleName = (string) $value->PatientMiddleName;
                 //$person->initials = (string)$value->PatientNamePrefix;
                 $person->identifier = (string) $value->PatientSS;
                 $address = new Address();
                 $address->name = 'Main';
                 $address->type = 4;
                 $address->active = 1;
                 $address->line1 = (string) $value->PatientAddressLine1;
                 $address->line2 = (string) $value->PatientAddressLine2;
                 $address->city = (string) $value->PatientCity;
                 $address->state = (string) $value->PatientState;
                 $address->postalCode = (string) $value->PatientZip;
                 $patient = new Patient();
                 $patient->person = $person;
                 $patient->homeAddress = $address;
                 $patient->persist();
                 $phone = new PhoneNumber();
                 $phone->personId = $patient->personId;
                 $phone->name = 'Primary';
                 $phone->type = 4;
                 $phone->number = str_replace('-', '', (string) $value->PatientPhone);
                 $phone->persist();
                 break;
             case 'medication':
                 break;
         }
     }
     echo 'Done';
     die;
 }
コード例 #16
0
ファイル: Pharmacy.php プロジェクト: dragonlet/clearhealth
 public static function loadPharmacy($filename)
 {
     trigger_error('before loading pharmacies: ' . calcTS(), E_USER_NOTICE);
     set_time_limit(300);
     // 5 minutes
     $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . preg_replace('/.*(\\/|\\ee)/', '', $filename);
     $pharmDataTmp = fopen($filename, 'r');
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('pharmacies', array('pharmacyId', 'NCPDPID', 'preferred'));
     $pharmacies = array();
     if ($rows = $db->fetchAll($sqlSelect)) {
         foreach ($rows as $row) {
             $pharmacies[$row['NCPDPID']] = array('pharmacyId' => $row['pharmacyId'], 'preferred' => $row['preferred']);
         }
     }
     fseek($pharmDataTmp, 0);
     $counter = 0;
     while ($line = fgets($pharmDataTmp)) {
         $pharmacy = array();
         $pharmacy['NCPDPID'] = substr($line, 0, 7);
         $pharmacy['StoreNumber'] = substr($line, 7, 35);
         $pharmacy['ReferenceNumberAlt1'] = substr($line, 42, 35);
         $pharmacy['ReferenceNumberAlt1Qualifier'] = substr($line, 77, 3);
         $pharmacy['StoreName'] = substr($line, 80, 35);
         $pharmacy['AddressLine1'] = substr($line, 115, 35);
         $pharmacy['AddressLine2'] = substr($line, 150, 35);
         $pharmacy['City'] = substr($line, 185, 35);
         $pharmacy['State'] = substr($line, 220, 2);
         $pharmacy['Zip'] = substr($line, 222, 11);
         $pharmacy['PhonePrimary'] = substr($line, 233, 25);
         $pharmacy['Fax'] = substr($line, 258, 25);
         $pharmacy['Email'] = substr($line, 283, 80);
         $pharmacy['PhoneAlt1'] = substr($line, 363, 25);
         $pharmacy['PhoneAlt1Qualifier'] = substr($line, 388, 3);
         $pharmacy['PhoneAlt2'] = substr($line, 391, 25);
         $pharmacy['PhoneAlt2Qualifier'] = substr($line, 416, 3);
         $pharmacy['PhoneAlt3'] = substr($line, 419, 25);
         $pharmacy['PhoneAlt3Qualifier'] = substr($line, 444, 3);
         $pharmacy['PhoneAlt4'] = substr($line, 447, 25);
         $pharmacy['PhoneAlt4Qualifier'] = substr($line, 472, 3);
         $pharmacy['PhoneAlt5'] = substr($line, 475, 25);
         $pharmacy['PhoneAlt5Qualifier'] = substr($line, 500, 3);
         $pharmacy['ActiveStartTime'] = substr($line, 503, 22);
         $pharmacy['ActiveEndTime'] = substr($line, 525, 22);
         $pharmacy['ServiceLevel'] = substr($line, 547, 5);
         $pharmacy['PartnerAccount'] = substr($line, 552, 35);
         $pharmacy['LastModifiedDate'] = substr($line, 587, 22);
         $pharmacy['TwentyFourHourFlag'] = substr($line, 609, 1);
         $pharmacy['Available CrossStreet'] = substr($line, 610, 35);
         $pharmacy['RecordChange'] = substr($line, 645, 1);
         $pharmacy['OldServiceLevel'] = substr($line, 646, 5);
         $pharmacy['TextServiceLevel'] = substr($line, 651, 100);
         $pharmacy['TextServiceLevelChange'] = substr($line, 751, 100);
         $pharmacy['Version'] = substr($line, 851, 5);
         $pharmacy['NPI'] = substr($line, 856, 10);
         $data = array();
         foreach ($pharmacy as $key => $value) {
             $data[$key] = trim($value);
         }
         $p = new Pharmacy();
         $p->_shouldAudit = false;
         $p->populateWithArray($data);
         if (isset($pharmacies[$p->NCPDPID])) {
             $p->pharmacyId = $pharmacies[$p->NCPDPID]['pharmacyId'];
             $p->preferred = $pharmacies[$p->NCPDPID]['preferred'];
         }
         //$p->populatePharmacyIdWithNCPDPID();
         $p->persist();
         $counter++;
     }
     fclose($pharmDataTmp);
     unlink($filename);
     trigger_error('Number of rows updated: ' . $counter, E_USER_NOTICE);
     trigger_error('after loading pharmacies: ' . calcTS(), E_USER_NOTICE);
     return $counter;
 }
コード例 #17
0
ファイル: ePrescribe.php プロジェクト: dragonlet/clearhealth
 public static function pull()
 {
     $ch = curl_init();
     $ePrescribeURL = Zend_Registry::get('config')->healthcloud->URL;
     $ePrescribeURL .= 'ss-manager.raw/pull-inbounds?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey;
     curl_setopt($ch, CURLOPT_URL, $ePrescribeURL);
     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);
     $error = '';
     $ret = 0;
     if (!curl_errno($ch)) {
         try {
             $xml = new SimpleXMLElement($output);
             foreach ($xml->data as $messages) {
                 foreach ($messages as $key => $message) {
                     $rawMessage = base64_decode((string) $message->rawMessage);
                     if ($key == 'refillRequest') {
                         $messageId = (string) $message->messageId;
                         $rxReferenceNumber = (string) $message->rxReferenceNumber;
                         $prescriberOrderNumber = (string) $message->prescriberOrderNumber;
                         $auditId = 0;
                         $medicationId = 0;
                         $xmlMessage = new SimpleXMLElement($rawMessage);
                         $lastName = (string) $xmlMessage->Body->RefillRequest->Patient->Name->LastName;
                         $firstName = (string) $xmlMessage->Body->RefillRequest->Patient->Name->FirstName;
                         $messageInfo = ' for ' . $lastName . ', ' . $firstName;
                         $description = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->DrugDescription;
                         $datePrescribed = date('m/d/Y', strtotime((string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->WrittenDate));
                         $messageInfo .= ' - ' . $description . ' #' . $datePrescribed;
                         if (strlen($prescriberOrderNumber) > 0) {
                             // currently check for medicationId using the prescriberOrderNumber medication_audit
                             $medAudit = explode('_', $prescriberOrderNumber);
                             $medicationId = (int) $medAudit[0];
                             $auditId = isset($medAudit[1]) ? (int) $medAudit[1] : 0;
                         }
                         $medication = new Medication();
                         $medication->medicationId = $medicationId;
                         $medication->populate();
                         $patientId = (int) $medication->personId;
                         $unresolved = 0;
                         // retrieve providerId using SPI
                         $SPI = (string) $xmlMessage->Body->RefillRequest->Prescriber->Identification->SPI;
                         $eprescriber = new EPrescriber();
                         $eprescriber->populateBySPI($SPI);
                         $providerId = (int) $eprescriber->providerId;
                         if (!$patientId > 0) {
                             // PON not set or invalid PON, try to automatch based on name, dob, medication and dates in the refreq, if only one match automatically link with correct PON
                             // retrieve pharmacyId using NCPDPID
                             $NCPDPID = (string) $xmlMessage->Body->RefillRequest->Pharmacy->Identification->NCPDPID;
                             $pharmacy = new Pharmacy();
                             $pharmacy->NCPDPID = $NCPDPID;
                             $pharmacy->populatePharmacyIdWithNCPDPID();
                             $pharmacyId = (string) $pharmacy->pharmacyId;
                             $gender = (string) $xmlMessage->Body->RefillRequest->Patient->Gender;
                             $dob = (string) $xmlMessage->Body->RefillRequest->Patient->DateOfBirth;
                             // retrieve patientId using LastName, FirstName, Gender and DOB
                             $db = Zend_Registry::get('dbAdapter');
                             $sqlSelect = $db->select()->from('person', 'person_id')->where('last_name = ?', $lastName)->where('first_name = ?', $firstName)->where('date_of_birth = ?', date('Y-m-d', strtotime($dob)))->limit(1);
                             if ($row = $db->fetchRow($sqlSelect)) {
                                 $patientId = $row['person_id'];
                             }
                             //trigger_error($sqlSelect->__toString());
                             // $qualifiers = Medication::listQuantityQualifiersMapping(); TODO: since qualifier are ambiguous, temporarily not to use this qualifier
                             $quantity = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->Quantity->Value;
                             $sqlSelect = $db->select()->from('medications')->where('description = ?', $description)->where('quantity = ?', $quantity)->where('personId = ?', (int) $patientId)->where('prescriberPersonId = ?', (int) $providerId)->where('pharmacyId = ?', (int) $pharmacyId);
                             $writtenDate = (string) $xmlMessage->Body->RefillRequest->MedicationPrescribed->WrittenDate;
                             if (strlen($writtenDate) > 0) {
                                 $sqlSelect->where('datePrescribed LIKE ?', date('Y-m-d', strtotime($writtenDate)) . '%');
                             }
                             $medicationMatched = false;
                             //trigger_error($sqlSelect->__toString());
                             $rows = $db->fetchAll($sqlSelect);
                             if (count($rows) == 1) {
                                 $medication = new Medication();
                                 $medication->populateWithArray($rows[0]);
                                 $medicationId = $medication->medicationId;
                                 $auditId = Medication::getAuditId($medicationId);
                                 if ($auditId > 0) {
                                     $xmlMessage->Body->RefillRequest->PrescriberOrderNumber = $medicationId . '_' . $auditId;
                                     $rawMessage = $xmlMessage->asXML();
                                 }
                                 //trigger_error($sqlSelect->__toString());
                                 $medicationMatched = true;
                             }
                             $messageInfo = ' (Invalid/Missing PON';
                             if ($patientId > 0 && $medicationMatched) {
                                 $patient = new Patient();
                                 $patient->personId = $patientId;
                                 $patient->populate();
                                 $messageInfo .= ' - automatched to \'' . $patient->displayName . '\' MRN#' . $patient->recordNumber;
                             } else {
                                 $unresolved = 1;
                             }
                             $messageInfo .= ')';
                         }
                         $refillRequest = new MedicationRefillRequest();
                         $refillRequest->messageId = $messageId;
                         $refillRequest->medicationId = $medicationId;
                         $refillRequest->action = '';
                         $refillRequest->status = '';
                         $refillRequest->dateStart = '';
                         $refillRequest->details = 'Re: ' . $rxReferenceNumber;
                         $refillRequest->dateTime = date('Y-m-d H:i:s');
                         // disable audits autoprocess, this was set at CHProcessingDaemon
                         $processedAudits = Audit::$_processedAudits;
                         Audit::$_processedAudits = false;
                         $refillRequest->persist();
                         Audit::$_processedAudits = $processedAudits;
                         $messaging = new Messaging();
                         $messaging->messagingId = $messageId;
                         $messaging->populate();
                         $messaging->messageType = 'RefillRequest';
                         $messaging->objectId = $refillRequest->messageId;
                         $messaging->objectClass = 'MedicationRefillRequest';
                         $messaging->note = 'Refill request received - Re:' . $rxReferenceNumber . $messageInfo;
                         $messaging->auditId = $auditId;
                         $messaging->refills = (string) $message->refills;
                         $messaging->personId = $patientId;
                         $messaging->providerId = $providerId;
                         $messaging->unresolved = $unresolved;
                     } else {
                         if ($key == 'status') {
                             $relatesToMessageId = (string) $message->relatesToMessageId;
                             $messageId = (string) $message->messageId;
                             $code = (string) $message->code;
                             $description = (string) $message->description;
                             $messaging = new Messaging();
                             $messaging->messageType = 'Status';
                             $messaging->note = 'Status received for unknown messageId: ' . $relatesToMessageId;
                             $tmpMsg = new Messaging();
                             $tmpMsg->messagingId = $relatesToMessageId;
                             if ($tmpMsg->populate()) {
                                 // populate for newRx details
                                 $tmpMsg->status = 'Sent and Verified';
                                 $x = explode('(', $tmpMsg->note);
                                 $tmpMsg->note = 'newRx';
                                 if ($tmpMsg->objectClass == 'MedicationRefillResponse') {
                                     $tmpMsg->note = 'Refill response';
                                 }
                                 $tmpMsg->note .= ' sent and verified';
                                 if (isset($x[1])) {
                                     unset($x[0]);
                                     $tmpMsg->note .= ' (' . implode('(', $x);
                                 }
                                 $tmpMsg->unresolved = 0;
                                 $tmpMsg->persist();
                                 $messaging->auditId = $tmpMsg->auditId;
                                 $messaging->objectId = $tmpMsg->objectId;
                                 $messaging->objectClass = $tmpMsg->objectClass;
                                 $messaging->personId = $tmpMsg->personId;
                                 $messaging->providerId = $tmpMsg->providerId;
                                 $xmlTmpMessage = new SimpleXMLElement($tmpMsg->rawMessage);
                                 $lastName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->LastName;
                                 $firstName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->FirstName;
                                 $messageInfo = $lastName . ', ' . $firstName;
                                 $drugDescription = (string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->DrugDescription;
                                 $datePrescribed = date('m/d/Y', strtotime((string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->WrittenDate));
                                 $messageInfo .= ' - ' . $drugDescription . ' #' . $datePrescribed;
                                 $messaging->note = 'Status received for ' . $messageInfo;
                             }
                             $messaging->note .= "\n" . $code . ':' . $description;
                         } else {
                             if ($key == 'error') {
                                 $relatesToMessageId = (string) $message->relatesToMessageId;
                                 $messageId = (string) $message->messageId;
                                 $code = (string) $message->code;
                                 $description = (string) $message->description;
                                 $messaging = new Messaging();
                                 $messaging->messageType = 'Error';
                                 $messaging->note = 'Error received for unknown messageId: ' . $relatesToMessageId;
                                 $tmpMsg = new Messaging();
                                 $tmpMsg->messagingId = $relatesToMessageId;
                                 if ($tmpMsg->populate()) {
                                     // populate for newRx details
                                     $tmpMsg->status = 'Sent and Verified';
                                     $x = explode('(', $tmpMsg->note);
                                     $tmpMsg->note = 'newRx';
                                     if ($tmpMsg->objectClass == 'MedicationRefillResponse') {
                                         $tmpMsg->note = 'Refill response';
                                     }
                                     $tmpMsg->note .= ' sent and verified';
                                     if (isset($x[1])) {
                                         unset($x[0]);
                                         $tmpMsg->note .= ' (' . implode('(', $x);
                                     }
                                     $tmpMsg->unresolved = 0;
                                     $tmpMsg->persist();
                                     $messaging->auditId = $tmpMsg->auditId;
                                     $messaging->objectId = $tmpMsg->objectId;
                                     $messaging->objectClass = $tmpMsg->objectClass;
                                     $messaging->personId = $tmpMsg->personId;
                                     $messaging->providerId = $tmpMsg->providerId;
                                     $xmlTmpMessage = new SimpleXMLElement($tmpMsg->rawMessage);
                                     $lastName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->LastName;
                                     $firstName = (string) $xmlTmpMessage->Body->NewRx->Patient->Name->FirstName;
                                     $messageInfo = $lastName . ', ' . $firstName;
                                     $drugDescription = (string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->DrugDescription;
                                     $datePrescribed = date('m/d/Y', strtotime((string) $xmlTmpMessage->Body->NewRx->MedicationPrescribed->WrittenDate));
                                     $messageInfo .= ' - ' . $drugDescription . ' #' . $datePrescribed;
                                     $messaging->note = 'Error received for ' . $messageInfo;
                                 }
                                 $messaging->note .= "\n" . $code . ':' . $description;
                             } else {
                                 continue;
                             }
                         }
                     }
                     $messaging->rawMessage = $rawMessage;
                     $messaging->rawMessageResponse = base64_decode((string) $message->rawMessageResponse);
                     $messaging->status = 'Received';
                     $messaging->dateStatus = date('Y-m-d H:i:s');
                     $messaging->persist();
                     $ret++;
                 }
             }
             if ($ret > 0) {
                 self::sendPullResponse();
             }
         } catch (Exception $e) {
             $error = __('There was an error, the response couldn\'t be parsed as XML: ' . $output);
             trigger_error($error, E_USER_NOTICE);
         }
     } else {
         $error = __('There was an error connecting to HealthCloud. Please try again or contact the system administrator.');
         trigger_error('Curl error connecting to healthcare: ' . curl_error($ch), E_USER_NOTICE);
     }
     curl_close($ch);
     return $ret;
 }
コード例 #18
0
ファイル: PharmacyController.php プロジェクト: huynt57/soyba
 public function actionGetNearPharmacy()
 {
     try {
         $request = Yii::app()->request;
         $lat = StringHelper::filterString($request->getQuery('lat'));
         $lng = StringHelper::filterString($request->getQuery('lng'));
         $limit = StringHelper::filterString($request->getQuery('limit'));
         $offset = StringHelper::filterString($request->getQuery('offset'));
         $data = Pharmacy::model()->getNearPharmacy($lat, $lng, $limit, $offset);
         ResponseHelper::JsonReturnSuccess($data, 'success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
コード例 #19
0
 public function processSendPharmacyAction()
 {
     $pharmacyId = $this->_getParam('pharmacyId');
     $recordChange = $this->_getParam('recordChange');
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $pharmacyId;
     $pharmacy->populate();
     $pharmacy->RecordChange = $recordChange;
     $ret = $pharmacy->sendPharmacy();
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }
コード例 #20
0
ファイル: history_title.php プロジェクト: katopenzz/openemr
</head>
<body class="body_title">

<?php 
$result = getPatientData($pid, "fname,lname,pid,pubpid,phone_home,pharmacy_id,DOB,DATE_FORMAT(DOB,'%Y%m%d') as DOB_YMD");
$provider_results = sqlQuery("select * from users where username=?", array($_SESSION["authUser"]));
$age = getPatientAge($result["DOB_YMD"]);
$info = 'ID: ' . $result['pubpid'];
if ($result['DOB']) {
    $info .= ', ' . xl('DOB') . ': ' . $result['DOB'] . ', ' . xl('Age') . ': ' . $age;
}
if ($result['phone_home']) {
    $info .= ', ' . xl('Home') . ': ' . $result['phone_home'];
}
if ($result['pharmacy_id']) {
    $pharmacy = new Pharmacy($result['pharmacy_id']);
    if ($pharmacy->get_phone()) {
        $info .= ', ' . xl('Pharm') . ': ' . $pharmacy->get_phone();
    }
}
//escape variables for output (to prevent xss attacks)
$patient_esc = htmlspecialchars($result["fname"] . " " . $result["lname"], ENT_NOQUOTES);
$info_esc = htmlspecialchars($info, ENT_NOQUOTES);
$provider_esc = htmlspecialchars($provider_results["fname"] . ' ' . $provider_results["lname"], ENT_NOQUOTES);
?>

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
 <tr>
  <td style="width:45%; vertical-align:middle; white-space: nowrap">
   <span class="title_bar_top"><?php 
echo $patient_esc;
    public function editPharmacyInfo($ID)
    {
        $newpharmacy = new Pharmacy();
        $rs = mysql_query("SELECT u.UserName,p.Name,p.PhoneNumber,p.Address FROM pharmacy p,user u where u.ID=p.ID and u.ID='" . $ID . "'");
        $row = mysql_fetch_assoc($rs);
        echo '<form method="post" action="' . $newpharmacy->editPharmacy($ID) . '">';
        ?>
											
                                            <table>
                                            	<tr>
                                                	<td>
                                                    	 اسم المستخدم
                                                    </td>
                                                	<td>
                                                    	<?php 
        echo '<input name="UserName" type="text" value="' . $row['UserName'] . '" />*';
        ?>
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                	<td>
                                                    	 الاسم 
                                                    </td>
                                                	<td>
                                                    	<?php 
        echo '<input name="Name" type="text" value="' . $row['Name'] . '" />*';
        ?>
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                	<td>
                                                    	  رقم الهاتف
                                                    </td>
                                                	<td>
                                                    	<?php 
        echo '<input name="PhoneNumber" type="text" value="' . $row['PhoneNumber'] . '" />*';
        ?>
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                	<td>
                                                    	   العنوان 
                                                    </td>
                                                	<td>
                                                    	<?php 
        echo '<input name="Address" type="text" value="' . $row['Address'] . '" />*';
        ?>
                                                    </td>
                                                </tr>
                                                
                                            </table>
                                            
											
                                            <?php 
        echo '<input name="editPharmacy" type="submit" value="تعديل" />';
        echo '</form>';
    }