edihistory -- revisions and cleanup of 277 claim status functions
[openemr.git] / ccr / createCCRProblem.php
blob2ad1d36a057c9b3734d5ffff2e47f107f96f5ad2
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 // ------------------------------------------------------------------------ //
28 $result = getProblemData();
29 $row = sqlFetchArray($result);
30 $pCount =0;
31 //while ($row = sqlFetchArray($result)) {
33 do {
35 $pCount++;
37 $e_Problem = $ccr->createElement('Problem');
38 $e_Problems->appendChild($e_Problem);
40 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'PROB'.$pCount);
41 $e_Problem->appendChild($e_CCRDataObjectID);
43 $e_DateTime = $ccr->createElement('DateTime');
44 $e_Problem->appendChild($e_DateTime);
46 $date = date_create($row['date']);
48 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
49 $e_DateTime->appendChild($e_ExactDateTime);
51 $e_IDs = $ccr->createElement('IDs');
52 $e_Problem->appendChild($e_IDs);
54 $e_ID = $ccr->createElement('ID', $row['pid']);
55 $e_IDs->appendChild($e_ID);
57 $e_IDs->appendChild(sourceType($ccr, $sourceID));
59 $e_Type = $ccr->createElement('Type');
60 $e_Problem->appendChild($e_Type);
62 $e_Text = $ccr->createElement('Text', 'Problem'); // Changed to pass through validator, Problem type must be one of the required string values: Problem, Condition, Diagnosis, Symptom, Finding, Complaint, Functional Limitation.
63 //$e_Text = $ccr->createElement('Text', $row['prob_title']);
64 $e_Type->appendChild($e_Text);
66 $e_Description = $ccr->createElement('Description' );
67 $e_Problem->appendChild($e_Description);
69 $e_Text = $ccr->createElement('Text', lookup_code_descriptions($row['diagnosis']));
70 $e_Description->appendChild($e_Text);
72 $e_Code = $ccr->createElement('Code');
73 $e_Description->appendChild($e_Code);
75 $e_Value = $ccr->createElement('Value',$row['diagnosis']);
76 $e_Code->appendChild($e_Value);
78 $e_Value = $ccr->createElement('CodingSystem', 'ICD9-CM');
79 $e_Code->appendChild($e_Value);
81 $e_Status = $ccr->createElement('Status');
82 $e_Problem->appendChild($e_Status);
84 // $e_Text = $ccr->createElement('Text', $row['outcome']);
85 $e_Text = $ccr->createElement('Text', 'Active');
86 $e_Status->appendChild($e_Text);
88 //$e_CommentID = $ccr->createElement('CommentID', $row['comments']);
89 //$e_Problem->appendChild($e_CommentID);
91 $e_Source = $ccr->createElement('Source');
93 $e_Actor = $ccr->createElement('Actor');
94 $e_Source->appendChild($e_Actor);
96 $e_ActorID = $ccr->createElement('ActorID',$uuid);
97 $e_Actor->appendChild($e_ActorID);
99 $e_Problem->appendChild($e_Source);
101 $e_CommentID = $ccr->createElement('CommentID', $row['comments']);
102 $e_Problem->appendChild($e_CommentID);
104 $e_Episodes = $ccr->createElement('Episodes' );
105 $e_Problem->appendChild($e_Episodes);
107 $e_Number = $ccr->createElement('Number');
108 $e_Episodes->appendChild($e_Number);
110 $e_Episode = $ccr->createElement('Episode');
111 $e_Episodes->appendChild($e_Episode);
113 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'EP'.$pCount);
114 $e_Episode->appendChild($e_CCRDataObjectID);
116 $e_Episode->appendChild(sourceType($ccr, $sourceID));
118 $e_Episodes->appendChild(sourceType($ccr, $sourceID));
120 $e_HealthStatus = $ccr->createElement('HealthStatus' );
121 $e_Problem->appendChild($e_HealthStatus);
123 $e_DateTime = $ccr->createElement('DateTime');
124 $e_HealthStatus->appendChild($e_DateTime);
126 $e_ExactDateTime = $ccr->createElement('ExactDateTime' );
127 $e_DateTime->appendChild($e_ExactDateTime);
129 $e_Description = $ccr->createElement('Description' );
130 $e_HealthStatus->appendChild($e_Description);
132 $e_Text = $ccr->createElement('Text',$row['reason']);
133 $e_Description->appendChild($e_Text);
135 $e_HealthStatus->appendChild(sourceType($ccr, $sourceID));
137 } while ($row = sqlFetchArray($result));
140 // complex type should go in different find and should be included in createCCR.php
142 function sourceType($ccr, $uuid){
144 $e_Source = $ccr->createElement('Source');
146 $e_Actor = $ccr->createElement('Actor');
147 $e_Source->appendChild($e_Actor);
149 $e_ActorID = $ccr->createElement('ActorID',$uuid);
150 $e_Actor->appendChild($e_ActorID);
152 return $e_Source;