major bug fix two - web root path
[openemr.git] / sql / 3_2_0-to-4_0_0_upgrade.sql
blob8a80bf9a38948f3e2cbc828f6970c5dfa36781fe
1 #IfNotRow categories name Advance Directive
2   INSERT INTO categories select (select MAX(id) from categories) + 1, 'Advance Directive', '', 1, rght, rght + 7 from categories where name = 'Categories';
3   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';
4   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';
5   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';
6   UPDATE categories SET rght = rght + 8 WHERE name = 'Categories';
7   UPDATE categories_seq SET id = (select MAX(id) from categories);
8 #EndIf
10 #IfMissingColumn patient_data completed_ad
11 ALTER TABLE patient_data
12   ADD completed_ad VARCHAR(3) NOT NULL DEFAULT 'NO',
13   ADD ad_reviewed date DEFAULT NULL;
14 #EndIf
16 #IfNotRow2D list_options list_id lists option_id apptstat
17 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'   ,'apptstat','Appointment Statuses', 1,0);
18 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','-'       ,'- None'              , 5,0);
19 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','*'       ,'* Reminder done'     ,10,0);
20 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','+'       ,'+ Chart pulled'      ,15,0);
21 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','x'       ,'x Canceled'          ,20,0);
22 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','?'       ,'? No show'           ,25,0);
23 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','@'       ,'@ Arrived'           ,30,0);
24 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','~'       ,'~ Arrived late'      ,35,0);
25 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','!'       ,'! Left w/o visit'    ,40,0);
26 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','#'       ,'# Ins/fin issue'     ,45,0);
27 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','<'       ,'< In exam room'      ,50,0);
28 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','>'       ,'> Checked out'       ,55,0);
29 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','$'       ,'$ Coding done'       ,60,0);
30 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('apptstat','%'       ,'% Canceled < 24h'    ,65,0);
31 ALTER TABLE openemr_postcalendar_events CHANGE pc_apptstatus pc_apptstatus varchar(15) NOT NULL DEFAULT '-';
32 #EndIf
34 #IfNotRow2D layout_options form_id DEM field_id referral_source
35 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');
36 #EndIf
38 #IfMissingColumn list_options notes
39 ALTER TABLE list_options
40   CHANGE mapping mapping varchar(31) NOT NULL DEFAULT '',
41   ADD notes varchar(255) NOT NULL DEFAULT '';
42 #EndIf
44 #IfNotRow2D list_options list_id lists option_id warehouse
45 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','warehouse','Warehouses',21,0);
46 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('warehouse','onsite','On Site', 5,0);
47 #EndIf
49 #IfNotRow2D list_options list_id lists option_id abook_type
50 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','abook_type'  ,'Address Book Types'  , 1,0);
51 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_img','Imaging Service'     , 5,0);
52 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_imm','Immunization Service',10,0);
53 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','ord_lab','Lab Service'         ,15,0);
54 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','spe'    ,'Specialist'          ,20,0);
55 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','vendor' ,'Vendor'              ,25,0);
56 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('abook_type','oth'    ,'Other'               ,95,0);
57 #EndIf
59 #IfMissingColumn users abook_type
60 ALTER TABLE users
61   ADD abook_type varchar(31) NOT NULL DEFAULT '';
62 #EndIf
64 #IfNotRow2D list_options list_id lists option_id proc_type
65 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_type','Procedure Types', 1,0);
66 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','grp','Group'          ,10,0);
67 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','ord','Procedure Order',20,0);
68 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','res','Discrete Result',30,0);
69 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_type','rec','Recommendation' ,40,0);
70 #EndIf
72 #IfNotRow2D list_options list_id lists option_id proc_body_site
73 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_body_site','Procedure Body Sites', 1,0);
74 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','arm'    ,'Arm'    ,10,0);
75 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','buttock','Buttock',20,0);
76 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_body_site','oth'    ,'Other'  ,90,0);
77 #EndIf
79 #IfNotRow2D list_options list_id lists option_id proc_specimen
80 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_specimen','Procedure Specimen Types', 1,0);
81 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','blood' ,'Blood' ,10,0);
82 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','saliva','Saliva',20,0);
83 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','urine' ,'Urine' ,30,0);
84 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_specimen','oth'   ,'Other' ,90,0);
85 #EndIf
87 #IfNotRow2D list_options list_id lists option_id proc_route
88 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_route','Procedure Routes', 1,0);
89 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','inj' ,'Injection',10,0);
90 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oral','Oral'     ,20,0);
91 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_route','oth' ,'Other'    ,90,0);
92 #EndIf
94 #IfNotRow2D list_options list_id lists option_id proc_lat
95 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_lat','Procedure Lateralities', 1,0);
96 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','left' ,'Left'     ,10,0);
97 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','right','Right'    ,20,0);
98 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_lat','bilat','Bilateral',30,0);
99 #EndIf
101 #IfNotRow2D list_options list_id lists option_id proc_unit
102 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists','proc_unit','Procedure Units', 1);
103 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','bool'       ,'Boolean'    ,  5);
104 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','cu_mm'      ,'CU.MM'      , 10);
105 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','fl'         ,'FL'         , 20);
106 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','g_dl'       ,'G/DL'       , 30);
107 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','gm_dl'      ,'GM/DL'      , 40);
108 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','hmol_l'     ,'HMOL/L'     , 50);
109 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','iu_l'       ,'IU/L'       , 60);
110 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mg_dl'      ,'MG/DL'      , 70);
111 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','mil_cu_mm'  ,'Mil/CU.MM'  , 80);
112 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percent'    ,'Percent'    , 90);
113 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','percentile' ,'Percentile' ,100);
114 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','pg'         ,'PG'         ,110);
115 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','ratio'      ,'Ratio'      ,120);
116 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','thous_cu_mm','Thous/CU.MM',130);
117 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units'      ,'Units'      ,140);
118 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','units_l'    ,'Units/L'    ,150);
119 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','days'       ,'Days'       ,600);
120 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','weeks'      ,'Weeks'      ,610);
121 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','months'     ,'Months'     ,620);
122 INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('proc_unit','oth'        ,'Other'      ,990);
123 #EndIf
125 #IfNotRow2D list_options list_id lists option_id ord_priority
126 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_priority','Order Priorities', 1,0);
127 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','high'  ,'High'  ,10,0);
128 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_priority','normal','Normal',20,0);
129 #EndIf
131 #IfNotRow2D list_options list_id lists option_id ord_status
132 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','ord_status','Order Statuses', 1,0);
133 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','pending' ,'Pending' ,10,0);
134 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','routed'  ,'Routed'  ,20,0);
135 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','complete','Complete',30,0);
136 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('ord_status','canceled','Canceled',40,0);
137 #EndIf
139 #IfNotRow2D list_options list_id lists option_id proc_rep_status
140 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_rep_status','Procedure Report Statuses', 1,0);
141 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','final'  ,'Final'      ,10,0);
142 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','review' ,'Reviewed'   ,20,0);
143 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','prelim' ,'Preliminary',30,0);
144 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','cancel' ,'Canceled'   ,40,0);
145 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','error'  ,'Error'      ,50,0);
146 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_rep_status','correct','Corrected'  ,60,0);
147 #EndIf
149 #IfNotRow2D list_options list_id lists option_id proc_res_abnormal
150 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_abnormal','Procedure Result Abnormal', 1,0);
151 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','no'  ,'No'  ,10,0);
152 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','yes' ,'Yes' ,20,0);
153 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','high','High',30,0);
154 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_abnormal','low' ,'Low' ,40,0);
155 #EndIf
157 #IfNotRow2D list_options list_id lists option_id proc_res_status
158 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_status','Procedure Result Statuses', 1,0);
159 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','final'     ,'Final'      ,10,0);
160 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','prelim'    ,'Preliminary',20,0);
161 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','cancel'    ,'Canceled'   ,30,0);
162 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','error'     ,'Error'      ,40,0);
163 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','correct'   ,'Corrected'  ,50,0);
164 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_status','incomplete','Incomplete' ,60,0);
165 #EndIf
167 #IfNotRow2D list_options list_id lists option_id proc_res_bool
168 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','proc_res_bool','Procedure Boolean Results', 1,0);
169 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','neg' ,'Negative',10,0);
170 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('proc_res_bool','pos' ,'Positive',20,0);
171 #EndIf
173 #IfNotTable procedure_type
174 CREATE TABLE `procedure_type` (
175   `procedure_type_id`   bigint(20)   NOT NULL AUTO_INCREMENT,
176   `parent`              bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references procedure_type.procedure_type_id',
177   `name`                varchar(63)  NOT NULL DEFAULT '' COMMENT 'name for this category, procedure or result type',
178   `lab_id`              bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references users.id, 0 means default to parent',
179   `procedure_code`      varchar(31)  NOT NULL DEFAULT '' COMMENT 'code identifying this procedure',
180   `procedure_type`      varchar(31)  NOT NULL DEFAULT '' COMMENT 'see list proc_type',
181   `body_site`           varchar(31)  NOT NULL DEFAULT '' COMMENT 'where to do injection, e.g. arm, buttok',
182   `specimen`            varchar(31)  NOT NULL DEFAULT '' COMMENT 'blood, urine, saliva, etc.',
183   `route_admin`         varchar(31)  NOT NULL DEFAULT '' COMMENT 'oral, injection',
184   `laterality`          varchar(31)  NOT NULL DEFAULT '' COMMENT 'left, right, ...',
185   `description`         varchar(255) NOT NULL DEFAULT '' COMMENT 'descriptive text for procedure_code',
186   `standard_code`       varchar(255) NOT NULL DEFAULT '' COMMENT 'industry standard code type and code (e.g. CPT4:12345)',
187   `related_code`        varchar(255) NOT NULL DEFAULT '' COMMENT 'suggested code(s) for followup services if result is abnormal',
188   `units`               varchar(31)  NOT NULL DEFAULT '' COMMENT 'default for procedure_result.units',
189   `range`               varchar(255) NOT NULL DEFAULT '' COMMENT 'default for procedure_result.range',
190   `seq`                 int(11)      NOT NULL default 0  COMMENT 'sequence number for ordering',
191   PRIMARY KEY (`procedure_type_id`),
192   KEY parent (parent)
193 ) ENGINE=MyISAM;
194 #EndIf
196 #IfNotTable procedure_order
197 CREATE TABLE `procedure_order` (
198   `procedure_order_id`     bigint(20)   NOT NULL AUTO_INCREMENT,
199   `procedure_type_id`      bigint(20)   NOT NULL            COMMENT 'references procedure_type.procedure_type_id',
200   `provider_id`            bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references users.id',
201   `patient_id`             bigint(20)   NOT NULL            COMMENT 'references patient_data.pid',
202   `encounter_id`           bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references form_encounter.encounter',
203   `date_collected`         datetime     DEFAULT NULL        COMMENT 'time specimen collected',
204   `date_ordered`           date         DEFAULT NULL,
205   `order_priority`         varchar(31)  NOT NULL DEFAULT '',
206   `order_status`           varchar(31)  NOT NULL DEFAULT '' COMMENT 'pending,routed,complete,canceled',
207   `patient_instructions`   text         NOT NULL DEFAULT '',
208   `activity`               tinyint(1)   NOT NULL DEFAULT 1  COMMENT '0 if deleted',
209   `control_id`             bigint(20)   NOT NULL            COMMENT 'This is the CONTROL ID that is sent back from lab',
210   PRIMARY KEY (`procedure_order_id`),
211   KEY datepid (date_ordered, patient_id)
212 ) ENGINE=MyISAM;
213 #EndIf
215 #IfNotTable procedure_report
216 CREATE TABLE `procedure_report` (
217   `procedure_report_id` bigint(20)     NOT NULL AUTO_INCREMENT,
218   `procedure_order_id`  bigint(20)     DEFAULT NULL   COMMENT 'references procedure_order.procedure_order_id',
219   `date_collected`      datetime       DEFAULT NULL,
220   `date_report`         date           DEFAULT NULL,
221   `source`              bigint(20)     NOT NULL DEFAULT 0  COMMENT 'references users.id, who entered this data',
222   `specimen_num`        varchar(63)    NOT NULL DEFAULT '',
223   `report_status`       varchar(31)    NOT NULL DEFAULT '' COMMENT 'received,complete,error',
224   `review_status`       varchar(31)    NOT NULL DEFAULT 'received' COMMENT 'panding reivew status: received,reviewed',
225   PRIMARY KEY (`procedure_report_id`),
226   KEY procedure_order_id (procedure_order_id)
227 ) ENGINE=MyISAM; 
228 #EndIf
230 #IfNotTable procedure_result
231 CREATE TABLE `procedure_result` (
232   `procedure_result_id` bigint(20)   NOT NULL AUTO_INCREMENT,
233   `procedure_report_id` bigint(20)   NOT NULL            COMMENT 'references procedure_report.procedure_report_id',
234   `procedure_type_id`   bigint(20)   NOT NULL            COMMENT 'references procedure_type.procedure_type_id',
235   `date`                datetime     DEFAULT NULL        COMMENT 'lab-provided date specific to this result',
236   `facility`            varchar(255) NOT NULL DEFAULT '' COMMENT 'lab-provided testing facility ID',
237   `units`               varchar(31)  NOT NULL DEFAULT '',
238   `result`              varchar(255) NOT NULL DEFAULT '',
239   `range`               varchar(255) NOT NULL DEFAULT '',
240   `abnormal`            varchar(31)  NOT NULL DEFAULT '' COMMENT 'no,yes,high,low',
241   `comments`            text         NOT NULL DEFAULT '' COMMENT 'comments from the lab',
242   `document_id`         bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references documents.id if this result is a document',
243   `result_status`       varchar(31)  NOT NULL DEFAULT '' COMMENT 'preliminary, cannot be done, final, corrected, incompete...etc.',
244   PRIMARY KEY (`procedure_result_id`),
245   KEY procedure_report_id (procedure_report_id)
246 ) ENGINE=MyISAM; 
247 #EndIf
249 #IfMissingColumn history_data recreational_drugs
250 ALTER TABLE history_data ADD recreational_drugs longtext;
251 #EndIf
253 update layout_options set seq = 1, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'coffee';
254 update layout_options set seq = 6, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'exercise_patterns';
255 update layout_options set seq = 2, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'tobacco';
256 update layout_options set seq = 3, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'alcohol';
257 update layout_options set seq = 5, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'counseling';
258 update layout_options set seq = 7, data_type = 28, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'hazardous_activities';
259 update layout_options set seq = 8, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'sleep_patterns';
260 update layout_options set seq = 9, titlecols = 1, datacols = 3 where form_id = 'HIS' and field_id = 'seatbelt_use';
262 #IfNotRow2D layout_options form_id HIS field_id recreational_drugs
263 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');
264 #EndIf
266 #IfMissingColumn users pwd_expiration_date
267 ALTER TABLE users ADD pwd_expiration_date date DEFAULT NULL;
268 #EndIf
270 #IfMissingColumn users pwd_history1
271 ALTER TABLE users ADD pwd_history1 longtext DEFAULT NULL;
272 #EndIf
274 #IfMissingColumn users pwd_history2
275 ALTER TABLE users ADD pwd_history2 longtext DEFAULT NULL;
276 #EndIf
278 #IfMissingColumn drug_inventory warehouse_id
279 ALTER TABLE drug_inventory
280   ADD warehouse_id varchar(31) NOT NULL DEFAULT '';
281 #EndIf
283 #IfMissingColumn drug_inventory vendor_id
284 ALTER TABLE drug_inventory
285   ADD vendor_id bigint(20) NOT NULL DEFAULT 0;
286 #EndIf
288 #IfMissingColumn drug_sales xfer_inventory_id
289 ALTER TABLE drug_sales
290   ADD xfer_inventory_id int(11) NOT NULL DEFAULT 0;
291 #EndIf
293 #IfMissingColumn drugs allow_combining
294 ALTER TABLE drugs
295   ADD allow_combining tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 = allow filling an order from multiple lots',
296   ADD allow_multiple  tinyint(1) NOT NULL DEFAULT 1 COMMENT '1 = allow multiple lots at one warehouse';
297 #EndIf
299 #IfNotRow registry directory procedure_order
300 INSERT INTO `registry` VALUES ('Procedure Order', 1, 'procedure_order', NULL, 1, 1, '2010-02-25 00:00:00', 0, 'Administrative', '');
301 #EndIf
303 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'fee_sheet';
304 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'procedure_order';
305 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'newpatient';
306 UPDATE registry SET category = 'Administrative' WHERE category = 'category' AND directory = 'misc_billing_options';
307 UPDATE registry SET category = 'Clinical' WHERE category = 'category';
309 #IfMissingColumn log patient_id
310 ALTER TABLE log ADD patient_id bigint(20) DEFAULT NULL;
311 #EndIf
313 #IfMissingColumn log success
314 ALTER TABLE log ADD success tinyint(1) DEFAULT 1;
315 #EndIf
317 #IfMissingColumn log checksum
318 ALTER TABLE log ADD checksum longtext DEFAULT NULL;
319 #EndIf
321 #IfMissingColumn log crt_user
322 ALTER TABLE log ADD crt_user varchar(255) DEFAULT NULL;
323 #EndIf
325 #IfMissingColumn users default_warehouse
326 ALTER TABLE users ADD default_warehouse varchar(31) NOT NULL DEFAULT '';
327 #EndIf
329 UPDATE layout_options SET edit_options = 'N'  WHERE form_id = 'DEM' AND field_id = 'title'  AND edit_options = '';
330 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'fname'  AND edit_options = 'C';
331 UPDATE layout_options SET edit_options = 'CD' WHERE form_id = 'DEM' AND field_id = 'lname'  AND edit_options = 'C';
332 UPDATE layout_options SET edit_options = 'ND' WHERE form_id = 'DEM' AND field_id = 'pubpid' AND edit_options = '';
333 UPDATE layout_options SET edit_options = 'N'  WHERE form_id = 'DEM' AND field_id = 'sex'    AND edit_options = '';
335 #IfNotRow2D list_options list_id lists option_id message_status
336 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists'         ,'message_status','Message Status',45,0);
337 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Done'           ,'Done'         , 5,0);
338 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Forwarded'      ,'Forwarded'    ,10,0);
339 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','New'            ,'New'          ,15,0);
340 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('message_status','Read'           ,'Read'         ,20,0);
341 #EndIf
343 #IfNotRow2D list_options list_id note_type option_id Lab Results
344 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Lab Results' ,'Lab Results', 15,0);
345 #EndIf
346 #IfNotRow2D list_options list_id note_type option_id New Orders
347 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','New Orders' ,'New Orders', 20,0);
348 #EndIf
349 #IfNotRow2D list_options list_id note_type option_id Patient Reminders
350 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('note_type','Patient Reminders' ,'Patient Reminders', 25,0);
351 #EndIf
353 #IfMissingColumn pnotes message_status
354 ALTER TABLE pnotes
355   ADD message_status VARCHAR(20) NOT NULL DEFAULT 'New';
356 #EndIf
358 #IfNotTable globals
359 CREATE TABLE `globals` (
360   `gl_name`             varchar(63)    NOT NULL,
361   `gl_index`            int(11)        NOT NULL DEFAULT 0,
362   `gl_value`            varchar(255)   NOT NULL DEFAULT '',
363   PRIMARY KEY (`gl_name`, `gl_index`)
364 ) ENGINE=MyISAM; 
365 #EndIf