CCR-CCD module: minor bug fix
[openemr.git] / ccr / createCCR.php
blob78fc7d47e1ba36e26ed8c511d491489e10e1f87c
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 require_once(dirname(__FILE__) . "/../interface/globals.php");
28 require_once(dirname(__FILE__) . "/../library/sql-ccr.inc");
29 require_once(dirname(__FILE__) . "/../library/sql.inc");
30 require_once(dirname(__FILE__) . "/uuid.php");
33 <?php
35 function createCCR($action){
37 $authorID = getUuid();
39 echo '<!--';
41 $ccr = new DOMDocument('1.0','UTF-8');
42 $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="ccr.xsl"');
43 $ccr->appendChild($e_styleSheet);
45 $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord');
46 $ccr->appendChild($e_ccr);
48 /////////////// Header
50 require_once("createCCRHeader.php");
51 $e_Body = $ccr->createElement('Body');
52 $e_ccr->appendChild($e_Body);
54 /////////////// Problems
56 $e_Problems = $ccr->createElement('Problems');
57 require_once("createCCRProblem.php");
58 $e_Body->appendChild($e_Problems);
60 /////////////// Alerts
62 $e_Alerts = $ccr->createElement('Alerts');
63 require_once("createCCRAlerts.php");
64 $e_Body->appendChild($e_Alerts);
66 ////////////////// Medication
68 $e_Medications = $ccr->createElement('Medications');
69 require_once("createCCRMedication.php");
70 $e_Body->appendChild($e_Medications);
72 ///////////////// Immunization
74 $e_Immunizations = $ccr->createElement('Immunizations');
75 require_once("createCCRImmunization.php");
76 $e_Body->appendChild($e_Immunizations);
79 /////////////////// Results
81 $e_Results = $ccr->createElement('Results');
82 require_once("createCCRResult.php");
83 $e_Body->appendChild($e_Results);
86 /////////////////// Procedures
88 $e_Procedures = $ccr->createElement('Procedures');
89 require_once("createCCRProcedure.php");
90 $e_Body->appendChild($e_Procedures);
92 //////////////////// Footer
94 // $e_VitalSigns = $ccr->createElement('VitalSigns');
95 // $e_Body->appendChild($e_VitalSigns);
97 /////////////// Actors
99 $e_Actors = $ccr->createElement('Actors');
100 require_once("createCCRActor.php");
101 $e_ccr->appendChild($e_Actors);
104 // save created CCR in file
106 echo " \n action=".$action;
109 if ($action=="generate"){
110 gnrtCCR($ccr);
113 if($action == "viewccd"){
114 viewCCD($ccr);
118 function gnrtCCR($ccr){
119 global $css_header;
120 echo "\n css_header=$css_header";
121 $ccr->preserveWhiteSpace = false;
122 $ccr->formatOutput = true;
123 $ccr->save('generatedXml/ccrDebug.xml');
125 $xmlDom = new DOMDocument();
126 $xmlDom->loadXML($ccr->saveXML());
128 $ss = new DOMDocument();
129 $ss->load('ccr.xsl');
131 $proc = new XSLTProcessor();
133 $proc->importStylesheet($ss);
134 $s_html = $proc->transformToXML($xmlDom);
136 echo '-->';
137 echo $s_html;
141 function viewCCD($ccr){
143 $ccr->preserveWhiteSpace = false;
144 $ccr->formatOutput = true;
146 $ccr->save('generatedXml/ccrForCCD.xml');
148 $xmlDom = new DOMDocument();
149 $xmlDom->loadXML($ccr->saveXML());
151 $ccr_ccd = new DOMDocument();
152 $ccr_ccd->load('ccd/ccr_ccd.xsl');
154 $xslt = new XSLTProcessor();
155 $xslt->importStylesheet($ccr_ccd);
157 $ccd = new DOMDocument();
158 $ccd->preserveWhiteSpace = false;
159 $ccd->formatOutput = true;
161 $ccd->loadXML($xslt->transformToXML($xmlDom));
163 $ccd->save('generatedXml/ccdDebug.xml');
166 $ss = new DOMDocument();
167 $ss->load("ccd/cda.xsl");
169 $xslt->importStyleSheet($ss);
171 $html = $xslt->transformToXML($ccd);
173 echo '-->';
174 echo $html;
180 function sourceType($ccr, $uuid){
182 $e_Source = $ccr->createElement('Source');
184 $e_Actor = $ccr->createElement('Actor');
185 $e_Source->appendChild($e_Actor);
187 $e_ActorID = $ccr->createElement('ActorID',$uuid);
188 $e_Actor->appendChild($e_ActorID);
190 return $e_Source;
194 createCCR($_POST['ccrAction']);