public function processAttachToNotesAction() { $attachmentId = (int) $this->_getParam('attachmentId'); $attachmentReferenceId = $this->_getParam('attachmentReferenceId'); $attachment = new Attachment(); $attachment->attachmentId = $attachmentId; $attachment->populate(); $attachment->attachmentReferenceId = $attachmentReferenceId; $attachment->persist(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(true); }
public function viewAttachmentAction() { $attachmentId = (int) $this->_getParam('attachmentId'); $attachment = new Attachment(); $attachment->attachmentId = $attachmentId; $attachment->populate(); $db = Zend_Registry::get('dbAdapter'); $sql = "select data from attachmentBlobs where attachmentId = " . $attachmentId; $stmt = $db->query($sql); $row = $stmt->fetch(); $this->view->content = $row['data']; switch ($attachment->mimeType) { case 'image/png': case 'image/jpg': case 'image/jpeg': case 'image/gif': $this->getResponse()->setHeader('Content-Type', $attachment->mimeType); break; case 'application/x-shockwave-flash': $this->getResponse()->setHeader('Content-Type', $attachment->mimeType); $stmt->closeCursor(); $this->render(); return; break; default: $this->getResponse()->setHeader('Content-Type', 'application/binary'); } $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="' . $attachment->name . '"'); $stmt->closeCursor(); $this->render(); }
public function getPhoto() { $picture = ''; if ($this->activePhoto > 0) { $attachment = new Attachment(); $attachment->attachmentId = (int) $this->activePhoto; $attachment->populate(); $picture = base64_encode($attachment->rawData); } return $picture; }
public function populateXML(SimpleXMLElement $xml = null, $checked = true) { if ($xml === null) { $xml = new SimpleXMLElement('<data/>'); } $personId = (int) $this->person_id; $person = $this->person; $picture = ''; if ($person->activePhoto > 0) { $attachment = new Attachment(); $attachment->attachmentId = (int) $person->activePhoto; $attachment->populate(); $picture = base64_encode($attachment->rawData); } $xmlPatient = $xml->addChild('patient'); $xmlPerson = $xmlPatient->addChild('person'); $this->_addChild($xmlPerson, 'picture', $picture, $checked); $this->_addChild($xmlPerson, 'lastName', $person->lastName, $checked); $this->_addChild($xmlPerson, 'firstName', $person->firstName, $checked); $this->_addChild($xmlPerson, 'middleName', $person->middleName, $checked); $identifier = ''; if ($person->identifierType == 'SSN') { $identifier = $person->identifier; } $this->_addChild($xmlPerson, 'identifier', $identifier, $checked); $this->_addChild($xmlPerson, 'gender', $person->gender, $checked); $dateOfBirth = explode(' ', date('m d Y', strtotime($person->dateOfBirth))); $this->_addChild($xmlPerson, 'dobMonth', $dateOfBirth[0], $checked); $this->_addChild($xmlPerson, 'dobDay', $dateOfBirth[1], $checked); $this->_addChild($xmlPerson, 'dobYear', $dateOfBirth[2], $checked); $statistics = PatientStatisticsDefinition::getPatientStatistics($personId); $race = ''; if (isset($statistics['Race'])) { $race = $statistics['Race']; } else { if (isset($statistics['race'])) { $race = $statistics['race']; } } $this->_addChild($xmlPerson, 'race', $race, $checked); $maritalStatus = $person->maritalStatus ? $person->maritalStatus : 'Other'; $this->_addChild($xmlPerson, 'maritalStatus', $maritalStatus, $checked); $addresses = Address::listAddresses($personId); foreach ($addresses as $address) { switch ($address->type) { case Address::TYPE_MAIN: $type = 'mainAddress'; break; case Address::TYPE_SEC: $type = 'secondaryAddress'; break; case Address::TYPE_HOME: $type = 'homeAddress'; break; case Address::TYPE_EMPLOYER: $type = 'employerAddress'; break; case Address::TYPE_BILLING: $type = 'billingAddress'; break; case Address::TYPE_OTHER: default: $type = 'otherAddress'; break; } $xmlAddress = $xmlPatient->addChild($type); $this->_addChild($xmlAddress, 'line1', $address->line1, $checked); $this->_addChild($xmlAddress, 'city', $address->city, $checked); $this->_addChild($xmlAddress, 'state', $address->state, $checked); $this->_addChild($xmlAddress, 'zip', $address->postalCode, $checked); } $phoneNumbers = PhoneNumber::listPhoneNumbers($personId); foreach ($phoneNumbers as $phoneNumber) { switch ($phoneNumber->type) { case PhoneNumber::TYPE_HOME: $type = 'homePhone'; break; case PhoneNumber::TYPE_WORK: $type = 'workPhone'; break; case PhoneNumber::TYPE_BILLING: $type = 'billingPhone'; break; case PhoneNumber::TYPE_EMPLOYER: $type = 'employerPhone'; break; case PhoneNumber::TYPE_MOBILE: $type = 'mobilePhone'; break; case PhoneNumber::TYPE_EMERGENCY: $type = 'emergencyPhone'; break; case PhoneNumber::TYPE_FAX: $type = 'faxPhone'; break; case PhoneNumber::TYPE_HOME_EVE: $type = 'homeEvePhone'; break; case PhoneNumber::TYPE_HOME_DAY: $type = 'homeDayPhone'; break; case PhoneNumber::TYPE_BEEPER: $type = 'beeperPhone'; break; default: $type = 'otherPhone'; break; } $xmlPhone = $xmlPatient->addChild($type); $this->_addChild($xmlPhone, 'number', $phoneNumber->number, $checked); } if ($person->primaryPracticeId > 0) { $practice = new Practice(); $practice->practiceId = (int) $person->primaryPracticeId; $practice->populate(); $address = $practice->primaryAddress; $xmlPractice = $xmlPatient->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name, $checked); $xmlPrimaryAddress = $xmlPractice->addChild('primaryAddress'); $this->_addChild($xmlPrimaryAddress, 'line1', $address->line1, $checked); $this->_addChild($xmlPrimaryAddress, 'city', $address->city, $checked); $this->_addChild($xmlPrimaryAddress, 'state', $address->state, $checked); $this->_addChild($xmlPrimaryAddress, 'zip', $address->postalCode, $checked); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number, $checked); $this->_addChild($xmlPractice, 'faxNumber', $practice->fax->number, $checked); } $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($personId); $primary = null; $secondary = null; foreach ($insuredRelationshipIterator as $item) { if (!$item->active) { continue; } if ($primary === null) { $primary = $item; } else { if ($secondary === null) { $secondary = $item; } else { break; } } } $xmlPayer = $xmlPatient->addChild('payer'); if ($primary !== null) { $this->_addChild($xmlPayer, 'medicareNumber', $primary->insuranceProgram->payerIdentifier, $checked); } if ($secondary !== null) { $this->_addChild($xmlPayer, 'medicaidNumber', $secondary->insuranceProgram->payerIdentifier, $checked); } return $xml; }
protected function _editView($viewId = 0, $mode = 'add') { $reportView = new ReportView(); $reportView->reportBaseId = (int) $this->_getParam('baseId'); if ($viewId > 0) { $reportView->reportViewId = $viewId; $reportView->populate(); } $form = new WebVista_Form(array('name' => $mode . '-view')); $form->setAction(Zend_Registry::get('baseUrl') . 'reports-manager.raw/process-' . $mode . '-view'); $form->loadORM($reportView, 'ReportView'); $form->setWindow('winReportBaseViewId'); $this->view->form = $form; $queries = array(); $reportQuery = new ReportQuery(); $reportQuery->reportBaseId = $reportView->reportBaseId; $reportQueryIterator = $reportQuery->getIteratorByBaseId(); $this->view->queries = $reportQueryIterator->toArray('reportQueryId', 'displayName'); $mappings = array(); if ($reportView->unserializedColumnDefinitions === null) { $reportView->unserializedColumnDefinitions = array(); } foreach ($reportView->unserializedColumnDefinitions as $col) { $mappings[] = $this->_generateMappingGridRowData($col); } $this->view->mappings = $mappings; $this->view->transformTypes = ReportView::getTransformTypes(); $this->view->showResults = ReportView::getShowResultOptions(); $showResultsOptions = $reportView->unserializedShowResultsOptions; if (isset($showResultsOptions['pdfTemplateFile'])) { $attachment = new Attachment(); $attachment->attachmentId = (int) $showResultsOptions['pdfTemplateFile']; $attachment->populate(); $showResultsOptions['pdfTemplateFileContent'] = '<a href="' . $this->view->baseUrl . '/attachments.raw/view-attachment?attachmentId=' . $attachment->attachmentId . '">' . $attachment->name . '</a>'; } $this->view->showResultsOptions = $showResultsOptions; $this->view->lineEndings = ReportView::getLineEndingOptions(); $this->render('edit-view'); }
public function defaultPatientHeaderAction() { $personId = (int) $this->_getParam('personId'); // e76f18cd-d388-4c53-b940-53cb81b80c5e $referenceId = $this->_getParam('referenceId'); $data = $this->_getAttachmentData($referenceId); $patient = new Patient(); $patient->personId = $personId; $patient->populate(); $person = $patient->person; $picture = ''; if ($person->activePhoto > 0) { $attachment = new Attachment(); $attachment->attachmentId = (int) $person->activePhoto; $attachment->populate(); $picture = base64_encode($attachment->rawData); } $xml = new SimpleXMLElement('<patientHeader/>'); $xmlPatient = $xml->addChild('patient'); $this->_addChild($xmlPatient, 'picture', $picture); $this->_addChild($xmlPatient, 'lastName', $person->lastName); $this->_addChild($xmlPatient, 'firstName', $person->firstName); $this->_addChild($xmlPatient, 'dateOfBirth', $person->dateOfBirth); $this->_addChild($xmlPatient, 'gender', $person->gender); $statistics = PatientStatisticsDefinition::getPatientStatistics($personId); $race = ''; if (isset($statistics['Race'])) { $race = $statistics['Race']; } else { if (isset($statistics['race'])) { $race = $statistics['race']; } } $this->_addChild($xmlPatient, 'race', $race); $this->_addChild($xmlPatient, 'maritalStatus', $person->displayMaritalStatus); $addresses = Address::listAddresses($personId); $phoneNumbers = PhoneNumber::listPhoneNumbers($personId); $address = null; if (isset($addresses[Address::TYPE_BILLING])) { $address = $addresses[Address::TYPE_BILLING]; } else { if (isset($addresses[Address::TYPE_HOME])) { $address = $addresses[Address::TYPE_HOME]; } else { if (isset($addresses[Address::TYPE_MAIN])) { $address = $addresses[Address::TYPE_MAIN]; } else { if (isset($addresses[Address::TYPE_SEC])) { $address = $addresses[Address::TYPE_SEC]; } else { if (isset($addresses[Address::TYPE_OTHER])) { $address = $addresses[Address::TYPE_OTHER]; } } } } } if ($address !== null) { $phone = ''; if (isset($phoneNumbers[PhoneNumber::TYPE_BILLING])) { $phone = $phoneNumbers[PhoneNumber::TYPE_BILLING]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_WORK])) { $phone = $phoneNumbers[PhoneNumber::TYPE_WORK]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME_DAY])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME_DAY]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME_EVE])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME_EVE]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_MOBILE])) { $phone = $phoneNumbers[PhoneNumber::TYPE_MOBILE]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_BEEPER])) { $phone = $phoneNumbers[PhoneNumber::TYPE_BEEPER]->number; } } } } } } } $this->_addChild($xmlPatient, 'billingLine1', $address->line1); $this->_addChild($xmlPatient, 'billingCity', $address->city); $this->_addChild($xmlPatient, 'billingState', $address->state); $this->_addChild($xmlPatient, 'billingZip', $address->postalCode); $this->_addChild($xmlPatient, 'phoneNumber', $phone); } if ($person->primaryPracticeId > 0) { $practice = new Practice(); $practice->practiceId = (int) $person->primaryPracticeId; $practice->populate(); $address = $practice->primaryAddress; $xmlPractice = $xml->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name); $this->_addChild($xmlPractice, 'primaryLine1', $address->line1); $this->_addChild($xmlPractice, 'primaryCity', $address->city); $this->_addChild($xmlPractice, 'primaryState', $address->state); $this->_addChild($xmlPractice, 'primaryZip', $address->postalCode); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number); $this->_addChild($xmlPractice, 'faxNumber', $practice->fax->number); } $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($personId); $primary = null; $secondary = null; foreach ($insuredRelationshipIterator as $item) { if (!$item->active) { continue; } if ($primary === null) { $primary = $item; } else { if ($secondary === null) { $secondary = $item; } else { break; } } } $xmlPayer = $xml->addChild('payer'); if ($primary !== null) { $this->_addChild($xmlPayer, 'primary', $primary->insuranceProgram->name); } if ($secondary !== null) { $this->_addChild($xmlPayer, 'secondary', $secondary->insuranceProgram->name); } /*$xmlGuarantor = $xml->addChild('guarantor'); $this->_addChild($xmlGuarantor,'lastName',''); $this->_addChild($xmlGuarantor,'firstName',''); $this->_addChild($xmlGuarantor,'dateOfBirth',''); $this->_addChild($xmlGuarantor,'phone','');*/ // get the current visit $xmlProvider = $xml->addChild('provider'); $lastName = ''; $firstName = ''; $dateOfBirth = ''; $phone = ''; $visit = new Visit(); $visit->populateLatestVisit($personId); if ($visit->visitId > 0) { $provider = new Provider(); $provider->personId = $visit->providerId; $provider->populate(); $person = $provider->person; $lastName = $person->lastName; $firstName = $person->firstName; $dateOfBirth = $person->dateOfBirth; $phone = $person->phoneNumber->number; } $this->_addChild($xmlProvider, 'lastName', $lastName); $this->_addChild($xmlProvider, 'firstName', $firstName); $this->_addChild($xmlProvider, 'dateOfBirth', $dateOfBirth); $this->_addChild($xmlProvider, 'phone', $phone); try { $content = ReportBase::mergepdfset($xml, $data); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); } catch (Exception $e) { $content = '<script>alert("' . $e->getMessage() . '")</script>'; } $this->view->content = $content; $this->render('binary-template'); }
function _makeThumbnail($height, $width, $personId) { $person = new Person(); $person->personId = $personId; $person->populate(); $picFile = ''; if ($person->activePhoto > 0) { $attachmentId = $person->activePhoto; $attachment = new Attachment(); $attachment->attachmentId = $attachmentId; $attachment->populate(); $db = Zend_Registry::get('dbAdapter'); $sql = "select data from attachmentBlobs where attachmentId = " . $attachmentId; $stmt = $db->query($sql); $row = $stmt->fetch(); $picFile = tempnam('/tmp', 'patpic'); file_put_contents($picFile, $row['data']); $stmt->closeCursor(); } else { $patientDir = Zend_Registry::get('config')->document->legacyStorePath . '/' . $personId; if ($personId == 0 || !file_exists($patientDir)) { $this->noPictureAction(); } $dir = dir($patientDir); $picturePath = array(); while (false !== ($entry = $dir->read())) { if (preg_match('/.*_pat_pic([0-9]+.*).jpg/', $entry, $matches)) { $timestamp = strtotime($matches[1]); if (!isset($picturePath['timestamp']) || isset($picturePath['timestamp']) && $timestamp > $picturePath['timestamp']) { $picturePath['timestamp'] = $timestamp; $picturePath['path'] = $patientDir . '/' . $entry; } } } $picFile = $picturePath['path']; } if (!file_exists($picFile)) { $this->noPictureAction(); } $patientPicture = new ResizeImage(); $patientPicture->load($picFile); $patientPicture->resize((int) $width, (int) $height); return $patientPicture; }
public function viewAttachmentAction() { $attachmentId = (int) $this->_getParam('attachmentId'); $attachment = new Attachment(); $attachment->attachmentId = $attachmentId; $attachment->populate(); $db = Zend_Registry::get('dbAdapter'); $sql = "select data from attachmentBlobs where attachmentId = " . $attachmentId; $stmt = $db->query($sql); $row = $stmt->fetch(); $this->view->content = $row['data']; $stmt->closeCursor(); $this->getResponse()->setHeader('Content-Type', 'application/binary'); $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="' . $attachment->name . '"'); $this->render(); }