edihistory -- revisions and cleanup of 277 claim status functions
[openemr.git] / ccr / createCCRMedication.php
blob8538c44b57ec001fa25b65df6aeedf5fe4dc5db3
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 = getMedicationData();
29 $value = sqlFetchArray($result);
31 do {
33 $e_Medication = $ccr->createElement('Medication');
34 $e_Medications->appendChild($e_Medication);
36 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', getUuid());
37 $e_Medication->appendChild($e_CCRDataObjectID);
39 $e_DateTime = $ccr->createElement('DateTime');
40 $e_Medication->appendChild($e_DateTime);
42 $date = date_create($value['date_added']);
44 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
45 $e_DateTime->appendChild($e_ExactDateTime);
47 $e_Type = $ccr->createElement('Type');
48 $e_Medication->appendChild($e_Type);
50 $e_Text = $ccr->createElement('Text', 'Medication');
51 $e_Type->appendChild($e_Text);
53 $e_Status = $ccr->createElement('Status');
54 $e_Medication->appendChild($e_Status);
56 $e_Text = $ccr->createElement('Text',$value['active']);
57 $e_Status->appendChild($e_Text);
59 $e_Medication->appendChild(sourceType($ccr, $sourceID));
61 $e_Product = $ccr->createElement('Product');
62 $e_Medication->appendChild($e_Product);
64 $e_ProductName = $ccr->createElement('ProductName');
65 $e_Product->appendChild($e_ProductName);
67 $e_Text = $ccr->createElement('Text',$value['drug']);
68 $e_ProductName->appendChild(clone $e_Text);
70 $e_Code = $ccr->createElement('Code');
71 $e_ProductName->appendChild($e_Code);
73 $e_Value = $ccr->createElement('Value',$value['rxnorm_drugcode']);
74 $e_Code->appendChild($e_Value);
76 $e_Value = $ccr->createElement('CodingSystem', 'RxNorm');
77 $e_Code->appendChild($e_Value);
79 $e_Strength = $ccr->createElement('Strength');
80 $e_Product->appendChild($e_Strength);
82 $e_Value = $ccr->createElement('Value', $value['size']);
83 $e_Strength->appendChild($e_Value);
85 $e_Units = $ccr->createElement('Units');
86 $e_Strength->appendChild($e_Units);
88 $e_Unit = $ccr->createElement('Unit', $value['title']);
89 $e_Units->appendChild($e_Unit);
91 $e_Form = $ccr->createElement('Form');
92 $e_Product->appendChild($e_Form);
94 $e_Text = $ccr->createElement('Text', $value['form']);
95 $e_Form->appendChild($e_Text);
97 $e_Quantity = $ccr->createElement('Quantity');
98 $e_Medication->appendChild($e_Quantity);
100 $e_Value = $ccr->createElement('Value', $value['quantity']);
101 $e_Quantity->appendChild($e_Value);
103 $e_Units = $ccr->createElement('Units');
104 $e_Quantity->appendChild($e_Units);
106 $e_Unit = $ccr->createElement('Unit', '');
107 $e_Units->appendChild($e_Unit);
109 $e_Directions = $ccr->createElement('Directions');
110 $e_Medication->appendChild($e_Directions);
112 $e_Direction = $ccr->createElement('Direction');
113 $e_Directions->appendChild($e_Direction);
115 $e_Description = $ccr->createElement('Description');
116 $e_Direction->appendChild($e_Description);
118 $e_Text = $ccr->createElement('Text', '');
119 $e_Description->appendChild(clone $e_Text);
121 $e_Route = $ccr->createElement('Route');
122 $e_Direction->appendChild($e_Route);
124 $e_Text = $ccr->createElement('Text', 'Tablet');
125 $e_Route->appendChild($e_Text);
127 $e_Site = $ccr->createElement('Site');
128 $e_Direction->appendChild($e_Site);
130 $e_Text = $ccr->createElement('Text', 'Oral');
131 $e_Site->appendChild($e_Text);
133 $e_PatientInstructions = $ccr->createElement('PatientInstructions');
134 $e_Medication->appendChild($e_PatientInstructions);
136 $e_Instruction = $ccr->createElement('Instruction');
137 $e_PatientInstructions->appendChild($e_Instruction);
139 $e_Text = $ccr->createElement('Text', $value['note']);
140 $e_Instruction->appendChild($e_Text);
142 $e_Refills = $ccr->createElement('Refills');
143 $e_Medication->appendChild($e_Refills);
145 $e_Refill = $ccr->createElement('Refill');
146 $e_Refills->appendChild($e_Refill);
148 $e_Number = $ccr->createElement('Number', $value['refills']);
149 $e_Refill->appendChild($e_Number);
151 } while ($value = sqlFetchArray($result));