updated some intructions on the sql upgrade script
[openemr.git] / ccr / createCCRMedication.php
blob3ae3c1bccbd28f0190b1e6eefbecf7b02e41f008
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 = getMedicationData();
25 $value = sqlFetchArray($result);
27 do {
29 $e_Medication = $ccr->createElement('Medication');
30 $e_Medications->appendChild($e_Medication);
32 $e_CCRDataObjectID = $ccr->createElement('CCRDataObjectID', getUuid());
33 $e_Medication->appendChild($e_CCRDataObjectID);
35 $e_DateTime = $ccr->createElement('DateTime');
36 $e_Medication->appendChild($e_DateTime);
38 $date = date_create($value['date_added']);
40 $e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
41 $e_DateTime->appendChild($e_ExactDateTime);
43 $e_Type = $ccr->createElement('Type');
44 $e_Medication->appendChild($e_Type);
46 $e_Text = $ccr->createElement('Text', 'Medication');
47 $e_Type->appendChild($e_Text);
49 $e_Status = $ccr->createElement('Status');
50 $e_Medication->appendChild($e_Status);
52 $e_Text = $ccr->createElement('Text',$value['active']);
53 $e_Status->appendChild($e_Text);
55 $e_Medication->appendChild(sourceType($ccr, $sourceID));
57 $e_Product = $ccr->createElement('Product');
58 $e_Medication->appendChild($e_Product);
60 $e_ProductName = $ccr->createElement('ProductName');
61 $e_Product->appendChild($e_ProductName);
63 $e_Text = $ccr->createElement('Text',$value['drug']);
64 $e_ProductName->appendChild(clone $e_Text);
66 $e_Code = $ccr->createElement('Code');
67 $e_ProductName->appendChild($e_Code);
69 $e_Value = $ccr->createElement('Value',$value['rxnorm_drugcode']);
70 $e_Code->appendChild($e_Value);
72 $e_Value = $ccr->createElement('CodingSystem', 'RxNorm');
73 $e_Code->appendChild($e_Value);
75 $e_Strength = $ccr->createElement('Strength');
76 $e_Product->appendChild($e_Strength);
78 $e_Value = $ccr->createElement('Value', $value['size']);
79 $e_Strength->appendChild($e_Value);
81 $e_Units = $ccr->createElement('Units');
82 $e_Strength->appendChild($e_Units);
84 $e_Unit = $ccr->createElement('Unit', $value['title']);
85 $e_Units->appendChild($e_Unit);
87 $e_Form = $ccr->createElement('Form');
88 $e_Product->appendChild($e_Form);
90 $e_Text = $ccr->createElement('Text', $value['form']);
91 $e_Form->appendChild($e_Text);
93 $e_Quantity = $ccr->createElement('Quantity');
94 $e_Medication->appendChild($e_Quantity);
96 $e_Value = $ccr->createElement('Value', $value['quantity']);
97 $e_Quantity->appendChild($e_Value);
99 $e_Units = $ccr->createElement('Units');
100 $e_Quantity->appendChild($e_Units);
102 $e_Unit = $ccr->createElement('Unit', '');
103 $e_Units->appendChild($e_Unit);
105 $e_Directions = $ccr->createElement('Directions');
106 $e_Medication->appendChild($e_Directions);
108 $e_Direction = $ccr->createElement('Direction');
109 $e_Directions->appendChild($e_Direction);
111 $e_Description = $ccr->createElement('Description');
112 $e_Direction->appendChild($e_Description);
114 $e_Text = $ccr->createElement('Text', '');
115 $e_Description->appendChild(clone $e_Text);
117 $e_Route = $ccr->createElement('Route');
118 $e_Direction->appendChild($e_Route);
120 $e_Text = $ccr->createElement('Text', 'Tablet');
121 $e_Route->appendChild($e_Text);
123 $e_Site = $ccr->createElement('Site');
124 $e_Direction->appendChild($e_Site);
126 $e_Text = $ccr->createElement('Text', 'Oral');
127 $e_Site->appendChild($e_Text);
129 $e_PatientInstructions = $ccr->createElement('PatientInstructions');
130 $e_Medication->appendChild($e_PatientInstructions);
132 $e_Instruction = $ccr->createElement('Instruction');
133 $e_PatientInstructions->appendChild($e_Instruction);
135 $e_Text = $ccr->createElement('Text', $value['note']);
136 $e_Instruction->appendChild($e_Text);
138 $e_Refills = $ccr->createElement('Refills');
139 $e_Medication->appendChild($e_Refills);
141 $e_Refill = $ccr->createElement('Refill');
142 $e_Refills->appendChild($e_Refill);
144 $e_Number = $ccr->createElement('Number', $value['refills']);
145 $e_Refill->appendChild($e_Number);
147 } while ($value = sqlFetchArray($result));