Add medication dosage to the patient dashboard and reports (#5621 #5623) (#5622)
[openemr.git] / ccr / createCCRActor.php
blobcbb728e950db8dc7687ef151ccbbbc3da800991e
1 <?php
3 /**
4 * CCR Script.
6 * Copyright (C) 2010 Garden State Health Systems <http://www.gshsys.com/>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Garden State Health Systems <http://www.gshsys.com/>
21 * @link http://www.open-emr.org
24 $result = getActorData();
25 while ($row = sqlFetchArray($result[0])) {
26 $e_Actor = $ccr->createElement('Actor');
27 $e_Actors->appendChild($e_Actor);
29 $e_ActorObjectID = $ccr->createElement('ActorObjectID', 'A1234'); // Refer createCCRHeader.php
30 $e_Actor->appendChild($e_ActorObjectID);
32 $e_Person = $ccr->createElement('Person');
33 $e_Actor->appendChild($e_Person);
35 $e_Name = $ccr->createElement('Name');
36 $e_Person->appendChild($e_Name);
38 $e_CurrentName = $ccr->createElement('CurrentName');
39 $e_Name->appendChild($e_CurrentName);
41 $e_Given = $ccr->createElement('Given', $row['fname']);
42 $e_CurrentName->appendChild($e_Given);
44 $e_Family = $ccr->createElement('Family', $row['lname']);
45 $e_CurrentName->appendChild($e_Family);
47 $e_Suffix = $ccr->createElement('Suffix');
48 $e_CurrentName->appendChild($e_Suffix);
50 $e_DateOfBirth = $ccr->createElement('DateOfBirth');
51 $e_Person->appendChild($e_DateOfBirth);
53 $dob = date_create($row['DOB']);
55 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $dob->format('Y-m-d\TH:i:s\Z'));
56 $e_DateOfBirth->appendChild($e_ExactDateTime);
58 $e_Gender = $ccr->createElement('Gender');
59 $e_Person->appendChild($e_Gender);
61 $e_Text = $ccr->createElement('Text', $row['sex']);
62 $e_Gender->appendChild($e_Text);
64 $e_Code = $ccr->createElement('Code');
65 $e_Gender->appendChild($e_Code);
67 $e_Value = $ccr->createElement('Value');
68 $e_Code->appendChild($e_Value);
70 $e_IDs = $ccr->createElement('IDs');
71 $e_Actor->appendChild($e_IDs);
73 $e_Type = $ccr->createElement('Type');
74 $e_IDs->appendChild($e_Type);
76 $e_Text = $ccr->createElement('Text', 'Patient ID');
77 $e_Type->appendChild($e_Text);
79 $e_ID = $ccr->createElement('ID', $row['pid']);
80 $e_IDs->appendChild($e_ID);
82 $e_Source = $ccr->createElement('Source');
83 $e_IDs->appendChild($e_Source);
85 $e_SourceActor = $ccr->createElement('Actor');
86 $e_Source->appendChild($e_SourceActor);
88 $e_ActorID = $ccr->createElement('ActorID', getUuid());
89 $e_SourceActor->appendChild($e_ActorID);
91 // address
92 $e_Address = $ccr->createElement('Address');
93 $e_Actor->appendChild($e_Address);
95 $e_Type = $ccr->createElement('Type');
96 $e_Address->appendChild($e_Type);
98 $e_Text = $ccr->createElement('Text', 'H');
99 $e_Type->appendChild($e_Text);
101 $e_Line1 = $ccr->createElement('Line1', $row['street']);
102 $e_Address->appendChild($e_Line1);
104 $e_Line2 = $ccr->createElement('Line2');
105 $e_Address->appendChild($e_Line1);
107 $e_City = $ccr->createElement('City', $row['city']);
108 $e_Address->appendChild($e_City);
110 $e_State = $ccr->createElement('State', $row['state']);
111 $e_Address->appendChild($e_State);
113 $e_PostalCode = $ccr->createElement('PostalCode', $row['postal_code']);
114 $e_Address->appendChild($e_PostalCode);
116 $e_Telephone = $ccr->createElement('Telephone');
117 $e_Actor->appendChild($e_Telephone);
119 $e_Value = $ccr->createElement('Value', $row['phone_contact']);
120 $e_Telephone->appendChild($e_Value);
122 $e_Source = $ccr->createElement('Source');
123 $e_Actor->appendChild($e_Source);
125 $e_Actor = $ccr->createElement('Actor');
126 $e_Source->appendChild($e_Actor);
128 $e_ActorID = $ccr->createElement('ActorID', $authorID);
129 $e_Actor->appendChild($e_ActorID);
132 $row1 = sqlFetchArray($result[1]);
133 //////// Actor Information Systems
135 $e_Actor = $ccr->createElement('Actor');
136 $e_Actors->appendChild($e_Actor);
138 $e_ActorObjectID = $ccr->createElement('ActorObjectID', $authorID);
139 $e_Actor->appendChild($e_ActorObjectID);
141 $e_InformationSystem = $ccr->createElement('InformationSystem');
142 $e_Actor->appendChild($e_InformationSystem);
144 $e_Name = $ccr->createElement('Name', $row1['facility']);
145 $e_InformationSystem->appendChild($e_Name);
147 $e_Type = $ccr->createElement('Type', 'Facility');
148 $e_InformationSystem->appendChild($e_Type);
150 $e_IDs = $ccr->createElement('IDs');
151 $e_Actor->appendChild($e_IDs);
153 $e_Type = $ccr->createElement('Type');
154 $e_IDs->appendChild($e_Type);
156 $e_Text = $ccr->createElement('Text', '');
157 $e_Type->appendChild($e_Text);
159 $e_ID = $ccr->createElement('ID', '');
160 $e_IDs->appendChild($e_ID);
162 $e_Source = $ccr->createElement('Source');
163 $e_IDs->appendChild($e_Source);
165 $e_SourceActor = $ccr->createElement('Actor');
166 $e_Source->appendChild($e_SourceActor);
168 $e_ActorID = $ccr->createElement('ActorID', $authorID);
169 $e_SourceActor->appendChild($e_ActorID);
171 $e_Address = $ccr->createElement('Address');
172 $e_Actor->appendChild($e_Address);
174 $e_Type = $ccr->createElement('Type');
175 $e_Address->appendChild($e_Type);
177 $e_Text = $ccr->createElement('Text', 'WP');
178 $e_Type->appendChild($e_Text);
180 $e_Line1 = $ccr->createElement('Line1', $row1['street']);
181 $e_Address->appendChild($e_Line1);
183 $e_Line2 = $ccr->createElement('Line2');
184 $e_Address->appendChild($e_Line1);
186 $e_City = $ccr->createElement('City', $row1['city']);
187 $e_Address->appendChild($e_City);
189 $e_State = $ccr->createElement('State', $row1['state'] . ' ');
190 $e_Address->appendChild($e_State);
192 $e_PostalCode = $ccr->createElement('PostalCode', $row1['postal_code']);
193 $e_Address->appendChild($e_PostalCode);
195 $e_Telephone = $ccr->createElement('Telephone');
196 $e_Actor->appendChild($e_Telephone);
198 $e_Phone = $ccr->createElement('Value', $row1['phone']);
199 $e_Telephone->appendChild($e_Phone);
201 $e_Source = $ccr->createElement('Source');
202 $e_Actor->appendChild($e_Source);
204 $e_Actor = $ccr->createElement('Actor');
205 $e_Source->appendChild($e_Actor);
207 $e_ActorID = $ccr->createElement('ActorID', $authorID);
208 $e_Actor->appendChild($e_ActorID);
210 //////// Actor Information Systems
211 $e_Actor = $ccr->createElement('Actor');
212 $e_Actors->appendChild($e_Actor);
214 $e_ActorObjectID = $ccr->createElement('ActorObjectID', $oemrID);
215 $e_Actor->appendChild($e_ActorObjectID);
217 $e_InformationSystem = $ccr->createElement('InformationSystem');
218 $e_Actor->appendChild($e_InformationSystem);
220 $e_Name = $ccr->createElement('Name', 'OEMR');
221 $e_InformationSystem->appendChild($e_Name);
223 $e_Type = $ccr->createElement('Type', 'OpenEMR');
224 $e_InformationSystem->appendChild($e_Type);
226 $e_Version = $ccr->createElement('Version', '4.x');
227 $e_InformationSystem->appendChild($e_Version);
229 $e_IDs = $ccr->createElement('IDs');
230 $e_Actor->appendChild($e_IDs);
232 $e_Type = $ccr->createElement('Type');
233 $e_IDs->appendChild($e_Type);
235 $e_Text = $ccr->createElement('Text', 'Certification #');
236 $e_Type->appendChild($e_Text);
238 $e_ID = $ccr->createElement('ID', 'EHRX-OEMRXXXXXX-2011');
239 $e_IDs->appendChild($e_ID);
241 $e_Source = $ccr->createElement('Source');
242 $e_IDs->appendChild($e_Source);
244 $e_SourceActor = $ccr->createElement('Actor');
245 $e_Source->appendChild($e_SourceActor);
247 $e_ActorID = $ccr->createElement('ActorID', $authorID);
248 $e_SourceActor->appendChild($e_ActorID);
250 $e_Address = $ccr->createElement('Address');
251 $e_Actor->appendChild($e_Address);
253 $e_Type = $ccr->createElement('Type');
254 $e_Address->appendChild($e_Type);
256 $e_Text = $ccr->createElement('Text', 'WP');
257 $e_Type->appendChild($e_Text);
259 $e_Line1 = $ccr->createElement('Line1', '2365 Springs Rd. NE');
260 $e_Address->appendChild($e_Line1);
262 $e_Line2 = $ccr->createElement('Line2');
263 $e_Address->appendChild($e_Line1);
265 $e_City = $ccr->createElement('City', 'Hickory');
266 $e_Address->appendChild($e_City);
268 $e_State = $ccr->createElement('State', 'NC ');
269 $e_Address->appendChild($e_State);
271 $e_PostalCode = $ccr->createElement('PostalCode', '28601');
272 $e_Address->appendChild($e_PostalCode);
274 $e_Telephone = $ccr->createElement('Telephone');
275 $e_Actor->appendChild($e_Telephone);
277 $e_Phone = $ccr->createElement('Value', '000-000-0000');
278 $e_Telephone->appendChild($e_Phone);
280 $e_Source = $ccr->createElement('Source');
281 $e_Actor->appendChild($e_Source);
283 $e_Actor = $ccr->createElement('Actor');
284 $e_Source->appendChild($e_Actor);
286 $e_ActorID = $ccr->createElement('ActorID', $authorID);
287 $e_Actor->appendChild($e_ActorID);
289 while ($row2 = sqlFetchArray($result[2])) {
290 $e_Actor = $ccr->createElement('Actor');
291 $e_Actors->appendChild($e_Actor);
293 $e_ActorObjectID = $ccr->createElement('ActorObjectID', ${"labID{$row2['id']}"});
294 $e_Actor->appendChild($e_ActorObjectID);
296 $e_InformationSystem = $ccr->createElement('InformationSystem');
297 $e_Actor->appendChild($e_InformationSystem);
299 $e_Name = $ccr->createElement('Name', $row2['lname'] . " " . $row2['fname']);
300 $e_InformationSystem->appendChild($e_Name);
302 $e_Type = $ccr->createElement('Type', 'Lab Service');
303 $e_InformationSystem->appendChild($e_Type);
305 $e_IDs = $ccr->createElement('IDs');
306 $e_Actor->appendChild($e_IDs);
308 $e_Type = $ccr->createElement('Type');
309 $e_IDs->appendChild($e_Type);
311 $e_Text = $ccr->createElement('Text', '');
312 $e_Type->appendChild($e_Text);
314 $e_ID = $ccr->createElement('ID', '');
315 $e_IDs->appendChild($e_ID);
317 $e_Source = $ccr->createElement('Source');
318 $e_IDs->appendChild($e_Source);
320 $e_SourceActor = $ccr->createElement('Actor');
321 $e_Source->appendChild($e_SourceActor);
323 $e_ActorID = $ccr->createElement('ActorID', $authorID);
324 $e_SourceActor->appendChild($e_ActorID);
326 $e_Address = $ccr->createElement('Address');
327 $e_Actor->appendChild($e_Address);
329 $e_Type = $ccr->createElement('Type');
330 $e_Address->appendChild($e_Type);
332 $e_Text = $ccr->createElement('Text', 'WP');
333 $e_Type->appendChild($e_Text);
335 $e_Line1 = $ccr->createElement('Line1', $row2['street']);
336 $e_Address->appendChild($e_Line1);
338 $e_Line2 = $ccr->createElement('Line2');
339 $e_Address->appendChild($e_Line1);
341 $e_City = $ccr->createElement('City', $row2['city']);
342 $e_Address->appendChild($e_City);
344 $e_State = $ccr->createElement('State', $row2['state'] . ' ');
345 $e_Address->appendChild($e_State);
347 $e_PostalCode = $ccr->createElement('PostalCode', $row2['zip']);
348 $e_Address->appendChild($e_PostalCode);
350 $e_Telephone = $ccr->createElement('Telephone');
351 $e_Actor->appendChild($e_Telephone);
353 $e_Phone = $ccr->createElement('Value', $row2['phone']);
354 $e_Telephone->appendChild($e_Phone);
356 $e_Source = $ccr->createElement('Source');
357 $e_Actor->appendChild($e_Source);
359 $e_Actor = $ccr->createElement('Actor');
360 $e_Source->appendChild($e_Actor);
362 $e_ActorID = $ccr->createElement('ActorID', $authorID);
363 $e_Actor->appendChild($e_ActorID);