Added a provider filter to Procedures / Electronic Reports.
[openemr.git] / ccr / createCCRProblem.php
blob72081f7b31c7081670f70cb5f14aad601c632fb5
1 <?php
2 /**
3 * CCR Script.
5 * Copyright (C) 2010 Garden State Health Systems <http://www.gshsys.com/>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Garden State Health Systems <http://www.gshsys.com/>
20 * @link http://www.open-emr.org
24 $result = getProblemData();
25 $row = sqlFetchArray($result);
26 $pCount =0;
27 //while ($row = sqlFetchArray($result)) {
29 do {
31 $pCount++;
33 $e_Problem = $ccr->createElement('Problem');
34 $e_Problems->appendChild($e_Problem);
36 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'PROB'.$pCount);
37 $e_Problem->appendChild($e_CCRDataObjectID);
39 $e_DateTime = $ccr->createElement('DateTime');
40 $e_Problem->appendChild($e_DateTime);
42 $date = date_create($row['date']);
44 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
45 $e_DateTime->appendChild($e_ExactDateTime);
47 $e_IDs = $ccr->createElement('IDs');
48 $e_Problem->appendChild($e_IDs);
50 $e_ID = $ccr->createElement('ID', $row['pid']);
51 $e_IDs->appendChild($e_ID);
53 $e_IDs->appendChild(sourceType($ccr, $sourceID));
55 $e_Type = $ccr->createElement('Type');
56 $e_Problem->appendChild($e_Type);
58 $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.
59 //$e_Text = $ccr->createElement('Text', $row['prob_title']);
60 $e_Type->appendChild($e_Text);
62 $e_Description = $ccr->createElement('Description' );
63 $e_Problem->appendChild($e_Description);
65 $e_Text = $ccr->createElement('Text', lookup_code_descriptions($row['diagnosis']));
66 $e_Description->appendChild($e_Text);
68 $e_Code = $ccr->createElement('Code');
69 $e_Description->appendChild($e_Code);
71 $e_Value = $ccr->createElement('Value',$row['diagnosis']);
72 $e_Code->appendChild($e_Value);
74 $e_Value = $ccr->createElement('CodingSystem', 'ICD9-CM');
75 $e_Code->appendChild($e_Value);
77 $e_Status = $ccr->createElement('Status');
78 $e_Problem->appendChild($e_Status);
80 // $e_Text = $ccr->createElement('Text', $row['outcome']);
81 $e_Text = $ccr->createElement('Text', 'Active');
82 $e_Status->appendChild($e_Text);
84 //$e_CommentID = $ccr->createElement('CommentID', $row['comments']);
85 //$e_Problem->appendChild($e_CommentID);
87 $e_Source = $ccr->createElement('Source');
89 $e_Actor = $ccr->createElement('Actor');
90 $e_Source->appendChild($e_Actor);
92 $e_ActorID = $ccr->createElement('ActorID',$uuid);
93 $e_Actor->appendChild($e_ActorID);
95 $e_Problem->appendChild($e_Source);
97 $e_CommentID = $ccr->createElement('CommentID', $row['comments']);
98 $e_Problem->appendChild($e_CommentID);
100 $e_Episodes = $ccr->createElement('Episodes' );
101 $e_Problem->appendChild($e_Episodes);
103 $e_Number = $ccr->createElement('Number');
104 $e_Episodes->appendChild($e_Number);
106 $e_Episode = $ccr->createElement('Episode');
107 $e_Episodes->appendChild($e_Episode);
109 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', 'EP'.$pCount);
110 $e_Episode->appendChild($e_CCRDataObjectID);
112 $e_Episode->appendChild(sourceType($ccr, $sourceID));
114 $e_Episodes->appendChild(sourceType($ccr, $sourceID));
116 $e_HealthStatus = $ccr->createElement('HealthStatus' );
117 $e_Problem->appendChild($e_HealthStatus);
119 $e_DateTime = $ccr->createElement('DateTime');
120 $e_HealthStatus->appendChild($e_DateTime);
122 $e_ExactDateTime = $ccr->createElement('ExactDateTime' );
123 $e_DateTime->appendChild($e_ExactDateTime);
125 $e_Description = $ccr->createElement('Description' );
126 $e_HealthStatus->appendChild($e_Description);
128 $e_Text = $ccr->createElement('Text',$row['reason']);
129 $e_Description->appendChild($e_Text);
131 $e_HealthStatus->appendChild(sourceType($ccr, $sourceID));
133 } while ($row = sqlFetchArray($result));
136 // complex type should go in different find and should be included in createCCR.php
138 function sourceType($ccr, $uuid){
140 $e_Source = $ccr->createElement('Source');
142 $e_Actor = $ccr->createElement('Actor');
143 $e_Source->appendChild($e_Actor);
145 $e_ActorID = $ccr->createElement('ActorID',$uuid);
146 $e_Actor->appendChild($e_ActorID);
148 return $e_Source;