fix: ccda zip import and php warnings and deprecations (#7416)
[openemr.git] / sql / 5_0_0-to-5_0_1_upgrade.sql
blobc7a21f748ae358bca42f5862dfcfae8fdc9c5cb6
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 --  #IfColumn
13 --    arguments: table_name colname
14 --    behavior:  if the table and column exist,  the block will be executed
16 --  #IfMissingColumn
17 --    arguments: table_name colname
18 --    behavior:  if the table exists but the column does not,  the block will be executed
20 --  #IfNotColumnType
21 --    arguments: table_name colname value
22 --    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
24 --  #IfNotRow
25 --    arguments: table_name colname value
26 --    behavior:  If the table table_name does not have a row where colname = value, the block will be executed.
28 --  #IfNotRow2D
29 --    arguments: table_name colname value colname2 value2
30 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed.
32 --  #IfNotRow3D
33 --    arguments: table_name colname value colname2 value2 colname3 value3
34 --    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.
36 --  #IfNotRow4D
37 --    arguments: table_name colname value colname2 value2 colname3 value3 colname4 value4
38 --    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.
40 --  #IfNotRow2Dx2
41 --    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.
42 --    arguments: table_name colname value colname2 value2 colname3 value3
43 --    behavior:  The block will be executed if both statements below are true:
44 --               1) The table table_name does not have a row where colname = value AND colname2 = value2.
45 --               2) The table table_name does not have a row where colname = value AND colname3 = value3.
47 --  #IfRow2D
48 --    arguments: table_name colname value colname2 value2
49 --    behavior:  If the table table_name does have a row where colname = value AND colname2 = value2, the block will be executed.
51 --  #IfRow3D
52 --        arguments: table_name colname value colname2 value2 colname3 value3
53 --        behavior:  If the table table_name does have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed.
55 --  #IfIndex
56 --    desc:      This function is most often used for dropping of indexes/keys.
57 --    arguments: table_name colname
58 --    behavior:  If the table and index exist the relevant statements are executed, otherwise not.
60 --  #IfNotIndex
61 --    desc:      This function will allow adding of indexes/keys.
62 --    arguments: table_name colname
63 --    behavior:  If the index does not exist, it will be created
65 --  #EndIf
66 --    all blocks are terminated with a #EndIf statement.
68 --  #IfNotListReaction
69 --    Custom function for creating Reaction List
71 --  #IfNotListOccupation
72 --    Custom function for creating Occupation List
74 --  #IfTextNullFixNeeded
75 --    desc: convert all text fields without default null to have default null.
76 --    arguments: none
78 --  #IfTableEngine
79 --    desc:      Execute SQL if the table has been created with given engine specified.
80 --    arguments: table_name engine
81 --    behavior:  Use when engine conversion requires more than one ALTER TABLE
83 --  #IfInnoDBMigrationNeeded
84 --    desc: find all MyISAM tables and convert them to InnoDB.
85 --    arguments: none
86 --    behavior: can take a long time.
88 #IfMissingColumn list_options edit_options
89   ALTER TABLE `list_options` ADD `edit_options` TINYINT(1) NOT NULL DEFAULT '1';
90 #Endif
92 #IfMissingColumn list_options timestamp
93 ALTER TABLE `list_options` ADD `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
94 #Endif
96 #IfNotTable multiple_db
97   CREATE TABLE `multiple_db` (
98     `id` int(11) NOT NULL AUTO_INCREMENT,
99     `namespace` varchar(255) NOT NULL,
100     `username` varchar(255) NOT NULL,
101     `password` text,
102     `dbname` varchar(255) NOT NULL,
103     `host` varchar(255) NOT NULL DEFAULT 'localhost',
104     `port` smallint(4) NOT NULL DEFAULT '3306',
105     `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
106      UNIQUE KEY `namespace` (namespace),
107      PRIMARY KEY (id)
108   ) ENGINE=InnoDB;
109 #EndIf
111 #IfNotRow2D list_options list_id page_validation option_id therapy_groups_add#addGroup
112 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `notes`, `activity`) VALUES ('page_validation', 'therapy_groups_add#addGroup', '/interface/therapy_groups/index.php?method=addGroup', 120, '{group_name:{presence: true}}', 1);
113 #EndIf
115 #IfNotRow2D list_options list_id page_validation option_id therapy_groups_edit#editGroup
116 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `notes`, `activity`) VALUES ('page_validation', 'therapy_groups_edit#editGroup', '/interface/therapy_groups/index.php?method=groupDetails', 125, '{group_name:{presence: true}}', 1);
117 #EndIf
119 #IfNotRow2D list_options list_id page_validation option_id tg_add#add-participant-form
120 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `notes`, `activity`) VALUES ('page_validation', 'tg_add#add-participant-form', '/interface/therapy_groups/index.php?method=groupParticipants', 130, '{participant_name:{presence: true}, group_patient_start:{presence: true}}', 1);
121 #EndIf
123 #IfNotRow2D list_options list_id page_validation option_id add_edit_event#theform_groups
124 INSERT INTO `list_options` (`list_id`,`option_id`,`title`,`seq`,`is_default`,`option_value`,`mapping`,`notes`,`codes`,`toggle_setting_1`,`toggle_setting_2`,`activity`,`subtype`)
125 VALUES ('page_validation','add_edit_event#theform_groups','/interface/main/calendar/add_edit_event.php?group=true',150,0,0,'','{form_group:{presence: true}}','',0,0,1,'');
126 #EndIf
128 #IfNotRow2D list_options list_id page_validation option_id common#new-encounter-form
129 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `notes`, `activity`) VALUES ('page_validation', 'common#new-encounter-form', '/interface/forms/newGroupEncounter/common.php', 160, '{pc_catid:{exclusion: ["_blank"]}}', 1);
130 #EndIf
133 #IfNotTable therapy_groups
134 CREATE TABLE `therapy_groups` (
135   `group_id` int(11) NOT NULL auto_increment,
136   `group_name` varchar(255) NOT NULL ,
137   `group_start_date` date NOT NULL ,
138   `group_end_date` date,
139   `group_type` tinyint NOT NULL,
140   `group_participation` tinyint NOT NULL,
141   `group_status` int(11) NOT NULL,
142   `group_notes` text,
143   `group_guest_counselors` varchar(255),
144   PRIMARY KEY  (`group_id`)
145 ) ENGINE=InnoDB;
146 #EndIf
148 #IfNotTable therapy_groups_participants
149 CREATE TABLE `therapy_groups_participants` (
150   `group_id` int(11) NOT NULL,
151   `pid` int(11) NOT NULL ,
152   `group_patient_status` int(11) NOT NULL,
153   `group_patient_start` date NOT NULL ,
154   `group_patient_end` date,
155   `group_patient_comment` text,
156   PRIMARY KEY (`group_id`,`pid`)
157 ) ENGINE=InnoDB;
158 #EndIf
160 #IfNotTable therapy_groups_participant_attendance
161 CREATE TABLE `therapy_groups_participant_attendance` (
162   `form_id` int(11) NOT NULL,
163   `pid` int(11) NOT NULL ,
164   `meeting_patient_comment` text ,
165   `meeting_patient_status` varchar(15),
166   PRIMARY KEY (`form_id`,`pid`)
167 ) ENGINE=InnoDB;
168 #EndIf
170 #IfNotTable therapy_groups_counselors
171 CREATE TABLE `therapy_groups_counselors`(
172         `group_id` int(11) NOT NULL,
173         `user_id` int(11) NOT NULL,
174         PRIMARY KEY (`group_id`,`user_id`)
175 ) ENGINE=InnoDB;
176 #EndIf
178 #IfMissingColumn openemr_postcalendar_events pc_gid
179 ALTER TABLE openemr_postcalendar_events ADD pc_gid int(11) DEFAULT 0;
180 #EndIf
182 #IfNotRow2D list_options list_id lists option_id groupstat
183 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`) VALUES ('lists', 'groupstat', 'Group Statuses', '13', '0', '0');
184 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '-', '- None', '10', '0', '0', 'FEFDCF|0');
185 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '=', '= Took Place', '20', '0', '0', 'FF2414|0');
186 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '>', '> Did Not Take Place', '30', '0', '0', 'BFBFBF|0');
187 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '<', '< Not Reported', '40', '0', '0', 'FEFDCF|0');
188 #EndIf
190 #IfNotRow openemr_postcalendar_categories pc_catname Group Therapy
191 INSERT INTO openemr_postcalendar_categories (`pc_catname`, `pc_catcolor`, `pc_recurrspec`, `pc_duration` ,`pc_cattype` , `pc_active` , `pc_seq`)
192 VALUES ('Group Therapy' , '#BFBFBF' , 'a:5:{s:17:"event_repeat_freq";s:1:"0";s:22:"event_repeat_freq_type";s:1:"0";s:19:"event_repeat_on_num";s:1:"1";s:19:"event_repeat_on_day";s:1:"0";s:20:"event_repeat_on_freq";s:1:"0";}', '3600', '3', '1', '90');
193 #EndIf
196 #IfNotTable form_groups_encounter
197 CREATE TABLE `form_groups_encounter` (
198   `id` bigint(20) NOT NULL auto_increment,
199   `date` datetime default NULL,
200   `reason` longtext,
201   `facility` longtext,
202   `facility_id` int(11) NOT NULL default '0',
203   `group_id` bigint(20) default NULL,
204   `encounter` bigint(20) default NULL,
205   `onset_date` datetime default NULL,
206   `sensitivity` varchar(30) default NULL,
207   `billing_note` text,
208   `pc_catid` int(11) NOT NULL default '5' COMMENT 'event category from openemr_postcalendar_categories',
209   `last_level_billed` int  NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
210   `last_level_closed` int  NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
211   `last_stmt_date`    date DEFAULT NULL,
212   `stmt_count`        int  NOT NULL DEFAULT 0,
213   `provider_id` INT(11) DEFAULT '0' COMMENT 'default and main provider for this visit',
214   `supervisor_id` INT(11) DEFAULT '0' COMMENT 'supervising provider, if any, for this visit',
215   `invoice_refno` varchar(31) NOT NULL DEFAULT '',
216   `referral_source` varchar(31) NOT NULL DEFAULT '',
217   `billing_facility` INT(11) NOT NULL DEFAULT 0,
218   `external_id` VARCHAR(20) DEFAULT NULL,
219   `pos_code` tinyint(4) default NULL,
220   `counselors` VARCHAR (255),
221   `appt_id` INT(11) default NULL,
222   PRIMARY KEY  (`id`),
223   KEY `pid_encounter` (`group_id`, `encounter`),
224   KEY `encounter_date` (`date`)
225 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
226 #EndIf
228 #IfMissingColumn forms therapy_group_id
229 ALTER TABLE  `forms` ADD  `therapy_group_id` INT(11) DEFAULT NULL;
230 #EndIf
232 #IfMissingColumn registry patient_encounter
233 ALTER TABLE `registry` ADD `patient_encounter` TINYINT NOT NULL DEFAULT '1';
234 #EndIf
236 #IfMissingColumn registry therapy_group_encounter
237 ALTER TABLE `registry` ADD `therapy_group_encounter` TINYINT NOT NULL DEFAULT '0';
238 #EndIf
241 #IfNotRow2D list_options list_id lists option_id attendstat
242 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`) VALUES ('lists', 'attendstat', 'Group Attendance Statuses', '15', '0', '0');
243 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`, `toggle_setting_1`) VALUES ('attendstat', '-', '- Not Reported', '10', '0', '0', 'FEFDCF|0', '0');
244 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`, `toggle_setting_1`) VALUES ('attendstat', '@', '@ Attended', '20', '0', '0', 'FF2414|0', '1');
245 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`, `toggle_setting_1`) VALUES ('attendstat', '?', '? Did Not Attend', '30', '0', '0', 'BFBFBF|0', '1');
246 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`, `toggle_setting_1`) VALUES ('attendstat', '~', '~ Late Arrival', '40', '0', '0', 'BFBFBF|0', '1');
247 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`, `toggle_setting_1`) VALUES ('attendstat', 'x', 'x Cancelled', '50', '0', '0', 'FEFDCF|0', '0');
248 #EndIf
250 #IfNotRow registry directory group_attendance
251 INSERT INTO registry (name, state, directory, sql_run, unpackaged, date, priority, category, nickname, patient_encounter, therapy_group_encounter) VALUES ('Group Attendance Form', 1, 'group_attendance', 1, 1, '2015-10-15 00:00:00', 0, 'Clinical', '',0,1);
252 #EndIf
254 #IfNotRow registry directory newGroupEncounter
255 INSERT INTO registry (name, state, directory, sql_run, unpackaged, date, priority, category, nickname, patient_encounter, therapy_group_encounter) VALUES ('New Group Encounter Form', 1, 'newGroupEncounter', 1, 1, '2015-10-15 00:00:00', 0, 'Clinical', '',0,1);
256 #EndIf
258 #IfTable form_therapy_groups_attendance
259 RENAME TABLE form_therapy_groups_attendance TO form_group_attendance;
260 #EndIf
262 #IfNotTable form_group_attendance
263 CREATE TABLE `form_group_attendance` (
264   id    bigint(20) auto_increment,
265   date  date,
266   group_id      int(11),
267   user  varchar(255),
268   groupname     varchar(255),
269   authorized    tinyint(4),
270   encounter_id  int(11),
271   activity      tinyint(4),
272   PRIMARY KEY (`id`)
273 ) ENGINE=InnoDB ;
274 #EndIf
276 #IfNotRow2D list_options list_id lists option_id files_white_list
277 INSERT INTO list_options (`list_id`, `option_id`, `title`) VALUES ('lists', 'files_white_list', 'Files type white list');
278 #EndIf
280 #IfNotTable onsite_documents
281 CREATE TABLE `onsite_documents` (
282   `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
283   `pid` int(10) UNSIGNED DEFAULT NULL,
284   `facility` int(10) UNSIGNED DEFAULT NULL,
285   `provider` int(10) UNSIGNED DEFAULT NULL,
286   `encounter` int(10) UNSIGNED DEFAULT NULL,
287   `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
288   `doc_type` varchar(255) NOT NULL,
289   `patient_signed_status` smallint(5) UNSIGNED NOT NULL,
290   `patient_signed_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
291   `authorize_signed_time` datetime DEFAULT NULL,
292   `accept_signed_status` smallint(5) NOT NULL,
293   `authorizing_signator` varchar(50) NOT NULL,
294   `review_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
295   `denial_reason` varchar(255) NOT NULL,
296   `authorized_signature` text,
297   `patient_signature` text,
298   `full_document` blob,
299   `file_name` varchar(255) NOT NULL,
300   `file_path` varchar(255) NOT NULL,
301   PRIMARY KEY (`id`)
302 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
303 #EndIf
305 #IfNotTable onsite_mail
306 CREATE TABLE `onsite_mail` (
307   `id` bigint(20) NOT NULL AUTO_INCREMENT,
308   `date` datetime DEFAULT NULL,
309   `owner` bigint(20) DEFAULT NULL,
310   `user` varchar(255) DEFAULT NULL,
311   `groupname` varchar(255) DEFAULT NULL,
312   `activity` tinyint(4) DEFAULT NULL,
313   `authorized` tinyint(4) DEFAULT NULL,
314   `header` varchar(255) DEFAULT NULL,
315   `title` varchar(255) DEFAULT NULL,
316   `body` longtext,
317   `recipient_id` varchar(128) DEFAULT NULL,
318   `recipient_name` varchar(255) DEFAULT NULL,
319   `sender_id` varchar(128) DEFAULT NULL,
320   `sender_name` varchar(255) DEFAULT NULL,
321   `assigned_to` varchar(255) DEFAULT NULL,
322   `deleted` tinyint(4) DEFAULT '0' COMMENT 'flag indicates note is deleted',
323   `delete_date` datetime DEFAULT NULL,
324   `mtype` varchar(128) DEFAULT NULL,
325   `message_status` varchar(20) NOT NULL DEFAULT 'New',
326   `mail_chain` int(11) DEFAULT NULL,
327   `reply_mail_chain` int(11) DEFAULT NULL,
328   `is_msg_encrypted` tinyint(2) DEFAULT '0' COMMENT 'Whether messsage encrypted 0-Not encrypted, 1-Encrypted',
329   PRIMARY KEY (`id`),
330   KEY `pid` (`owner`)
331 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
332 #EndIf
334 #IfNotTable onsite_messages
335 CREATE TABLE `onsite_messages` (
336   `id` int(11) NOT NULL AUTO_INCREMENT,
337   `username` varchar(64) NOT NULL,
338   `message` longtext,
339   `ip` varchar(15) NOT NULL,
340   `date` datetime NOT NULL,
341   `sender_id` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'who sent id',
342  `recip_id` varchar(255) NOT NULL COMMENT 'who to id array',
343   PRIMARY KEY (`id`)
344 ) ENGINE=InnoDB COMMENT='Portal messages' AUTO_INCREMENT=1 ;
345 #EndIf
347 #IfNotTable onsite_online
348 CREATE TABLE `onsite_online` (
349   `hash` varchar(32) NOT NULL,
350   `ip` varchar(15) NOT NULL,
351   `last_update` datetime NOT NULL,
352   `username` varchar(64) NOT NULL,
353   `userid` int(11) UNSIGNED DEFAULT NULL,
354   PRIMARY KEY (`hash`)
355 ) ENGINE=InnoDB;
356 #EndIf
358 #IfNotTable onsite_portal_activity
359 CREATE TABLE `onsite_portal_activity` (
360   `id` bigint(20) NOT NULL AUTO_INCREMENT,
361   `date` datetime DEFAULT NULL,
362   `patient_id` bigint(20) DEFAULT NULL,
363   `activity` varchar(255) DEFAULT NULL,
364   `require_audit` tinyint(1) DEFAULT '1',
365   `pending_action` varchar(255) DEFAULT NULL,
366   `action_taken` varchar(255) DEFAULT NULL,
367   `status` varchar(255) DEFAULT NULL,
368   `narrative` longtext,
369   `table_action` longtext,
370   `table_args` longtext,
371   `action_user` int(11) DEFAULT NULL,
372   `action_taken_time` datetime DEFAULT NULL,
373   `checksum` longtext,
374   PRIMARY KEY (`id`),
375   KEY `date` (`date`)
376 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
377 #EndIf
379 #IfNotTable onsite_signatures
380 CREATE TABLE `onsite_signatures` (
381   `id` bigint(20) NOT NULL AUTO_INCREMENT,
382   `status` varchar(128) NOT NULL DEFAULT 'waiting',
383   `type` varchar(128) NOT NULL,
384   `created` int(11) NOT NULL,
385   `lastmod` datetime NOT NULL,
386   `pid` bigint(20) DEFAULT NULL,
387   `encounter` int(11) DEFAULT NULL,
388   `user` varchar(255) DEFAULT NULL,
389   `activity` tinyint(4) NOT NULL DEFAULT '0',
390   `authorized` tinyint(4) DEFAULT NULL,
391   `signator` varchar(255) NOT NULL,
392   `sig_image` text,
393   `signature` text,
394   `sig_hash` varchar(128) NOT NULL,
395   `ip` varchar(46) NOT NULL,
396   PRIMARY KEY (`id`),
397   UNIQUE KEY `pid` (`pid`,`user`),
398   KEY `encounter` (`encounter`)
399 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
400 #EndIf
402 #IfNotRow categories name Onsite Portal
403 INSERT INTO categories select (select MAX(id) from categories) + 1, 'Onsite Portal', '', 1, rght, rght + 5 from categories where name = 'Categories';
404 INSERT INTO categories select (select MAX(id) from categories) + 1, 'Patient', '', (select id from categories where name = 'Onsite Portal'), rght + 1, rght + 2 from categories where name = 'Categories';
405 INSERT INTO categories select (select MAX(id) from categories) + 1, 'Reviewed', '', (select id from categories where name = 'Onsite Portal'), rght + 3, rght + 4 from categories where name = 'Categories';
406 UPDATE categories SET rght = rght + 6 WHERE name = 'Categories';
407 UPDATE categories_seq SET id = (select MAX(id) from categories);
408 #EndIf
410 #IfNotRow2D list_options list_id apptstat option_id ^
411 INSERT INTO list_options ( `list_id`, `option_id`, `title`, `seq`, `is_default`, `notes` ) VALUES ('apptstat','^','^ Pending',70,0,'FEFDCF|0');
412 #EndIf
414 #IfMissingColumn registry aco_spec
415 ALTER TABLE `registry` ADD `aco_spec` varchar(63) NOT NULL default 'encounters|notes';
416 UPDATE `registry` SET `aco_spec` = 'patients|appt'     WHERE directory = 'newpatient';
417 UPDATE `registry` SET `aco_spec` = 'patients|appt'     WHERE directory = 'newGroupEncounter';
418 UPDATE `registry` SET `aco_spec` = 'encounters|coding' WHERE directory = 'fee_sheet';
419 UPDATE `registry` SET `aco_spec` = 'encounters|coding' WHERE directory = 'misc_billing_options';
420 UPDATE `registry` SET `aco_spec` = 'patients|lab'      WHERE directory = 'procedure_order';
421 #EndIf
423 #IfNotColumnType lbf_data field_value longtext
424 ALTER TABLE `lbf_data` CHANGE `field_value` `field_value` longtext;
425 #EndIf
427 #IfMissingColumn issue_types aco_spec
428 ALTER TABLE `issue_types` ADD `aco_spec` varchar(63) NOT NULL default 'patients|med';
429 #EndIf
431 #IfMissingColumn categories aco_spec
432 ALTER TABLE `categories` ADD `aco_spec` varchar(63) NOT NULL default 'patients|docs';
433 #EndIf
435 #IfNotColumnType onsite_mail owner varchar(128)
436 ALTER TABLE `onsite_mail` CHANGE `owner` `owner` varchar(128) DEFAULT NULL;
437 #Endif
439 #IfNotColumnType openemr_postcalendar_events pc_facility int(11)
440 ALTER TABLE `openemr_postcalendar_events` CHANGE `pc_facility` `pc_facility` int(11) NOT NULL DEFAULT '0' COMMENT 'facility id for this event';
441 #Endif
443 #IfMissingColumn form_misc_billing_options onset_date
444 ALTER TABLE `form_misc_billing_options` ADD `onset_date` date default NULL;
445 UPDATE `list_options` SET `option_id` = 'DK', `title` = 'Ordering Provider' WHERE `list_id` = 'provider_qualifier_code' AND `option_id` = 'dk';
446 UPDATE `list_options` SET `option_id` = 'DN', `title` = 'Referring Provider', `is_default` = '1' WHERE `list_id` = 'provider_qualifier_code' AND `option_id` = 'dn';
447 #EndIF
449 #IfNotRow2D list_options list_id provider_qualifier_code option_id DQ
450 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`) VALUES ('provider_qualifier_code', 'DQ', 'Supervising Provider', '30', '0');
451 #EndIf
453 #IfMissingColumn users main_menu_role
454 ALTER TABLE `users` ADD `main_menu_role` VARCHAR(50) NOT NULL DEFAULT 'standard';
455 #EndIf
457 #IfMissingColumn openemr_postcalendar_categories aco_spec
458 ALTER TABLE `openemr_postcalendar_categories` ADD COLUMN `aco_spec` VARCHAR(63) NOT NULL DEFAULT 'encounters|notes';
459 #EndIf
460 #IfNotRow2D list_options list_id lists option_id apps
461 INSERT INTO list_options (list_id,option_id,title) VALUES ('lists','apps','Apps');
462 INSERT INTO list_options (list_id,option_id,title,seq,is_default,activity) VALUES ('apps','*OpenEMR','main/main_screen.php',10,1,0);
463 INSERT INTO list_options (list_id,option_id,title,seq,is_default,activity) VALUES ('apps','Calendar','main/calendar/index.php',20,0,0);
464 #EndIf
466 #IfNotColumnType list_options list_id varchar(100)
467 ALTER TABLE `list_options` CHANGE `list_id` `list_id` VARCHAR(100) NOT NULL DEFAULT '';
468 #EndIf
470 #IfNotColumnType list_options option_id varchar(100)
471 ALTER TABLE `list_options` CHANGE `option_id` `option_id` VARCHAR(100) NOT NULL DEFAULT '';
472 #EndIf
474 #IfNotColumnType layout_options list_id varchar(100)
475 ALTER TABLE `layout_options` CHANGE `list_id` `list_id` VARCHAR(100) NOT NULL DEFAULT '';
476 #EndIf
478 #IfNotColumnType layout_options list_backup_id varchar(100)
479 ALTER TABLE `layout_options` CHANGE `list_backup_id` `list_backup_id` VARCHAR(100) NOT NULL DEFAULT '';
480 #EndIf
482 #IfNotTable patient_birthday_alert
483 CREATE TABLE `patient_birthday_alert` (
484   `pid` bigint(20) NOT NULL DEFAULT 0,
485   `user_id` bigint(20) NOT NULL DEFAULT 0,
486   `turned_off_on` date NOT NULL,
487   PRIMARY KEY  (`pid`,`user_id`)
488 ) ENGINE=InnoDB;
489 #EndIf
491 #IfNotRow4D supported_external_dataloads load_type ICD10 load_source CMS load_release_date 2017-10-01 load_filename 2018-ICD-10-PCS-Order-File.zip
492 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
493 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-PCS-Order-File.zip', '264b342310236f2b3927062d2c72cfe3');
494 #EndIf
496 #IfNotRow4D supported_external_dataloads load_type ICD10 load_source CMS load_release_date 2017-10-01 load_filename 2018-ICD-10-CM-General-Equivalence-Mappings.zip
497 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
498 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-CM-General-Equivalence-Mappings.zip', '787a025fdcf6e1da1a85be779004f670');
499 #EndIf
501 UPDATE `supported_external_dataloads` SET `load_filename`='2018-ICD-10-Code-Descriptions.zip' WHERE `load_filename`='2018-ICD-10-Code-Dedcriptions.zip' AND `load_release_date`='2017-10-01';
502 #IfNotRow4D supported_external_dataloads load_type ICD10 load_source CMS load_release_date 2017-10-01 load_filename 2018-ICD-10-Code-Descriptions.zip
503 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
504 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-Code-Descriptions.zip', '6f9c77440132e30f565222ca9bb6599c');
505 #EndIf
507 #IfNotRow4D supported_external_dataloads load_type ICD10 load_source CMS load_release_date 2017-10-01 load_filename 2018-ICD-10-PCS-General-Equivalence-Mappings.zip
508 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
509 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-PCS-General-Equivalence-Mappings.zip', 'bb73c80e272da28712887d7979b1cebf');
510 #EndIf
512 #IfColumn x12_partners x12_version
513 ALTER TABLE `x12_partners` DROP COLUMN `x12_version`;
514 #EndIf
516 #IfNotRow2D list_options list_id page_validation option_id add_edit_event#theform_prov
517 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `notes`, `activity`) VALUES
518 ('page_validation', 'add_edit_event#theform_prov', '/interface/main/calendar/add_edit_event.php?prov=true', 170, '{}', 1);
519 #EndIf
521 #IfMissingColumn claims submitted_claim
522 ALTER TABLE `claims` ADD COLUMN `submitted_claim` TEXT COMMENT 'This claims form claim data';
523 #EndIf
525 #IfMissingColumn billing revenue_code
526 ALTER TABLE `billing` ADD COLUMN `revenue_code` varchar(6) NOT NULL DEFAULT "" COMMENT 'Item revenue code';
527 #EndIf
529 #IfMissingColumn codes revenue_code
530 ALTER TABLE `codes` ADD COLUMN `revenue_code` varchar(6) NOT NULL DEFAULT "" COMMENT 'Item revenue code';
531 #EndIf
533 #IfMissingColumn users weno_prov_id
534 ALTER TABLE `users` ADD `weno_prov_id` VARCHAR(15) DEFAULT NULL;
535 #EndIf
537 #IfMissingColumn prescriptions ntx
538 ALTER TABLE `prescriptions` ADD `ntx` INT(2) DEFAULT NULL;
539 #EndIf
541 #IfMissingColumn prescriptions rtx
542 ALTER TABLE `prescriptions` ADD `rtx` INT(2) DEFAULT NULL;
543 #EndIf
545 #IfMissingColumn prescriptions txDate
546 ALTER TABLE `prescriptions` ADD `txDate` DATE NOT NULL;
547 #EndIf
549 #IfMissingColumn pharmacies ncpdp
550 ALTER TABLE `pharmacies` ADD `ncpdp` INT(12) DEFAULT NULL;
551 #EndIf
553 #IfMissingColumn pharmacies npi
554 ALTER TABLE `pharmacies` ADD `npi` INT(12) DEFAULT NULL;
555 #EndIf
557 #IfNotRow2Dx2 list_options list_id state option_id PR title Puerto Rico
558 INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('state','PR','Puerto Rico',39,0);
559 #EndIf
561 #IfNotTable erx_drug_paid
562 CREATE TABLE `erx_drug_paid` (
563   `drugid` int(11) NOT NULL AUTO_INCREMENT,
564   `drug_label_name` varchar(45) NOT NULL,
565   `ahfs_descr` varchar(45) NOT NULL,
566   `ndc` bigint(12) NOT NULL,
567   `price_per_unit` decimal(5,2) NOT NULL,
568   `avg_price` decimal(6,2) NOT NULL,
569   `avg_price_paid` int(6) NOT NULL,
570   `avg_savings` decimal(6,2) NOT NULL,
571   `avg_percent` decimal(6,2) NOT NULL,
572    PRIMARY KEY (`drugid`)
573    ) ENGINE=InnoDB;
574 #EndIf
576 #IfNotTable erx_rx_log
577 CREATE TABLE `erx_rx_log` (
578  `id` int(20) NOT NULL AUTO_INCREMENT,
579  `prescription_id` int(6) NOT NULL,
580  `date` varchar(25) NOT NULL,
581  `time` varchar(15) NOT NULL,
582  `code` int(6) NOT NULL,
583  `status` text,
584  `message_id` varchar(100) DEFAULT NULL,
585  `read` int(1) DEFAULT NULL,
586  PRIMARY KEY (`id`)
587   ) ENGINE=InnoDB;
588 #EndIf
590 #IfNotTable erx_narcotics
591 CREATE TABLE `erx_narcotics` (
592   `id` int(11) NOT NULL AUTO_INCREMENT,
593   `drug` varchar(255) NOT NULL,
594   `dea_number` varchar(5) NOT NULL,
595   `csa_sch` varchar(2) NOT NULL,
596   `narc` varchar(2) NOT NULL,
597   `other_names` varchar(255) NOT NULL,
598    PRIMARY KEY (`id`)
599   ) ENGINE=InnoDB;
600 #EndIf
602 UPDATE `globals` SET `gl_value`='style_red.css' WHERE `gl_name`='css_header' AND `gl_value`='style_flat_red.css';
603 UPDATE `globals` SET `gl_value`='style_manila.css' WHERE `gl_name`='css_header' AND `gl_value`='style_tan.css';
604 UPDATE `globals` SET `gl_value`='style_light.css' WHERE `gl_name`='css_header' AND (`gl_value`='style_babyblu.css'
605  OR `gl_value`='style_metal.css'
606  OR `gl_value`='style_oemr.css'
607  OR `gl_value`='style_purple.css'
608  OR `gl_value`='style_radiant.css'
609  OR `gl_value`='style_sky_blue.css');
611 UPDATE `user_settings` SET `setting_value`='style_red.css' WHERE `setting_label`='global:css_header' AND `setting_value`='style_flat_red.css';
612 UPDATE `user_settings` SET `setting_value`='style_manila.css' WHERE `setting_label`='global:css_header' AND `setting_value`='style_tan.css';
613 UPDATE `user_settings` SET `setting_value`='style_light.css' WHERE `setting_label`='global:css_header' AND (`setting_value`='style_babyblu.css'
614  OR `setting_value`='style_metal.css'
615  OR `setting_value`='style_oemr.css'
616  OR `setting_value`='style_purple.css'
617  OR `setting_value`='style_radiant.css'
618  OR `setting_value`='style_sky_blue.css');
620 #IfNotColumnType facility country_code varchar(30)
621 ALTER TABLE `facility` CHANGE `country_code` `country_code` varchar(30) NOT NULL default '';
622 #EndIf
624 #IfNotColumnType layout_options group_name varchar(255)
625 ALTER TABLE `layout_options` CHANGE `group_name` `group_name` varchar(255) NOT NULL default '';
626 #EndIf
628 #IfMissingColumn forms issue_id
629 ALTER TABLE `forms` ADD COLUMN `issue_id` bigint(20) NOT NULL default 0 COMMENT 'references lists.id to identify a case';
630 #EndIf
632 #IfMissingColumn forms provider_id
633 ALTER TABLE `forms` ADD COLUMN `provider_id` bigint(20) NOT NULL default 0 COMMENT 'references users.id to identify a provider';
634 #EndIf
636 #IfNotTable layout_group_properties
637 CREATE TABLE `layout_group_properties` (
638   grp_form_id     varchar(31)    not null,
639   grp_group_id    varchar(31)    not null default '' comment 'empty when representing the whole form',
640   grp_title       varchar(63)    not null default '' comment 'descriptive name of the form or group',
641   grp_subtitle    varchar(63)    not null default '' comment 'for display under the title',
642   grp_mapping     varchar(31)    not null default '' comment 'the form category',
643   grp_seq         int(11)        not null default 0  comment 'optional order within mapping',
644   grp_activity    tinyint(1)     not null default 1,
645   grp_repeats     int(11)        not null default 0,
646   grp_columns     int(11)        not null default 0,
647   grp_size        int(11)        not null default 0,
648   grp_issue_type  varchar(75)    not null default '',
649   grp_aco_spec    varchar(63)    not null default '',
650   grp_services    varchar(4095)  not null default '',
651   grp_products    varchar(4095)  not null default '',
652   grp_diags       varchar(4095)  not null default '',
653   PRIMARY KEY (grp_form_id, grp_group_id)
654 ) ENGINE=InnoDB;
655 ALTER TABLE layout_options ADD COLUMN group_id VARCHAR(31) NOT NULL default '' AFTER group_name;
656 #ConvertLayoutProperties
657 ALTER TABLE layout_options DROP COLUMN group_name;
658 DELETE FROM list_options WHERE list_id = 'lbfnames';
659 DELETE FROM list_options WHERE list_id = 'lists' AND option_id = 'lbfnames';
660 DELETE FROM list_options WHERE list_id = 'transactions';
661 DELETE FROM list_options WHERE list_id = 'lists' AND option_id = 'transactions';
662 #EndIf
664 #IfMissingColumn openemr_postcalendar_categories pc_constant_id
665 ALTER TABLE `openemr_postcalendar_categories` ADD `pc_constant_id` VARCHAR (255) default NULL;
666 UPDATE `openemr_postcalendar_categories` SET pc_constant_id = LOWER(REPLACE (pc_catname,' ', '_'));
667 #EndIf
669 #IfNotIndex openemr_postcalendar_categories pc_constant_id
670 ALTER TABLE openemr_postcalendar_categories ADD UNIQUE KEY (`pc_constant_id`);
671 #EndIf
673 #IfMissingColumn facility facility_taxonomy
674 ALTER TABLE facility ADD facility_taxonomy VARCHAR(15) DEFAULT NULL;
675 #EndIf
677 #IfNotTable medex_icons
678 CREATE TABLE `medex_icons` (
679   `i_UID` int(11) NOT NULL AUTO_INCREMENT,
680   `msg_type` varchar(50) NOT NULL,
681   `msg_status` varchar(10) NOT NULL,
682   `i_description` varchar(255) NOT NULL,
683   `i_html` text,
684   `i_blob` longtext,
685   PRIMARY KEY (`i_UID`)
686 ) ENGINE=InnoDB;
688 INSERT INTO `medex_icons` (`i_UID`, `msg_type`, `msg_status`, `i_description`, `i_html`, `i_blob`) VALUES
689 (1, 'SMS', 'ALLOWED', '', '<i title="SMS is possible." class="fa fa-commenting-o fa-fw"></i>', ''),
690 (2, 'SMS', 'NotAllowed', '', '<span class="fa-stack" title="SMS not possible"><i class="fa fa-commenting-o fa-stack-1x fa-fw"></i><i class="fa fa-ban fa-stack-2x text-danger"></i></span>', ''),
691 (3, 'SMS', 'SCHEDULED', '', '<span class="btn scheduled" title="SMS scheduled"><i class="fa fa-commenting-o fa-fw"></i></span>', ''),
692 (4, 'SMS', 'SENT', '', '<span class="btn" title="SMS Sent - in process" style="padding:5px;background-color:yellow;color:black;"><i class="fa fa-commenting-o fa-fw"></i></span>', ''),
693 (5, 'SMS', 'READ', '', '<span class="btn" title="SMS Delivered - waiting for response" aria-label="SMS Delivered" style="padding:5px;background-color:#146abd;"><i class="fa fa-commenting-o fa-inverse fa-flip-horizontal fa-fw" aria-hidden="true"></i></span>', ''),
694 (6, 'SMS', 'FAILED', '', '<span class="btn" title="SMS Failed to be delivered" style="padding:5px;background-color:#ffc4c4;color:#000;"><i class="fa fa-commenting-o fa-fw"></i></span>', ''),
695 (7, 'SMS', 'CONFIRMED', '', '<span class="btn" title="Confirmed by SMS" style="padding:5px;background-color:green;"><i class="fa fa-commenting-o fa-inverse fa-fw"></i></span>', ''),
696 (8, 'SMS', 'CALL', '', '<span class="btn btn-success" style="padding:5px;background-color: red;" title="Patient requests Office Call">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', ''),
697 (9, 'SMS', 'EXTRA', '', '<span class="btn" title="EXTRA" style="padding:5px;background-color:#000;color:#fff;"><i class="fa fa-terminal fa-fw"></i></span>', ''),
698 (10, 'SMS', 'STOP', '', '<span class="btn btn-danger" title="OptOut of SMS Messaging. Demographics updated." aria-label=\'Optout SMS\'><i class="fa fa-commenting" aria-hidden="true"> STOP</i></span>', ''),
699 (11, 'AVM', 'ALLOWED', '', '<span title="Automated Voice Messages are possible" class="fa fa-phone fa-fw"></span>', ''),
700 (12, 'AVM', 'NotAllowed', '', '<span class="fa-stack" title="Automated Voice Messages are not allowed"><i class="fa fa-phone fa-fw fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x text-danger"></i></span>', ''),
701 (13, 'AVM', 'SCHEDULED', '', '<span class="btn scheduled" title="AVM scheduled"><i class="fa fa-phone fa-fw"></i></span>', ''),
702 (14, 'AVM', 'SENT', '', '<span class="btn" title="AVM in process, no response" style="padding:5px;background-color:yellow;color:black;"><i class="fa fa-volume-control-phone fa-fw"></i></span>', ''),
703 (15, 'AVM', 'FAILURE', '', '<span class="btn" title="AVM: Failed.  Check patient\'s phone numbers." style="padding:5px;background-color:#ffc4c4;color:#000;"><i class="fa fa-phone fa-fw"></i></span>', ''),
704 (16, 'AVM', 'CONFIRMED', '', '<span class="btn" title="Confirmed by AVM" style="padding:5px;background-color:green;"><i class="fa fa-phone fa-inverse fa-fw"></i></span>', ''),
705 (17, 'AVM', 'CALL', '', '<span class="btn btn-success" style="padding:5px;background-color: red;" title="Patient requests Office Call">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', ''),
706 (18, 'AVM', 'Other', '', '<span class="fa-stack fa-lg"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-terminal fa-fw fa-stack-1x fa-inverse"></i></span>', ''),
707 (19, 'AVM', 'STOP', '', '<span class="btn btn-danger" title="OptOut of Voice Messaging. Demographics updated." aria-label="Optout AVM"><i class="fa fa-phone" aria-hidden="true"> STOP</i></span>', ''),
708 (20, 'EMAIL', 'ALLOWED', '', '<span title="EMAIL is possible" class="fa fa-envelope-o fa-fw"></span>', ''),
709 (21, 'EMAIL', 'NotAllowed', '', '<span class="fa-stack" title="EMAIL is not possible"><i class="fa fa-envelope-o fa-fw fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x text-danger"></i></span>', ''),
710 (22, 'EMAIL', 'SCHEDULED', '', '<span class="btn scheduled" title="EMAIL scheduled"><i class="fa fa-envelope-o fa-fw"></i></span>', ''),
711 (23, 'EMAIL', 'SENT', '', '<span class="btn" style="padding:5px;background-color:yellow;color:black;" title="EMAIL Message sent, not opened"><i class="fa fa-envelope-o fa-fw"></i></span>', ''),
712 (24, 'EMAIL', 'READ', '', '<a class="btn" style="padding:5px;background-color:#146abd;" title="E-Mail was read/opened by patient" aria-label="Confirmed via email"><i class="fa fa-envelope-o fa-inverse fa-fw" aria-hidden="true"></i></a>', ''),
713 (25, 'EMAIL', 'FAILED', '', '<span class="btn" title="EMAIL: Failed.  Check patient''s email address." style="padding:5px;background-color:#ffc4c4;color:#000;"><i class="fa fa-envelope-o fa-fw"></i></span>', ''),
714 (26, 'EMAIL', 'CONFIRMED', '', '<a class="btn btn-success" style="padding:5px;background-color: green;" title="Confirmed by E-Mail" aria-label="Confirmed via email"><i class="fa fa-envelope-o fa-fw" aria-hidden="true"></i></a>', ''),
715 (27, 'EMAIL', 'CALL', '', '<span class="btn btn-success" style="padding:5px;background-color: red;" title="Patient requests Office Call">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', ''),
716 (28, 'EMAIL', 'Other', '', '<span class="fa-stack fa-lg"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-terminal fa-fw fa-stack-1x fa-inverse fa-fw"></i></span>', ''),
717 (29, 'EMAIL', 'STOP', '', '<span class="btn btn-danger" title="OptOut of EMAIL Messaging. Demographics updated." aria-label="Optout EMAIL"><i class="fa fa-envelope-o" aria-hidden="true"> STOP</i></span>', ''),
718 (30, 'POSTCARD', 'SENT', '', '<span class="btn" title="Postcard Sent - in process" style="padding:5px;background-color:yellow;color:black"><i class="fa fa-image fa-fw"></i></span>', ''),
719 (31, 'POSTCARD', 'READ', '', '<a class="btn" style="padding:5px;background-color:#146abd;" title="e-Postcard was delivered" aria-label="Postcard Delivered"><i class="fa fa-image fa-fw" aria-hidden="true"></i></a>', ''),
720 (32, 'POSTCARD', 'FAILED', '', '<span class="fa-stack fa-lg" title="Delivery Failure - check Address for this patient"><i class="fa fa-image fa-fw fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x text-danger"></i></span>', ''),
721 (33, 'POSTCARD', 'SCHEDULED', '', '<span class="btn scheduled" title="Postcard Campaign Event is scheduled."><i class="fa fa-image fa-fw"></i></span>', ''),
722 (36, 'AVM', 'READ', '', '<span class="btn" title="AVM completed - waiting for manual response" aria-label="AVM Delivered" style="padding:5px;background-color:#146abd;"><i class="fa fa-inverse fa-phone fa-fw" aria-hidden="true"></i></span>', ''),
723 (37, 'SMS', 'CALLED', '', '<span class="btn btn-success" style="padding:5px;background-color:#146abd;" title="Patient requests Office Call: COMPLETED">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', ''),
724 (38, 'AVM', 'CALLED', '', '<span class="btn btn-success" style="padding:5px;background-color:#146abd;" title="Patient requests Office Call: COMPLETED">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', ''),
725 (39, 'EMAIL', 'CALLED', '', '<span class="btn btn-success" style="padding:5px;background-color:#146abd;" title="Patient requests Office Call: COMPLETED">\r\n<i class="fa fa-flag fa-fw"></i></span>\r\n', '');
726 #Endif
729 #IfNotTable medex_outgoing
730 CREATE TABLE `medex_outgoing` (
731   `msg_uid` int(11) NOT NULL AUTO_INCREMENT,
732   `msg_pid` int(11) NOT NULL,
733   `msg_pc_eid` varchar(11) NOT NULL,
734   `campaign_uid` int(11) NOT NULL DEFAULT '0',
735   `msg_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
736   `msg_type` varchar(50) NOT NULL,
737   `msg_reply` varchar(50) DEFAULT NULL,
738   `msg_extra_text` text,
739   `medex_uid` varchar(11),
740   PRIMARY KEY (`msg_uid`),
741   UNIQUE KEY `msg_eid` (`msg_uid`,`msg_pc_eid`,`medex_uid`)
742 ) ENGINE=InnoDB;
743 #Endif
745 #IfNotTable medex_prefs
746 CREATE TABLE `medex_prefs` (
747   `MedEx_id` int(11) DEFAULT '0',
748   `ME_username` varchar(100) DEFAULT NULL,
749   `ME_api_key` text,
750   `ME_facilities` varchar(50) DEFAULT NULL,
751   `ME_providers` varchar(100) DEFAULT NULL,
752   `ME_hipaa_default_override` varchar(3) DEFAULT NULL,
753   `PHONE_country_code` int(4) NOT NULL DEFAULT '1',
754   `MSGS_default_yes` varchar(3) DEFAULT NULL,
755   `POSTCARDS_local` varchar(3) DEFAULT NULL,
756   `POSTCARDS_remote` varchar(3) DEFAULT NULL,
757   `LABELS_local` varchar(3) DEFAULT NULL,
758   `LABELS_choice` varchar(50) DEFAULT NULL,
759   `combine_time` tinyint(4) DEFAULT NULL,
760   `postcard_top` varchar(255) DEFAULT NULL,
761   `MedEx_lastupdated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
762   UNIQUE KEY `ME_username` (`ME_username`)
763 ) ENGINE=InnoDB;
764 #Endif
766 #IfNotTable medex_recalls
767 CREATE TABLE `medex_recalls` (
768   `r_ID` int(11) NOT NULL AUTO_INCREMENT,
769   `r_PRACTID` int(11) NOT NULL,
770   `r_pid` int(11) NOT NULL COMMENT 'PatientID from pat_data',
771   `r_eventDate` date NOT NULL COMMENT 'Date of Appt or Recall',
772   `r_facility` int(11) NOT NULL,
773   `r_provider` int(11) NOT NULL,
774   `r_reason` varchar(255) DEFAULT NULL,
775   `r_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
776   PRIMARY KEY (`r_ID`),
777   UNIQUE KEY `r_PRACTID` (`r_PRACTID`,`r_pid`)
778 ) ENGINE=InnoDB;
779 #Endif
781 #IfNotRow background_services name MedEx
782 INSERT INTO `background_services` (`name`, `title`, `active`, `running`, `next_run`, `execute_interval`, `function`, `require_once`, `sort_order`) VALUES
783 ('MedEx', 'MedEx Messaging Service', 0, 0, '2017-05-09 17:39:10', 0, 'start_MedEx', '/library/MedEx/MedEx_background.php', 100);
784 #Endif
786 #IfNotRow2D list_options list_id apptstat option_id AVM
787 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) VALUES
788 ('apptstat', 'AVM', 'AVM Confirmed', 110, 0, 0, '', 'F0FFE8|0', '', 0, 0, 1, '');
790 #IfNotRow2D list_options list_id apptstat option_id CALL
791 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) VALUES
792 ('apptstat', 'CALL', 'Callback requested', 130, 0, 0, '', 'FFDBE2|5', '', 0, 0, 1, '');
794 #IfNotRow2D list_options list_id apptstat option_id SMS
795 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) VALUES
796 ('apptstat', 'SMS', 'SMS Confirmed', 90, 0, 0, '', 'F0FFE8|0', '', 0, 0, 1, '');
798 #IfNotRow2D list_options list_id apptstat option_id EMAIL
799 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`) VALUES
800 ('apptstat', 'EMAIL', 'EMAIL Confirmed', 20, 0, 0, '', 'FFEBE3|0', '', 0, 0, 1, '');
801 #Endif
803 #IfMissingColumn log_comment_encrypt version
804 ALTER TABLE `log_comment_encrypt` ADD `version` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0 for mycrypt and 1 for openssl';
805 #Endif
807 #IfNotColumnType form_misc_billing_options icn_resubmission_number VARCHAR(35)
808 ALTER TABLE form_misc_billing_options CHANGE `icn_resubmission_number` `icn_resubmission_number` VARCHAR(35) DEFAULT NULL;
809 #EndIf
811 #IfMissingColumn users patient_menu_role
812 ALTER TABLE `users` ADD `patient_menu_role` VARCHAR(50) NOT NULL DEFAULT 'standard';
813 #EndIf