Пример #1
0
 public function indexAction()
 {
     $action = $this->getRequest()->getPost('action');
     $am_id = $this->getRequest()->getPost('am_id');
     if ($action == 'add_new_patient') {
         $this->getCcrTable()->insert_patient($am_id);
     }
     $category_details = $this->getCcrTable()->fetch_cat_id('CCR');
     $time_start = date('Y-m-d H:i:s');
     $docid = \Documents\Controller\DocumentsController::uploadAction();
     $uploaded_documents = array();
     $uploaded_documents = $this->getCcrTable()->fetch_uploaded_documents(array('user' => $_SESSION['authId'], 'time_start' => $time_start, 'time_end' => date('Y-m-d H:i:s')));
     if ($uploaded_documents[0]['id'] > 0) {
         $_REQUEST["document_id"] = $uploaded_documents[0]['id'];
         $_REQUEST["batch_import"] = 'YES';
         $this->importAction();
     } else {
         $result = \Documents\Plugin\Documents::fetchXmlDocuments();
         foreach ($result as $row) {
             if ($row['doc_type'] == 'CCR') {
                 $_REQUEST["document_id"] = $row['doc_id'];
                 $this->importAction();
                 \Documents\Model\DocumentsTable::updateDocumentCategoryUsingCatname($row['doc_type'], $row['doc_id']);
             }
         }
     }
     $records = $this->getCcrTable()->document_fetch(array('cat_title' => 'CCR'));
     $view = new ViewModel(array('records' => $records, 'category_id' => $category_details[0]['id'], 'file_location' => basename($_FILES['file']['name']), 'patient_id' => '00', 'listenerObject' => $this->listenerObject, 'commonplugin' => $this->CommonPlugin()));
     return $view;
 }
Пример #2
0
 public function uploadAction()
 {
     $request = $this->getRequest();
     $upload = $request->getPost('upload');
     $category_details = \Carecoordination\Controller\CarecoordinationController::getCarecoordinationTable()->fetch_cat_id('CCD');
     if ($upload == 1) {
         $time_start = date('Y-m-d H:i:s');
         $cdoc = \Documents\Controller\DocumentsController::uploadAction();
         $uploaded_documents = array();
         $uploaded_documents = \Carecoordination\Controller\CarecoordinationController::getCarecoordinationTable()->fetch_uploaded_documents(array('user' => $_SESSION['authId'], 'time_start' => $time_start, 'time_end' => date('Y-m-d H:i:s')));
         if ($uploaded_documents[0]['id'] > 0) {
             $_REQUEST["document_id"] = $uploaded_documents[0]['id'];
             $_REQUEST["batch_import"] = 'YES';
             $this->importAction();
         }
     } else {
         $result = \Documents\Plugin\Documents::fetchXmlDocuments();
         foreach ($result as $row) {
             if ($row['doc_type'] == 'CCD') {
                 $_REQUEST["document_id"] = $row['doc_id'];
                 $this->importAction();
                 \Documents\Model\DocumentsTable::updateDocumentCategoryUsingCatname($row['doc_type'], $row['doc_id']);
             }
         }
     }
     $records = \Carecoordination\Controller\CarecoordinationController::getCarecoordinationTable()->document_fetch(array('cat_title' => 'CCD', 'type' => '13'));
     $view = new ViewModel(array('records' => $records, 'category_id' => $category_details[0]['id'], 'file_location' => basename($_FILES['file']['name']), 'patient_id' => '00', 'listenerObject' => $this->listenerObject));
     return $view;
 }
 public function logCCDA($pid, $encounter, $content, $time, $status, $user_id, $view = 0, $transfer = 0, $emr_transfer = 0)
 {
     $content = base64_decode($content);
     $file_path = '';
     $couch_id = array();
     if ($GLOBALS['document_storage_method'] == 1) {
         $data = array('data' => base64_encode($content), 'pid' => $pid, 'encounter' => $encounter, 'mimetype' => 'text/xml');
         $couch = \Documents\Plugin\Documents::couchDB();
         $couch_id = \Documents\Plugin\Documents::saveCouchDocument($couch, $data);
     } else {
         $file_path = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $pid . '/CCDA';
         $file_name = $pid . "_" . $encounter . "_" . $time . ".xml";
         if (!is_dir($file_path)) {
             mkdir($file_path, 0777, true);
         }
         $fccda = fopen($file_path . "/" . $file_name, "w");
         fwrite($fccda, $content);
         fclose($fccda);
         $file_path = $file_path . "/" . $file_name;
     }
     $query = "insert into ccda (pid, encounter, ccda_data, time, status, user_id, couch_docid, couch_revid, view, transfer,emr_transfer) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?)";
     $appTable = new ApplicationTable();
     $result = $appTable->zQuery($query, array($pid, $encounter, $file_path, $time, $status, $user_id, $couch_id[0], $couch_id[1], $view, $transfer, $emr_transfer));
     return $moduleInsertId = $result->getGeneratedValue();
 }
Пример #4
0
 public function getDocument($document_id)
 {
     $content = \Documents\Plugin\Documents::getDocument($document_id);
     return $content;
 }
Пример #5
0
 public function retrieveAction()
 {
     // List of Preview Available File types
     $previewAvailableFiles = array('application/pdf', 'image/jpeg', 'image/png', 'image/gif', 'text/plain', 'text/html', 'text/xml');
     $request = $this->getRequest();
     $documentId = $this->params()->fromRoute('id');
     $doEncryption = $this->params()->fromRoute('doencryption') == '1' ? true : false;
     $encryptionKey = $this->params()->fromRoute('key');
     $type = $this->params()->fromRoute('download') == '1' ? "attachment" : "inline";
     $result = $this->getDocumentsTable()->getDocument($documentId);
     $skip_headers = false;
     $contentType = $result['mimetype'];
     $document = \Documents\Plugin\Documents::getDocument($documentId, $doEncryption, $encryptionKey);
     $categoryIds = $this->getDocumentsTable()->getCategoryIDs(array('CCD', 'CCR', 'CCDA'));
     if (in_array($result['category_id'], $categoryIds) && $contentType == 'text/xml' && !$doEncryption) {
         $xml = simplexml_load_string($document);
         $xsl = new \DomDocument();
         switch ($result['category_id']) {
             case $categoryIds['CCD']:
                 $style = "ccd.xsl";
                 break;
             case $categoryIds['CCR']:
                 $style = "ccr.xsl";
                 break;
             case $categoryIds['CCDA']:
                 $style = "ccda.xsl";
                 break;
         }
         $xsl->load(__DIR__ . '/../../../../../public/xsl/' . $style);
         $proc = new \XSLTProcessor();
         $proc->importStyleSheet($xsl);
         $document = $proc->transformToXML($xml);
     }
     if ($type == "inline" && !$doEncryption) {
         if (in_array($result['mimetype'], $previewAvailableFiles)) {
             if (in_array($result['category_id'], $categoryIds) && $contentType == 'text/xml') {
                 $contentType = 'text/html';
             }
         } else {
             $skip_headers = true;
         }
     } else {
         if ($doEncryption) {
             $contentType = "application/octet-stream";
         } else {
             $contentType = $result['mimetype'];
         }
     }
     if (!$skip_headers) {
         $response = $this->getResponse();
         $response->setContent($document);
         $headers = $response->getHeaders();
         $headers->clearHeaders()->addHeaderLine('Content-Type', $contentType)->addHeaderLine('Content-Disposition', $type . '; filename="' . $result['name'] . '"')->addHeaderLine('Content-Length', strlen($document));
         $response->setHeaders($headers);
         return $this->response;
     }
 }
Пример #6
0
 public function fetchXmlDocuments()
 {
     $obj = new ApplicationTable();
     $query = "SELECT doc.id \n\t    FROM categories_to_documents AS cat_doc\n\t    JOIN documents AS doc ON doc.imported = 0 AND doc.id = cat_doc.document_id AND doc.mimetype = 'text/xml'\n\t    WHERE cat_doc.category_id = 1";
     $result = $obj->zQuery($query);
     $count = 0;
     $module = array();
     foreach ($result as $row) {
         $content = \Documents\Plugin\Documents::getDocument($row['id']);
         $module[$count]['doc_id'] = $row['id'];
         if (preg_match("/<ClinicalDocument/", $content)) {
             if (preg_match("/2.16.840.1.113883.3.88.11.32.1/", $content)) {
                 $module[$count]['doc_type'] = 'CCD';
             } else {
                 $module[$count]['doc_type'] = 'CCDA';
             }
         } elseif (preg_match("/<ccr:ContinuityOfCareRecord/", $content)) {
             $module[$count]['doc_type'] = 'CCR';
         }
         $count++;
     }
     return $module;
 }