fix: For prior PR #6749 (#6803)
[openemr.git] / ccr / createCCRMedication.php
blob223f4ef4b09a24fd652167c73c3ead4f6410428d
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 = getMedicationData();
25 $value = sqlFetchArray($result);
27 do {
28 $e_Medication = $ccr->createElement('Medication');
29 $e_Medications->appendChild($e_Medication);
31 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', getUuid());
32 $e_Medication->appendChild($e_CCRDataObjectID);
34 $e_DateTime = $ccr->createElement('DateTime');
35 $e_Medication->appendChild($e_DateTime);
37 $date = date_create($value['date_added']);
39 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
40 $e_DateTime->appendChild($e_ExactDateTime);
42 $e_Type = $ccr->createElement('Type');
43 $e_Medication->appendChild($e_Type);
45 $e_Text = $ccr->createElement('Text', 'Medication');
46 $e_Type->appendChild($e_Text);
48 $e_Status = $ccr->createElement('Status');
49 $e_Medication->appendChild($e_Status);
51 $e_Text = $ccr->createElement('Text', $value['active']);
52 $e_Status->appendChild($e_Text);
54 $e_Medication->appendChild(sourceType($ccr, $sourceID));
56 $e_Product = $ccr->createElement('Product');
57 $e_Medication->appendChild($e_Product);
59 $e_ProductName = $ccr->createElement('ProductName');
60 $e_Product->appendChild($e_ProductName);
62 $e_Text = $ccr->createElement('Text', $value['drug']);
63 $e_ProductName->appendChild(clone $e_Text);
65 $e_Code = $ccr->createElement('Code');
66 $e_ProductName->appendChild($e_Code);
68 $e_Value = $ccr->createElement('Value', $value['rxnorm_drugcode']);
69 $e_Code->appendChild($e_Value);
71 $e_Value = $ccr->createElement('CodingSystem', 'RxNorm');
72 $e_Code->appendChild($e_Value);
74 $e_Strength = $ccr->createElement('Strength');
75 $e_Product->appendChild($e_Strength);
77 $e_Value = $ccr->createElement('Value', $value['size']);
78 $e_Strength->appendChild($e_Value);
80 $e_Units = $ccr->createElement('Units');
81 $e_Strength->appendChild($e_Units);
83 $e_Unit = $ccr->createElement('Unit', $value['title']);
84 $e_Units->appendChild($e_Unit);
86 $e_Form = $ccr->createElement('Form');
87 $e_Product->appendChild($e_Form);
89 $e_Text = $ccr->createElement('Text', $value['form']);
90 $e_Form->appendChild($e_Text);
92 $e_Quantity = $ccr->createElement('Quantity');
93 $e_Medication->appendChild($e_Quantity);
95 $e_Value = $ccr->createElement('Value', $value['quantity']);
96 $e_Quantity->appendChild($e_Value);
98 $e_Units = $ccr->createElement('Units');
99 $e_Quantity->appendChild($e_Units);
101 $e_Unit = $ccr->createElement('Unit', '');
102 $e_Units->appendChild($e_Unit);
104 $e_Directions = $ccr->createElement('Directions');
105 $e_Medication->appendChild($e_Directions);
107 $e_Direction = $ccr->createElement('Direction');
108 $e_Directions->appendChild($e_Direction);
110 $e_Description = $ccr->createElement('Description');
111 $e_Direction->appendChild($e_Description);
113 $e_Text = $ccr->createElement('Text', '');
114 $e_Description->appendChild(clone $e_Text);
116 $e_Route = $ccr->createElement('Route');
117 $e_Direction->appendChild($e_Route);
119 $e_Text = $ccr->createElement('Text', 'Tablet');
120 $e_Route->appendChild($e_Text);
122 $e_Site = $ccr->createElement('Site');
123 $e_Direction->appendChild($e_Site);
125 $e_Text = $ccr->createElement('Text', 'Oral');
126 $e_Site->appendChild($e_Text);
128 $e_PatientInstructions = $ccr->createElement('PatientInstructions');
129 $e_Medication->appendChild($e_PatientInstructions);
131 $e_Instruction = $ccr->createElement('Instruction');
132 $e_PatientInstructions->appendChild($e_Instruction);
134 $e_Text = $ccr->createElement('Text', $value['note']);
135 $e_Instruction->appendChild($e_Text);
137 $e_Refills = $ccr->createElement('Refills');
138 $e_Medication->appendChild($e_Refills);
140 $e_Refill = $ccr->createElement('Refill');
141 $e_Refills->appendChild($e_Refill);
143 $e_Number = $ccr->createElement('Number', $value['refills']);
144 $e_Refill->appendChild($e_Number);
145 } while ($value = sqlFetchArray($result));