Updated Acknowledgments page
[openemr.git] / sql / 4_1_1-to-4_1_2_upgrade.sql
blobdd478e4b38ac411a388a13ab2c86d396620fd60c
1 --
2 --  Comment Meta Language Constructs:
3 --
4 --  #IfNotTable
5 --    argument: table_name
6 --    behavior: if the table_name does not exist,  the block will be executed
8 --  #IfTable
9 --    argument: table_name
10 --    behavior: if the table_name does exist, the block will be executed
12 --  #IfMissingColumn
13 --    arguments: table_name colname
14 --    behavior:  if the table exists but the column does not,  the block will be executed
16 --  #IfNotColumnType
17 --    arguments: table_name colname value
18 --    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
20 --  #IfNotRow
21 --    arguments: table_name colname value
22 --    behavior:  If the table table_name does not have a row where colname = value, the block will be executed.
24 --  #IfNotRow2D
25 --    arguments: table_name colname value colname2 value2
26 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed.
28 --  #IfNotRow3D
29 --    arguments: table_name colname value colname2 value2 colname3 value3
30 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed.
32 --  #IfNotRow4D
33 --    arguments: table_name colname value colname2 value2 colname3 value3 colname4 value4
34 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3 AND colname4 = value4, the block will be executed.
36 --  #IfNotRow2Dx2
37 --    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.
38 --    arguments: table_name colname value colname2 value2 colname3 value3
39 --    behavior:  The block will be executed if both statements below are true:
40 --               1) The table table_name does not have a row where colname = value AND colname2 = value2.
41 --               2) The table table_name does not have a row where colname = value AND colname3 = value3.
43 --  #IfRow2D
44 --    arguments: table_name colname value colname2 value2
45 --    behavior:  If the table table_name does have a row where colname = value AND colname2 = value2, the block will be executed.
47 --  #IfIndex
48 --    desc:      This function is most often used for dropping of indexes/keys.
49 --    arguments: table_name colname
50 --    behavior:  If the table and index exist the relevant statements are executed, otherwise not.
52 --  #IfNotIndex
53 --    desc:      This function will allow adding of indexes/keys.
54 --    arguments: table_name colname
55 --    behavior:  If the index does not exist, it will be created
57 --  #IfNotMigrateClickOptions
58 --    Custom function for the importing of the Clickoptions settings (if exist) from the codebase into the database
60 --  #EndIf
61 --    all blocks are terminated with a #EndIf statement.
63 #IfNotTable report_results
64 CREATE TABLE `report_results` (
65   `report_id` bigint(20) NOT NULL,
66   `field_id` varchar(31) NOT NULL default '',
67   `field_value` text,
68   PRIMARY KEY (`report_id`,`field_id`)
69 ) ENGINE=MyISAM;
70 #EndIf
72 #IfMissingColumn version v_acl
73 ALTER TABLE `version` ADD COLUMN `v_acl` int(11) NOT NULL DEFAULT 0;
74 #EndIf
76 #IfMissingColumn documents_legal_detail dld_moved
77 ALTER TABLE `documents_legal_detail` ADD COLUMN `dld_moved` tinyint(4) NOT NULL DEFAULT '0'; 
78 #EndIf
80 #IfMissingColumn documents_legal_detail dld_patient_comments
81 ALTER TABLE `documents_legal_detail` ADD COLUMN `dld_patient_comments` text COMMENT 'Patient comments stored here';
82 #EndIf
84 #IfMissingColumn documents_legal_master dlm_upload_type
85 ALTER TABLE `documents_legal_master` ADD COLUMN `dlm_upload_type` tinyint(4) DEFAULT '0' COMMENT '0-Provider Uploaded,1-Patient Uploaded';
86 #EndIf
88 #IfMissingColumn list_options codes
89 ALTER TABLE `list_options` ADD COLUMN `codes` varchar(255) NOT NULL DEFAULT '';
90 UPDATE list_options SET `codes`='SNOMED-CT:449868002' WHERE list_id='smoking_status' AND option_id='1' AND title='Current every day smoker';
91 UPDATE list_options SET `codes`='SNOMED-CT:428041000124106' WHERE list_id='smoking_status' AND option_id='2' AND title='Current some day smoker';
92 UPDATE list_options SET `codes`='SNOMED-CT:8517006' WHERE list_id='smoking_status' AND option_id='3' AND title='Former smoker';
93 UPDATE list_options SET `codes`='SNOMED-CT:266919005' WHERE list_id='smoking_status' AND option_id='4' AND title='Never smoker';
94 UPDATE list_options SET `codes`='SNOMED-CT:77176002' WHERE list_id='smoking_status' AND option_id='5' AND title='Smoker, current status unknown';
95 UPDATE list_options SET `codes`='SNOMED-CT:266927001' WHERE list_id='smoking_status' AND option_id='9' AND title='Unknown if ever smoked';
96 #EndIf
98 #IfNotRow2Dx2 list_options list_id smoking_status option_id 15 title Heavy tobacco smoker
99 INSERT INTO list_options ( list_id, option_id, title, seq, is_default, codes ) VALUES ('smoking_status', '15', 'Heavy tobacco smoker', 70, 0, "SNOMED-CT:428071000124103");
100 #EndIf
102 #IfNotRow2Dx2 list_options list_id smoking_status option_id 16 title Light tobacco smoker
103 INSERT INTO list_options ( list_id, option_id, title, seq, is_default, codes ) VALUES ('smoking_status', '16', 'Light tobacco smoker', 80, 0, "SNOMED-CT:428061000124105");
104 #EndIf
106 #IfMissingColumn code_types ct_term
107 ALTER TABLE `code_types` ADD COLUMN ct_term tinyint(1) NOT NULL default 0 COMMENT '1 if this is a clinical term';
108 #EndIf
110 #IfNotRow code_types ct_key SNOMED-CT
111 DROP TABLE IF EXISTS `temp_table_one`;
112 CREATE TABLE `temp_table_one` (
113   `id` int(11) NOT NULL DEFAULT '0',
114   `seq` int(11) NOT NULL DEFAULT '0'
115 ) ENGINE=MyISAM ;
116 INSERT INTO `temp_table_one` (`id`, `seq`) VALUES ( IF( ((SELECT MAX(`ct_id`) FROM `code_types`)>=100), ((SELECT MAX(`ct_id`) FROM `code_types`) + 1), 100 ) , IF( ((SELECT MAX(`ct_seq`) FROM `code_types`)>=100), ((SELECT MAX(`ct_seq`) FROM `code_types`) + 1), 100 )  );
117 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('SNOMED-CT' , (SELECT MAX(`id`) FROM `temp_table_one`), (SELECT MAX(`seq`) FROM `temp_table_one`), 0, '', 0, 0, 1, 0, 0, 'SNOMED Clinical Term', 7, 0, 0, 1);
118 DROP TABLE `temp_table_one`;
119 #EndIf
121 #IfNotColumnType codes code varchar(25)
122 ALTER TABLE `codes` CHANGE `code` `code` varchar(25) NOT NULL default '';
123 #EndIf
125 #IfNotColumnType billing code varchar(20)
126 ALTER TABLE `billing` CHANGE `code` `code` varchar(20) default NULL;
127 #EndIf
129 #IfNotColumnType ar_activity code varchar(20)
130 ALTER TABLE `ar_activity` CHANGE `code` `code` varchar(20) NOT NULL COMMENT 'empty means claim level';
131 #EndIf
133 #IfNotTable procedure_questions
134 CREATE TABLE `procedure_questions` (
135   `lab_id`              bigint(20)   NOT NULL DEFAULT 0   COMMENT 'references users.id to identify the lab',
136   `procedure_code`      varchar(31)  NOT NULL DEFAULT ''  COMMENT 'references procedure_type.procedure_code to identify this order type',
137   `question_code`       varchar(31)  NOT NULL DEFAULT ''  COMMENT 'code identifying this question',
138   `seq`                 int(11)      NOT NULL default 0   COMMENT 'sequence number for ordering',
139   `question_text`       varchar(255) NOT NULL DEFAULT ''  COMMENT 'descriptive text for question_code',
140   `required`            tinyint(1)   NOT NULL DEFAULT 0   COMMENT '1 = required, 0 = not',
141   `maxsize`             int          NOT NULL DEFAULT 0   COMMENT 'maximum length if text input field',
142   `fldtype`             char(1)      NOT NULL DEFAULT 'T' COMMENT 'Text, Number, Select, Multiselect, Date, Gestational-age',
143   `options`             text         NOT NULL DEFAULT ''  COMMENT 'choices for fldtype S and T',
144   `activity`            tinyint(1)   NOT NULL DEFAULT 1   COMMENT '1 = active, 0 = inactive',
145   PRIMARY KEY (`lab_id`, `procedure_code`, `question_code`)
146 ) ENGINE=MyISAM;
147 #EndIf
149 #IfMissingColumn procedure_type activity
150 ALTER TABLE `procedure_type` ADD COLUMN `activity` tinyint(1) NOT NULL default 1;
151 #EndIf
153 #IfMissingColumn procedure_type notes
154 ALTER TABLE `procedure_type` ADD COLUMN `notes` varchar(255) NOT NULL default '';
155 #EndIf
157 #IfNotTable procedure_answers
158 CREATE TABLE `procedure_answers` (
159   `procedure_order_id`  bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references procedure_order.procedure_order_id',
160   `procedure_order_seq` int(11)      NOT NULL DEFAULT 1  COMMENT 'references procedure_order_code.seq',
161   `question_code`       varchar(31)  NOT NULL DEFAULT '' COMMENT 'references procedure_questions.question_code',
162   `answer_seq`          int(11)      NOT NULL AUTO_INCREMENT COMMENT 'supports multiple-choice questions',
163   `answer`              varchar(255) NOT NULL DEFAULT '' COMMENT 'answer data',
164   PRIMARY KEY (`procedure_order_id`, `procedure_order_seq`, `question_code`, `answer_seq`)
165 ) ENGINE=MyISAM;
166 #EndIf
168 #IfNotTable procedure_providers
169 CREATE TABLE `procedure_providers` (
170   `ppid`         bigint(20)   NOT NULL auto_increment,
171   `name`         varchar(255) NOT NULL DEFAULT '',
172   `npi`          varchar(15)  NOT NULL DEFAULT '',
173   `protocol`     varchar(15)  NOT NULL DEFAULT 'DL',
174   `login`        varchar(255) NOT NULL DEFAULT '',
175   `password`     varchar(255) NOT NULL DEFAULT '',
176   `orders_path`  varchar(255) NOT NULL DEFAULT '',
177   `results_path` varchar(255) NOT NULL DEFAULT '',
178   `notes`        text         NOT NULL DEFAULT '',
179   PRIMARY KEY (`ppid`)
180 ) ENGINE=MyISAM;
181 #EndIf
183 #IfNotTable procedure_order_code
184 CREATE TABLE `procedure_order_code` (
185   `procedure_order_id`  bigint(20)  NOT NULL,
186   `procedure_order_seq` int(11)     NOT NULL AUTO_INCREMENT COMMENT 'supports multiple tests per order',
187   `procedure_type_id`   bigint(20)  NOT NULL                COMMENT 'references procedure_type.procedure_type_id',
188   `procedure_code`      varchar(31) NOT NULL DEFAULT ''     COMMENT 'copy of procedure_type.procedure_code',
189   PRIMARY KEY (`procedure_order_id`, `procedure_order_seq`)
190 ) ENGINE=MyISAM;
191 INSERT INTO procedure_order_code
192   SELECT po.procedure_order_id, 1, po.procedure_type_id, pt.procedure_code
193   FROM procedure_order AS po
194   LEFT JOIN procedure_type AS pt ON pt.procedure_type_id = po.procedure_type_id;
195 ALTER TABLE `procedure_order`
196   DROP COLUMN `procedure_type_id`;
197 #EndIf
199 #IfMissingColumn procedure_order lab_id
200 ALTER TABLE `procedure_order`
201   ADD COLUMN `lab_id`            bigint(20)   NOT NULL DEFAULT 0  COMMENT 'references procedure_providers.ppid',
202   ADD COLUMN `specimen_type`     varchar(31)  NOT NULL DEFAULT '' COMMENT 'from the Specimen_Type list',
203   ADD COLUMN `specimen_location` varchar(31)  NOT NULL DEFAULT '' COMMENT 'from the Specimen_Location list',
204   ADD COLUMN `specimen_volume`   varchar(30)  NOT NULL DEFAULT '' COMMENT 'from a text input field';
205 UPDATE procedure_order AS po, procedure_order_code AS pc, procedure_type AS pt
206   SET po.lab_id = pt.lab_id WHERE
207   po.lab_id = 0 AND
208   pc.procedure_order_id = po.procedure_order_id AND
209   pt.procedure_type_id = pc.procedure_type_id AND
210   pt.lab_id != 0;
211 #EndIf
213 #IfMissingColumn procedure_report procedure_order_seq
214 ALTER TABLE procedure_report
215   ADD COLUMN `procedure_order_seq` int(11) NOT NULL DEFAULT 1 COMMENT 'references procedure_order_code.procedure_order_seq';
216 #EndIf
218 #IfMissingColumn procedure_order diagnoses
219 ALTER TABLE `procedure_order`
220   ADD COLUMN `diagnoses` text NOT NULL DEFAULT '' COMMENT 'diagnoses and maybe other coding (e.g. ICD9:111.11)';
221 #EndIf
223 #IfMissingColumn procedure_providers remote_host
224 ALTER TABLE `procedure_providers`
225   ADD COLUMN `remote_host` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'IP or hostname of remote server',
226   ADD COLUMN `send_app_id` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Sending application ID (MSH-3.1)',
227   ADD COLUMN `send_fac_id` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Sending facility ID (MSH-4.1)',
228   ADD COLUMN `recv_app_id` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Receiving application ID (MSH-5.1)',
229   ADD COLUMN `recv_fac_id` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Receiving facility ID (MSH-6.1)',
230   ADD COLUMN `DorP`        char(1)       NOT NULL DEFAULT 'D' COMMENT 'Debugging or Production (MSH-11)';
231 #EndIf
233 #IfMissingColumn procedure_order_code procedure_source
234 ALTER TABLE `procedure_order_code`
235   ADD COLUMN `procedure_source` char(1) NOT NULL DEFAULT '1' COMMENT '1=original order, 2=added after order sent';
236 #EndIf
238 #IfMissingColumn procedure_result result_code
239 ALTER TABLE `procedure_result`
240   ADD COLUMN `result_data_type` char(1) NOT NULL DEFAULT 'S' COMMENT
241   'N=Numeric, S=String, F=Formatted, E=External, L=Long text as first line of comments',
242   ADD COLUMN `result_code` varchar(31) NOT NULL DEFAULT '' COMMENT
243   'LOINC code, might match a procedure_type.procedure_code',
244   ADD COLUMN `result_text` varchar(255) NOT NULL DEFAULT '' COMMENT
245   'Description of result_code';
246 # This severs the link between procedure_result and procedure_type:
247 UPDATE procedure_result AS ps, procedure_type AS pt
248   SET ps.result_code = pt.procedure_code, ps.result_text = pt.description
249   WHERE pt.procedure_type_id = ps.procedure_type_id;
250 ALTER TABLE `procedure_result` DROP COLUMN procedure_type_id;
251 #EndIf
253 #IfMissingColumn procedure_questions tips
254 ALTER TABLE `procedure_questions`
255   ADD COLUMN `tips` varchar(255) NOT NULL DEFAULT '' COMMENT 'Additional instructions for answering the question';
256 #EndIf
258 #IfMissingColumn procedure_order_code procedure_name
259 ALTER TABLE `procedure_order_code`
260   ADD COLUMN `procedure_name` varchar(255) NOT NULL DEFAULT '' COMMENT
261   'Descriptive name of procedure_code';
262 # This severs the link between procedure_order_code and procedure_type:
263 UPDATE procedure_order_code AS pc, procedure_order AS po, procedure_type AS pt
264   SET pc.procedure_name = pt.name
265   WHERE po.procedure_order_id = pc.procedure_order_id AND
266   pt.lab_id = po.lab_id AND
267   pt.procedure_code = pc.procedure_code;
268 ALTER TABLE `procedure_order_code` DROP COLUMN procedure_type_id;
269 #EndIf
271 #IfMissingColumn procedure_report report_notes
272 ALTER TABLE procedure_report
273   ADD COLUMN `report_notes` text NOT NULL DEFAULT '' COMMENT 'Notes from the lab';
274 #EndIf
276 #IfNotRow code_types ct_key SNOMED-PR
277 DROP TABLE IF EXISTS `temp_table_one`;
278 CREATE TABLE `temp_table_one` (
279   `id` int(11) NOT NULL DEFAULT '0',
280   `seq` int(11) NOT NULL DEFAULT '0'
281 ) ENGINE=MyISAM ;
282 INSERT INTO `temp_table_one` (`id`, `seq`) VALUES ( IF( ((SELECT MAX(`ct_id`) FROM `code_types`)>=100), ((SELECT MAX(`ct_id`) FROM `code_types`) + 1), 100 ) , IF( ((SELECT MAX(`ct_seq`) FROM `code_types`)>=100), ((SELECT MAX(`ct_seq`) FROM `code_types`) + 1), 100 )  );
283 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('SNOMED-PR' , (SELECT MAX(`id`) FROM `temp_table_one`), (SELECT MAX(`seq`) FROM `temp_table_one`), 0, 'SNOMED', 1, 0, 0, 0, 0, 'SNOMED Procedure', 9, 1, 1, 0);
284 DROP TABLE `temp_table_one`;
285 #EndIf
287 #IfNotTable background_services 
288 CREATE TABLE IF NOT EXISTS `background_services` (
289   `name` varchar(31) NOT NULL,
290   `title` varchar(127) NOT NULL COMMENT 'name for reports',
291   `active` tinyint(1) NOT NULL default '0',
292   `running` tinyint(1) NOT NULL default '-1',
293   `next_run` timestamp NOT NULL default CURRENT_TIMESTAMP,
294   `execute_interval` int(11) NOT NULL default '0' COMMENT 'minimum number of minutes between function calls,0=manual mode',
295   `function` varchar(127) NOT NULL COMMENT 'name of background service function',
296   `require_once` varchar(255) default NULL COMMENT 'include file (if necessary)',
297   `sort_order` int(11) NOT NULL default '100' COMMENT 'lower numbers will be run first',
298   PRIMARY KEY  (`name`)
299 ) ENGINE=MyISAM;
300 #EndIf
302 #IfNotRow background_services name phimail
303 INSERT INTO `background_services` (`name`, `title`, `execute_interval`, `function`, `require_once`, `sort_order`) VALUES
304 ('phimail', 'phiMail Direct Messaging Service', 5, 'phimail_check', '/library/direct_message_check.inc', 100);
305 #EndIf
307 #IfNotRow users username phimail-service
308 INSERT INTO `users` (username,password,lname,authorized,active) 
309   VALUES ('phimail-service','NoLogin','phiMail Gateway',0,0);
310 #EndIf
312 #IfNotRow users username portal-user
313 INSERT INTO `users` (username,password,lname,authorized,active) 
314   VALUES ('portal-user','NoLogin','Patient Portal User',0,0);
315 #EndIf
317 #IfNotTable direct_message_log
318 CREATE TABLE IF NOT EXISTS `direct_message_log` (
319   `id` bigint(20) NOT NULL auto_increment,
320   `msg_type` char(1) NOT NULL COMMENT 'S=sent,R=received',
321   `msg_id` varchar(127) NOT NULL,
322   `sender` varchar(255) NOT NULL,
323   `recipient` varchar(255) NOT NULL,
324   `create_ts` timestamp NOT NULL default CURRENT_TIMESTAMP,
325   `status` char(1) NOT NULL COMMENT 'Q=queued,D=dispatched,R=received,F=failed',
326   `status_info` varchar(511) default NULL,
327   `status_ts` timestamp NULL default NULL,
328   `patient_id` bigint(20) default NULL,
329   `user_id` bigint(20) default NULL,
330   PRIMARY KEY  (`id`),
331   KEY `msg_id` (`msg_id`),
332   KEY `patient_id` (`patient_id`)
333 ) ENGINE=MyISAM;
334 #EndIf
336 #IfMissingColumn procedure_order_code diagnoses
337 ALTER TABLE `procedure_order_code`
338   ADD COLUMN `diagnoses` text NOT NULL DEFAULT '' COMMENT
339   'diagnoses and maybe other coding (e.g. ICD9:111.11)';
340 UPDATE procedure_order_code AS pc, procedure_order AS po
341   SET pc.diagnoses = po.diagnoses
342   WHERE po.procedure_order_id = pc.procedure_order_id;
343 #EndIf
345 # At this point this obsolete column will always exist, because it was created
346 # and then moved to another table during this release cycle.
347 ALTER TABLE `procedure_order` DROP COLUMN diagnoses;
349 #IfMissingColumn lists modifydate
350 ALTER TABLE `lists` ADD COLUMN `modifydate` timestamp NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
351 #EndIf
353 #IfMissingColumn code_types ct_problem
354 ALTER TABLE `code_types` ADD COLUMN `ct_problem` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 if this code type is used as a medical problem';
355 UPDATE code_types SET ct_problem = 1 WHERE ct_key='ICD9';
356 UPDATE code_types SET ct_problem = 1 WHERE ct_key='DSMIV';
357 UPDATE code_types SET ct_problem = 1 WHERE ct_key='ICD10';
358 UPDATE code_types SET ct_problem = 1 WHERE ct_key='SNOMED';
359 #EndIf
361 #IfMissingColumn procedure_order date_transmitted
362 ALTER TABLE `procedure_order`
363   ADD COLUMN `date_transmitted` datetime DEFAULT NULL COMMENT
364   'time of order transmission, null if unsent';
365 UPDATE procedure_order SET date_transmitted = date_ordered WHERE
366   date_transmitted IS NULL AND date_ordered IS NOT NULL;
367 #EndIf
369 #IfNotRow2D list_options list_id lists option_id issue_types
370 INSERT INTO list_options (`list_id`,`option_id`,`title`) VALUES ('lists','issue_types','Issue Types');
371 #EndIf
373 #IfNotMigrateClickOptions
374 #EndIf
376 #IfNotTable issue_types
377 CREATE TABLE `issue_types` (
378   `category` varchar(75) NOT NULL DEFAULT '',
379   `type` varchar(75) NOT NULL DEFAULT '',
380   `plural` varchar(75) NOT NULL DEFAULT '',
381   `singular` varchar(75) NOT NULL DEFAULT '',
382   `abbreviation` varchar(75) NOT NULL DEFAULT '',
383   `style` smallint(6) NOT NULL DEFAULT '0',
384   `force_show` smallint(6) NOT NULL DEFAULT '0',
385   `ordering` int(11) NOT NULL DEFAULT '0',
386   PRIMARY KEY (`category`,`type`)
387 ) ENGINE=MyISAM;
388 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('10','default','medical_problem','Medical Problems','Problem','P','0','1');
389 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('30','default','medication','Medications','Medication','M','0','1');
390 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('20','default','allergy','Allergies','Allergy','A','0','1');
391 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('40','default','surgery','Surgeries','Surgery','S','0','0');
392 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('50','default','dental','Dental Issues','Dental','D','0','0');
393 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('10','athletic_team','football_injury','Football Injuries','Injury','I','2','1');
394 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('20','athletic_team','medical_problem','Medical Problems','Medical','P','0','0');
395 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('30','athletic_team','allergy','Allergies','Allergy','A','1','0');
396 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('40','athletic_team','general','General','General','G','1','0');
397 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('10','ippf_specific','medical_problem','Medical Problems','Problem','P','0','1');
398 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('30','ippf_specific','medication','Medications','Medication','M','0','1');
399 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('20','ippf_specific','allergy','Allergies','Allergy','Y','0','1');
400 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('40','ippf_specific','surgery','Surgeries','Surgery','S','0','0');
401 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('50','ippf_specific','ippf_gcac','Abortions','Abortion','A','3','0');
402 INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbreviation`,`style`,`force_show`) VALUES ('60','ippf_specific','contraceptive','Contraception','Contraception','C','4','0');
403 #EndIf
405 #IfMissingColumn issue_types active
406 ALTER TABLE `issue_types` ADD COLUMN `active` tinyint(1) NOT NULL DEFAULT '1';
407 #EndIf
409 #IfNotColumnType immunizations administered_date datetime
410 ALTER TABLE `immunizations`
411   MODIFY COLUMN administered_date datetime DEFAULT NULL;
412 #EndIf
414 #IfMissingColumn immunizations amount_administered
415 ALTER TABLE `immunizations`
416   ADD COLUMN `amount_administered` int(11) DEFAULT NULL;
417 #EndIf
419 #IfMissingColumn immunizations amount_administered_unit
420 ALTER TABLE `immunizations`
421   ADD COLUMN `amount_administered_unit` varchar(50) DEFAULT NULL;
422 #EndIf
424 #IfMissingColumn immunizations expiration_date
425 ALTER TABLE `immunizations`
426   ADD COLUMN `expiration_date` date DEFAULT NULL;
427 #EndIf
429 #IfMissingColumn immunizations route
430 ALTER TABLE `immunizations`
431   ADD COLUMN `route` varchar(100) DEFAULT NULL;
432 #EndIf
434 #IfMissingColumn immunizations administration_site
435 ALTER TABLE `immunizations`
436   ADD COLUMN `administration_site` varchar(100) DEFAULT NULL;
437 #EndIf
439 #IfMissingColumn immunizations added_erroneously
440 ALTER TABLE `immunizations`
441   ADD COLUMN `added_erroneously` tinyint(1) NOT NULL DEFAULT '0';
442 #EndIf
444 #IfMissingColumn documents path_depth
445 ALTER TABLE `documents` ADD COLUMN `path_depth` TINYINT DEFAULT '1' COMMENT 'Depth of path to use in url to find document. Not applicable for CouchDB.';
446 #Endif
448 #IfNotTable users_secure
449 CREATE TABLE `users_secure` (
450   `id` bigint(20) NOT NULL,
451   `username` varchar(255) DEFAULT NULL,
452   `password` varchar(255),
453   `salt` varchar(255),
454   `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
455   `password_history1` varchar(255),
456   `salt_history1` varchar(255),
457   `password_history2` varchar(255),
458   `salt_history2` varchar(255),
459   PRIMARY KEY (`id`),
460   UNIQUE KEY `USERNAME_ID` (`id`,`username`)
461 ) ENGINE=InnoDb; 
462 #EndIf
464 #IfMissingColumn patient_access_onsite portal_salt
465 ALTER TABLE `patient_access_onsite` ADD COLUMN `portal_salt` VARCHAR(100) NULL;
466 #Endif
468 #IfMissingColumn procedure_order clinical_hx
469 ALTER TABLE `procedure_order`
470   ADD COLUMN `clinical_hx` varchar(255) DEFAULT '' COMMENT
471   'clinical history text that may be relevant to the order';
472 #EndIf
474 #IfMissingColumn procedure_order_code do_not_send
475 ALTER TABLE `procedure_order_code`
476   ADD COLUMN `do_not_send` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 = normal, 1 = do not transmit to lab';
477 #EndIf