Finalized translations for version 4.0 release
[openemr.git] / ccr / createCCR.php
blob7fcbac0d6f3ea47e40c2f045d8e7cc74c9962d23
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 // This is same xml as gnrtCCR and does not seem to be used below
165 // so commenting this out for now.
166 //if ($raw == "yes") {
167 // echo '-->';
168 // echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
169 // echo $ccr->saveXml();
170 // echo "</textarea>";
171 // return;
174 $xmlDom = new DOMDocument();
175 $xmlDom->loadXML($ccr->saveXML());
177 $ccr_ccd = new DOMDocument();
178 $ccr_ccd->load('ccd/ccr_ccd.xsl');
180 $xslt = new XSLTProcessor();
181 $xslt->importStylesheet($ccr_ccd);
183 $ccd = new DOMDocument();
184 $ccd->preserveWhiteSpace = false;
185 $ccd->formatOutput = true;
187 $ccd->loadXML($xslt->transformToXML($xmlDom));
189 $ccd->save('generatedXml/ccdDebug.xml');
191 if ($raw == "yes") {
192 echo '-->';
193 echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
194 echo $ccd->saveXml();
195 echo "</textarea>";
196 return;
199 $ss = new DOMDocument();
200 $ss->load("ccd/cda.xsl");
202 $xslt->importStyleSheet($ss);
204 $html = $xslt->transformToXML($ccd);
206 echo '-->';
207 echo $html;
213 function sourceType($ccr, $uuid){
215 $e_Source = $ccr->createElement('Source');
217 $e_Actor = $ccr->createElement('Actor');
218 $e_Source->appendChild($e_Actor);
220 $e_ActorID = $ccr->createElement('ActorID',$uuid);
221 $e_Actor->appendChild($e_ActorID);
223 return $e_Source;
227 createCCR($_POST['ccrAction'],$_POST['raw']);