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