First impression, update the look of the landing page (#3626)
[openemr.git] / ccr / display.php
blob4aab0240e23407a1e762422c6cc49d078cd41f76
1 <?php
3 require_once(dirname(__FILE__) . "/../interface/globals.php");
5 $type = $_GET['type'];
6 $document_id = $_GET['doc_id'];
7 $d = new Document($document_id);
8 $url = $d->get_url();
9 $storagemethod = $d->get_storagemethod();
10 $couch_docid = $d->get_couch_docid();
11 $couch_revid = $d->get_couch_revid();
13 if ($couch_docid && $couch_revid) {
14 $couch = new CouchDB();
15 $data = array($GLOBALS['couchdb_dbase'],$couch_docid);
16 $resp = $couch->retrieve_doc($data);
17 $xml = base64_decode($resp->data);
18 if ($content == '' && $GLOBALS['couchdb_log'] == 1) {
19 $log_content = date('Y-m-d H:i:s') . " ==> Retrieving document\r\n";
20 $log_content = date('Y-m-d H:i:s') . " ==> URL: " . $url . "\r\n";
21 $log_content .= date('Y-m-d H:i:s') . " ==> CouchDB Document Id: " . $couch_docid . "\r\n";
22 $log_content .= date('Y-m-d H:i:s') . " ==> CouchDB Revision Id: " . $couch_revid . "\r\n";
23 $log_content .= date('Y-m-d H:i:s') . " ==> Failed to fetch document content from CouchDB.\r\n";
24 //$log_content .= date('Y-m-d H:i:s')." ==> Will try to download file from HardDisk if exists.\r\n\r\n";
25 $this->document_upload_download_log($d->get_foreign_id(), $log_content);
26 die(xlt("File retrieval from CouchDB failed"));
28 } else {
29 $url = preg_replace("|^(.*)://|", "", $url);
30 // Collect filename and path
31 $from_all = explode("/", $url);
32 $from_filename = array_pop($from_all);
33 $from_pathname_array = array();
34 for ($i = 0; $i < $d->get_path_depth(); $i++) {
35 $from_pathname_array[] = array_pop($from_all);
38 $from_pathname_array = array_reverse($from_pathname_array);
39 $from_pathname = implode("/", $from_pathname_array);
40 $temp_url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_pathname . '/' . $from_filename;
41 if (!file_exists($temp_url)) {
42 echo xl('The requested document is not present at the expected location on the filesystem or there are not sufficient permissions to access it.', '', '', ' ') . $temp_url;
43 } else {
44 $url = $temp_url;
45 $f = fopen($url, "r");
46 $xml = fread($f, filesize($url));
47 fclose($f);
51 if ($type == "CCR") {
52 $xmlDom = new DOMDocument();
53 $xmlDom->loadXML($xml);
54 $ss = new DOMDocument();
55 $ss->load(dirname(__FILE__) . '/stylesheet/ccr.xsl');
56 $proc = new XSLTProcessor();
57 $proc->importStylesheet($ss);
58 $s_html = $proc->transformToXML($xmlDom);
59 echo $s_html;
60 } else {
61 $xmlDom = new DOMDocument();
62 $xmlDom->loadXML($xml);
63 $ss = new DOMDocument();
64 $ss->load(dirname(__FILE__) . '/stylesheet/cda.xsl');
65 $xslt = new XSLTProcessor();
66 $xslt->importStyleSheet($ss);
67 $html = $xslt->transformToXML($xmlDom);
68 echo $html;