CCR/CCD reporting module: added option to see the raw xml
[openemr.git] / ccr / createCCR.php
blob7a5ef0f181528a4b2a2986e6ee3a7ca4db9b2aee
1 <?php
2 // ------------------------------------------------------------------------ //
3 // Garden State Health Systems //
4 // Copyright (c) 2010 gshsys.com //
5 // <http://www.gshsys.com/> //
6 // ------------------------------------------------------------------------ //
7 // This program is free software; you can redistribute it and/or modify //
8 // it under the terms of the GNU General Public License as published by //
9 // the Free Software Foundation; either version 2 of the License, or //
10 // (at your option) any later version. //
11 // //
12 // You may not change or alter any portion of this comment or credits //
13 // of supporting developers from this source code or any supporting //
14 // source code which is considered copyrighted (c) material of the //
15 // original comment or credit authors. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details. //
21 // //
22 // You should have received a copy of the GNU General Public License //
23 // along with this program; if not, write to the Free Software //
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
25 // ------------------------------------------------------------------------ //
27 //SANITIZE ALL ESCAPES
28 $sanitize_all_escapes=true;
31 //STOP FAKE REGISTER GLOBALS
32 $fake_register_globals=false;
35 require_once(dirname(__FILE__) . "/../interface/globals.php");
36 require_once(dirname(__FILE__) . "/../library/sql-ccr.inc");
37 require_once(dirname(__FILE__) . "/../library/sql.inc");
38 require_once(dirname(__FILE__) . "/uuid.php");
41 <?php
43 function createCCR($action,$raw="no"){
45 $authorID = getUuid();
47 echo '<!--';
49 $ccr = new DOMDocument('1.0','UTF-8');
50 $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="ccr.xsl"');
51 $ccr->appendChild($e_styleSheet);
53 $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord');
54 $ccr->appendChild($e_ccr);
56 /////////////// Header
58 require_once("createCCRHeader.php");
59 $e_Body = $ccr->createElement('Body');
60 $e_ccr->appendChild($e_Body);
62 /////////////// Problems
64 $e_Problems = $ccr->createElement('Problems');
65 require_once("createCCRProblem.php");
66 $e_Body->appendChild($e_Problems);
68 /////////////// Alerts
70 $e_Alerts = $ccr->createElement('Alerts');
71 require_once("createCCRAlerts.php");
72 $e_Body->appendChild($e_Alerts);
74 ////////////////// Medication
76 $e_Medications = $ccr->createElement('Medications');
77 require_once("createCCRMedication.php");
78 $e_Body->appendChild($e_Medications);
80 ///////////////// Immunization
82 $e_Immunizations = $ccr->createElement('Immunizations');
83 require_once("createCCRImmunization.php");
84 $e_Body->appendChild($e_Immunizations);
87 /////////////////// Results
89 $e_Results = $ccr->createElement('Results');
90 require_once("createCCRResult.php");
91 $e_Body->appendChild($e_Results);
94 /////////////////// Procedures
96 $e_Procedures = $ccr->createElement('Procedures');
97 require_once("createCCRProcedure.php");
98 $e_Body->appendChild($e_Procedures);
100 //////////////////// Footer
102 // $e_VitalSigns = $ccr->createElement('VitalSigns');
103 // $e_Body->appendChild($e_VitalSigns);
105 /////////////// Actors
107 $e_Actors = $ccr->createElement('Actors');
108 require_once("createCCRActor.php");
109 $e_ccr->appendChild($e_Actors);
112 // save created CCR in file
114 echo " \n action=".$action;
117 if ($action=="generate"){
118 gnrtCCR($ccr,$raw);
121 if($action == "viewccd"){
122 viewCCD($ccr,$raw);
126 function gnrtCCR($ccr,$raw="no"){
127 global $css_header;
128 echo "\n css_header=$css_header";
129 $ccr->preserveWhiteSpace = false;
130 $ccr->formatOutput = true;
131 $ccr->save('generatedXml/ccrDebug.xml');
133 if ($raw == "yes") {
134 echo '-->';
135 echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
136 echo $ccr->saveXml();
137 echo "</textarea>";
138 return;
141 $xmlDom = new DOMDocument();
142 $xmlDom->loadXML($ccr->saveXML());
144 $ss = new DOMDocument();
145 $ss->load('ccr.xsl');
147 $proc = new XSLTProcessor();
149 $proc->importStylesheet($ss);
150 $s_html = $proc->transformToXML($xmlDom);
152 echo '-->';
153 echo $s_html;
157 function viewCCD($ccr,$raw="no"){
159 $ccr->preserveWhiteSpace = false;
160 $ccr->formatOutput = true;
162 $ccr->save('generatedXml/ccrForCCD.xml');
164 if ($raw == "yes") {
165 echo '-->';
166 echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
167 echo $ccr->saveXml();
168 echo "</textarea>";
169 return;
172 $xmlDom = new DOMDocument();
173 $xmlDom->loadXML($ccr->saveXML());
175 $ccr_ccd = new DOMDocument();
176 $ccr_ccd->load('ccd/ccr_ccd.xsl');
178 $xslt = new XSLTProcessor();
179 $xslt->importStylesheet($ccr_ccd);
181 $ccd = new DOMDocument();
182 $ccd->preserveWhiteSpace = false;
183 $ccd->formatOutput = true;
185 $ccd->loadXML($xslt->transformToXML($xmlDom));
187 $ccd->save('generatedXml/ccdDebug.xml');
190 $ss = new DOMDocument();
191 $ss->load("ccd/cda.xsl");
193 $xslt->importStyleSheet($ss);
195 $html = $xslt->transformToXML($ccd);
197 echo '-->';
198 echo $html;
204 function sourceType($ccr, $uuid){
206 $e_Source = $ccr->createElement('Source');
208 $e_Actor = $ccr->createElement('Actor');
209 $e_Source->appendChild($e_Actor);
211 $e_ActorID = $ccr->createElement('ActorID',$uuid);
212 $e_Actor->appendChild($e_ActorID);
214 return $e_Source;
218 createCCR($_POST['ccrAction'],$_POST['raw']);