2 -- Comment Meta Language for sql upgrades:
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
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.
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:
20 -- argument: table_name
21 -- behavior: if the table_name does not exist, the block will be executed
24 -- argument: table_name
25 -- behavior: if the table_name does exist, the block will be executed
28 -- arguments: table_name colname
29 -- behavior: if the colname in the table_name table does not exist, the block will be executed
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
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.
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.
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.
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;
57 #IfMissingColumn log success
58 ALTER TABLE log ADD success tinyint(1) DEFAULT 1;
61 #IfMissingColumn log checksum
62 ALTER TABLE log ADD checksum longtext DEFAULT NULL;
65 #IfMissingColumn log crt_user
66 ALTER TABLE log ADD crt_user varchar(255) DEFAULT NULL;
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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');
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, '', '', '');
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, '', '', '');
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, '', '', '');
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, '', '', '');
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, '', '', '');
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 '';
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);
296 #IfMissingColumn patient_data completed_ad
297 ALTER TABLE patient_data
298 ADD completed_ad VARCHAR(3) NOT NULL DEFAULT 'NO',
299 ADD ad_reviewed date DEFAULT NULL;
302 #IfNotRow2D list_options list_id lists option_id apptstat
303 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'apptstat','Appointment Statuses', 1,0);
304 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','-' ,'- None' , 5,0);
305 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','*' ,'* Reminder done' ,10,0);
306 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','+' ,'+ Chart pulled' ,15,0);
307 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','x' ,'x Canceled' ,20,0);
308 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','?' ,'? No show' ,25,0);
309 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','@' ,'@ Arrived' ,30,0);
310 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','~' ,'~ Arrived late' ,35,0);
311 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','!' ,'! Left w/o visit' ,40,0);
312 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','#' ,'# Ins/fin issue' ,45,0);
313 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','<' ,'< In exam room' ,50,0);
314 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','>' ,'> Checked out' ,55,0);
315 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','$' ,'$ Coding done' ,60,0);
316 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','%' ,'% Canceled < 24h' ,65,0);
317 ALTER TABLE openemr_postcalendar_events CHANGE pc_apptstatus pc_apptstatus varchar(15) NOT NULL DEFAULT '-';
320 #IfNotRow2D list_options list_id lists option_id transactions
321 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists', 'transactions', 'Transactions', 20, 0);
322 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Referral', 'Referral', 10, 0);
323 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Patient Request', 'Patient Request', 20, 0);
324 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Physician Request', 'Physician Request', 30, 0);
325 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Legal', 'Legal', 40, 0);
326 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('transactions', 'Billing', 'Billing', 50, 0);
329 #IfNotRow2D layout_options form_id DEM field_id referral_source
330 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');
333 #IfMissingColumn list_options notes
334 ALTER TABLE list_options
335 CHANGE mapping mapping varchar(31) NOT NULL DEFAULT '',
336 ADD notes varchar(255) NOT NULL DEFAULT '';
339 #IfNotRow2D list_options list_id lists option_id warehouse
340 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','warehouse','Warehouses',21,0);
341 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('warehouse','onsite','On Site', 5,0);
344 #IfNotRow2D list_options list_id lists option_id abook_type
345 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','abook_type' ,'Address Book Types' , 1,0);
346 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_img','Imaging Service' , 5,0);
347 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_imm','Immunization Service',10,0);
348 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_lab','Lab Service' ,15,0);
349 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','spe' ,'Specialist' ,20,0);
350 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','vendor' ,'Vendor' ,25,0);
351 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','oth' ,'Other' ,95,0);
354 #IfMissingColumn users abook_type
356 ADD abook_type varchar(31) NOT NULL DEFAULT '';
359 #IfNotRow2D list_options list_id lists option_id proc_type
360 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_type','Procedure Types', 1,0);
361 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','grp','Group' ,10,0);
362 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','ord','Procedure Order',20,0);
363 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','res','Discrete Result',30,0);
364 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','rec','Recommendation' ,40,0);
367 #IfNotRow2D list_options list_id lists option_id proc_body_site
368 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_body_site','Procedure Body Sites', 1,0);
369 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','arm' ,'Arm' ,10,0);
370 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','buttock','Buttock',20,0);
371 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','oth' ,'Other' ,90,0);
374 #IfNotRow2D list_options list_id lists option_id proc_specimen
375 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_specimen','Procedure Specimen Types', 1,0);
376 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','blood' ,'Blood' ,10,0);
377 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','saliva','Saliva',20,0);
378 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','urine' ,'Urine' ,30,0);
379 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','oth' ,'Other' ,90,0);
382 #IfNotRow2D list_options list_id lists option_id proc_route
383 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_route','Procedure Routes', 1,0);
384 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','inj' ,'Injection',10,0);
385 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oral','Oral' ,20,0);
386 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oth' ,'Other' ,90,0);
389 #IfNotRow2D list_options list_id lists option_id proc_lat
390 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_lat','Procedure Lateralities', 1,0);
391 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','left' ,'Left' ,10,0);
392 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','right','Right' ,20,0);
393 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','bilat','Bilateral',30,0);
396 #IfNotRow2D list_options list_id lists option_id proc_unit
397 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists','proc_unit','Procedure Units', 1);
398 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','bool' ,'Boolean' , 5);
399 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','cu_mm' ,'CU.MM' , 10);
400 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','fl' ,'FL' , 20);
401 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','g_dl' ,'G/DL' , 30);
402 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','gm_dl' ,'GM/DL' , 40);
403 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','hmol_l' ,'HMOL/L' , 50);
404 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','iu_l' ,'IU/L' , 60);
405 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mg_dl' ,'MG/DL' , 70);
406 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mil_cu_mm' ,'Mil/CU.MM' , 80);
407 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percent' ,'Percent' , 90);
408 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percentile' ,'Percentile' ,100);
409 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','pg' ,'PG' ,110);
410 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','ratio' ,'Ratio' ,120);
411 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','thous_cu_mm','Thous/CU.MM',130);
412 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units' ,'Units' ,140);
413 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units_l' ,'Units/L' ,150);
414 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','days' ,'Days' ,600);
415 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','weeks' ,'Weeks' ,610);
416 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','months' ,'Months' ,620);
417 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','oth' ,'Other' ,990);
420 #IfNotRow2D list_options list_id lists option_id ord_priority
421 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_priority','Order Priorities', 1,0);
422 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','high' ,'High' ,10,0);
423 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','normal','Normal',20,0);
426 #IfNotRow2D list_options list_id lists option_id ord_status
427 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_status','Order Statuses', 1,0);
428 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','pending' ,'Pending' ,10,0);
429 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','routed' ,'Routed' ,20,0);
430 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','complete','Complete',30,0);
431 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','canceled','Canceled',40,0);
434 #IfNotRow2D list_options list_id lists option_id proc_rep_status
435 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_rep_status','Procedure Report Statuses', 1,0);
436 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','final' ,'Final' ,10,0);
437 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','review' ,'Reviewed' ,20,0);
438 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','prelim' ,'Preliminary',30,0);
439 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','cancel' ,'Canceled' ,40,0);
440 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','error' ,'Error' ,50,0);
441 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','correct','Corrected' ,60,0);
444 #IfNotRow2D list_options list_id lists option_id proc_res_abnormal
445 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_abnormal','Procedure Result Abnormal', 1,0);
446 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','no' ,'No' ,10,0);
447 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','yes' ,'Yes' ,20,0);
448 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','high','High',30,0);
449 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','low' ,'Low' ,40,0);
452 #IfNotRow2D list_options list_id lists option_id proc_res_status
453 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_status','Procedure Result Statuses', 1,0);
454 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','final' ,'Final' ,10,0);
455 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','prelim' ,'Preliminary',20,0);
456 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','cancel' ,'Canceled' ,30,0);
457 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','error' ,'Error' ,40,0);
458 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','correct' ,'Corrected' ,50,0);
459 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','incomplete','Incomplete' ,60,0);
462 #IfNotRow2D list_options list_id lists option_id proc_res_bool
463 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_bool','Procedure Boolean Results', 1,0);
464 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','neg' ,'Negative',10,0);
465 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','pos' ,'Positive',20,0);
468 #IfNotTable procedure_type
469 CREATE TABLE `procedure_type` (
470 `procedure_type_id` bigint(20) NOT NULL AUTO_INCREMENT,
471 `parent` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references procedure_type.procedure_type_id',
472 `name` varchar(63) NOT NULL DEFAULT '' COMMENT 'name for this category, procedure or result type',
473 `lab_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references users.id, 0 means default to parent',
474 `procedure_code` varchar(31) NOT NULL DEFAULT '' COMMENT 'code identifying this procedure',
475 `procedure_type` varchar(31) NOT NULL DEFAULT '' COMMENT 'see list proc_type',
476 `body_site` varchar(31) NOT NULL DEFAULT '' COMMENT 'where to do injection, e.g. arm, buttok',
477 `specimen` varchar(31) NOT NULL DEFAULT '' COMMENT 'blood, urine, saliva, etc.',
478 `route_admin` varchar(31) NOT NULL DEFAULT '' COMMENT 'oral, injection',
479 `laterality` varchar(31) NOT NULL DEFAULT '' COMMENT 'left, right, ...',
480 `description` varchar(255) NOT NULL DEFAULT '' COMMENT 'descriptive text for procedure_code',
481 `standard_code` varchar(255) NOT NULL DEFAULT '' COMMENT 'industry standard code type and code (e.g. CPT4:12345)',
482 `related_code` varchar(255) NOT NULL DEFAULT '' COMMENT 'suggested code(s) for followup services if result is abnormal',
483 `units` varchar(31) NOT NULL DEFAULT '' COMMENT 'default for procedure_result.units',
484 `range` varchar(255) NOT NULL DEFAULT '' COMMENT 'default for procedure_result.range',
485 `seq` int(11) NOT NULL default 0 COMMENT 'sequence number for ordering',
486 PRIMARY KEY (`procedure_type_id`),
491 #IfNotTable procedure_order
492 CREATE TABLE `procedure_order` (
493 `procedure_order_id` bigint(20) NOT NULL AUTO_INCREMENT,
494 `procedure_type_id` bigint(20) NOT NULL COMMENT 'references procedure_type.procedure_type_id',
495 `provider_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references users.id',
496 `patient_id` bigint(20) NOT NULL COMMENT 'references patient_data.pid',
497 `encounter_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references form_encounter.encounter',
498 `date_collected` datetime DEFAULT NULL COMMENT 'time specimen collected',
499 `date_ordered` date DEFAULT NULL,
500 `order_priority` varchar(31) NOT NULL DEFAULT '',
501 `order_status` varchar(31) NOT NULL DEFAULT '' COMMENT 'pending,routed,complete,canceled',
502 `patient_instructions` text NOT NULL DEFAULT '',
503 `activity` tinyint(1) NOT NULL DEFAULT 1 COMMENT '0 if deleted',
504 `control_id` bigint(20) NOT NULL COMMENT 'This is the CONTROL ID that is sent back from lab',
505 PRIMARY KEY (`procedure_order_id`),
506 KEY datepid (date_ordered, patient_id)
510 #IfNotTable procedure_report
511 CREATE TABLE `procedure_report` (
512 `procedure_report_id` bigint(20) NOT NULL AUTO_INCREMENT,
513 `procedure_order_id` bigint(20) DEFAULT NULL COMMENT 'references procedure_order.procedure_order_id',
514 `date_collected` datetime DEFAULT NULL,
515 `date_report` date DEFAULT NULL,
516 `source` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references users.id, who entered this data',
517 `specimen_num` varchar(63) NOT NULL DEFAULT '',
518 `report_status` varchar(31) NOT NULL DEFAULT '' COMMENT 'received,complete,error',
519 `review_status` varchar(31) NOT NULL DEFAULT 'received' COMMENT 'panding reivew status: received,reviewed',
520 PRIMARY KEY (`procedure_report_id`),
521 KEY procedure_order_id (procedure_order_id)
525 #IfNotTable procedure_result
526 CREATE TABLE `procedure_result` (
527 `procedure_result_id` bigint(20) NOT NULL AUTO_INCREMENT,
528 `procedure_report_id` bigint(20) NOT NULL COMMENT 'references procedure_report.procedure_report_id',
529 `procedure_type_id` bigint(20) NOT NULL COMMENT 'references procedure_type.procedure_type_id',
530 `date` datetime DEFAULT NULL COMMENT 'lab-provided date specific to this result',
531 `facility` varchar(255) NOT NULL DEFAULT '' COMMENT 'lab-provided testing facility ID',
532 `units` varchar(31) NOT NULL DEFAULT '',
533 `result` varchar(255) NOT NULL DEFAULT '',
534 `range` varchar(255) NOT NULL DEFAULT '',
535 `abnormal` varchar(31) NOT NULL DEFAULT '' COMMENT 'no,yes,high,low',
536 `comments` text NOT NULL DEFAULT '' COMMENT 'comments from the lab',
537 `document_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references documents.id if this result is a document',
538 `result_status` varchar(31) NOT NULL DEFAULT '' COMMENT 'preliminary, cannot be done, final, corrected, incompete...etc.',
539 PRIMARY KEY (`procedure_result_id`),
540 KEY procedure_report_id (procedure_report_id)
544 #IfMissingColumn history_data recreational_drugs
545 ALTER TABLE history_data ADD recreational_drugs longtext;
548 update layout_options set seq = 1, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'coffee';
549 update layout_options set seq = 6, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'exercise_patterns';
550 update layout_options set seq = 2, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'tobacco';
551 update layout_options set seq = 3, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'alcohol';
552 update layout_options set seq = 5, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'counseling';
553 update layout_options set seq = 7, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'hazardous_activities';
554 update layout_options set seq = 8, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'sleep_patterns';
555 update layout_options set seq = 9, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'seatbelt_use';
557 #IfNotRow2D layout_options form_id HIS field_id recreational_drugs
558 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');
561 #IfMissingColumn users pwd_expiration_date
562 ALTER TABLE users ADD pwd_expiration_date date DEFAULT NULL;
565 #IfMissingColumn users pwd_history1
566 ALTER TABLE users ADD pwd_history1 longtext DEFAULT NULL;
569 #IfMissingColumn users pwd_history2
570 ALTER TABLE users ADD pwd_history2 longtext DEFAULT NULL;
573 #IfMissingColumn drug_inventory warehouse_id
574 ALTER TABLE drug_inventory
575 ADD warehouse_id varchar(31) NOT NULL DEFAULT '';
578 #IfMissingColumn drug_inventory vendor_id
579 ALTER TABLE drug_inventory
580 ADD vendor_id bigint(20) NOT NULL DEFAULT 0;
583 #IfMissingColumn drug_sales xfer_inventory_id
584 ALTER TABLE drug_sales
585 ADD xfer_inventory_id int(11) NOT NULL DEFAULT 0;
588 #IfMissingColumn drugs allow_combining
590 ADD allow_combining tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 = allow filling an order from multiple lots',
591 ADD allow_multiple tinyint(1) NOT NULL DEFAULT 1 COMMENT '1 = allow multiple lots at one warehouse';
594 #IfNotRow registry directory procedure_order
595 INSERT INTO `registry` VALUES ('Procedure Order', 1, 'procedure_order', NULL, 1, 1, '2010-02-25 00:00:00', 0, 'Administrative', '');
598 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'fee_sheet';
599 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'procedure_order';
600 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'newpatient';
601 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'misc_billing_options';
602 UPDATE registry SET category = 'Clinical' WHERE category = 'category';
604 #IfMissingColumn users default_warehouse
605 ALTER TABLE users ADD default_warehouse varchar(31) NOT NULL DEFAULT '';
608 UPDATE layout_options SET edit_options = 'N' WHERE form_id = 'DEM' AND field_id = 'title' AND edit_options = '';
609 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'fname' AND edit_options = 'C';
610 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'lname' AND edit_options = 'C';
611 UPDATE layout_options SET edit_options = 'ND' WHERE form_id = 'DEM' AND field_id = 'pubpid' AND edit_options = '';
612 UPDATE layout_options SET edit_options = 'N' WHERE form_id = 'DEM' AND field_id = 'sex' AND edit_options = '';
614 #IfNotRow2D list_options list_id lists option_id message_status
615 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'message_status','Message Status',45,0);
616 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Done' ,'Done' , 5,0);
617 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Forwarded' ,'Forwarded' ,10,0);
618 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','New' ,'New' ,15,0);
619 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Read' ,'Read' ,20,0);
622 #IfNotRow2D list_options list_id note_type option_id Lab Results
623 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Lab Results' ,'Lab Results', 15,0);
625 #IfNotRow2D list_options list_id note_type option_id New Orders
626 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','New Orders' ,'New Orders', 20,0);
628 #IfNotRow2D list_options list_id note_type option_id Patient Reminders
629 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Patient Reminders' ,'Patient Reminders', 25,0);
632 #IfMissingColumn pnotes message_status
634 ADD message_status VARCHAR(20) NOT NULL DEFAULT 'New';
638 CREATE TABLE `globals` (
639 `gl_name` varchar(63) NOT NULL,
640 `gl_index` int(11) NOT NULL DEFAULT 0,
641 `gl_value` varchar(255) NOT NULL DEFAULT '',
642 PRIMARY KEY (`gl_name`, `gl_index`)
646 #IfNotTable lang_custom
647 CREATE TABLE lang_custom (
648 `lang_description` varchar(100) NOT NULL default '',
649 `lang_code` char(2) NOT NULL default '',
650 `constant_name` varchar(255) NOT NULL default '',
651 `definition` mediumtext NOT NULL default ''
655 #IfNotRow2D list_options list_id lists option_id irnpool
656 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'irnpool','Invoice Reference Number Pools', 1,0);
657 INSERT INTO list_options ( list_id, option_id, title, seq, is_default, notes ) VALUES ('irnpool','main','Main',1,1,'000001');
660 #IfMissingColumn users irnpool
661 ALTER TABLE users ADD irnpool varchar(31) NOT NULL DEFAULT '';
664 #IfMissingColumn form_encounter invoice_refno
665 ALTER TABLE form_encounter ADD invoice_refno varchar(31) NOT NULL DEFAULT '';
668 #IfMissingColumn drug_sales notes
669 ALTER TABLE drug_sales
670 ADD notes varchar(255) NOT NULL DEFAULT '';
673 #IfNotTable code_types
674 CREATE TABLE code_types (
675 ct_key varchar(15) NOT NULL COMMENT 'short alphanumeric name',
676 ct_id int(11) UNIQUE NOT NULL COMMENT 'numeric identifier',
677 ct_seq int(11) NOT NULL DEFAULT 0 COMMENT 'sort order',
678 ct_mod int(11) NOT NULL DEFAULT 0 COMMENT 'length of modifier field',
679 ct_just varchar(15) NOT NULL DEFAULT ''COMMENT 'ct_key of justify type, if any',
680 ct_mask varchar(9) NOT NULL DEFAULT ''COMMENT 'formatting mask for code values',
681 ct_fee tinyint(1) NOT NULL default 0 COMMENT '1 if fees are used',
682 ct_rel tinyint(1) NOT NULL default 0 COMMENT '1 if can relate to other code types',
683 ct_nofs tinyint(1) NOT NULL default 0 COMMENT '1 if to be hidden in the fee sheet',
684 ct_diag tinyint(1) NOT NULL default 0 COMMENT '1 if this is a diagnosis type',
687 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);
688 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);
689 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);
692 #IfNotRow2D list_options list_id lists option_id code_types
693 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists', 'code_types', 'Code Types', 1);
696 #IfMissingColumn codes reportable
698 ADD `reportable` TINYINT(1) DEFAULT 0 COMMENT '0 = non-reportable, 1 = reportable';
701 #IfNotTable syndromic_surveillance
702 CREATE TABLE `syndromic_surveillance` (
703 `id` bigint(20) NOT NULL auto_increment,
704 `lists_id` bigint(20) NOT NULL,
705 `submission_date` datetime NOT NULL,
706 `filename` varchar(255) NOT NULL default '',
709 ) ENGINE=MyISAM AUTO_INCREMENT=1 ;
712 #IfMissingColumn lists reinjury_id
714 ADD reinjury_id bigint(20) NOT NULL DEFAULT 0,
715 ADD injury_part varchar(31) NOT NULL DEFAULT '',
716 ADD injury_type varchar(31) NOT NULL DEFAULT '';
719 ALTER TABLE layout_options CHANGE description description text;
721 #IfMissingColumn transactions refer_reply_date
722 ALTER TABLE transactions ADD refer_reply_date date DEFAULT NULL;
725 #IfMissingColumn transactions reply_related_code
726 ALTER TABLE transactions ADD reply_related_code varchar(255) NOT NULL DEFAULT '';
729 #IfNotTable extended_log
730 CREATE TABLE `extended_log` (
731 `id` bigint(20) NOT NULL AUTO_INCREMENT,
732 `date` datetime DEFAULT NULL,
733 `event` varchar(255) DEFAULT NULL,
734 `user` varchar(255) DEFAULT NULL,
735 `recipient` varchar(255) DEFAULT NULL,
736 `description` longtext,
737 `patient_id` bigint(20) DEFAULT NULL,
739 ) ENGINE=MyISAM AUTO_INCREMENT=1;
742 #IfNotRow2D list_options list_id lists option_id disclosure_type
743 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'disclosure_type','Disclosure Type', 1,0);
744 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-treatment', 'Treatment', 10, 0);
745 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-payment', 'Payment', 20, 0);
746 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('disclosure_type', 'disclosure-healthcareoperations', 'Health Care Operations', 30, 0);
749 #IfNotTable user_settings
750 CREATE TABLE `user_settings` (
751 `setting_user` bigint(20) NOT NULL DEFAULT 0,
752 `setting_label` varchar(63) NOT NULL,
753 `setting_value` varchar(255) NOT NULL DEFAULT '',
754 PRIMARY KEY (`setting_user`, `setting_label`)
756 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'allergy_ps_expand', '1');
757 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'appointments_ps_expand', '1');
758 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'demographics_ps_expand', '0');
759 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'dental_ps_expand', '1');
760 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'directives_ps_expand', '1');
761 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'disclosures_ps_expand', '0');
762 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'immunizations_ps_expand', '1');
763 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'insurance_ps_expand', '0');
764 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'medical_problem_ps_expand', '1');
765 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'medication_ps_expand', '1');
766 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'pnotes_ps_expand', '0');
767 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'prescriptions_ps_expand', '1');
768 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'surgery_ps_expand', '1');
769 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'vitals_ps_expand', '1');
772 #IfNotRow user_settings setting_label gacl_protect
773 INSERT INTO user_settings ( setting_user, setting_label, setting_value ) VALUES (0, 'gacl_protect', '0');
777 CREATE TABLE version (
778 v_major int(11) NOT NULL DEFAULT 0,
779 v_minor int(11) NOT NULL DEFAULT 0,
780 v_patch int(11) NOT NULL DEFAULT 0,
781 v_tag varchar(31) NOT NULL DEFAULT '',
782 v_database int(11) NOT NULL DEFAULT 0
784 INSERT INTO version (v_major, v_minor, v_patch, v_tag, v_database) VALUES (0, 0, 0, '', 0);
787 #IfMissingColumn lists injury_grade
789 ADD injury_grade varchar(31) NOT NULL DEFAULT '';
792 #IfMissingColumn form_encounter referral_source
793 ALTER TABLE form_encounter ADD referral_source varchar(31) NOT NULL DEFAULT '';
796 #IfMissingColumn facility tax_id_type
797 ALTER TABLE facility ADD COLUMN tax_id_type VARCHAR(31) NOT NULL DEFAULT '' AFTER facility_npi;
800 #IfMissingColumn ar_session created_time
801 ALTER TABLE `ar_session` ADD `created_time` timestamp NOT NULL default CURRENT_TIMESTAMP,
802 ADD `modified_time` datetime NOT NULL,
803 ADD `global_amount` decimal( 12, 2 ) NOT NULL ,
804 ADD `payment_type` varchar( 50 ) NOT NULL ,
805 ADD `description` text NOT NULL ,
806 ADD `adjustment_code` varchar( 50 ) NOT NULL ,
807 ADD `post_to_date` date NOT NULL ,
808 ADD `patient_id` int( 11 ) NOT NULL ,
809 ADD `payment_method` varchar( 25 ) NOT NULL ;
812 #IfMissingColumn ar_activity modified_time
813 ALTER TABLE `ar_activity` ADD `modified_time` datetime NOT NULL,
814 ADD `follow_up` char(1) NOT NULL,
815 ADD `follow_up_note` text NOT NULL,
816 ADD `account_code` varchar(15) NOT NULL;
819 #IfNotRow2D list_options list_id lists option_id payment_adjustment_code
820 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_adjustment_code','Payment Adjustment Code', 1,0);
821 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'family_payment', 'Family Payment', 20, 0);
822 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'group_payment', 'Group Payment', 30, 0);
823 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'insurance_payment', 'Insurance Payment', 40, 0);
824 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'patient_payment', 'Patient Payment', 50, 0);
825 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_adjustment_code', 'pre_payment', 'Pre Payment', 60, 0);
828 #IfNotRow2D list_options list_id lists option_id payment_ins
829 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_ins','Payment Ins', 1,0);
830 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '0', 'Pat', 40, 0);
831 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '1', 'Ins1', 10, 0);
832 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '2', 'Ins2', 20, 0);
833 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_ins', '3', 'Ins3', 30, 0);
836 #IfNotRow2D list_options list_id lists option_id payment_method
837 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_method','Payment Method', 1,0);
838 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'bank_draft', 'Bank Draft', 50, 0);
839 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'cash', 'Cash', 20, 0);
840 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'check_payment', 'Check Payment', 10, 0);
841 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'credit_card', 'Credit Card', 30, 0);
842 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_method', 'electronic', 'Electronic', 40, 0);
845 #IfNotRow2D list_options list_id lists option_id payment_sort_by
846 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_sort_by','Payment Sort By', 1,0);
847 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'check_date', 'Check Date', 20, 0);
848 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payer_id', 'Ins Code', 40, 0);
849 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payment_method', 'Payment Method', 50, 0);
850 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'payment_type', 'Paying Entity', 30, 0);
851 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'pay_total', 'Amount', 70, 0);
852 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'reference', 'Check Number', 60, 0);
853 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_sort_by', 'session_id', 'Id', 10, 0);
856 #IfNotRow2D list_options list_id lists option_id payment_status
857 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_status','Payment Status', 1,0);
858 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_status', 'fully_paid', 'Fully Paid', 10, 0);
859 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_status', 'unapplied', 'Unapplied', 20, 0);
862 #IfNotRow2D list_options list_id lists option_id payment_type
863 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'payment_type','Payment Type', 1,0);
864 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_type', 'insurance', 'Insurance', 10, 0);
865 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('payment_type', 'patient', 'Patient', 20, 0);
868 #IfNotRow2D list_options list_id lists option_id smoking_status
869 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists' ,'smoking_status','Smoking Status', 1,0);
870 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '1', 'Current every day smoker', 10, 0);
871 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '2', 'Current some day smoker', 20, 0);
872 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '3', 'Former smoker', 30, 0);
873 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '4', 'Never smoker', 40, 0);
874 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '5', 'Smoker, current status unknown', 50, 0);
875 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('smoking_status', '9', 'Unknown if ever smoked', 60, 0);
878 UPDATE layout_options SET seq=2 WHERE form_id = 'HIS' AND field_id='coffee';
879 UPDATE layout_options SET data_type=32,seq=1,fld_length=0,list_id='smoking_status' WHERE form_id = 'HIS' AND field_id='tobacco';
881 #IfMissingColumn drug_sales distributor_id
882 ALTER TABLE drug_sales ADD distributor_id bigint(20) NOT NULL DEFAULT 0;
885 #IfNotRow2D list_options list_id abook_type option_id dist
886 INSERT INTO list_options (list_id,option_id,title,seq,is_default) VALUES ('abook_type','dist','Distributor',30,0);