CCR-CCD module: minor bug fix
[openemr.git] / ccr / createCCRProblem.php
blobb5b38a098c2ec3cc0808ea47045a7a4651fc4e15
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__) . "/../library/sql-ccr.inc");
29 $result = getProblemData();
30 $row = sqlFetchArray($result);
31 $pCount =0;
32 //while ($row = sqlFetchArray($result)) {
34 do {
36 $pCount++;
37 echo 'encounter :'.$row['encounter'].'\n';
39 $e_Problem = $ccr->createElement('Problem');
40 $e_Problems->appendChild($e_Problem);
42 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'PROB'.$pCount);
43 $e_Problem->appendChild($e_CCRDataObjectID);
45 $e_DateTime = $ccr->createElement('DateTime');
46 $e_Problem->appendChild($e_DateTime);
48 $date = date_create($row['date']);
50 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
51 $e_DateTime->appendChild($e_ExactDateTime);
53 $e_IDs = $ccr->createElement('IDs');
54 $e_Problem->appendChild($e_IDs);
56 $e_ID = $ccr->createElement('ID', $row['pid']);
57 $e_IDs->appendChild($e_ID);
59 $e_IDs->appendChild(sourceType($ccr, $authorID));
61 $e_Type = $ccr->createElement('Type');
62 $e_Problem->appendChild($e_Type);
64 $e_Text = $ccr->createElement('Text', $row['prob_title']);
65 $e_Type->appendChild($e_Text);
67 $e_Description = $ccr->createElement('Description' );
68 $e_Problem->appendChild($e_Description);
70 $e_Text = $ccr->createElement('Text', $row['code_text']);
71 $e_Description->appendChild($e_Text);
73 $e_Code = $ccr->createElement('Code');
74 $e_Description->appendChild($e_Code);
76 $e_Value = $ccr->createElement('Value',$row['diagnosis']);
77 $e_Code->appendChild($e_Value);
79 $e_Status = $ccr->createElement('Status');
80 $e_Problem->appendChild($e_Status);
82 // $e_Text = $ccr->createElement('Text', $row['outcome']);
83 $e_Text = $ccr->createElement('Text', 'Active');
84 $e_Status->appendChild($e_Text);
86 $e_CommentID = $ccr->createElement('CommentID', $row['comments']);
87 $e_Problem->appendChild($e_CommentID);
89 $e_Episodes = $ccr->createElement('Episodes' );
90 $e_Problem->appendChild($e_Episodes);
92 $e_Number = $ccr->createElement('Number');
93 $e_Episodes->appendChild($e_Number);
95 $e_Episode = $ccr->createElement('Episode');
96 $e_Episodes->appendChild($e_Episode);
98 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'EP'.$pCount);
99 $e_Episode->appendChild($e_CCRDataObjectID);
101 $e_Episode->appendChild(sourceType($ccr, $authorID));
103 $e_Episodes->appendChild(sourceType($ccr, $authorID));
105 $e_HealthStatus = $ccr->createElement('HealthStatus' );
106 $e_Problem->appendChild($e_HealthStatus);
108 $e_DateTime = $ccr->createElement('DateTime');
109 $e_HealthStatus->appendChild($e_DateTime);
111 $e_ExactDateTime = $ccr->createElement('ExactDateTime' );
112 $e_DateTime->appendChild($e_ExactDateTime);
114 $e_Description = $ccr->createElement('Description' );
115 $e_HealthStatus->appendChild($e_Description);
117 $e_Text = $ccr->createElement('Text',$row['reason']);
118 $e_Description->appendChild($e_Text);
120 $e_HealthStatus->appendChild(sourceType($ccr, $authorID));
122 } while ($row = sqlFetchArray($result));
125 // complex type should go in different find and should be included in createCCR.php
127 function sourceType($ccr, $uuid){
129 $e_Source = $ccr->createElement('Source');
131 $e_Actor = $ccr->createElement('Actor');
132 $e_Source->appendChild($e_Actor);
134 $e_ActorID = $ccr->createElement('ActorID',$uuid);
135 $e_Actor->appendChild($e_ActorID);
137 return $e_Source;