Clickmap Graphical API and Pain Form
[openemr.git] / ccr / createCCR.php
blob4991ab03b6b1430b5015692e91eae811a2d53d33
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();
46 $patientID = getUuid();
47 $sourceID = getUuid();
48 $oemrID = getUuid();
50 echo '<!--';
52 $ccr = new DOMDocument('1.0','UTF-8');
53 $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="ccr.xsl"');
54 $ccr->appendChild($e_styleSheet);
56 $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord');
57 $ccr->appendChild($e_ccr);
59 /////////////// Header
61 require_once("createCCRHeader.php");
62 $e_Body = $ccr->createElement('Body');
63 $e_ccr->appendChild($e_Body);
65 /////////////// Problems
67 $e_Problems = $ccr->createElement('Problems');
68 require_once("createCCRProblem.php");
69 $e_Body->appendChild($e_Problems);
71 /////////////// Alerts
73 $e_Alerts = $ccr->createElement('Alerts');
74 require_once("createCCRAlerts.php");
75 $e_Body->appendChild($e_Alerts);
77 ////////////////// Medication
79 $e_Medications = $ccr->createElement('Medications');
80 require_once("createCCRMedication.php");
81 $e_Body->appendChild($e_Medications);
83 ///////////////// Immunization
85 $e_Immunizations = $ccr->createElement('Immunizations');
86 require_once("createCCRImmunization.php");
87 $e_Body->appendChild($e_Immunizations);
90 /////////////////// Results
92 $e_Results = $ccr->createElement('Results');
93 require_once("createCCRResult.php");
94 $e_Body->appendChild($e_Results);
97 /////////////////// Procedures
99 $e_Procedures = $ccr->createElement('Procedures');
100 require_once("createCCRProcedure.php");
101 $e_Body->appendChild($e_Procedures);
103 //////////////////// Footer
105 // $e_VitalSigns = $ccr->createElement('VitalSigns');
106 // $e_Body->appendChild($e_VitalSigns);
108 /////////////// Actors
110 $e_Actors = $ccr->createElement('Actors');
111 require_once("createCCRActor.php");
112 $e_ccr->appendChild($e_Actors);
115 // save created CCR in file
117 echo " \n action=".$action;
120 if ($action=="generate"){
121 gnrtCCR($ccr,$raw);
124 if($action == "viewccd"){
125 viewCCD($ccr,$raw);
129 function gnrtCCR($ccr,$raw="no"){
130 global $css_header;
131 echo "\n css_header=$css_header";
132 $ccr->preserveWhiteSpace = false;
133 $ccr->formatOutput = true;
134 $ccr->save('generatedXml/ccrDebug.xml');
136 if ($raw == "yes") {
137 echo '-->';
138 echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
139 echo $ccr->saveXml();
140 echo "</textarea>";
141 return;
144 $xmlDom = new DOMDocument();
145 $xmlDom->loadXML($ccr->saveXML());
147 $ss = new DOMDocument();
148 $ss->load('ccr.xsl');
150 $proc = new XSLTProcessor();
152 $proc->importStylesheet($ss);
153 $s_html = $proc->transformToXML($xmlDom);
155 echo '-->';
156 echo $s_html;
160 function viewCCD($ccr,$raw="no"){
162 $ccr->preserveWhiteSpace = false;
163 $ccr->formatOutput = true;
165 $ccr->save('generatedXml/ccrForCCD.xml');
167 // This is same xml as gnrtCCR and does not seem to be used below
168 // so commenting this out for now.
169 //if ($raw == "yes") {
170 // echo '-->';
171 // echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
172 // echo $ccr->saveXml();
173 // echo "</textarea>";
174 // return;
177 $xmlDom = new DOMDocument();
178 $xmlDom->loadXML($ccr->saveXML());
180 $ccr_ccd = new DOMDocument();
181 $ccr_ccd->load('ccd/ccr_ccd.xsl');
183 $xslt = new XSLTProcessor();
184 $xslt->importStylesheet($ccr_ccd);
186 $ccd = new DOMDocument();
187 $ccd->preserveWhiteSpace = false;
188 $ccd->formatOutput = true;
190 $ccd->loadXML($xslt->transformToXML($xmlDom));
192 $ccd->save('generatedXml/ccdDebug.xml');
194 if ($raw == "yes") {
195 echo '-->';
196 echo "<textarea rows='25' cols='500' style='width:95%' readonly>";
197 echo $ccd->saveXml();
198 echo "</textarea>";
199 return;
202 $ss = new DOMDocument();
203 $ss->load("ccd/cda.xsl");
205 $xslt->importStyleSheet($ss);
207 $html = $xslt->transformToXML($ccd);
209 echo '-->';
210 echo $html;
216 function sourceType($ccr, $uuid){
218 $e_Source = $ccr->createElement('Source');
220 $e_Actor = $ccr->createElement('Actor');
221 $e_Source->appendChild($e_Actor);
223 $e_ActorID = $ccr->createElement('ActorID',$uuid);
224 $e_Actor->appendChild($e_ActorID);
226 return $e_Source;
230 createCCR($_POST['ccrAction'],$_POST['raw']);