Updated Acknowledgments page
[openemr.git] / sql / 3_2_0-to-4_0_0_upgrade.sql
blob5ccdc24340d038f90b3ca7df0b5c558a40b32b1a
1 --
2 --  Comment Meta Language for sql upgrades:
3 --
4 --  Each section within an upgrade sql file is enveloped with an #If*/#EndIf block.  At first glance, these appear to be standard mysql 
5 --  comments meant to be cryptic hints to -other developers about the sql goodness contained therein.  However, were you to rely on such basic premises,
6 --  you would find yourself grossly decieved.  Indeed, without the knowledge that these comments are, in fact a sneakily embedded meta langauge derived 
7 --  for a purpose none-other than to aid in the protection of the database during upgrades,  you would no doubt be subject to much ridicule and public 
8 --  beratement at the hands of the very developers who envisioned such a crafty use of comments. -jwallace
9 --
10 --  While these lines are as enigmatic as they are functional, there is a method to the madness.  Let's take a moment to briefly go over proper comment meta language use.
11 --  
12 --  The #If* sections have the behavior of functions and come complete with arguments supplied command-line style 
14 --  Your Comment meta language lines cannot contain any other comment styles such as the nefarious double dashes "--" lest your lines be skipped and 
15 --  the blocks automatcially executed with out regard to the existing database state.   
17 --  Comment Meta Language Constructs:
18 -- 
19 --  #IfNotTable
20 --    argument: table_name
21 --    behavior: if the table_name does not exist,  the block will be executed
23 --  #IfTable
24 --    argument: table_name
25 --    behavior: if the table_name does exist, the block will be executed
27 --  #IfMissingColumn
28 --    arguments: table_name colname
29 --    behavior:  if the colname in the table_name table does not exist,  the block will be executed
31 --  #IfNotColumnType
32 --    arguments: table_name colname value
33 --    behavior:  If the table table_name does not have a column colname with a data type equal to value, then the block will be executed
35 --  #IfNotRow
36 --    arguments: table_name colname value
37 --    behavior:  If the table table_name does not have a row where colname = value, the block will be executed.
39 --  #IfNotRow2D
40 --    arguments: table_name colname value colname2 value2
41 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed.
43 --  #IfNotRow2Dx2
44 --    desc:      This is a very specialized function to allow adding items to the list_options table to avoid both redundant option_id and title in each element.
45 --    arguments: table_name colname value colname2 value2 colname3 value3
46 --    behavior:  The block will be executed if both statements below are true:
47 --               1) The table table_name does not have a row where colname = value AND colname2 = value2.
48 --               2) The table table_name does not have a row where colname = value AND colname3 = value3.
50 --  #EndIf
51 --    all blocks are terminated with and #EndIf statement. 
53 #IfMissingColumn log patient_id
54 ALTER TABLE log ADD patient_id bigint(20) DEFAULT NULL;
55 #EndIf
57 #IfMissingColumn log success
58 ALTER TABLE log ADD success tinyint(1) DEFAULT 1;
59 #EndIf
61 #IfMissingColumn log checksum
62 ALTER TABLE log ADD checksum longtext DEFAULT NULL;
63 #EndIf
65 #IfMissingColumn log crt_user
66 ALTER TABLE log ADD crt_user varchar(255) DEFAULT NULL;
67 #EndIf
69 #IfNotRow2Dx2 list_options list_id language option_id armenian title Armenian
70 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'armenian', 'Armenian', 10, 0);
71 #EndIf
72 #IfNotRow2Dx2 list_options list_id language option_id chinese title Chinese
73 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'chinese', 'Chinese', 20, 0);
74 #EndIf
75 #IfNotRow2Dx2 list_options list_id language option_id danish title Danish
76 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'danish', 'Danish', 30, 0);
77 #EndIf
78 #IfNotRow2Dx2 list_options list_id language option_id deaf title Deaf
79 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'deaf', 'Deaf', 40, 0);
80 #EndIf
81 #IfNotRow2Dx2 list_options list_id language option_id farsi title Farsi
82 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'farsi', 'Farsi', 60, 0);
83 #EndIf
84 #IfNotRow2Dx2 list_options list_id language option_id french title French
85 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'french', 'French', 70, 0);
86 #EndIf
87 #IfNotRow2Dx2 list_options list_id language option_id german title German
88 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'german', 'German', 80, 0);
89 #EndIf
90 #IfNotRow2Dx2 list_options list_id language option_id greek title Greek
91 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'greek', 'Greek', 90, 0);
92 #EndIf
93 #IfNotRow2Dx2 list_options list_id language option_id hmong title Hmong
94 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'hmong', 'Hmong', 100, 0);
95 #EndIf
96 #IfNotRow2Dx2 list_options list_id language option_id italian title Italian
97 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'italian', 'Italian', 110, 0);
98 #EndIf
99 #IfNotRow2Dx2 list_options list_id language option_id japanese title Japanese
100 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'japanese', 'Japanese', 120, 0);
101 #EndIf
102 #IfNotRow2Dx2 list_options list_id language option_id korean title Korean
103 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'korean', 'Korean', 130, 0);
104 #EndIf
105 #IfNotRow2Dx2 list_options list_id language option_id laotian title Laotian
106 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'laotian', 'Laotian', 140, 0);
107 #EndIf
108 #IfNotRow2Dx2 list_options list_id language option_id mien title Mien
109 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'mien', 'Mien', 150, 0);
110 #EndIf
111 #IfNotRow2Dx2 list_options list_id language option_id norwegian title Norwegian
112 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'norwegian', 'Norwegian', 160, 0);
113 #EndIf
114 #IfNotRow2Dx2 list_options list_id language option_id othrs title Others
115 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'othrs', 'Others', 170, 0);
116 #EndIf
117 #IfNotRow2Dx2 list_options list_id language option_id portuguese title Portuguese
118 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'portuguese', 'Portuguese', 180, 0);
119 #EndIf
120 #IfNotRow2Dx2 list_options list_id language option_id punjabi title Punjabi
121 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'punjabi', 'Punjabi', 190, 0);
122 #EndIf
123 #IfNotRow2Dx2 list_options list_id language option_id russian title Russian
124 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'russian', 'Russian', 200, 0);
125 #EndIf
126 #IfNotRow2Dx2 list_options list_id language option_id tagalog title Tagalog
127 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'tagalog', 'Tagalog', 220, 0);
128 #EndIf
129 #IfNotRow2Dx2 list_options list_id language option_id turkish title Turkish
130 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'turkish', 'Turkish', 230, 0);
131 #EndIf
132 #IfNotRow2Dx2 list_options list_id language option_id vietnamese title Vietnamese
133 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'vietnamese', 'Vietnamese', 240, 0);
134 #EndIf
135 #IfNotRow2Dx2 list_options list_id language option_id yiddish title Yiddish
136 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'yiddish', 'Yiddish', 250, 0);
137 #EndIf
138 #IfNotRow2Dx2 list_options list_id language option_id zulu title Zulu
139 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('language', 'zulu', 'Zulu', 260, 0);
140 #EndIf
142 update list_options set seq = 50 where list_id = 'language' and option_id = 'English';
143 update list_options set seq = 210 where list_id = 'language' and option_id = 'Spanish';
145 #IfNotRow2Dx2 list_options list_id ethrace option_id aleut title ALEUT
146 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'aleut', 'ALEUT', 10,  0);
147 #EndIf
148 #IfNotRow2Dx2 list_options list_id ethrace option_id amer_indian title American Indian
149 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'amer_indian', 'American Indian', 20, 0);
150 #EndIf
151 #IfNotRow2Dx2 list_options list_id ethrace option_id cambodian title Cambodian
152 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'cambodian', 'Cambodian', 50, 0);
153 #EndIf
154 #IfNotRow2Dx2 list_options list_id ethrace option_id cs_american title Central/South American
155 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'cs_american', 'Central/South American', 70, 0);
156 #EndIf
157 #IfNotRow2Dx2 list_options list_id ethrace option_id chinese title Chinese
158 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'chinese', 'Chinese', 80, 0);
159 #EndIf
160 #IfNotRow2Dx2 list_options list_id ethrace option_id cuban title Cuban
161 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'cuban', 'Cuban', 90, 0);
162 #EndIf
163 #IfNotRow2Dx2 list_options list_id ethrace option_id eskimo title Eskimo
164 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'eskimo', 'Eskimo', 100, 0);
165 #EndIf
166 #IfNotRow2Dx2 list_options list_id ethrace option_id filipino title Filipino
167 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'filipino', 'Filipino', 110, 0);
168 #EndIf
169 #IfNotRow2Dx2 list_options list_id ethrace option_id guamanian title Guamanian
170 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'guamanian', 'Guamanian', 120, 0);
171 #EndIf
172 #IfNotRow2Dx2 list_options list_id ethrace option_id hawaiian title Hawaiian
173 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'hawaiian', 'Hawaiian', 130, 0);
174 #EndIf
175 #IfNotRow2Dx2 list_options list_id ethrace option_id othr_us title Hispanic - Other (Born in US)
176 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'othr_us', 'Hispanic - Other (Born in US)', 150, 0);
177 #EndIf
178 #IfNotRow2Dx2 list_options list_id ethrace option_id othr_non_us title Hispanic - Other (Born outside US)
179 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'othr_non_us', 'Hispanic - Other (Born outside US)', 160, 0);
180 #EndIf
181 #IfNotRow2Dx2 list_options list_id ethrace option_id hmong title Hmong
182 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'hmong', 'Hmong', 170, 0);
183 #EndIf
184 #IfNotRow2Dx2 list_options list_id ethrace option_id indian title Indian
185 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'indian', 'Indian', 180, 0);
186 #EndIf
187 #IfNotRow2Dx2 list_options list_id ethrace option_id japanese title Japanese
188 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'japanese', 'Japanese', 190, 0);
189 #EndIf
190 #IfNotRow2Dx2 list_options list_id ethrace option_id korean title Korean
191 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'korean', 'Korean', 200, 0);
192 #EndIf
193 #IfNotRow2Dx2 list_options list_id ethrace option_id laotian title Laotian
194 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'laotian', 'Laotian', 210, 0);
195 #EndIf
196 #IfNotRow2Dx2 list_options list_id ethrace option_id mexican title Mexican/MexAmer/Chicano
197 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'mexican', 'Mexican/MexAmer/Chicano', 220, 0);
198 #EndIf
199 #IfNotRow2Dx2 list_options list_id ethrace option_id mlt-race title Multiracial
200 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'mlt-race', 'Multiracial', 230, 0);
201 #EndIf
202 #IfNotRow2Dx2 list_options list_id ethrace option_id othr title Other
203 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'othr', 'Other', 240, 0);
204 #EndIf
205 #IfNotRow2Dx2 list_options list_id ethrace option_id othr_spec title Other - Specified
206 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'othr_spec', 'Other - Specified', 250, 0);
207 #EndIf
208 #IfNotRow2Dx2 list_options list_id ethrace option_id pac_island title Pacific Islander
209 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'pac_island', 'Pacific Islander', 260, 0);
210 #EndIf
211 #IfNotRow2Dx2 list_options list_id ethrace option_id puerto_rican title Puerto Rican
212 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'puerto_rican', 'Puerto Rican', 270, 0);
213 #EndIf
214 #IfNotRow2Dx2 list_options list_id ethrace option_id refused title Refused To State
215 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'refused', 'Refused To State', 280, 0);
216 #EndIf
217 #IfNotRow2Dx2 list_options list_id ethrace option_id samoan title Samoan
218 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'samoan', 'Samoan', 290, 0);
219 #EndIf
220 #IfNotRow2Dx2 list_options list_id ethrace option_id spec title Specified
221 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'spec', 'Specified', 300, 0);
222 #EndIf
223 #IfNotRow2Dx2 list_options list_id ethrace option_id thai title Thai
224 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'thai', 'Thai', 310, 0);
225 #EndIf
226 #IfNotRow2Dx2 list_options list_id ethrace option_id unknown title Unknown
227 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'unknown', 'Unknown', 320, 0);
228 #EndIf
229 #IfNotRow2Dx2 list_options list_id ethrace option_id unspec title Unspecified
230 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'unspec', 'Unspecified', 330, 0);
231 #EndIf
232 #IfNotRow2Dx2 list_options list_id ethrace option_id vietnamese title Vietnamese
233 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'vietnamese', 'Vietnamese', 340, 0);
234 #EndIf
235 #IfNotRow2Dx2 list_options list_id ethrace option_id white title White
236 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'white', 'White', 350, 0);
237 #EndIf
238 #IfNotRow2Dx2 list_options list_id ethrace option_id withheld title Withheld
239 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethrace', 'withheld', 'Withheld', 360, 0);
240 #EndIf
242 update list_options set seq = 60 where list_id = 'ethrace' and option_id = 'Caucasian';
243 update list_options set seq = 30 where list_id = 'ethrace' and option_id = 'Asian';
244 update list_options set seq = 40 where list_id = 'ethrace' and option_id = 'Black';
245 update list_options set seq = 140 where list_id = 'ethrace' and option_id = 'Hispanic';
247 #IfNotRow2D list_options list_id lists option_id eligibility
248 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists', 'eligibility', 'Eligibility', 47, 0);
249 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('eligibility', 'eligible', 'Eligible', 10, 0);
250 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('eligibility', 'ineligible', 'Ineligible', 20, 0);
251 #EndIf
253 #IfNotRow2D layout_options form_id DEM field_id vfc
254 INSERT INTO `layout_options` VALUES ('DEM', 'vfc', '5Stats', 'VFC', 12, 1, 1, 20, 0, 'eligibility', 1, 1, '', '', 'Eligibility status for Vaccine for Children supplied vaccine');
255 #EndIf
257 #IfNotRow2D layout_options form_id DEM field_id mothersname
258 INSERT INTO `layout_options` VALUES ('DEM', 'mothersname', '2Contact', 'Mother''s Name', 6, 2, 1, 20, 63, '', 1, 1, '', '', '');
259 #EndIf
261 #IfNotRow2D layout_options form_id DEM field_id guardiansname
262 INSERT INTO `layout_options` VALUES ('DEM', 'guardiansname', '2Contact', 'Guardian''s Name', 7, 2, 1, 20, 63, '', 1, 1, '', '', '');
263 #EndIf
265 #IfNotRow2D layout_options form_id DEM field_id allow_imm_reg_use
266 INSERT INTO `layout_options` VALUES ('DEM', 'allow_imm_reg_use', '3Choices', 'Allow Immunization Registry Use', 9, 1, 1, 0, 0, 'yesno', 1, 1, '', '', '');
267 #EndIf
269 #IfNotRow2D layout_options form_id DEM field_id allow_imm_info_share
270 INSERT INTO `layout_options` VALUES ('DEM', 'allow_imm_info_share', '3Choices', 'Allow Immunization Info Sharing', 10, 1, 1, 0, 0, 'yesno', 1, 1, '', '', '');
271 #EndIf
273 #IfNotRow2D layout_options form_id DEM field_id allow_health_info_ex
274 INSERT INTO `layout_options` VALUES ('DEM', 'allow_health_info_ex', '3Choices', 'Allow Health Information Exchange', 11, 1, 1, 0, 0, 'yesno', 1, 1, '', '', '');
275 #EndIf
277 #IfMissingColumn patient_data vfc
278 ALTER TABlE patient_data
279   ADD vfc varchar(255) NOT NULL DEFAULT '',
280   ADD mothersname varchar(255) NOT NULL DEFAULT '',
281   ADD guardiansname varchar(255) NOT NULL DEFAULT '',
282   ADD allow_imm_reg_use varchar(255) NOT NULL DEFAULT '',
283   ADD allow_imm_info_share varchar(255) NOT NULL DEFAULT '',
284   ADD allow_health_info_ex varchar(255) NOT NULL DEFAULT '';
285 #EndIf
287 #IfNotRow categories name Advance Directive
288   INSERT INTO categories select (select MAX(id) from categories) + 1, 'Advance Directive', '', 1, rght, rght + 7 from categories where name = 'Categories';
289   INSERT INTO categories select (select MAX(id) from categories) + 1, 'Do Not Resuscitate Order', '', (select id from categories where name = 'Advance Directive'), rght + 1, rght + 2 from categories where name = 'Categories';
290   INSERT INTO categories select (select MAX(id) from categories) + 1, 'Durable Power of Attorney', '', (select id from categories where name = 'Advance Directive'), rght + 3, rght + 4 from categories where name = 'Categories';
291   INSERT INTO categories select (select MAX(id) from categories) + 1, 'Living Will', '', (select id from categories where name = 'Advance Directive'), rght + 5, rght + 6 from categories where name = 'Categories';
292   UPDATE categories SET rght = rght + 8 WHERE name = 'Categories';
293   UPDATE categories_seq SET id = (select MAX(id) from categories);
294 #EndIf
296 #IfNotRow categories name Patient Photograph
297  INSERT INTO categories select (select MAX(id) from categories) + 1, 'Patient Photograph', '', 1, rght, rght + 1 from categories where name = 'Categories';
298  UPDATE categories SET rght = rght + 2 WHERE name = 'Categories';
299  UPDATE categories_seq SET id = (select MAX(id) from categories);
300 #Endif
302 #IfMissingColumn patient_data completed_ad
303 ALTER TABLE patient_data
304   ADD completed_ad VARCHAR(3) NOT NULL DEFAULT 'NO',
305   ADD ad_reviewed date DEFAULT NULL;
306 #EndIf
308 #IfNotRow2D list_options list_id lists option_id apptstat
309 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'apptstat','Appointment Statuses', 1,0);
310 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','-'       ,'- None'              , 5,0);
311 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','*'       ,'* Reminder done'     ,10,0);
312 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','+'       ,'+ Chart pulled'      ,15,0);
313 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','x'       ,'x Canceled'          ,20,0);
314 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','?'       ,'? No show'           ,25,0);
315 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','@'       ,'@ Arrived'           ,30,0);
316 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','~'       ,'~ Arrived late'      ,35,0);
317 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','!'       ,'! Left w/o visit'    ,40,0);
318 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','#'       ,'# Ins/fin issue'     ,45,0);
319 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','<'       ,'< In exam room'      ,50,0);
320 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','>'       ,'> Checked out'       ,55,0);
321 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','$'       ,'$ Coding done'       ,60,0);
322 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','%'       ,'% Canceled < 24h'    ,65,0);
323 ALTER TABLE openemr_postcalendar_events CHANGE pc_apptstatus pc_apptstatus varchar(15) NOT NULL DEFAULT '-';
324 #EndIf
326 #IfNotRow2D list_options list_id lists option_id transactions
327 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists', 'transactions', 'Transactions', 20, 0);
328 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Referral', 'Referral', 10, 0);
329 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Patient Request', 'Patient Request', 20, 0);
330 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Physician Request', 'Physician Request', 30, 0);
331 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Legal', 'Legal', 40, 0);
332 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Billing', 'Billing', 50, 0);
333 #EndIf
335 #IfNotRow2D layout_options form_id DEM field_id referral_source
336 INSERT INTO `layout_options` VALUES ('DEM', 'referral_source', '5Stats', 'Referral Source',10, 26, 1, 0, 0, 'refsource', 1, 1, '', '', 'How did they hear about us');
337 #EndIf
339 #IfMissingColumn list_options notes
340 ALTER TABLE list_options
341   CHANGE mapping mapping varchar(31) NOT NULL DEFAULT '',
342   ADD notes varchar(255) NOT NULL DEFAULT '';
343 #EndIf
345 #IfNotRow2D list_options list_id lists option_id warehouse
346 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','warehouse','Warehouses',21,0);
347 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('warehouse','onsite','On Site', 5,0);
348 #EndIf
350 #IfNotRow2D list_options list_id lists option_id abook_type
351 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','abook_type'  ,'Address Book Types'  , 1,0);
352 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_img','Imaging Service'     , 5,0);
353 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_imm','Immunization Service',10,0);
354 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_lab','Lab Service'         ,15,0);
355 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','spe'    ,'Specialist'          ,20,0);
356 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','vendor' ,'Vendor'              ,25,0);
357 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','oth'    ,'Other'               ,95,0);
358 #EndIf
360 #IfMissingColumn users abook_type
361 ALTER TABLE users
362   ADD abook_type varchar(31) NOT NULL DEFAULT '';
363 #EndIf
365 #IfNotRow2D list_options list_id lists option_id proc_type
366 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_type','Procedure Types', 1,0);
367 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','grp','Group'          ,10,0);
368 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','ord','Procedure Order',20,0);
369 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','res','Discrete Result',30,0);
370 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','rec','Recommendation' ,40,0);
371 #EndIf
373 #IfNotRow2D list_options list_id lists option_id proc_body_site
374 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_body_site','Procedure Body Sites', 1,0);
375 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','arm'    ,'Arm'    ,10,0);
376 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','buttock','Buttock',20,0);
377 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','oth'    ,'Other'  ,90,0);
378 #EndIf
380 #IfNotRow2D list_options list_id lists option_id proc_specimen
381 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_specimen','Procedure Specimen Types', 1,0);
382 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','blood' ,'Blood' ,10,0);
383 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','saliva','Saliva',20,0);
384 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','urine' ,'Urine' ,30,0);
385 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','oth'   ,'Other' ,90,0);
386 #EndIf
388 #IfNotRow2D list_options list_id lists option_id proc_route
389 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_route','Procedure Routes', 1,0);
390 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','inj' ,'Injection',10,0);
391 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oral','Oral'     ,20,0);
392 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oth' ,'Other'    ,90,0);
393 #EndIf
395 #IfNotRow2D list_options list_id lists option_id proc_lat
396 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_lat','Procedure Lateralities', 1,0);
397 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','left' ,'Left'     ,10,0);
398 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','right','Right'    ,20,0);
399 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','bilat','Bilateral',30,0);
400 #EndIf
402 #IfNotRow2D list_options list_id lists option_id proc_unit
403 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists','proc_unit','Procedure Units', 1);
404 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','bool'       ,'Boolean'    ,  5);
405 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','cu_mm'      ,'CU.MM'      , 10);
406 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','fl'         ,'FL'         , 20);
407 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','g_dl'       ,'G/DL'       , 30);
408 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','gm_dl'      ,'GM/DL'      , 40);
409 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','hmol_l'     ,'HMOL/L'     , 50);
410 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','iu_l'       ,'IU/L'       , 60);
411 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mg_dl'      ,'MG/DL'      , 70);
412 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mil_cu_mm'  ,'Mil/CU.MM'  , 80);
413 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percent'    ,'Percent'    , 90);
414 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percentile' ,'Percentile' ,100);
415 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','pg'         ,'PG'         ,110);
416 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','ratio'      ,'Ratio'      ,120);
417 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','thous_cu_mm','Thous/CU.MM',130);
418 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units'      ,'Units'      ,140);
419 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units_l'    ,'Units/L'    ,150);
420 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','days'       ,'Days'       ,600);
421 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','weeks'      ,'Weeks'      ,610);
422 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','months'     ,'Months'     ,620);
423 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','oth'        ,'Other'      ,990);
424 #EndIf
426 #IfNotRow2D list_options list_id lists option_id ord_priority
427 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_priority','Order Priorities', 1,0);
428 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','high'  ,'High'  ,10,0);
429 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','normal','Normal',20,0);
430 #EndIf
432 #IfNotRow2D list_options list_id lists option_id ord_status
433 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_status','Order Statuses', 1,0);
434 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','pending' ,'Pending' ,10,0);
435 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','routed'  ,'Routed'  ,20,0);
436 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','complete','Complete',30,0);
437 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','canceled','Canceled',40,0);
438 #EndIf
440 #IfNotRow2D list_options list_id lists option_id proc_rep_status
441 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_rep_status','Procedure Report Statuses', 1,0);
442 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','final'  ,'Final'      ,10,0);
443 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','review' ,'Reviewed'   ,20,0);
444 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','prelim' ,'Preliminary',30,0);
445 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','cancel' ,'Canceled'   ,40,0);
446 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','error'  ,'Error'      ,50,0);
447 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','correct','Corrected'  ,60,0);
448 #EndIf
450 #IfNotRow2D list_options list_id lists option_id proc_res_abnormal
451 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_abnormal','Procedure Result Abnormal', 1,0);
452 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','no'  ,'No'  ,10,0);
453 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','yes' ,'Yes' ,20,0);
454 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','high','High',30,0);
455 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','low' ,'Low' ,40,0);
456 #EndIf
458 #IfNotRow2D list_options list_id lists option_id proc_res_status
459 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_status','Procedure Result Statuses', 1,0);
460 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','final'     ,'Final'      ,10,0);
461 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','prelim'    ,'Preliminary',20,0);
462 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','cancel'    ,'Canceled'   ,30,0);
463 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','error'     ,'Error'      ,40,0);
464 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','correct'   ,'Corrected'  ,50,0);
465 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','incomplete','Incomplete' ,60,0);
466 #EndIf
468 #IfNotRow2D list_options list_id lists option_id proc_res_bool
469 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_bool','Procedure Boolean Results', 1,0);
470 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','neg' ,'Negative',10,0);
471 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','pos' ,'Positive',20,0);
472 #EndIf
474 #IfNotTable procedure_type
475 CREATE TABLE `procedure_type` (
476   `procedure_type_id`   bigint(20)   NOT NULL AUTO_INCREMENT,
477   `parent`              bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references procedure_type.procedure_type_id',
478   `name`                varchar(63)  NOT NULL DEFAULT '' COMMENT 'name for this category, procedure or result type',
479   `lab_id`              bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references users.id, 0 means default to parent',
480   `procedure_code`      varchar(31)  NOT NULL DEFAULT '' COMMENT 'code identifying this procedure',
481   `procedure_type`      varchar(31)  NOT NULL DEFAULT '' COMMENT 'see list proc_type',
482   `body_site`           varchar(31)  NOT NULL DEFAULT '' COMMENT 'where to do injection, e.g. arm, buttok',
483   `specimen`            varchar(31)  NOT NULL DEFAULT '' COMMENT 'blood, urine, saliva, etc.',
484   `route_admin`         varchar(31)  NOT NULL DEFAULT '' COMMENT 'oral, injection',
485   `laterality`          varchar(31)  NOT NULL DEFAULT '' COMMENT 'left, right, ...',
486   `description`         varchar(255) NOT NULL DEFAULT '' COMMENT 'descriptive text for procedure_code',
487   `standard_code`       varchar(255) NOT NULL DEFAULT '' COMMENT 'industry standard code type and code (e.g. CPT4:12345)',
488   `related_code`        varchar(255) NOT NULL DEFAULT '' COMMENT 'suggested code(s) for followup services if result is abnormal',
489   `units`               varchar(31)  NOT NULL DEFAULT '' COMMENT 'default for procedure_result.units',
490   `range`               varchar(255) NOT NULL DEFAULT '' COMMENT 'default for procedure_result.range',
491   `seq`                 int(11)      NOT NULL default 0  COMMENT 'sequence number for ordering',
492   PRIMARY KEY (`procedure_type_id`),
493   KEY parent (parent)
494 ) ENGINE=MyISAM;
495 #EndIf
497 #IfNotTable procedure_order
498 CREATE TABLE `procedure_order` (
499   `procedure_order_id`     bigint(20)   NOT NULL AUTO_INCREMENT,
500   `procedure_type_id`      bigint(20)   NOT NULL            COMMENT 'references procedure_type.procedure_type_id',
501   `provider_id`            bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references users.id',
502   `patient_id`             bigint(20)   NOT NULL            COMMENT 'references patient_data.pid',
503   `encounter_id`           bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references form_encounter.encounter',
504   `date_collected`         datetime     DEFAULT NULL        COMMENT 'time specimen collected',
505   `date_ordered`           date         DEFAULT NULL,
506   `order_priority`         varchar(31)  NOT NULL DEFAULT '',
507   `order_status`           varchar(31)  NOT NULL DEFAULT '' COMMENT 'pending,routed,complete,canceled',
508   `patient_instructions`   text         NOT NULL DEFAULT '',
509   `activity`               tinyint(1)   NOT NULL DEFAULT 1  COMMENT '0 if deleted',
510   `control_id`             bigint(20)   NOT NULL            COMMENT 'This is the CONTROL ID that is sent back from lab',
511   PRIMARY KEY (`procedure_order_id`),
512   KEY datepid (date_ordered, patient_id)
513 ) ENGINE=MyISAM;
514 #EndIf
516 #IfNotTable procedure_report
517 CREATE TABLE `procedure_report` (
518   `procedure_report_id` bigint(20)     NOT NULL AUTO_INCREMENT,
519   `procedure_order_id`  bigint(20)     DEFAULT NULL   COMMENT 'references procedure_order.procedure_order_id',
520   `date_collected`      datetime       DEFAULT NULL,
521   `date_report`         date           DEFAULT NULL,
522   `source`              bigint(20)     NOT NULL DEFAULT 0  COMMENT 'references users.id, who entered this data',
523   `specimen_num`        varchar(63)    NOT NULL DEFAULT '',
524   `report_status`       varchar(31)    NOT NULL DEFAULT '' COMMENT 'received,complete,error',
525   `review_status`       varchar(31)    NOT NULL DEFAULT 'received' COMMENT 'panding reivew status: received,reviewed',
526   PRIMARY KEY (`procedure_report_id`),
527   KEY procedure_order_id (procedure_order_id)
528 ) ENGINE=MyISAM; 
529 #EndIf
531 #IfNotTable procedure_result
532 CREATE TABLE `procedure_result` (
533   `procedure_result_id` bigint(20)   NOT NULL AUTO_INCREMENT,
534   `procedure_report_id` bigint(20)   NOT NULL            COMMENT 'references procedure_report.procedure_report_id',
535   `procedure_type_id`   bigint(20)   NOT NULL            COMMENT 'references procedure_type.procedure_type_id',
536   `date`                datetime     DEFAULT NULL        COMMENT 'lab-provided date specific to this result',
537   `facility`            varchar(255) NOT NULL DEFAULT '' COMMENT 'lab-provided testing facility ID',
538   `units`               varchar(31)  NOT NULL DEFAULT '',
539   `result`              varchar(255) NOT NULL DEFAULT '',
540   `range`               varchar(255) NOT NULL DEFAULT '',
541   `abnormal`            varchar(31)  NOT NULL DEFAULT '' COMMENT 'no,yes,high,low',
542   `comments`            text         NOT NULL DEFAULT '' COMMENT 'comments from the lab',
543   `document_id`         bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references documents.id if this result is a document',
544   `result_status`       varchar(31)  NOT NULL DEFAULT '' COMMENT 'preliminary, cannot be done, final, corrected, incompete...etc.',
545   PRIMARY KEY (`procedure_result_id`),
546   KEY procedure_report_id (procedure_report_id)
547 ) ENGINE=MyISAM; 
548 #EndIf
550 #IfMissingColumn history_data recreational_drugs
551 ALTER TABLE history_data ADD recreational_drugs longtext;
552 #EndIf
554 update layout_options set seq = 1, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'coffee';
555 update layout_options set seq = 6, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'exercise_patterns';
556 update layout_options set seq = 2, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'tobacco';
557 update layout_options set seq = 3, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'alcohol';
558 update layout_options set seq = 5, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'counseling';
559 update layout_options set seq = 7, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'hazardous_activities';
560 update layout_options set seq = 8, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'sleep_patterns';
561 update layout_options set seq = 9, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'seatbelt_use';
563 #IfNotRow2D layout_options form_id HIS field_id recreational_drugs
564 INSERT INTO layout_options (form_id, field_id, group_name, title, seq, data_type, uor, fld_length, max_length, list_id, titlecols, datacols, default_value, edit_options, description) VALUES ('HIS','recreational_drugs','4Lifestyle','Recreational Drugs',4,28,1,20,255,'',1,3,'','' ,'Recreational drugs use');
565 #EndIf
567 #IfMissingColumn users pwd_expiration_date
568 ALTER TABLE users ADD pwd_expiration_date date DEFAULT NULL;
569 #EndIf
571 #IfMissingColumn users pwd_history1
572 ALTER TABLE users ADD pwd_history1 longtext DEFAULT NULL;
573 #EndIf
575 #IfMissingColumn users pwd_history2
576 ALTER TABLE users ADD pwd_history2 longtext DEFAULT NULL;
577 #EndIf
579 #IfMissingColumn drug_inventory warehouse_id
580 ALTER TABLE drug_inventory
581   ADD warehouse_id varchar(31) NOT NULL DEFAULT '';
582 #EndIf
584 #IfMissingColumn drug_inventory vendor_id
585 ALTER TABLE drug_inventory
586   ADD vendor_id bigint(20) NOT NULL DEFAULT 0;
587 #EndIf
589 #IfMissingColumn drug_sales xfer_inventory_id
590 ALTER TABLE drug_sales
591   ADD xfer_inventory_id int(11) NOT NULL DEFAULT 0;
592 #EndIf
594 #IfMissingColumn drugs allow_combining
595 ALTER TABLE drugs
596   ADD allow_combining tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 = allow filling an order from multiple lots',
597   ADD allow_multiple  tinyint(1) NOT NULL DEFAULT 1 COMMENT '1 = allow multiple lots at one warehouse';
598 #EndIf
600 #IfNotRow registry directory procedure_order
601 INSERT INTO `registry` VALUES ('Procedure Order', 1, 'procedure_order', NULL, 1, 1, '2010-02-25 00:00:00', 0, 'Administrative', '');
602 #EndIf
604 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'fee_sheet';
605 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'procedure_order';
606 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'newpatient';
607 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'misc_billing_options';
608 UPDATE registry SET category = 'Clinical' WHERE category = 'category';
610 #IfMissingColumn users default_warehouse
611 ALTER TABLE users ADD default_warehouse varchar(31) NOT NULL DEFAULT '';
612 #EndIf
614 UPDATE layout_options SET edit_options = 'N'  WHERE form_id = 'DEM' AND field_id = 'title'  AND edit_options = '';
615 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'fname'  AND edit_options = 'C';
616 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'lname'  AND edit_options = 'C';
617 UPDATE layout_options SET edit_options = 'ND' WHERE form_id = 'DEM' AND field_id = 'pubpid' AND edit_options = '';
618 UPDATE layout_options SET edit_options = 'N'  WHERE form_id = 'DEM' AND field_id = 'sex'    AND edit_options = '';
620 #IfNotRow2D list_options list_id lists option_id message_status
621 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'         ,'message_status','Message Status',45,0);
622 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Done'           ,'Done'         , 5,0);
623 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Forwarded'      ,'Forwarded'    ,10,0);
624 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','New'            ,'New'          ,15,0);
625 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Read'           ,'Read'         ,20,0);
626 #EndIf
628 #IfNotRow2D list_options list_id note_type option_id Lab Results
629 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Lab Results' ,'Lab Results', 15,0);
630 #EndIf
631 #IfNotRow2D list_options list_id note_type option_id New Orders
632 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','New Orders' ,'New Orders', 20,0);
633 #EndIf
634 #IfNotRow2D list_options list_id note_type option_id Patient Reminders
635 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Patient Reminders' ,'Patient Reminders', 25,0);
636 #EndIf
638 #IfMissingColumn pnotes message_status
639 ALTER TABLE pnotes
640   ADD message_status VARCHAR(20) NOT NULL DEFAULT 'New';
641 #EndIf
643 #IfNotTable globals
644 CREATE TABLE `globals` (
645   `gl_name`             varchar(63)    NOT NULL,
646   `gl_index`            int(11)        NOT NULL DEFAULT 0,
647   `gl_value`            varchar(255)   NOT NULL DEFAULT '',
648   PRIMARY KEY (`gl_name`, `gl_index`)
649 ) ENGINE=MyISAM; 
650 #EndIf
652 #IfNotTable lang_custom
653 CREATE TABLE lang_custom (
654   `lang_description`   varchar(100)   NOT NULL default '',
655   `lang_code`          char(2)        NOT NULL default '',
656   `constant_name`      varchar(255)   NOT NULL default '',
657   `definition`         mediumtext     NOT NULL default ''
658 ) ENGINE=MyISAM;
659 #EndIf
661 #IfNotRow2D list_options list_id lists option_id irnpool
662 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'irnpool','Invoice Reference Number Pools', 1,0);
663 INSERT INTO list_options ( list_id, option_id, title, seq, is_default, notes ) VALUES ('irnpool','main','Main',1,1,'000001');
664 #EndIf
666 #IfMissingColumn users irnpool
667 ALTER TABLE users ADD irnpool varchar(31) NOT NULL DEFAULT '';
668 #EndIf
670 #IfMissingColumn form_encounter invoice_refno
671 ALTER TABLE form_encounter ADD invoice_refno varchar(31) NOT NULL DEFAULT '';
672 #EndIf
674 #IfMissingColumn drug_sales notes
675 ALTER TABLE drug_sales
676   ADD notes varchar(255) NOT NULL DEFAULT '';
677 #EndIf
679 #IfNotTable code_types
680 CREATE TABLE code_types (
681   ct_key  varchar(15) NOT NULL           COMMENT 'short alphanumeric name',
682   ct_id   int(11)     UNIQUE NOT NULL    COMMENT 'numeric identifier',
683   ct_seq  int(11)     NOT NULL DEFAULT 0 COMMENT 'sort order',
684   ct_mod  int(11)     NOT NULL DEFAULT 0 COMMENT 'length of modifier field',
685   ct_just varchar(15) NOT NULL DEFAULT ''COMMENT 'ct_key of justify type, if any',
686   ct_mask varchar(9)  NOT NULL DEFAULT ''COMMENT 'formatting mask for code values',
687   ct_fee  tinyint(1)  NOT NULL default 0 COMMENT '1 if fees are used',
688   ct_rel  tinyint(1)  NOT NULL default 0 COMMENT '1 if can relate to other code types',
689   ct_nofs tinyint(1)  NOT NULL default 0 COMMENT '1 if to be hidden in the fee sheet',
690   ct_diag tinyint(1)  NOT NULL default 0 COMMENT '1 if this is a diagnosis type',
691   PRIMARY KEY (ct_key)
692 ) ENGINE=MyISAM;
693 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag ) VALUES ('ICD9' , 2, 1, 2, ''    , 0, 0, 0, 1);
694 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag ) VALUES ('CPT4' , 1, 2, 2, 'ICD9', 1, 0, 0, 0);
695 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag ) VALUES ('HCPCS', 3, 3, 2, 'ICD9', 1, 0, 0, 0);
696 #EndIf
698 #IfNotRow2D list_options list_id lists option_id code_types
699 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists', 'code_types', 'Code Types', 1);
700 #EndIf
702 #IfMissingColumn codes reportable
703 ALTER TABLE `codes` 
704   ADD `reportable` TINYINT(1) DEFAULT 0 COMMENT '0 = non-reportable, 1 = reportable';
705 #EndIf
707 #IfNotTable syndromic_surveillance
708 CREATE TABLE `syndromic_surveillance` (
709   `id` bigint(20) NOT NULL auto_increment,
710   `lists_id` bigint(20) NOT NULL,
711   `submission_date` datetime NOT NULL,
712   `filename` varchar(255) NOT NULL default '',
713   PRIMARY KEY  (`id`),
714   KEY (`lists_id`)
715 ) ENGINE=MyISAM AUTO_INCREMENT=1 ;
716 #EndIf
718 #IfMissingColumn lists reinjury_id
719 ALTER TABLE lists
720   ADD reinjury_id bigint(20)  NOT NULL DEFAULT 0,
721   ADD injury_part varchar(31) NOT NULL DEFAULT '',
722   ADD injury_type varchar(31) NOT NULL DEFAULT '';
723 #EndIf
725 ALTER TABLE layout_options CHANGE description description text;
727 #IfMissingColumn transactions refer_reply_date
728 ALTER TABLE transactions ADD refer_reply_date date DEFAULT NULL;
729 #EndIf
731 #IfMissingColumn transactions reply_related_code
732 ALTER TABLE transactions ADD reply_related_code varchar(255) NOT NULL DEFAULT '';
733 #EndIf
735 #IfNotTable extended_log
736 CREATE TABLE `extended_log` (
737   `id`          bigint(20)   NOT NULL AUTO_INCREMENT,
738   `date`        datetime     DEFAULT NULL,
739   `event`       varchar(255) DEFAULT NULL,
740   `user`        varchar(255) DEFAULT NULL,
741   `recipient`   varchar(255) DEFAULT NULL,
742   `description` longtext,
743   `patient_id`  bigint(20)   DEFAULT NULL,
744   PRIMARY KEY  (`id`)
745 ) ENGINE=MyISAM AUTO_INCREMENT=1;
746 #EndIf
748 #IfNotRow2D list_options list_id lists option_id disclosure_type
749 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'disclosure_type','Disclosure Type', 1,0);
750 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-treatment', 'Treatment', 10, 0);
751 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-payment', 'Payment', 20, 0);
752 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-healthcareoperations', 'Health Care Operations', 30, 0);
753 #EndIf
755 #IfNotTable user_settings
756 CREATE TABLE `user_settings` (
757   `setting_user`  bigint(20)   NOT NULL DEFAULT 0,
758   `setting_label` varchar(63)  NOT NULL,
759   `setting_value` varchar(255) NOT NULL DEFAULT '',
760   PRIMARY KEY (`setting_user`, `setting_label`)
761 ) ENGINE=MyISAM;
762 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'allergy_ps_expand', '1');
763 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'appointments_ps_expand', '1');
764 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'demographics_ps_expand', '0');
765 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'dental_ps_expand', '1');
766 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'directives_ps_expand', '1');
767 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'disclosures_ps_expand', '0');
768 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'immunizations_ps_expand', '1');
769 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'insurance_ps_expand', '0');
770 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'medical_problem_ps_expand', '1');
771 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'medication_ps_expand', '1');
772 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'pnotes_ps_expand', '0');
773 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'prescriptions_ps_expand', '1');
774 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'surgery_ps_expand', '1');
775 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'vitals_ps_expand', '1');
776 #EndIf
778 #IfNotRow user_settings setting_label gacl_protect
779 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'gacl_protect', '0');
780 #EndIf
782 #IfNotTable version
783 CREATE TABLE version (
784   v_major    int(11)     NOT NULL DEFAULT 0,
785   v_minor    int(11)     NOT NULL DEFAULT 0,
786   v_patch    int(11)     NOT NULL DEFAULT 0,
787   v_tag      varchar(31) NOT NULL DEFAULT '',
788   v_database int(11)     NOT NULL DEFAULT 0
789 ) ENGINE=MyISAM;
790 INSERT INTO version (v_major, v_minor, v_patch, v_tag, v_database) VALUES (0, 0, 0, '', 0);
791 #EndIf
793 #IfMissingColumn lists injury_grade
794 ALTER TABLE lists
795   ADD injury_grade varchar(31) NOT NULL DEFAULT '';
796 #EndIf
798 #IfMissingColumn form_encounter referral_source
799 ALTER TABLE form_encounter ADD referral_source varchar(31) NOT NULL DEFAULT '';
800 #EndIf
802 #IfMissingColumn facility tax_id_type
803 ALTER TABLE facility ADD COLUMN tax_id_type VARCHAR(31) NOT NULL DEFAULT '' AFTER facility_npi;
804 #EndIf
806 #IfMissingColumn ar_session created_time
807 ALTER TABLE  `ar_session` ADD  `created_time` timestamp NOT NULL default CURRENT_TIMESTAMP,
808 ADD  `modified_time` datetime NOT NULL,
809 ADD  `global_amount` decimal( 12, 2 ) NOT NULL ,
810 ADD  `payment_type` varchar( 50 ) NOT NULL ,
811 ADD  `description` text NOT NULL ,
812 ADD  `adjustment_code` varchar( 50 ) NOT NULL ,
813 ADD  `post_to_date` date NOT NULL ,
814 ADD  `patient_id` int( 11 ) NOT NULL ,
815 ADD `payment_method` varchar( 25 ) NOT NULL ;
816 #EndIf
818 #IfMissingColumn ar_activity modified_time
819 ALTER TABLE `ar_activity` ADD `modified_time` datetime NOT NULL,
820 ADD `follow_up` char(1) NOT NULL,
821 ADD `follow_up_note` text NOT NULL,
822 ADD `account_code` varchar(15) NOT NULL;
823 #EndIf
825 #IfNotRow2D list_options list_id lists option_id payment_adjustment_code
826 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_adjustment_code','Payment Adjustment Code', 1,0);
827 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'family_payment', 'Family Payment', 20, 0);
828 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'group_payment', 'Group Payment', 30, 0);
829 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'insurance_payment', 'Insurance Payment', 40, 0);
830 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'patient_payment', 'Patient Payment', 50, 0);
831 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'pre_payment', 'Pre Payment', 60, 0);
832 #EndIf
834 #IfNotRow2D list_options list_id lists option_id payment_ins
835 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_ins','Payment Ins', 1,0);
836 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '0', 'Pat', 40, 0);
837 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '1', 'Ins1', 10, 0);
838 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '2', 'Ins2', 20, 0);
839 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '3', 'Ins3', 30, 0);
840 #EndIf
842 #IfNotRow2D list_options list_id lists option_id payment_method
843 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_method','Payment Method', 1,0);
844 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'bank_draft', 'Bank Draft', 50, 0);
845 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'cash', 'Cash', 20, 0);
846 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'check_payment', 'Check Payment', 10, 0);
847 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'credit_card', 'Credit Card', 30, 0);
848 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'electronic', 'Electronic', 40, 0);
849 #EndIf
851 #IfNotRow2D list_options list_id lists option_id payment_sort_by
852 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_sort_by','Payment Sort By', 1,0);
853 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'check_date', 'Check Date', 20, 0);
854 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payer_id', 'Ins Code', 40, 0);
855 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payment_method', 'Payment Method', 50, 0);
856 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payment_type', 'Paying Entity', 30, 0);
857 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'pay_total', 'Amount', 70, 0);
858 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'reference', 'Check Number', 60, 0);
859 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'session_id', 'Id', 10, 0);
860 #EndIf
862 #IfNotRow2D list_options list_id lists option_id payment_status
863 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_status','Payment Status', 1,0);
864 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_status', 'fully_paid', 'Fully Paid', 10, 0);
865 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_status', 'unapplied', 'Unapplied', 20, 0);
866 #EndIf
868 #IfNotRow2D list_options list_id lists option_id payment_type
869 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_type','Payment Type', 1,0);
870 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_type', 'insurance', 'Insurance', 10, 0);
871 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_type', 'patient', 'Patient', 20, 0);
872 #EndIf
874 #IfNotTable eligibility_response
875 CREATE TABLE `eligibility_response` (
876   `response_id` bigint(20) NOT NULL auto_increment,
877   `response_description` varchar(255) default NULL,
878   `response_status` enum('A','D') NOT NULL default 'A',
879   `response_vendor_id` bigint(20) default NULL,
880   `response_create_date` date default NULL,
881   `response_modify_date` date default NULL,
882   PRIMARY KEY  (`response_id`)
883 ) ENGINE=MyISAM AUTO_INCREMENT=1;
884 #EndIf
886 #IfNotTable eligibility_verification
887 CREATE TABLE `eligibility_verification` (
888   `verification_id` bigint(20) NOT NULL auto_increment,
889   `response_id` bigint(20) default NULL,
890   `insurance_id` bigint(20) default NULL,
891   `eligibility_check_date` datetime default NULL,
892   `copay` int(11) default NULL,
893   `deductible` int(11) default NULL,
894   `deductiblemet` enum('Y','N') default 'Y',
895   `create_date` date default NULL,
896   PRIMARY KEY  (`verification_id`),
897   KEY `insurance_id` (`insurance_id`)
898 ) ENGINE=MyISAM AUTO_INCREMENT=1;
899 #EndIf
901 #IfNotRow2D list_options list_id lists option_id smoking_status
902 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'smoking_status','Smoking Status', 1,0);
903 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '1', 'Current every day smoker', 10, 0);
904 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '2', 'Current some day smoker', 20, 0);
905 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '3', 'Former smoker', 30, 0);
906 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '4', 'Never smoker', 40, 0);
907 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '5', 'Smoker, current status unknown', 50, 0);
908 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '9', 'Unknown if ever smoked', 60, 0);
909 #EndIf
911 UPDATE layout_options SET seq=2 WHERE form_id = 'HIS' AND field_id='coffee';
912 UPDATE layout_options SET data_type=32,seq=1,fld_length=0,list_id='smoking_status' WHERE form_id = 'HIS' AND field_id='tobacco';
914 #IfMissingColumn drug_sales distributor_id
915 ALTER TABLE drug_sales ADD distributor_id bigint(20) NOT NULL DEFAULT 0;
916 #EndIf
918 #IfNotRow2D list_options list_id abook_type option_id dist
919 INSERT INTO list_options (list_id,option_id,title,seq,is_default) VALUES ('abook_type','dist','Distributor',30,0);
920 #EndIf
922 #IfNotRow2D list_options list_id adjreason option_value 1
923 UPDATE list_options SET option_value = 2 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'To co%';
924 UPDATE list_options SET option_value = 3 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'To ded%';
925 UPDATE list_options SET option_value = 4 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'Ins termed';
926 UPDATE list_options SET option_value = 4 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'No coverage';
927 UPDATE list_options SET option_value = 4 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'Pre-existing';
928 UPDATE list_options SET option_value = 5 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'Ins info%';
929 UPDATE list_options SET option_value = 5 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE 'Ins recoup';
930 UPDATE list_options SET option_value = 5 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE '%refund';
931 UPDATE list_options SET option_value = 5 WHERE list_id = 'adjreason' AND option_value = 0 AND option_id LIKE '%overpaid';
932 UPDATE list_options SET option_value = 1 WHERE list_id = 'adjreason' AND option_value = 0;
933 #EndIf
935 #IfNotRow2D user_settings setting_label billing_ps_expand setting_user 0
936 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'billing_ps_expand', '0');
937 #EndIf
939 #IfMissingColumn lists reaction
940 ALTER TABLE lists ADD reaction varchar(255) NOT NULL DEFAULT '';
941 #EndIf
943 #IfNotRow2D list_options list_id lists option_id race
944 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'race','Race', 1,0);
945 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('race', 'amer_ind_or_alaska_native', 'American Indian or Alaska Native', 10, 0);
946 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('race', 'Asian', 'Asian',20,0);
947 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('race', 'black_or_afri_amer', 'Black or African American',30,0);
948 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('race', 'native_hawai_or_pac_island', 'Native Hawaiian or Other Pacific Islander',40,0);
949 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('race', 'white', 'White',50,0);
950 #EndIf
952 #IfNotRow2D list_options list_id lists option_id ethnicity
953 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'ethnicity','Ethnicity', 1,0);
954 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethnicity', 'hisp_or_latin', 'Hispanic or Latino', 10, 0);
955 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ethnicity', 'not_hisp_or_latin', 'Not Hispanic or Latino', 10, 0);
956 #EndIf
958 #IfMissingColumn patient_data race
959 ALTER TABLE `patient_data` ADD `race` varchar(255) NOT NULL default '';
960 #EndIf
962 #IfMissingColumn patient_data ethnicity
963 ALTER TABLE `patient_data` ADD `ethnicity` varchar(255) NOT NULL default '';
964 #EndIf
966 #IfNotRow2D layout_options field_id race form_id DEM
967 INSERT INTO `layout_options` VALUES ('DEM', 'race', '5Stats', 'Race', 3, 33, 1, 0, 0, 'race', 1, 1, '', '', 'Race');
968 #EndIf
970 UPDATE layout_options SET data_type=33,list_id='ethnicity',field_id='ethnicity',title='Ethnicity',description='Ethnicity' WHERE form_id = 'DEM' AND field_id = 'ethnoracial';
971 UPDATE layout_options SET seq=4 WHERE form_id = 'DEM' and field_id='financial_review';
973 UPDATE patient_data SET ethnicity= case WHEN ethnoracial IN ('Hispanic','othr_us','othr_non_us') THEN ethnoracial ELSE '' END, race = case WHEN ethnoracial NOT IN ('Hispanic','othr_us','othr_non_us') THEN ethnoracial ELSE '' END;
975 UPDATE list_options SET option_value = 3 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'ord_img';
976 UPDATE list_options SET option_value = 3 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'ord_imm';
977 UPDATE list_options SET option_value = 3 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'ord_lab';
978 UPDATE list_options SET option_value = 2 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'spe';
979 UPDATE list_options SET option_value = 3 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'vendor';
980 UPDATE list_options SET option_value = 3 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'dist';
981 UPDATE list_options SET option_value = 1 WHERE list_id = 'abook_type' AND option_value = 0 AND option_id = 'oth';
983 #IfNotRow2D list_options list_id lists option_id payment_date
984 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'payment_date','Payment Date', 1,0);
985 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_date', 'date_val', 'Date', 10, 0);
986 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_date', 'post_to_date', 'Post To Date', 20, 0);
987 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_date', 'deposit_date', 'Deposit Date', 30, 0);
988 #EndIf
990 #IfNotRow2D list_options list_id lists option_id date_master_criteria
991 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists', 'date_master_criteria', 'Date Master Criteria', 33, 1);
992 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'all', 'All', 10, 0);
993 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'today', 'Today', 20, 0);
994 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'this_month_to_date', 'This Month to Date', 30, 0);
995 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'last_month', 'Last Month', 40, 0);
996 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'this_week_to_date', 'This Week to Date', 50, 0);
997 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'this_calendar_year', 'This Calendar Year', 60, 0);
998 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'last_calendar_year', 'Last Calendar Year', 70, 0);
999 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('date_master_criteria', 'custom', 'Custom', 80, 0);
1000 #EndIf
1002 #IfTable globals
1003 UPDATE globals SET gl_value = 'style_oemr.css' WHERE gl_name = 'css_header' AND gl_value = 'style_default.css';
1004 #EndIf
1006 #IfTable user_settings
1007 UPDATE user_settings SET setting_value = 'style_oemr.css' WHERE setting_label = 'global:css_header' AND setting_value = 'style_default.css';
1008 #EndIf
1010 #IfMissingColumn documents hash
1011 ALTER TABLE documents ADD hash varchar(40) DEFAULT NULL COMMENT '40-character SHA-1 hash of document';
1012 #EndIf
1014 #IfTable users
1015 UPDATE users SET pwd_history1='',pwd_history2='';
1016 #EndIf