Пример #1
0
 public function pdfMergeAttachmentAction()
 {
     //this function is primarily used by other controllers so parameters here are not permitted from _GET and _POST do to possible injection into the xmlData arg which would be very hard to filter
     $request = $this->getRequest();
     $request->setParamSources(array());
     $attachmentReferenceId = preg_replace('/[^a-zA-Z0-9-]/', '', $this->_getParam('attachmentReferenceId'));
     $xmlData = $this->_getParam('xmlData');
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $attachmentReferenceId;
     //'ff560b50-75d0-11de-8a39-0800200c9a66' uuid for prescription pdf
     $attachment->populateWithAttachmentReferenceId();
     $db = Zend_Registry::get('dbAdapter');
     $sql = "select data from attachmentBlobs where attachmentId = " . $attachment->attachmentId;
     $stmt = $db->query($sql);
     $row = $stmt->fetch();
     $this->view->pdfBase64 = base64_encode($row['data']);
     $stmt->closeCursor();
     $this->view->xmlData = $xmlData;
     header('Content-type: application/vnd.adobe.xfdf');
 }
Пример #2
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;
 }
Пример #3
0
    public function render(Zend_View_Interface $view = null)
    {
        // overtake $view arguments
        $currentView = $this->getView();
        $belongsTo = $this->getBelongsTo();
        $name = $this->getName();
        $value = $this->getValue();
        $id = $belongsTo . '-' . $name;
        $completeName = $belongsTo . '[' . $name . ']';
        $clinicalNoteId = $currentView->form->getElement("clinicalNoteId")->getValue();
        $annotationIterator = new ClinicalNoteAnnotationIterator();
        $filters = array();
        $filters['clinicalNoteId'] = $clinicalNoteId;
        $annotationIterator->setFilter($filters);
        $setDefaultAnnotations = "var annotations = [];";
        foreach ($annotationIterator as $annotation) {
            $setDefaultAnnotations .= PHP_EOL . "annotations.push({x:{$annotation->xAxis},y:{$annotation->yAxis},value:(<r><![CDATA[{$annotation->annotation}]]></r>).toString(),valueId:{$annotation->clinicalNoteAnnotationId}});";
        }
        $setDefaultAnnotations .= PHP_EOL . "{$name}ImageDrawing.setDefaultAnnotations(annotations);";
        $attachment = new Attachment();
        $md5sum = preg_replace('[^a-zA-Z0-9-]', '//', $this->getAttrib('md5'));
        if (strlen($md5sum) > 0) {
            $attachment->md5sum = $md5sum;
            $attachment->populateWithMd5sum();
        } else {
            $attachmentReferenceId = preg_replace('[^a-zA-Z0-9-]', '//', $this->getAttrib('src'));
            $attachment->attachmentReferenceId = $attachmentReferenceId;
            $attachment->populateWithAttachmentReferenceId();
        }
        $imageUrl = "{$currentView->baseUrl}/attachments.raw/view-attachment?attachmentId={$attachment->attachmentId}";
        $setDefaultLines = "var lines = [];";
        if ($value) {
            $setDefaultLines .= PHP_EOL . "lines = dojo.fromJson('{$value}');";
        }
        $setDefaultLines .= PHP_EOL . "{$name}ImageDrawing.setDefaultLines(lines);";
        /* NOTE: 
         * <div id="{$name}ContentSpace" style="position:relative;z-index:9999;"></div>
         * MUST be set to higher z-index otherwise the annotation will not display
         * <div id="{$name}Surface" style="position:relative;width:100%;height:100%;border: 1px solid #000;"></div>
         * MUST be set its position to relative otherwise the drawing position is misplaced
         */
        $docType = $currentView->doctype();
        $str = <<<EOL

<input type="hidden" id="{$name}PrintOnClick" value="{$name}PrintImageDrawing();" />
<input type="button" value="Draw" onClick="{$name}ImageDrawing.setAction('draw')" />
<input type="button" value="Annotate" onClick="{$name}ImageDrawing.setAction('annotate')" />
<input type="button" value="Clear" onClick="{$name}ImageDrawing.setAction('clear')" />
<div id="{$name}ContentSpace" style="position:relative;z-index:9999;"></div>
<div id="{$name}Surface" style="position:relative;width:100%;height:100%;border: 1px solid #000;"></div>

<input type="hidden" id="{$id}" name="{$completeName}" value="{$value}" />

<script type="text/javascript">

var surfaceHeight = 1000;
var surfaceWidth = 1650;
var {$name}ImageDrawing = new DrawingClass("{$name}Surface",surfaceWidth,surfaceHeight,"{$name}ContentSpace");
{$setDefaultLines}
{$setDefaultAnnotations}
{$name}ImageDrawing.loadImage('{$imageUrl}');
{$name}ImageDrawing.setEditURL('{$currentView->baseUrl}/clinical-notes.raw/process-edit-annotation');
{$name}ImageDrawing.setDeleteURL('{$currentView->baseUrl}/clinical-notes.raw/process-delete-annotation');
{$name}ImageDrawing.setClinicalNoteId('{$clinicalNoteId}');

globalNoteTemplateCallbacks.push(function(){
\tvar obj = dojo.byId("{$id}");
\tif (obj) {
\t\tvar lines = {$name}ImageDrawing.getLines();
\t\tobj.value = lines ;
\t}
\treturn true;
});

function {$name}PrintImageDrawing() {
\tvar printHtml = (<r><![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
{$docType}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
]]></r>).toString();

\tvar docHead = document.getElementsByTagName("head")[0];
\tprintHtml += docHead.innerHTML;
\tprintHtml += '</head><body class="tundra">';
\tprintHtml += dojo.byId('mainToolbar').innerHTML;

\t// transform annotation boxes to printer friendly
\t{$name}ImageDrawing.printerFriendlyAnnotations();
\tprintHtml += dojo.byId('cntemplateform').innerHTML;
\t// revert printer friendly annotation boxes after iframe assignment
\t{$name}ImageDrawing.revertPrinterFriendlyAnnotations();

\tprintHtml += "</body></html>";

\tvar iframe = dojo.byId("iframeprint");
\tvar doc = null;
\tif (iframe.contentDocument) {
\t\t// Firefox/Opera
\t\tdoc = iframe.contentDocument;
\t}
\telse if (iframe.contentWindow) {
\t\t// Internet Explorer
\t\tdoc = iframe.contentWindow.document;
\t}
\telse if (iframe.document) {
\t\t// Others
\t\tdoc = iframe.document;
\t}
\tif (doc == null) {
\t\tthrow "Document not initialized";
\t}

\tdoc.open();
\tdoc.write(printHtml);
\tdoc.close();

\t// revert printer friendly annotation boxes after iframe assignment
\t//{$name}ImageDrawing.revertPrinterFriendlyAnnotations();

\tdojo.byId('iframeprint').contentWindow.focus();
\tdojo.byId('iframeprint').contentWindow.print();
}

</script>

EOL;
        return $str;
    }
Пример #4
0
 protected function _getAttachmentData($referenceId)
 {
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $referenceId;
     $attachment->populateWithAttachmentReferenceId();
     $data = '';
     if (!$attachment->attachmentId > 0) {
         trigger_error('Invalid attachment reference id ' . $referenceId);
     } else {
         $data = $attachment->rawData;
     }
     return $data;
 }
Пример #5
0
 protected function _downloadCMSPDF(array $claimIds, $type)
 {
     $this->getResponse()->setHeader('Content-Type', 'application/pdf');
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $type;
     $attachment->populateWithAttachmentReferenceId();
     $inputFile = tempnam('/tmp', 'cms_');
     $outputFile = tempnam('/tmp', 'cms_');
     $xmlFile = tempnam('/tmp', 'cms_');
     file_put_contents($inputFile, $attachment->rawData);
     $xmlFile = $this->_generateCMSXML($claimIds, $type);
     $pdfset = exec('which pdfset');
     if (!strlen($pdfset) > 0) {
         $pdfset = '/usr/local/bin/pdfset';
     }
     $output = `{$pdfset} -i {$inputFile} -X {$xmlFile} -o {$outputFile}`;
     $ret = file_get_contents($outputFile);
     // cleanup mess
     unlink($inputFile);
     unlink($outputFile);
     unlink($xmlFile);
     //trigger_error(print_r($claimIds,true));
     //$cmd = "pdfset -i $inputFile -X $xmlFile -o $outputFile";
     //trigger_error($cmd);
     return $ret;
 }